Explorar el Código

新闻中心发布时间排序控制

huangct hace 8 años
padre
commit
e94024e86a

+ 12 - 0
jpress-web-admin/src/main/java/io/jpress/admin/controller/_ContentController.java

@@ -39,6 +39,7 @@ import io.jpress.utils.*;
 
 import java.math.BigInteger;
 import java.sql.SQLException;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -409,6 +410,17 @@ public class _ContentController extends JBaseCRUDController<Content> {
 		boolean saved = Db.tx(new IAtom() {
 			@Override
 			public boolean run() throws SQLException {
+				//新闻中心元数据排序时间
+				if ("news".equals(content.getModule()) && metas != null) {
+					String orderTime = metas.get("order_time").replaceAll("T", " ");
+					java.text.SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm");
+					try {
+						Date date = formatter.parse(orderTime);
+						content.setCreated(date);
+					} catch (ParseException e) {
+						e.printStackTrace();
+					}
+				}
 
 				boolean isSameAsOld = true;
 				Content oldContent = null;

+ 13 - 0
jpress-web-admin/src/main/webapp/WEB-INF/admin/content/_props_box.html

@@ -35,6 +35,19 @@
 					<a href="#tab_metadata" data-toggle="tab">元数据</a>
 				</li>
 
+				<#if module ?? && module.name=="news">
+					<li>
+						<#list module.metadatas as metadata>
+							<#if metadata.name == "order_time">
+								<input type="hidden" class="push_time" id="meta:order_time" name="meta:order_time" value="${(content.metadata(metadata.name))!}">
+								<a>排序时间:<input id="createDefaultTime" type="datetime-local" value="${(content.metadata(metadata.name))!}" onchange="getPushTime()"></a>
+							</#if>
+						</#list>
+					</li>
+				</#if>
+
+
+
 			</ul>
 			<div class="tab-content">
 				<div class="tab-pane active form-horizontal" id="tab_1">

+ 1 - 0
jpress-web-template-usoftchina/src/main/webapp/templates/usoftchina/tpl_config.xml

@@ -32,6 +32,7 @@
 	
 	<module title="新闻中心" name="news" list="新闻中心" add="发布新闻" comment="新闻评论">
 		<taxonomy title="分类" name="category" formType="select" />
+		<metadata dataType="input" name="order_time" title="排序时间"></metadata>
 	</module>
 
 	<module title="移动信息中心" name="uuhelper" list="软文列表" add="发布信息" comment="留言管理">