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

164 lines
7.2KB

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