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

196 lines
7.4KB

  1. <?php
  2. /**
  3. * 文档编辑
  4. *
  5. * @version $Id: archives_edit.php 1 8:26 2010年7月12日Z 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.*
  23. FROM `#@__archives` arc
  24. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  25. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid'";
  26. $arcRow = $dsql->GetOne($arcQuery);
  27. if (!is_array($arcRow)) {
  28. ShowMsg("读取档案基本信息出错!", "-1");
  29. exit();
  30. }
  31. $query = "SELECT * FROM `#@__channeltype` WHERE id='".$arcRow['channel']."'";
  32. $cInfos = $dsql->GetOne($query);
  33. if (!is_array($cInfos)) {
  34. ShowMsg("读取频道配置信息出错!", "javascript:;");
  35. exit();
  36. }
  37. $addtable = $cInfos['addtable'];
  38. $addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid='$aid'");
  39. $channelid = $arcRow['channel'];
  40. $tags = GetTags($aid);
  41. include DedeInclude("templets/archives_edit.htm");
  42. exit();
  43. }
  44. /*--------------------------------
  45. function __save(){ }
  46. -------------------------------*/
  47. else if ($dopost == 'save') {
  48. require_once(DEDEINC.'/image.func.php');
  49. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  50. $flag = isset($flags) ? join(',', $flags) : '';
  51. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  52. if (empty($typeid2)) $typeid2 = 0;
  53. if (!isset($autokey)) $autokey = 0;
  54. if (!isset($remote)) $remote = 0;
  55. if (!isset($dellink)) $dellink = 0;
  56. if (!isset($autolitpic)) $autolitpic = 0;
  57. if (!isset($writer)) $writer = '';
  58. if ($typeid == 0) {
  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. if (TestPurview('a_AccEdit')) {
  72. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  73. } else {
  74. CheckArcAdmin($id, $cuserLogin->getUserID());
  75. }
  76. }
  77. //对保存的内容进行处理
  78. $pubdate = GetMkTime($pubdate);
  79. $sortrank = AddDay($pubdate, $sortup);
  80. $ismake = $ishtml == 0 ? -1 : 0;
  81. $title = cn_substrR($title, $cfg_title_maxlen);
  82. $shorttitle = cn_substrR($shorttitle, 36);
  83. $color = cn_substrR($color, 7);
  84. $writer = cn_substrR($writer, 20);
  85. $source = cn_substrR($source, 30);
  86. $description = cn_substrR($description, $cfg_auot_description);
  87. $keywords = trim(cn_substrR($keywords, 60));
  88. $filename = trim(cn_substrR($filename, 40));
  89. $isremote = 0;
  90. $serviterm = empty($serviterm) ? "" : $serviterm;
  91. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  92. $adminid = $cuserLogin->getUserID();
  93. //处理上传的缩略图
  94. if (empty($ddisremote)) $ddisremote = 0;
  95. $litpic = GetDDImage('none', $picname, $ddisremote);
  96. //分析处理附加表数据
  97. $inadd_f = '';
  98. $inadd_v = '';
  99. if (!empty($dede_addonfields)) {
  100. $addonfields = explode(';', $dede_addonfields);
  101. $inadd_f = '';
  102. $inadd_v = '';
  103. if (is_array($addonfields)) {
  104. foreach ($addonfields as $v) {
  105. if ($v == '') {
  106. continue;
  107. }
  108. $vs = explode(',', $v);
  109. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  110. {
  111. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  112. } else {
  113. if (!isset(${$vs[0]})) {
  114. ${$vs[0]} = '';
  115. }
  116. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  117. }
  118. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  119. }
  120. }
  121. }
  122. //处理图片文档的自定义属性
  123. if ($litpic != '' && !preg_match("#p#", $flag)) {
  124. $flag = ($flag == '' ? 'p' : $flag.',p');
  125. }
  126. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  127. $flag = ($flag == '' ? 'j' : $flag.',j');
  128. }
  129. //跳转网址的文档强制为动态
  130. if (preg_match("#j#", $flag)) $ismake = -1;
  131. //更新数据库的SQL语句
  132. $inQuery = "UPDATE `#@__archives` SET
  133. typeid='$typeid',
  134. typeid2='$typeid2',
  135. sortrank='$sortrank',
  136. flag='$flag',
  137. notpost='$notpost',
  138. click='$click',
  139. ismake='$ismake',
  140. arcrank='$arcrank',
  141. money='$money',
  142. title='$title',
  143. color='$color',
  144. writer='$writer',
  145. source='$source',
  146. litpic='$litpic',
  147. pubdate='$pubdate',
  148. description='$description',
  149. keywords='$keywords',
  150. shorttitle='$shorttitle',
  151. filename='$filename',
  152. dutyadmin='$adminid',
  153. weight='$weight'
  154. WHERE id='$id'; ";
  155. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  156. ShowMsg("更新数据库archives表时出错,请检查", "-1");
  157. exit();
  158. }
  159. $cts = $dsql->GetOne("SELECT addtable From `#@__channeltype` WHERE id='$channelid' ");
  160. $addtable = trim($cts['addtable']);
  161. if ($addtable != '') {
  162. $useip = GetIP();
  163. $iquery = "UPDATE `$addtable` SET typeid='$typeid'{$inadd_f},redirecturl='$redirecturl',userip='$useip' WHERE aid='$id' ";
  164. if (!$dsql->ExecuteNoneQuery($iquery)) {
  165. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因", "javascript:;");
  166. exit();
  167. }
  168. }
  169. //生成HTML
  170. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  171. $artUrl = MakeArt($id, TRUE, TRUE, $isremote);
  172. if ($artUrl == '') {
  173. $artUrl = $cfg_phpurl."/view.php?aid=$id";
  174. }
  175. ClearMyAddon($id, $title);
  176. //自动更新关联内容
  177. if (is_array($automake)) {
  178. foreach ($automake as $key => $value) {
  179. if (isset(${$key}) && !empty(${$key})) {
  180. $ids = explode(",", ${$key});
  181. foreach ($ids as $id) {
  182. MakeArt($id, true, true, $isremote);
  183. }
  184. }
  185. }
  186. }
  187. //返回成功信息
  188. $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";
  189. $wintitle = "成功修改商品";
  190. $wecome_info = "文档管理::修改商品";
  191. $win = new OxWindow();
  192. $win->AddTitle("成功修改商品:");
  193. $win->AddMsgItem($msg);
  194. $winform = $win->GetWindow("hand", "&nbsp;", false);
  195. $win->Display();
  196. }