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

172 lines
7.3KB

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