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

140 lines
6.0KB

  1. <?php
  2. /**
  3. * 单表模型文档编辑
  4. *
  5. * @version $Id: archives_sg_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.*,arc.* FROM `#@__arctiny` arc
  23. LEFT JOIN `#@__channeltype` ch on ch.id=arc.channel WHERE arc.id='$aid' ";
  24. $cInfos = $dsql->GetOne($arcQuery);
  25. if (!is_array($cInfos)) {
  26. ShowMsg("读频道模型信息出错", "-1");
  27. exit();
  28. }
  29. $addtable = $cInfos['addtable'];
  30. $addRow = $dsql->GetOne("SELECT arc.*,ar.membername as rankname FROM `$addtable` arc LEFT JOIN `#@__arcrank` ar on ar.rank=arc.arcrank WHERE arc.aid='$aid'");
  31. $channelid = $cInfos['channel'];
  32. $tags = GetTags($aid);
  33. include DedeInclude('templets/archives_sg_edit.htm');
  34. exit();
  35. }
  36. /*--------------------------------
  37. function __save(){ }
  38. -------------------------------*/
  39. else if ($dopost == 'save') {
  40. require_once(DEDEINC.'/image.func.php');
  41. require_once(DEDEINC.'/oxwindow.class.php');
  42. if ($typeid == 0) {
  43. ShowMsg("请指定文档的栏目", "-1");
  44. exit();
  45. }
  46. if (empty($channelid)) {
  47. ShowMsg("文档为非指定的类型,请检查您发布内容的表单是否合法", "-1");
  48. exit();
  49. }
  50. if (!CheckChannel($typeid, $channelid)) {
  51. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  52. exit();
  53. }
  54. if (!TestPurview('a_Edit')) {
  55. if (TestPurview('a_AccEdit')) {
  56. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  57. } else {
  58. CheckArcAdmin($id, $cuserLogin->getUserID());
  59. }
  60. }
  61. //对保存的内容进行处理
  62. if (empty($flags)) $flag = '';
  63. else $flag = join(',', $flags);
  64. $title = cn_substrR($title, $cfg_title_maxlen);
  65. $isremote = 0;
  66. $serviterm = empty($serviterm) ? "" : $serviterm;
  67. if (empty($litpic_b64)) $litpic_b64 = '';
  68. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  69. $adminid = $cuserLogin->getUserID();
  70. //处理上传的缩略图
  71. if (empty($ddisremote)) $ddisremote = 0;
  72. $litpic = GetDDImage('none', $picname, $ddisremote);
  73. //处理新的缩略图上传
  74. if ($litpic_b64 != "") {
  75. $data = explode(',', $litpic_b64);
  76. $ntime = time();
  77. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  78. CreateDir($savepath);
  79. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  80. $fullUrl = $fullUrl.".png";
  81. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  82. // 加水印
  83. WaterImg($cfg_basedir.$fullUrl, 'up');
  84. $litpic = $fullUrl;
  85. }
  86. //分析处理附加表数据
  87. $inadd_f = '';
  88. $inadd_v = '';
  89. if (!empty($dede_addonfields)) {
  90. $addonfields = explode(';', $dede_addonfields);
  91. $inadd_f = '';
  92. $inadd_v = '';
  93. if (is_array($addonfields)) {
  94. foreach ($addonfields as $v) {
  95. if ($v == '') {
  96. continue;
  97. }
  98. $vs = explode(',', $v);
  99. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  100. {
  101. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  102. } else {
  103. if (!isset(${$vs[0]})) {
  104. ${$vs[0]} = '';
  105. }
  106. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  107. }
  108. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  109. }
  110. }
  111. }
  112. //处理图片文档的自定义属性
  113. if ($litpic != '' && !preg_match("#p#", $flag)) {
  114. $flag = ($flag == '' ? 'p' : $flag.',p');
  115. }
  116. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  117. $addtable = trim($cts['addtable']);
  118. if ($addtable != '') {
  119. $iquery = "UPDATE `$addtable` SET typeid='$typeid',arcrank='$arcrank',title='$title',flag='$flag',litpic='$litpic'{$inadd_f} WHERE aid='$id' ";
  120. if (!$dsql->ExecuteNoneQuery($iquery)) {
  121. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因", "javascript:;");
  122. exit();
  123. }
  124. }
  125. //生成HTML
  126. UpIndexKey($id, $arcrank, $typeid, $sortrank, '');
  127. $artUrl = MakeArt($id, TRUE, TRUE, $isremote);
  128. if ($artUrl == '') $artUrl = $cfg_phpurl."/view.php?aid=$id";
  129. ClearMyAddon($id, $title);
  130. //返回成功信息
  131. $msg = "请选择您的后续操作:<a href='archives_sg_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布新文档</a>&nbsp;&nbsp;<a href='archives_do.php?aid=".$id."&dopost=editArchives' class='btn btn-success btn-sm'>查看更改</a>&nbsp;&nbsp;<a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看文档</a>&nbsp;&nbsp;<a href='catalog_do.php?cid=$typeid&channelid={$channelid}&dopost=listArchives' class='btn btn-success btn-sm'>管理文档</a>&nbsp;&nbsp;<a href='catalog_main.php' class='btn btn-success btn-sm'>网站栏目管理</a>";
  132. $wintitle = "成功更改文档";
  133. $wecome_info = "文档管理::更改文档";
  134. $win = new OxWindow();
  135. $win->AddTitle("成功更改文档:");
  136. $win->AddMsgItem($msg);
  137. $winform = $win->GetWindow("hand", "&nbsp;", false);
  138. $win->Display();
  139. }