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

243 lines
9.4KB

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