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

178 lines
7.5KB

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