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

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