国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
7.1KB

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