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

186 lines
7.7KB

  1. <?php
  2. /**
  3. * 文档编辑
  4. *
  5. * @version $id:article_edit.php 14:12 2010年7月12日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 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 (file_exists(DEDEDATA.'/template.rand.php')) {
  16. require_once(DEDEDATA.'/template.rand.php');
  17. }
  18. if (empty($dopost)) $dopost = '';
  19. $aid = isset($aid) && is_numeric($aid) ? $aid : 0;
  20. if ($dopost != 'save') {
  21. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  22. require_once(DEDEINC."/dedetag.class.php");
  23. ClearMyAddon();
  24. //读取归档信息
  25. $query = "SELECT ch.typename AS channelname,ar.membername AS rankname,arc.* FROM `#@__archives` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel LEFT JOIN `#@__arcrank` ar ON ar.`rank`=arc.arcrank WHERE arc.id='$aid' ";
  26. $arcRow = $dsql->GetOne($query);
  27. if (!is_array($arcRow)) {
  28. ShowMsg("读取文档基本信息出错", "-1");
  29. exit();
  30. }
  31. $query = "SELECT * FROM `#@__channeltype` WHERE id='".$arcRow['channel']."'";
  32. $cInfos = $dsql->GetOne($query);
  33. if (!is_array($cInfos)) {
  34. ShowMsg("读取频道配置信息出错", "javascript:;");
  35. exit();
  36. }
  37. $addtable = $cInfos['addtable'];
  38. $addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid='$aid'");
  39. if (!is_array($addRow)) {
  40. ShowMsg("读取附加信息出错", "javascript:;");
  41. exit();
  42. }
  43. $channelid = $arcRow['channel'];
  44. $tags = GetTags($aid);
  45. include DedeInclude("templets/article_edit.htm");
  46. exit();
  47. }
  48. /*--------------------------------
  49. function __save(){ }
  50. -------------------------------*/
  51. else if ($dopost == 'save') {
  52. require_once(DEDEINC.'/image.func.php');
  53. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  54. $flag = isset($flags) ? join(',', $flags) : '';
  55. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  56. if (empty($typeid2)) $typeid2 = 0;
  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. if (empty($typeid)) {
  62. ShowMsg("请指定文档的栏目", "-1");
  63. exit();
  64. }
  65. if (empty($channelid)) {
  66. ShowMsg("文档为非指定的类型,请检查您发布内容的表单是否合法", "-1");
  67. exit();
  68. }
  69. if (!CheckChannel($typeid, $channelid)) {
  70. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  71. exit();
  72. }
  73. if (!TestPurview('a_Edit')) {
  74. if (TestPurview('a_AccEdit')) {
  75. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  76. } else {
  77. CheckArcAdmin($id, $cuserLogin->getUserID());
  78. }
  79. }
  80. //对保存的内容进行处理
  81. $pubdate = GetMkTime($pubdate);
  82. $sortrank = AddDay($pubdate, $sortup);
  83. $ismake = $ishtml == 0 ? -1 : 0;
  84. $autokey = 1;
  85. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  86. $shorttitle = cn_substrR($shorttitle, 36);
  87. $color = cn_substrR($color, 7);
  88. $writer = cn_substrR($writer, 20);
  89. $source = cn_substrR($source, 30);
  90. $description = cn_substrR($description, 250);
  91. $keywords = trim(cn_substrR($keywords, 60));
  92. $filename = trim(cn_substrR($filename, 40));
  93. $isremote = 0;
  94. $serviterm = empty($serviterm) ? "" : $serviterm;
  95. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  96. $arcrank = -1;
  97. }
  98. $adminid = $cuserLogin->getUserID();
  99. //处理上传的缩略图
  100. if (empty($ddisremote)) {
  101. $ddisremote = 0;
  102. }
  103. $litpic = GetDDImage('none', $picname, $ddisremote);
  104. //分析body里的内容
  105. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  106. //分析处理附加表数据
  107. $inadd_f = '';
  108. $inadd_v = '';
  109. if (!empty($dede_addonfields)) {
  110. $addonfields = explode(';', $dede_addonfields);
  111. $inadd_f = '';
  112. $inadd_v = '';
  113. if (is_array($addonfields)) {
  114. foreach ($addonfields as $v) {
  115. if ($v == '') {
  116. continue;
  117. }
  118. $vs = explode(',', $v);
  119. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  120. {
  121. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  122. } else {
  123. if (!isset(${$vs[0]})) {
  124. ${$vs[0]} = '';
  125. }
  126. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  127. }
  128. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  129. }
  130. }
  131. }
  132. //处理图片文档的自定义属性
  133. if ($litpic != '' && !preg_match("#p#", $flag)) {
  134. $flag = ($flag == '' ? 'p' : $flag.',p');
  135. }
  136. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  137. $flag = ($flag == '' ? 'j' : $flag.',j');
  138. }
  139. //跳转网址的文档强制为动态
  140. if (preg_match("#j#", $flag)) $ismake = -1;
  141. //更新数据库的SQL语句
  142. $query = "UPDATE `#@__archives` SET typeid='$typeid',typeid2='$typeid2',sortrank='$sortrank',flag='$flag',click='$click',ismake='$ismake',arcrank='$arcrank',money='$money',title='$title',color='$color',writer='$writer',source='$source',litpic='$litpic',pubdate='$pubdate',notpost='$notpost',description='$description',keywords='$keywords',shorttitle='$shorttitle',filename='$filename',dutyadmin='$adminid',weight='$weight'WHERE id='$id'; ";
  143. if (!$dsql->ExecuteNoneQuery($query)) {
  144. ShowMsg('数据保存到数据库主表`#@__archives`时出错,请检查数据库字段', -1);
  145. exit();
  146. }
  147. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  148. $addtable = trim($cts['addtable']);
  149. if ($addtable != '') {
  150. $useip = GetIP();
  151. $templet = empty($templet) ? '' : $templet;
  152. $iquery = "UPDATE `$addtable` SET typeid='$typeid',body='$body'{$inadd_f},redirecturl='$redirecturl',templet='$templet',userip='$useip' WHERE aid='$id'";
  153. if (!$dsql->ExecuteNoneQuery($iquery)) {
  154. ShowMsg("数据保存到数据库附加表时出错,请检查数据库字段", "javascript:;");
  155. exit();
  156. }
  157. }
  158. //生成网页
  159. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  160. $artUrl = MakeArt($id, true, true, $isremote);
  161. if ($artUrl == '') {
  162. $artUrl = $cfg_phpurl."/view.php?aid=$id";
  163. }
  164. ClearMyAddon($id, $title);
  165. //自动更新关联内容
  166. if (is_array($automake)) {
  167. foreach ($automake as $key => $value) {
  168. if (isset(${$key}) && !empty(${$key})) {
  169. $ids = explode(",", ${$key});
  170. foreach ($ids as $id) {
  171. MakeArt($id, true, true, $isremote);
  172. }
  173. }
  174. }
  175. }
  176. //返回成功信息
  177. $msg = "请选择您的后续操作:<a href='article_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布新文档</a><a href='archives_do.php?aid=".$id."&dopost=editArchives' class='btn btn-success btn-sm'>修改文档</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看文档</a><a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>管理文档</a>$backurl";
  178. $wintitle = "成功修改文档";
  179. $wecome_info = "文档管理::修改文档";
  180. $win = new OxWindow();
  181. $win->AddTitle("成功修改文档:");
  182. $win->AddMsgItem($msg);
  183. $winform = $win->GetWindow("hand", "&nbsp;", false);
  184. $win->Display();
  185. }
  186. ?>