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

182 line
7.6KB

  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. CheckCatalog($typeid, "您没有操作栏目<span class='text-primary'>{$typeid}</span>文档权限");
  75. }
  76. //对保存的文档进行处理
  77. $pubdate = GetMkTime($pubdate);
  78. $sortrank = AddDay($pubdate, $sortup);
  79. $ismake = $ishtml == 0 ? -1 : 0;
  80. $autokey = 1;
  81. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  82. $shorttitle = cn_substrR($shorttitle, 36);
  83. $color = cn_substrR($color, 7);
  84. $writer = cn_substrR($writer, 20);
  85. $source = cn_substrR($source, 30);
  86. $description = cn_substrR($description, 250);
  87. $keywords = trim(cn_substrR($keywords, 60));
  88. $filename = trim(cn_substrR($filename, 40));
  89. $isremote = 0;
  90. $serviterm = empty($serviterm) ? "" : $serviterm;
  91. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  92. $arcrank = -1;
  93. }
  94. $adminid = $cuserLogin->getUserID();
  95. //处理上传的缩略图
  96. if (empty($ddisremote)) {
  97. $ddisremote = 0;
  98. }
  99. $litpic = GetDDImage('none', $picname, $ddisremote);
  100. //分析body里的文档
  101. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  102. //分析处理附加表数据
  103. $inadd_f = '';
  104. $inadd_v = '';
  105. if (!empty($dede_addonfields)) {
  106. $addonfields = explode(';', $dede_addonfields);
  107. $inadd_f = '';
  108. $inadd_v = '';
  109. if (is_array($addonfields)) {
  110. foreach ($addonfields as $v) {
  111. if ($v == '') {
  112. continue;
  113. }
  114. $vs = explode(',', $v);
  115. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //网页文本特殊处理
  116. {
  117. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  118. } else {
  119. if (!isset(${$vs[0]})) {
  120. ${$vs[0]} = '';
  121. }
  122. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  123. }
  124. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  125. }
  126. }
  127. }
  128. //处理图片文档的自定义属性
  129. if ($litpic != '' && !preg_match("#p#", $flag)) {
  130. $flag = ($flag == '' ? 'p' : $flag.',p');
  131. }
  132. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  133. $flag = ($flag == '' ? 'j' : $flag.',j');
  134. }
  135. //跳转网址的文档强制为动态
  136. if (preg_match("#j#", $flag)) $ismake = -1;
  137. //更新数据库的SQL语句
  138. $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'; ";
  139. if (!$dsql->ExecuteNoneQuery($query)) {
  140. ShowMsg('数据保存到数据库主表`#@__archives`时出错,请检查数据库字段', -1);
  141. exit();
  142. }
  143. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  144. $addtable = trim($cts['addtable']);
  145. if ($addtable != '') {
  146. $useip = GetIP();
  147. $templet = empty($templet) ? '' : $templet;
  148. $iquery = "UPDATE `$addtable` SET typeid='$typeid',body='$body'{$inadd_f},redirecturl='$redirecturl',templet='$templet',userip='$useip' WHERE aid='$id'";
  149. if (!$dsql->ExecuteNoneQuery($iquery)) {
  150. ShowMsg("数据保存到数据库附加表时出错,请检查数据库字段", "javascript:;");
  151. exit();
  152. }
  153. }
  154. //生成网页
  155. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  156. $artUrl = MakeArt($id, true, true, $isremote);
  157. if ($artUrl == '') {
  158. $artUrl = $cfg_phpurl."/view.php?aid=$id";
  159. }
  160. ClearMyAddon($id, $title);
  161. //自动更新关联文档
  162. if (is_array($automake)) {
  163. foreach ($automake as $key => $value) {
  164. if (isset(${$key}) && !empty(${$key})) {
  165. $ids = explode(",", ${$key});
  166. foreach ($ids as $id) {
  167. MakeArt($id, true, true, $isremote);
  168. }
  169. }
  170. }
  171. }
  172. //返回成功信息
  173. $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";
  174. $wintitle = "成功修改文档";
  175. $wecome_info = "文档管理::修改文档";
  176. $win = new OxWindow();
  177. $win->AddTitle("成功修改文档");
  178. $win->AddMsgItem($msg);
  179. $winform = $win->GetWindow("hand", "&nbsp;", false);
  180. $win->Display();
  181. }
  182. ?>