国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

291 lines
9.7KB

  1. <?php
  2. /**
  3. * 专题编辑
  4. *
  5. * @version $Id: spec_edit.php 1 16:22 2010年7月20日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license http://help.dedecms.com/usersguide/license.html
  10. * @link http://www.dedecms.com
  11. */
  12. require_once(dirname(__FILE__)."/config.php");
  13. CheckPurview('a_Edit,a_AccEdit,a_MyEdit');
  14. require_once(DEDEINC."/customfields.func.php");
  15. require_once(DEDEADMIN."/inc/inc_archives_functions.php");
  16. if(empty($dopost)) $dopost = '';
  17. if($dopost!='save')
  18. {
  19. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  20. require_once(DEDEINC."/dedetag.class.php");
  21. ClearMyAddon();
  22. $aid = intval($aid);
  23. $channelid = -1;
  24. //读取归档信息
  25. $arcQuery = "SELECT ch.typename as channelname,ar.membername as rankname,arc.*
  26. FROM `#@__archives` arc
  27. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  28. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
  29. $arcRow = $dsql->GetOne($arcQuery);
  30. if(!is_array($arcRow))
  31. {
  32. ShowMsg("读取档案基本信息出错!","-1");
  33. exit();
  34. }
  35. $query = "SELECT * FROM `#@__channeltype` WHERE id='-1'";
  36. $cInfos = $dsql->GetOne($query);
  37. if(!is_array($cInfos))
  38. {
  39. ShowMsg("读取频道配置信息出错!","javascript:;");
  40. exit();
  41. }
  42. $addRow = $dsql->GetOne("SELECT * FROM `#@__addonspec` WHERE aid='$aid'");
  43. $tags = GetTags($aid);
  44. include DedeInclude("templets/spec_edit.htm");
  45. }
  46. /*--------------------------------
  47. function __save(){ }
  48. -------------------------------*/
  49. else if($dopost=='save')
  50. {
  51. require_once(DEDEINC.'/image.func.php');
  52. require_once(DEDEINC.'/oxwindow.class.php');
  53. $flag = isset($flags) ? join(',', $flags) : '';
  54. $notpost = isset($notpost) && $notpost == 1 ? 1: 0;
  55. if(!isset($tags)) $tags = '';
  56. $channelid= -1;
  57. //处理自定义字段会用到这些变量
  58. if(!isset($autokey)) $autokey = 0;
  59. if(!isset($remote)) $remote = 0;
  60. if(!isset($dellink)) $dellink = 0;
  61. if(!isset($autolitpic)) $autolitpic = 0;
  62. //对保存的内容进行处理
  63. $pubdate = GetMkTime($pubdate);
  64. $sortrank = AddDay($pubdate, $sortup);
  65. if($ishtml==0) $ismake = -1;
  66. else $ismake = 0;
  67. $title = cn_substrR($title, $cfg_title_maxlen);
  68. $shorttitle = cn_substrR($shorttitle, 36);
  69. $color = cn_substrR($color, 7);
  70. $writer = cn_substrR($writer, 20);
  71. $source = cn_substrR($source, 30);
  72. $description = cn_substrR($description, $cfg_auot_description);
  73. $keywords = trim(cn_substrR($keywords, 60));
  74. $filename = trim(cn_substrR($filename, 40));
  75. $isremote = 0;
  76. $serviterm = empty($serviterm)? "" : $serviterm;
  77. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  78. {
  79. $arcrank = -1;
  80. }
  81. $adminid = $cuserLogin->getUserID();
  82. //处理上传的缩略图
  83. if(empty($ddisremote))
  84. {
  85. $ddisremote = 0;
  86. }
  87. $litpic = GetDDImage('none', $picname, $ddisremote);
  88. // 处理新的缩略图上传
  89. if ($litpic_b64 != "") {
  90. $data = explode( ',', $litpic_b64 );
  91. $ntime = time();
  92. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  93. CreateDir($savepath);
  94. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  95. $fullUrl = $fullUrl.".png";
  96. file_put_contents($cfg_basedir.$fullUrl, base64_decode( $data[ 1 ] ));
  97. // 加水印
  98. WaterImg($cfg_basedir.$fullUrl, 'up');
  99. $litpic = $fullUrl;
  100. }
  101. //分析处理附加表数据
  102. $inadd_f = '';
  103. $inadd_v = '';
  104. if(!empty($dede_addonfields))
  105. {
  106. $addonfields = explode(';', $dede_addonfields);
  107. $inadd_f = '';
  108. $inadd_v = '';
  109. if(is_array($addonfields))
  110. {
  111. foreach($addonfields as $v)
  112. {
  113. if($v=='')
  114. {
  115. continue;
  116. }
  117. $vs = explode(',',$v);
  118. if($vs[1]=='htmltext'||$vs[1]=='textdata') //HTML文本特殊处理
  119. {
  120. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  121. }else{
  122. if(!isset(${$vs[0]}))
  123. {
  124. ${$vs[0]} = '';
  125. }
  126. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  127. }
  128. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  129. }
  130. }
  131. }
  132. //处理图片文档的自定义属性
  133. if($litpic!='' && !preg_match('#p#',$flag))
  134. {
  135. $flag = ($flag=='' ? 'p' : $flag.',p');
  136. }
  137. $inQuery = "UPDATE `#@__archives` SET
  138. typeid='$typeid',
  139. sortrank='$sortrank',
  140. flag='$flag',
  141. ismake='$ismake',
  142. arcrank='$arcrank',
  143. click='$click',
  144. title='$title',
  145. color='$color',
  146. writer='$writer',
  147. source='$source',
  148. litpic='$litpic',
  149. pubdate='$pubdate',
  150. notpost='$notpost',
  151. description='$description',
  152. keywords='$keywords',
  153. shorttitle='$shorttitle',
  154. filename='$filename'
  155. WHERE id='$id'; ";
  156. if(!$dsql->ExecuteNoneQuery($inQuery))
  157. {
  158. ShowMsg("更新数据库archives表时出错,请检查!","-1");
  159. exit();
  160. }
  161. //专题节点列表
  162. $arcids = array();
  163. $notelist = '';
  164. for($i=1;$i<=$cfg_specnote;$i++)
  165. {
  166. if(!empty(${'notename'.$i}))
  167. {
  168. $notename = str_replace("'","",trim(${'notename'.$i}));
  169. $arcid = trim(${'arcid'.$i});
  170. $col = trim(${'col'.$i});
  171. $imgwidth = trim(${'imgwidth'.$i});
  172. $imgheight = trim(${'imgheight'.$i});
  173. $titlelen = trim(${'titlelen'.$i});
  174. $infolen = trim(${'infolen'.$i});
  175. $listtmp = trim(${'listtmp'.$i});
  176. if(isset(${'noteid'.$i}))
  177. {
  178. $noteid = trim(${'noteid'.$i});
  179. }
  180. else
  181. {
  182. $noteid = $i;
  183. }
  184. if(isset(${'isauto'.$i}))
  185. {
  186. $isauto = trim(${'isauto'.$i});
  187. }
  188. else
  189. {
  190. $isauto = 0;
  191. }
  192. if(isset(${'keywords'.$i}))
  193. {
  194. $keywords = str_replace("'","",trim(${'keywords'.$i}));
  195. }
  196. else
  197. {
  198. $keywords = "";
  199. }
  200. if(!empty(${'typeid'.$i}))
  201. {
  202. $ttypeid = trim(${'typeid'.$i});
  203. }
  204. else
  205. {
  206. $ttypeid = 0;
  207. }
  208. if(!empty(${'rownum'.$i}))
  209. {
  210. $rownum = trim(${'rownum'.$i});
  211. }
  212. else
  213. {
  214. $rownum = 0;
  215. }
  216. $arcid = preg_replace("#[^0-9,]#", "", $arcid);
  217. $ids = explode(",", $arcid);
  218. $okids = "";
  219. if(is_array($ids))
  220. {
  221. foreach($ids as $mid)
  222. {
  223. $mid = trim($mid);
  224. if($mid=="") continue;
  225. if(!isset($arcids[$mid]))
  226. {
  227. if($okids=="")
  228. {
  229. $okids .= $mid;
  230. }
  231. else
  232. {
  233. $okids .= ",".$mid;
  234. }
  235. $arcids[$mid] = 1;
  236. }
  237. }
  238. }
  239. $notelist .= "{dede:specnote imgheight=\\'$imgheight\\' imgwidth=\\'$imgwidth\\'
  240. infolen=\\'$infolen\\' titlelen=\\'$titlelen\\' col=\\'$col\\' idlist=\\'$okids\\'
  241. name=\\'$notename\\' noteid=\\'$noteid\\' isauto=\'$isauto\' rownum=\\'$rownum\\'
  242. keywords=\\'$keywords\\' typeid=\\'$ttypeid\\'}
  243. $listtmp
  244. {/dede:specnote}\r\n";
  245. }
  246. }
  247. //更新附加表
  248. $inQuery = "UPDATE `#@__addonspec` SET typeid ='$typeid',note='$notelist'{$inadd_f},templet='$templet' WHERE aid='$id';";
  249. if(!$dsql->ExecuteNoneQuery($inQuery))
  250. {
  251. ShowMsg("更新数据库附加表 addonspec 时出错,请检查原因!", "-1");
  252. exit();
  253. }
  254. //生成HTML
  255. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  256. $artUrl = MakeArt($id, TRUE, TRUE, $isremote);
  257. if($artUrl=='')
  258. {
  259. $artUrl = $cfg_phpurl."/view.php?aid=$id";
  260. }
  261. ClearMyAddon($id, $title);
  262. //返回成功信息
  263. $msg = "  请选择你的后续操作:
  264. <a href='spec_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>发布新专题</a>
  265. &nbsp;&nbsp;
  266. <a href='archives_do.php?aid=".$id."&dopost=editArchives' class='btn btn-secondary btn-sm'>查看更改</a>
  267. &nbsp;&nbsp;
  268. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看专题</a>
  269. &nbsp;&nbsp;
  270. <a href='content_s_list.php' class='btn btn-secondary btn-sm'>已发布专题管理</a> ";
  271. $wintitle = "成功更改一个专题!";
  272. $wecome_info = "专题管理::更改专题";
  273. $win = new OxWindow();
  274. $win->AddTitle("成功更改专题!");
  275. $win->AddMsgItem($msg);
  276. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  277. $win->Display();
  278. }