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

101 lines
4.9KB

  1. <?php
  2. /**
  3. * 修改自定义文档模型
  4. *
  5. * @version $id:archives_edit.php 13:52 2010年7月9日 tianya $
  6. * @package DedeBIZ.User
  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. CheckRank(0, 0);//禁止游客操作
  13. require_once(DEDEINC."/dedetag.class.php");
  14. require_once(DEDEINC."/customfields.func.php");
  15. require_once(DEDEMEMBER."/inc/inc_catalog_options.php");
  16. require_once(DEDEMEMBER."/inc/inc_archives_functions.php");
  17. $channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 1;
  18. $aid = isset($aid) && is_numeric($aid) ? $aid : 0;
  19. $mtypesid = isset($mtypesid) && is_numeric($mtypesid) ? $mtypesid : 0;
  20. $menutype = 'content';
  21. if (empty($dopost)) {
  22. //读取归档信息
  23. $arcQuery = "SELECT arc.*,ch.addtable,ch.fieldset,arc.mtype as mtypeid,ch.arcsta FROM `#@__archives` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='$aid' And arc.mid='".$cfg_ml->M_ID."'; ";
  24. $row = $dsql->GetOne($arcQuery);
  25. if (!is_array($row)) {
  26. ShowMsg("读取文档信息出错", "index.php");
  27. exit();
  28. } else if ($row['arcrank'] >= 0) {
  29. $dtime = time();
  30. $maxtime = $cfg_mb_editday * 24 * 3600;
  31. if ($dtime - $row['senddate'] > $maxtime) {
  32. ShowMsg("这篇文档已锁定,暂时无法修改", "-1");
  33. exit();
  34. }
  35. }
  36. $addRow = $dsql->GetOne("SELECT * FROM `{$row['addtable']}` WHERE aid='$aid';");
  37. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='{$row['channel']}';");
  38. include(DEDEMEMBER."/templets/archives_edit.htm");
  39. exit();
  40. } else if ($dopost == 'save') {
  41. include(DEDEMEMBER.'/inc/archives_check_edit.php');
  42. //分析处理附加表数据
  43. $inadd_f = $inadd_m = '';
  44. if (!empty($dede_addonfields)) {
  45. $addonfields = explode(';', $dede_addonfields);
  46. if (is_array($addonfields)) {
  47. foreach ($addonfields as $v) {
  48. if ($v == '') {
  49. continue;
  50. }
  51. $vs = explode(',', $v);
  52. if (!isset(${$vs[0]})) {
  53. ${$vs[0]} = '';
  54. }
  55. //自动摘要和远程图片本地化
  56. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  57. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $vs[1]);
  58. }
  59. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $aid);
  60. $inadd_m .= ','.$vs[0];
  61. $inadd_f .= ','.$vs[0]." ='".${$vs[0]}."' ";
  62. }
  63. }
  64. //这里对前台提交的附加数据进行一次校验
  65. $fontiterm = PrintAutoFieldsAdd(stripslashes($cInfos['fieldset']), 'autofield', FALSE);
  66. if ($fontiterm != $inadd_m) {
  67. ShowMsg("提交的信息有错误,请修改重新提交", "-1");
  68. exit();
  69. }
  70. }
  71. //处理图片文档的自定义属性
  72. if ($litpic != '') $flag = 'p';
  73. //更新数据库的SQL语句
  74. $litpic = isset($litpic)? HtmlReplace($litpic, 1) : '';
  75. $upQuery = "UPDATE `#@__archives` SET ismake='$ismake',arcrank='$arcrank',typeid='$typeid',title='$title',litpic='$litpic',description='$description',keywords='$keywords',mtype='$mtypesid',flag='$flag' WHERE id='$aid' And mid='$mid'; ";
  76. if (!$dsql->ExecuteNoneQuery($upQuery)) {
  77. ShowMsg("数据保存到数据库文档主表出错,请联系管理员".$dsql->GetError(), "-1");
  78. exit();
  79. }
  80. if ($addtable != '') {
  81. $upQuery = "UPDATE `$addtable` SET typeid='$typeid'{$inadd_f}, userip='$userip' WHERE aid='$aid' ";
  82. if (!$dsql->ExecuteNoneQuery($upQuery)) {
  83. ShowMsg("数据保存到数据库附加表出错,请联系管理员", "javascript:;");
  84. exit();
  85. }
  86. }
  87. $arcrank = empty($arcrank) ? 0 : $arcrank;
  88. $sortrank = empty($sortrank) ? 0 : $sortrank;
  89. UpIndexKey($aid, $arcrank, $typeid, $sortrank, $tags);
  90. $artUrl = MakeArt($aid, TRUE);
  91. if ($artUrl == '') $artUrl = $cfg_phpurl."/view.php?aid=$aid";
  92. //返回成功信息
  93. $msg = "<a href='archives_add.php?cid=$typeid&channelid=$channelid' class='btn btn-success btn-sm'>发布自定义文档</a><a href='archives_edit.php?channelid=$channelid&aid=".$aid."' class='btn btn-success btn-sm'>修改自定义文档</a><a class='btn btn-success btn-sm' href='$artUrl' target='_blank'>浏览自定义文档</a><a href='content_list.php?channelid=$channelid' class='btn btn-success btn-sm'>管理自定义文档</a>";
  94. $wintitle = "成功修改自定义文档";
  95. $wecome_info = "文档管理 - 修改自定义文档";
  96. $win = new OxWindow();
  97. $win->AddMsgItem($msg);
  98. $winform = $win->GetWindow("hand", false);
  99. $win->Display(DEDEMEMBER."/templets/win_templet.htm");
  100. }
  101. ?>