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

179 line
7.4KB

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