国内流行的内容管理系统(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.

290 lines
9.5KB

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