edit.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <include file="public@header"/>
  2. <style type="text/css">
  3. .pic-list li {
  4. margin-bottom: 5px;
  5. }
  6. </style>
  7. <script type="text/html" id="photos-item-tpl">
  8. <li id="saved-image{id}">
  9. <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
  10. <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
  11. style="width: 200px;" title="图片名称">
  12. <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
  13. onclick="imagePreviewDialog(this.src);">
  14. <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
  15. <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
  16. </li>
  17. </script>
  18. <script type="text/html" id="files-item-tpl">
  19. <li id="saved-file{id}">
  20. <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
  21. <input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
  22. style="width: 200px;" title="文件名称">
  23. <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
  24. <a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
  25. <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
  26. </li>
  27. </script>
  28. </head>
  29. <body>
  30. <div class="wrap js-check-wrap">
  31. <ul class="nav nav-tabs">
  32. <li><a href="{:url('AdminArticle/index')}">文章管理</a></li>
  33. <li>
  34. <a href="{:url('AdminArticle/add')}">添加文章</a>
  35. </li>
  36. <li class="active"><a href="#">编辑文章</a></li>
  37. </ul>
  38. <form action="{:url('AdminArticle/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
  39. <div class="row">
  40. <div class="col-md-9">
  41. <table class="table table-bordered">
  42. <tr>
  43. <th width="100">分类<span class="form-required">*</span></th>
  44. <td>
  45. <input class="form-control" type="text" style="width:400px;" required
  46. value="{:implode(' ',$post_categories)}"
  47. placeholder="请选择分类" onclick="doSelectCategory();" id="js-categories-name-input"
  48. readonly/>
  49. <input class="form-control" type="hidden" value="{$post_category_ids}"
  50. name="post[categories]"
  51. id="js-categories-id-input"/>
  52. </td>
  53. </tr>
  54. <tr>
  55. <th>标题<span class="form-required">*</span></th>
  56. <td>
  57. <input id="post-id" type="hidden" name="post[id]" value="{$post.id}">
  58. <input class="form-control" type="text" name="post[post_title]"
  59. required value="{$post.post_title}" placeholder="请输入标题"/>
  60. </td>
  61. </tr>
  62. <tr>
  63. <th>关键词</th>
  64. <td>
  65. <input class="form-control" type="text" name="post[post_keywords]"
  66. value="{$post['post_keywords']}" placeholder="请输入关键字">
  67. <p class="help-block">多关键词之间用英文逗号隔开</p>
  68. </td>
  69. </tr>
  70. <tr>
  71. <th>文章来源</th>
  72. <td>
  73. <input class="form-control" type="text" name="post[post_source]"
  74. value="{$post['post_source']}" placeholder="请输入文章来源">
  75. </td>
  76. </tr>
  77. <tr>
  78. <th>摘要</th>
  79. <td>
  80. <textarea class="form-control" name="post[post_excerpt]" style="height: 50px;"
  81. placeholder="请填写摘要">{$post.post_excerpt}</textarea>
  82. </td>
  83. </tr>
  84. <tr>
  85. <th>内容</th>
  86. <td>
  87. <script type="text/plain" id="content" name="post[post_content]">{$post.post_content}</script>
  88. </td>
  89. </tr>
  90. <tr>
  91. <th>相册</th>
  92. <td>
  93. <ul id="photos" class="pic-list list-unstyled form-inline">
  94. <notempty name="post.more.photos">
  95. <foreach name="post.more.photos" item="vo">
  96. <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
  97. <li id="saved-image{$key}">
  98. <input id="photo-{$key}" type="hidden" name="photo_urls[]"
  99. value="{$vo.url}">
  100. <input class="form-control" id="photo-{$key}-name" type="text"
  101. name="photo_names[]"
  102. value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
  103. <img id="photo-{$key}-preview"
  104. src="{:cmf_get_image_preview_url($vo['url'])}"
  105. style="height:36px;width: 36px;"
  106. onclick="parent.imagePreviewDialog(this.src);">
  107. <a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
  108. <a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
  109. </li>
  110. </foreach>
  111. </notempty>
  112. </ul>
  113. <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
  114. class="btn btn-sm btn-default">选择图片</a>
  115. </td>
  116. </tr>
  117. <tr>
  118. <th>附件</th>
  119. <td>
  120. <ul id="files" class="pic-list list-unstyled form-inline">
  121. <notempty name="post.more.files">
  122. <foreach name="post.more.files" item="vo">
  123. <php>$file_url=cmf_get_file_download_url($vo['url']);</php>
  124. <li id="saved-file{$key}">
  125. <input id="file-{$key}" type="hidden" name="file_urls[]"
  126. value="{$vo.url}">
  127. <input class="form-control" id="file-{$key}-name" type="text"
  128. name="file_names[]"
  129. value="{$vo.name}" style="width: 200px;" title="图片名称">
  130. <a id="file-{$key}-preview" href="{$file_url}" target="_blank">下载</a>
  131. <a href="javascript:uploadOne('文件上传','#file-{$key}','file');">替换</a>
  132. <a href="javascript:(function(){$('#saved-file{$key}').remove();})();">移除</a>
  133. </li>
  134. </foreach>
  135. </notempty>
  136. </ul>
  137. <a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl','file');"
  138. class="btn btn-sm btn-default">选择文件</a>
  139. </td>
  140. </tr>
  141. <tr>
  142. <th>音频</th>
  143. <td class="form-inline">
  144. <input id="file-audio" class="form-control" type="text" name="post[more][audio]"
  145. value="{$post.more.audio|default=''}" placeholder="请上传音频文件" style="width: 200px;">
  146. <notempty name="post.more.audio">
  147. <a id="file-audio-preview" href="{:cmf_get_file_download_url($post.more.audio)}"
  148. target="_blank">下载</a>
  149. </notempty>
  150. <a href="javascript:uploadOne('文件上传','#file-audio','audio');">上传</a>
  151. </td>
  152. </tr>
  153. <tr>
  154. <th>视频</th>
  155. <td class="form-inline">
  156. <input id="file-video" class="form-control" type="text" name="post[more][video]"
  157. value="{$post.more.video|default=''}" placeholder="请上传视频文件" style="width: 200px;">
  158. <notempty name="post.more.video">
  159. <a id="file-video-preview" href="{:cmf_get_file_download_url($post.more.video)}"
  160. target="_blank">下载</a>
  161. </notempty>
  162. <a href="javascript:uploadOne('文件上传','#file-video','video');">上传</a>
  163. </td>
  164. </tr>
  165. </table>
  166. <hook name="portal_admin_article_edit_view_main"/>
  167. </div>
  168. <div class="col-md-3">
  169. <table class="table table-bordered">
  170. <tr>
  171. <th>缩略图</th>
  172. </tr>
  173. <tr>
  174. <td>
  175. <div style="text-align: center;">
  176. <input type="hidden" name="post[more][thumbnail]" id="thumbnail"
  177. value="{$post.more.thumbnail|default=''}">
  178. <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
  179. <if condition="empty($post.more.thumbnail)">
  180. <img src="__TMPL__/public/assets/images/default-thumbnail.png"
  181. id="thumbnail-preview"
  182. width="135" style="cursor: pointer"/>
  183. <else/>
  184. <img src="{:cmf_get_image_preview_url($post.more.thumbnail)}"
  185. id="thumbnail-preview"
  186. width="135" style="cursor: pointer"/>
  187. </if>
  188. </a>
  189. <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
  190. </div>
  191. </td>
  192. </tr>
  193. <tr>
  194. <th>发布时间</th>
  195. </tr>
  196. <tr>
  197. <td>
  198. <input class="form-control js-bootstrap-datetime" type="text" name="post[published_time]"
  199. value="{:date('Y-m-d H:i',$post['published_time'])}">
  200. </td>
  201. </tr>
  202. <!--
  203. <tr>
  204. <th>评论</th>
  205. </tr>
  206. <tr>
  207. <td>
  208. <label style="width: 88px"><a
  209. href="javascript:openIframeDialog('{:url('comment/commentadmin/index',array('post_id'=>$post['id']))}','评论列表')">查看评论</a></label>
  210. </td>
  211. </tr>
  212. -->
  213. <tr>
  214. <th>状态</th>
  215. <php>
  216. $status_yes=$post['post_status']==1?"checked":"";
  217. $is_top_yes=$post['is_top']==1?"checked":"";
  218. $recommended_yes=$post['recommended']==1?"checked":"";
  219. </php>
  220. </tr>
  221. <tr>
  222. <td>
  223. <div class="checkbox">
  224. <label>
  225. <input type="checkbox" id="post-status-checkbox" name="post[post_status]" value="1"
  226. {$status_yes}>发布
  227. <span id="post-status-error" style="color: red;display: none"></span>
  228. </label>
  229. </div>
  230. </td>
  231. </tr>
  232. <tr>
  233. <td>
  234. <div class="checkbox">
  235. <label><input type="checkbox" id="is-top-checkbox" name="post[is_top]" value="1"
  236. {$is_top_yes}>置顶</label>
  237. <span id="is-top-error" style="color: red;display: none"></span>
  238. </div>
  239. </td>
  240. </tr>
  241. <tr>
  242. <td>
  243. <div class="checkbox">
  244. <label>
  245. <input type="checkbox" id="recommended-checkbox" name="post[recommended]" value="1"
  246. {$recommended_yes}>推荐
  247. <span id="recommended-error" style="color: red;display: none"></span>
  248. </label>
  249. </div>
  250. </td>
  251. </tr>
  252. <tr>
  253. <th>文章模板</th>
  254. </tr>
  255. <tr>
  256. <td>
  257. <select class="form-control" name="post[more][template]" id="more-template-select">
  258. <option value="">请选择模板</option>
  259. <foreach name="article_theme_files" item="vo">
  260. <php>$value=preg_replace('/^portal\//','',$vo['file']);</php>
  261. <option value="{$value}">{$vo.name} {$vo.file}.html</option>
  262. </foreach>
  263. </select>
  264. </td>
  265. </tr>
  266. </table>
  267. <hook name="portal_admin_article_edit_view_right_sidebar"/>
  268. </div>
  269. </div>
  270. <div class="form-group">
  271. <div class="col-sm-offset-2 col-sm-10">
  272. <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
  273. <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
  274. </div>
  275. </div>
  276. </form>
  277. </div>
  278. <script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  279. <script type="text/javascript">
  280. //编辑器路径定义
  281. var editorURL = GV.WEB_ROOT;
  282. </script>
  283. <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
  284. <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
  285. <script type="text/javascript">
  286. $(function () {
  287. editorcontent = new baidu.editor.ui.Editor();
  288. editorcontent.render('content');
  289. try {
  290. editorcontent.sync();
  291. } catch (err) {
  292. }
  293. $('.btn-cancel-thumbnail').click(function () {
  294. $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  295. $('#thumbnail').val('');
  296. });
  297. $('#more-template-select').val("{$post.more.template|default=''}");
  298. });
  299. function doSelectCategory() {
  300. var selectedCategoriesId = $('#js-categories-id-input').val();
  301. openIframeLayer("{:url('AdminCategory/select')}?ids=" + selectedCategoriesId, '请选择分类', {
  302. area: ['700px', '400px'],
  303. btn: ['确定', '取消'],
  304. yes: function (index, layero) {
  305. //do something
  306. var iframeWin = window[layero.find('iframe')[0]['name']];
  307. var selectedCategories = iframeWin.confirm();
  308. if (selectedCategories.selectedCategoriesId.length == 0) {
  309. layer.msg('请选择分类');
  310. return;
  311. }
  312. $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
  313. $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
  314. //console.log(layer.getFrameIndex(index));
  315. layer.close(index); //如果设定了yes回调,需进行手工关闭
  316. }
  317. });
  318. }
  319. </script>
  320. <script>
  321. var publishYesUrl = "{:url('AdminArticle/publish',array('yes'=>1))}";
  322. var publishNoUrl = "{:url('AdminArticle/publish',array('no'=>1))}";
  323. var topYesUrl = "{:url('AdminArticle/top',array('yes'=>1))}";
  324. var topNoUrl = "{:url('AdminArticle/top',array('no'=>1))}";
  325. var recommendYesUrl = "{:url('AdminArticle/recommend',array('yes'=>1))}";
  326. var recommendNoUrl = "{:url('AdminArticle/recommend',array('no'=>1))}";
  327. var postId = $('#post-id').val();
  328. //发布操作
  329. $("#post-status-checkbox").change(function () {
  330. if ($('#post-status-checkbox').is(':checked')) {
  331. //发布
  332. $.ajax({
  333. url: publishYesUrl, type: "post", dataType: "json", data: {ids: postId}, success: function (data) {
  334. if (data.code != 1) {
  335. $('#post-status-checkbox').removeAttr("checked");
  336. $('#post-status-error').html(data.msg).show();
  337. } else {
  338. $('#post-status-error').hide();
  339. }
  340. }
  341. });
  342. } else {
  343. //取消发布
  344. $.ajax({
  345. url: publishNoUrl, type: "post", dataType: "json", data: {ids: postId}, success: function (data) {
  346. if (data.code != 1) {
  347. $('#post-status-checkbox').prop("checked", 'true');
  348. $('#post-status-error').html(data.msg).show();
  349. } else {
  350. $('#post-status-error').hide();
  351. }
  352. }
  353. });
  354. }
  355. });
  356. //置顶操作
  357. $("#is-top-checkbox").change(function () {
  358. if ($('#is-top-checkbox').is(':checked')) {
  359. //置顶
  360. $.ajax({
  361. url: topYesUrl, type: "post", dataType: "json", data: {ids: postId}, success: function (data) {
  362. if (data.code != 1) {
  363. $('#is-top-checkbox').removeAttr("checked");
  364. $('#is-top-error').html(data.msg).show();
  365. } else {
  366. $('#is-top-error').hide();
  367. }
  368. }
  369. });
  370. } else {
  371. //取消置顶
  372. $.ajax({
  373. url: topNoUrl, type: "post", dataType: "json", data: {ids: postId}, success: function (data) {
  374. if (data.code != 1) {
  375. $('#is-top-checkbox').prop("checked", 'true');
  376. $('#is-top-error').html(data.msg).show();
  377. } else {
  378. $('#is-top-error').hide();
  379. }
  380. }
  381. });
  382. }
  383. });
  384. //推荐操作
  385. $("#recommended-checkbox").change(function () {
  386. if ($('#recommended-checkbox').is(':checked')) {
  387. //推荐
  388. $.ajax({
  389. url: recommendYesUrl, type: "post", dataType: "json", data: {ids: postId}, success: function (data) {
  390. if (data.code != 1) {
  391. $('#recommended-checkbox').removeAttr("checked");
  392. $('#recommended-error').html(data.msg).show();
  393. } else {
  394. $('#recommended-error').hide();
  395. }
  396. }
  397. });
  398. } else {
  399. //取消推荐
  400. $.ajax({
  401. url: recommendNoUrl, type: "post", dataType: "json", data: {ids: postId}, success: function (data) {
  402. if (data.code != 1) {
  403. $('#recommended-checkbox').prop("checked", 'true');
  404. $('#recommended-error').html(data.msg).show();
  405. } else {
  406. $('#recommended-error').hide();
  407. }
  408. }
  409. });
  410. }
  411. });
  412. </script>
  413. </body>
  414. </html>