publish_picture.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <style type="text/css">
  2. #tbox {
  3. display: none;
  4. }
  5. </style>
  6. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/jquery.ui.js"></script>
  7. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
  8. <link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css" />
  9. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.validation.min.js" charset="utf-8"></script>
  10. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/fileupload/jquery.iframe-transport.js" charset="utf-8"></script>
  11. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/fileupload/jquery.ui.widget.js" charset="utf-8"></script>
  12. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/fileupload/jquery.fileupload.js" charset="utf-8"></script>
  13. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.mousewheel.js"></script>
  14. <script type="text/javascript">
  15. $(document).ready(function(){
  16. //发布时间选择
  17. $('#picture_publish_time').datepicker();
  18. //摘要计数
  19. $("[name='picture_image_abstract[]']").nc_text_count({max:140});
  20. $("#btn_draft").click(function(){
  21. if($(".exceeded").length <= 0) {
  22. $("#save_type").val('draft');
  23. $("#add_form").submit();
  24. }
  25. });
  26. $("#btn_publish").click(function(){
  27. if($(".exceeded").length <= 0) {
  28. $("#save_type").val('publish');
  29. $("#add_form").submit();
  30. }
  31. });
  32. $('#add_form').validate({
  33. errorPlacement: function(error, element){
  34. element.after(error);
  35. },
  36. success: function(label){
  37. label.addClass('valid');
  38. },
  39. rules : {
  40. picture_title: {
  41. required : true,
  42. minlength : 4,
  43. maxlength : 24
  44. },
  45. picture_title_short: {
  46. minlength : 4,
  47. maxlength : 12
  48. },
  49. picture_abstract: {
  50. maxlength : 140
  51. }
  52. },
  53. messages : {
  54. picture_title: {
  55. required : "<?php echo $lang['article_title_null'];?>",
  56. minlength: jQuery.validator.format("<?php echo $lang['article_title_error1'];?>"),
  57. maxlength : jQuery.validator.format("<?php echo $lang['article_title_error'];?>")
  58. },
  59. picture_title_short: {
  60. minlength: jQuery.validator.format("<?php echo $lang['article_title_error1'];?>"),
  61. maxlength : jQuery.validator.format("<?php echo $lang['article_title_error'];?>")
  62. },
  63. picture_abstract: {
  64. maxlength : jQuery.validator.format("<?php echo $lang['article_abstract_error'];?>")
  65. }
  66. }
  67. });
  68. //自定义滚定条
  69. $('#pic-upload-scrollbar').perfectScrollbar();
  70. //图片上传
  71. $("#picture_image_upload").fileupload({
  72. dataType: 'json',
  73. url: "<?php echo CMS_SITE_URL.DS.'index.php?act=publish&op=article_image_upload';?>",
  74. add: function(e,data) {
  75. $.each(data.files, function(index, file) {
  76. var image_content = '<li id=' + file.name.replace(/\./g, '_') + '>';
  77. image_content += '<dl class="picture-content">';
  78. image_content += '<dt class="picture-img">';
  79. image_content += '<div class="upload-thumb"><a href="Javascript: void(0);"><img src="' + LOADING_IMAGE + '" alt="" /></a></div>';
  80. image_content += '<div class="handle">';
  81. image_content += '<span class="upload-state">正在上传:' + file.name + '</span>';
  82. image_content += '</div>';
  83. image_content += '</dt>';
  84. image_content += '</dl>';
  85. image_content += '</li>';
  86. $(".picture-image-list").append(image_content);
  87. });
  88. data.submit();
  89. },
  90. done: function (e,data) {
  91. result = data.result;
  92. var $image_box = $('#' + result.origin_file_name.replace(/\./g, '_'));
  93. if(result.status == "success") {
  94. $image_box.find('img').attr('src', result.file_url);
  95. var $image_handle = $image_box.find('.handle');
  96. var image_handle = '<a nctype="btn_set_picture_image" image_name="'+result.file_name+'"><?php echo $lang['cms_cover'];?></a>';
  97. image_handle += '<a nctype="btn_drop_picture_image" image_name="'+result.file_name+'"><?php echo $lang['nc_delete'];?></a>';
  98. $image_handle.html(image_handle);
  99. var image_hidden = '<input name="picture_image_all[]" type="hidden" value="'+result.file_name + ',' + result.file_path +'" />';
  100. $image_handle.after(image_hidden);
  101. var image_content = '<dd class="picture-abstract"><h4><?php echo $lang['cms_image_abstract'];?></h4>';
  102. image_content += '<textarea name="picture_image_abstract[]" rows="2" class="textarea">';
  103. image_content += '</textarea></dd>';
  104. image_content += '<dd class="picture-add-goods">';
  105. image_content += '<input class="btn-type-s" nctype="btn_add_image_goods" image_name="'+result.file_name+'" type="button" value="添加商品" />';
  106. image_content += '</dd>';
  107. $image_box.find("dl").append(image_content);
  108. var image_goods_list = '<div class="goods-for-picture" nctype="image_goods_list"></div>';
  109. $image_box.append(image_goods_list);
  110. $image_box.find("textarea").nc_text_count({max:140});
  111. $image_box.attr('id', '');
  112. } else {
  113. $image_box.remove();
  114. showError(result.error);
  115. }
  116. }
  117. });
  118. //设封面图
  119. $("[nctype='btn_set_picture_image']").live("click",function(){
  120. var picture_image = $(this).parent().parent().find(".upload-thumb").html();
  121. $("#div_picture_image").html(picture_image);
  122. $("#picture_image").val($(this).attr("image_name"));
  123. });
  124. //图片删除
  125. $("[nctype='btn_drop_picture_image']").live("click",function(){
  126. var image_object = $(this).parents("li");
  127. var image_name = $(this).attr("image_name");
  128. $.getJSON("<?php echo CMS_SITE_URL.DS.'index.php?act=publish&op=article_image_drop';?>", { image_name: image_name }, function(result){
  129. if(result.status == "success") {
  130. image_object.remove();
  131. } else {
  132. showError(result.error);
  133. }
  134. });
  135. });
  136. //绑定商品
  137. $("[nctype='btn_add_image_goods']").live('click', function() {
  138. var add = '<div nctype="div_image_goods_add"><input class="text" style="width:235px;" nctype="image_goods_url" type="text" /><input class="btn-type-s" nctype="btn_goods_add_commit" type="button" image_name="'+$(this).attr("image_name")+'" value="<?php echo $lang['nc_confirm'];?>" /><input class="btn-type-s" nctype="btn_goods_add_cancel" type="button" value="<?php echo $lang['nc_cancel'];?>" /><div class="hint"><?php echo $lang['cms_picture_image_tips'];?></div></div>';
  139. $(this).after(add);
  140. $(this).hide();
  141. });
  142. //绑定商品确认
  143. $("[nctype='btn_goods_add_commit']").live('click', function() {
  144. var btn = $(this);
  145. var goods_list = btn.parents("li").find("[nctype='image_goods_list']");
  146. if(goods_list.find("dl").length < 3) {
  147. var url = encodeURIComponent($(this).parent().find("[nctype='image_goods_url']").val());
  148. var image_name = $(this).attr("image_name");
  149. if(url != '') {
  150. $.getJSON("<?php echo CMS_SITE_URL.DS.'index.php?act=api&op=goods_info_by_url';?>", { url: url}, function(data){
  151. if(data.result == "true") {
  152. var url_item = '<dl class="taobao-item">';
  153. url_item += '<dt class="taobao-item-title"><a href="'+data.url+'" target="_blank">'+data.title+'</a></dt>';
  154. url_item += '<dd class="taobao-item-img"><a href="'+data.url+'" target="_blank"><img src="'+data.image+'" alt="'+data.title+'" title="'+data.title+'" /></a></dd>';
  155. url_item += '<dd class="taobao-item-price"><?php echo $lang['currency'];?><em>'+data.price+'</em></dd>';
  156. url_item += '<dd class="taobao-item-delete" nctype="btn_image_goods_delete"><?php echo $lang['cms_delete'];?></dd>';
  157. url_item += '<input name="image_goods_url['+image_name+'][]" type="hidden" value="'+data.url+'" />';
  158. url_item += '<input name="image_goods_image['+image_name+'][]" type="hidden" value="'+data.image+'" />';
  159. url_item += '<input name="image_goods_price['+image_name+'][]" type="hidden" value="'+data.price+'"/>';
  160. url_item += '<input name="image_goods_title['+image_name+'][]" type="hidden" value="'+data.title+'"/>';
  161. url_item += '</dl>';
  162. goods_list.append(url_item);
  163. btn.parent().parent().find("[nctype='btn_add_image_goods']").show();
  164. btn.parent().remove();
  165. } else {
  166. alert(data.message);
  167. }
  168. });
  169. }
  170. }
  171. });
  172. //绑定商品取消
  173. $("[nctype='btn_goods_add_cancel']").live('click', function() {
  174. $(this).parent().parent().find("[nctype='btn_add_image_goods']").show();
  175. $(this).parent().remove();
  176. });
  177. //绑定商品删除
  178. $("[nctype='btn_image_goods_delete']").live('click', function() {
  179. $(this).parent().remove();
  180. });
  181. //标签操作
  182. $("[nctype='cms_tag']").live("click",function(){
  183. var current_css = $(this).attr("class");
  184. if(current_css == "btn-cms-tag") {
  185. $(this).attr("class","btn-cms-tag-selected");
  186. } else {
  187. $(this).attr("class","btn-cms-tag");
  188. }
  189. var cms_tag_selected = '';
  190. $(".btn-cms-tag-selected").each(function(){
  191. cms_tag_selected += $(this).attr("tag_id") + ",";
  192. });
  193. $("#picture_tag").val(cms_tag_selected.substring(0, cms_tag_selected.length-1));
  194. });
  195. });
  196. </script>
  197. <div class="cms-content mt10">
  198. <form id="add_form" method="post" action="index.php?act=publish&op=publish_picture_save">
  199. <input id="save_type" name="save_type" type="hidden" value="draft" />
  200. <input id="picture_id" name="picture_id" type="hidden" value="<?php if(!empty($output['picture_detail'])) echo $output['picture_detail']['picture_id'];?>" />
  201. <div class="cms-publish-content">
  202. <table class="cms-publish-table cms-publish-table-picture">
  203. <tbody>
  204. <tr>
  205. <th><?php echo $lang['cms_article_class'];?><?php echo $lang['nc_colon'];?></th>
  206. <td><select id="picture_class" name="picture_class">
  207. <?php if(!empty($output['picture_class_list']) && is_array($output['picture_class_list'])) {?>
  208. <?php foreach($output['picture_class_list'] as $value) {?>
  209. <option value="<?php echo $value['class_id'];?>" <?php if($value['class_id'] == $output['picture_detail']['picture_class_id']) echo 'selected';?>><?php echo $value['class_name'];?></option>
  210. <?php } ?>
  211. <?php } ?>
  212. </select></td>
  213. <td rowspan="3" class="w200"><input id="picture_image" name="picture_image" type="hidden" value="" />
  214. <div class="edit-cover-pic">
  215. <div id="div_picture_image" class="edit-cover-pic">
  216. <?php if(!empty($output['picture_detail']['picture_image'])) { ?>
  217. <img alt="" src="<?php echo getCMSArticleImageUrl($output['picture_detail']['picture_attachment_path'],$output['picture_detail']['picture_image'], 'list');?>">
  218. <?php } ?>
  219. </div>
  220. <p class="edit-cover-text"><?php echo $lang['cms_cover'];?></p>
  221. </td>
  222. </tr>
  223. <tr>
  224. <th><?php echo $lang['cms_title'];?><?php echo $lang['nc_colon'];?></th>
  225. <td><input id="picture_title" class="text w300" name="picture_title" type="text" value="<?php if(!empty($output['picture_detail'])) echo $output['picture_detail']['picture_title'];?>" />
  226. <div class="hint"><?php echo $lang['cms_title_explain'];?></div></td>
  227. </tr>
  228. <tr>
  229. <th><?php echo $lang['cms_title_short'];?><?php echo $lang['nc_colon'];?></th>
  230. <td><input id="article_title_short" class="text w300" name="picture_title_short" type="text" value="<?php if(!empty($output['picture_detail'])) echo $output['picture_detail']['picture_title_short'];?>" />
  231. <div class="hint"><?php echo $lang['cms_title_short_explain'];?></div></td>
  232. </tr>
  233. <tr>
  234. <th><?php echo $lang['cms_article_abstract'];?><?php echo $lang['nc_colon'];?></th>
  235. <td colspan="2"><div>
  236. <textarea name="picture_abstract" rows="3" class="textarea" style=" width:650px" id="picture_abstract"><?php if(!empty($output['picture_detail'])) echo $output['picture_detail']['picture_abstract'];?>
  237. </textarea>
  238. <div class="hint"><?php echo $lang['cms_article_abstract_explain'];?></div>
  239. </div></td>
  240. </tr>
  241. <tr>
  242. <th><?php echo $lang['cms_image_upload'];?><?php echo $lang['nc_colon'];?></th>
  243. <td colspan="2">
  244. <div id="pic-upload-scrollbar"><ul class="picture-image-list">
  245. <?php if(!empty($output['picture_image_list'])) { ?>
  246. <?php if(!empty($output['picture_image_list']) && is_array($output['picture_image_list'])) { ?>
  247. <?php foreach ($output['picture_image_list'] as $key=>$value) { ?>
  248. <li>
  249. <dl class="picture-content">
  250. <dt class="picture-img">
  251. <div class="upload-thumb"><a href="Javascript: void(0);"><img nctype="picture_image_item" alt="" src="<?php echo getCMSArticleImageUrl(empty($value['image_path'])?$output['picture_detail']['picture_attachment_path']:$value['image_path'], $value['image_name'], 'list');?>"></a></div>
  252. <div class="handle"><a image_name="<?php echo $value['image_name'];?>" nctype="btn_set_picture_image"><?php echo $lang['cms_cover'];?></a><a image_name="<?php echo $value['image_name'];?>" nctype="btn_drop_picture_image"><?php echo $lang['nc_delete'];?></a></div>
  253. </dt>
  254. <input type="hidden" value="<?php echo $value['image_name'].','.$value['image_path'];?>" name="picture_image_all[]">
  255. <dd class="picture-abstract">
  256. <h4><?php echo $lang['cms_image_abstract'];?></h4>
  257. <textarea name="picture_image_abstract[]" rows="2" class="textarea"><?php echo $value['image_abstract'];?></textarea>
  258. </dd>
  259. <dd class="picture-add-goods">
  260. <input class="btn-type-s" nctype="btn_add_image_goods" image_name="<?php echo $value['image_name'];?>" type="button" value="<?php echo $lang['cms_goods_add'];?>" />
  261. </dd>
  262. </dl>
  263. <div class="goods-for-picture" nctype="image_goods_list">
  264. <?php $image_goods_list = unserialize($value['image_goods']);?>
  265. <?php if(!empty($image_goods_list) && is_array($image_goods_list)) { ?>
  266. <?php foreach ($image_goods_list as $image_value) {?>
  267. <dl class="taobao-item">
  268. <dt class="taobao-item-title"><a href="<?php echo $image_value['url'];?>" target="_blank"><?php echo $image_value['title'];?></a></dt>
  269. <dd class="taobao-item-img"><a href="<?php echo $image_value['link'];?>" target="_blank"> <img src="<?php echo $image_value['image'];?>" alt="<?php echo $image_value['title'];?>" title="<?php echo $image_value['title'];?>" /> </a> </dd>
  270. <dd class="taobao-item-price"><?php echo $lang['currency'];?><em><?php echo $image_value['price'];?></em></dd>
  271. <dd class="taobao-item-delete" nctype="btn_image_goods_delete" title="<?php echo $lang['nc_delete'];?>"><?php echo $lang['nc_delete'];?></dd>
  272. <input name="image_goods_url[<?php echo $value['image_name'];?>][]" type="hidden" value="<?php echo $image_value['url'];?>" />
  273. <input name="image_goods_image[<?php echo $value['image_name'];?>][]" type="hidden" value="<?php echo $image_value['image'];?>" />
  274. <input name="image_goods_price[<?php echo $value['image_name'];?>][]" type="hidden" value="<?php echo $image_value['price'];?>"/>
  275. <input name="image_goods_title[<?php echo $value['image_name'];?>][]" type="hidden" value="<?php echo $image_value['title'];?>"/>
  276. </dl>
  277. <?php } ?>
  278. <?php } ?>
  279. </div>
  280. </li>
  281. <?php } ?>
  282. <?php } ?>
  283. <?php } ?>
  284. </ul></div>
  285. <div class="upload-btn"><a href="javascript:void(0);"><span>
  286. <input type="file" name="article_image_upload" id="picture_image_upload" multiple="" file_id="0" style="width:120px; height: 40px; cursor: pointer; opacity:0; filter: alpha(opacity=0)" size="1" hidefocus="true" />
  287. </span>
  288. <div class="upload-button"><i></i><?php echo $lang['cms_image_upload'];?></div>
  289. <input id="submit_button" style="display:none" type="button" value="&nbsp;" onClick="submit_form($(this))" />
  290. </a></div></td>
  291. </tr>
  292. <tr>
  293. <th><?php echo $lang['cms_text_publisher'];?></th>
  294. <td colspan="2"><input id="picture_author" class="text w100" name="picture_author" type="text" value="<?php echo empty($output['picture_detail']['picture_author'])?$output['publisher_info']['name']:$output['picture_detail']['picture_author'];?>"/>
  295. <div class="hint"><?php echo $lang['cms_publisher_explain'];?></div></td>
  296. </tr>
  297. <tr>
  298. <th><?php echo $lang['cms_publish_time'];?></th>
  299. <td colspan="2"><input id="picture_publish_time" class="text w100" name="picture_publish_time" type="text" value="<?php echo empty($output['picture_detail'])?date('Y-m-d',time()):date('Y-m-d',$output['picture_detail']['picture_publish_time']);?>"/>
  300. <div class="hint"><?php echo $lang['cms_publish_time_explain'];?></div></td>
  301. </tr>
  302. <tr>
  303. <th><?php echo $lang['cms_tag'];?><?php echo $lang['nc_colon'];?></th>
  304. <td colspan="2"><?php if(!empty($output['tag_list']) && is_array($output['tag_list'])) {?>
  305. <ul>
  306. <?php $tag_selected = explode(',',$output['picture_detail']['picture_tag']);?>
  307. <?php foreach($output['tag_list'] as $value) {?>
  308. <li nctype="cms_tag" class="<?php echo in_array($value['tag_id'],$tag_selected)?'btn-cms-tag-selected':'btn-cms-tag';?>" tag_id="<?php echo $value['tag_id'];?>"><?php echo $value['tag_name'];?></li>
  309. <?php } ?>
  310. </ul>
  311. <?php } ?>
  312. <input id="picture_tag" name="picture_tag" type="hidden" value="<?php if(!empty($output['picture_detail'])) echo $output['picture_detail']['picture_tag'];?>"/></td>
  313. </tr>
  314. <tr>
  315. <th><?php echo $lang['cms_keyword'];?><?php echo $lang['nc_colon'];?></th>
  316. <td colspan="2"><input id="picture_keyword" class="text w380" name="picture_keyword" type="text" value="<?php if(!empty($output['picture_detail'])) echo $output['picture_detail']['picture_keyword'];?>"/><div class="hint"><?php echo $lang['cms_keyword_expalin'];?></div></td>
  317. </tr>
  318. </tbody>
  319. <tfoot>
  320. <tr>
  321. <td colspan="21"><a id="btn_draft" class="btn-draft" href="javascript:void(0);"><?php echo $lang['cms_article_save_draft'];?></a> <a id="btn_publish" class="btn-publish" href="javascript:void(0);"><?php echo $lang['cms_text_publish'];?></a></td>
  322. </tr>
  323. </tfoot>
  324. </table>
  325. </div>
  326. </form>
  327. </div>