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

178 lines
6.7KB

  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) 2021, 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. -------------------------------*/ else if ($dopost == 'save') {
  39. require_once(DEDEINC . '/image.func.php');
  40. require_once(DEDEINC . '/oxwindow.class.php');
  41. if ($typeid == 0) {
  42. ShowMsg("请指定文档的栏目!", "-1");
  43. exit();
  44. }
  45. if (empty($channelid)) {
  46. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  47. exit();
  48. }
  49. if (!CheckChannel($typeid, $channelid)) {
  50. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  51. exit();
  52. }
  53. if (!TestPurview('a_Edit')) {
  54. if (TestPurview('a_AccEdit')) {
  55. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
  56. } else {
  57. CheckArcAdmin($id, $cuserLogin->getUserID());
  58. }
  59. }
  60. //对保存的内容进行处理
  61. if (empty($flags)) $flag = '';
  62. else $flag = join(',', $flags);
  63. $title = cn_substrR($title, $cfg_title_maxlen);
  64. $isremote = 0;
  65. $serviterm = empty($serviterm) ? "" : $serviterm;
  66. if (empty($litpic_b64)) $litpic_b64 = '';
  67. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  68. $adminid = $cuserLogin->getUserID();
  69. //处理上传的缩略图
  70. if (empty($ddisremote)) $ddisremote = 0;
  71. $litpic = GetDDImage('none', $picname, $ddisremote);
  72. // 处理新的缩略图上传
  73. if ($litpic_b64 != "") {
  74. $data = explode(',', $litpic_b64);
  75. $ntime = time();
  76. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  77. CreateDir($savepath);
  78. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  79. $fullUrl = $fullUrl . ".png";
  80. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  81. // 加水印
  82. WaterImg($cfg_basedir . $fullUrl, 'up');
  83. $litpic = $fullUrl;
  84. }
  85. //分析处理附加表数据
  86. $inadd_f = '';
  87. $inadd_v = '';
  88. if (!empty($dede_addonfields)) {
  89. $addonfields = explode(';', $dede_addonfields);
  90. $inadd_f = '';
  91. $inadd_v = '';
  92. if (is_array($addonfields)) {
  93. foreach ($addonfields as $v) {
  94. if ($v == '') {
  95. continue;
  96. }
  97. $vs = explode(',', $v);
  98. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  99. {
  100. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  101. } else {
  102. if (!isset(${$vs[0]})) {
  103. ${$vs[0]} = '';
  104. }
  105. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  106. }
  107. $inadd_f .= ",`{$vs[0]}` = '" . ${$vs[0]} . "'";
  108. }
  109. }
  110. }
  111. //处理图片文档的自定义属性
  112. if ($litpic != '' && !preg_match("#p#", $flag)) {
  113. $flag = ($flag == '' ? 'p' : $flag . ',p');
  114. }
  115. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  116. $addtable = trim($cts['addtable']);
  117. if ($addtable != '') {
  118. $iquery = "UPDATE `$addtable` SET typeid='$typeid',arcrank='$arcrank',title='$title',flag='$flag',litpic='$litpic'{$inadd_f} WHERE aid='$id' ";
  119. if (!$dsql->ExecuteNoneQuery($iquery)) {
  120. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因!", "javascript:;");
  121. exit();
  122. }
  123. }
  124. //生成HTML
  125. UpIndexKey($id, $arcrank, $typeid, $sortrank, '');
  126. if ($cfg_remote_site == 'Y' && $isremote == "1") {
  127. if ($serviterm != "") {
  128. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  129. $config = array(
  130. 'hostname' => $servurl, 'username' => $servuser,
  131. 'password' => $servpwd, 'debug' => 'TRUE'
  132. );
  133. } else {
  134. $config = array();
  135. }
  136. if (!$ftp->connect($config)) exit('Error:None FTP Connection!');
  137. }
  138. $artUrl = MakeArt($id, TRUE, TRUE, $isremote);
  139. if ($artUrl == '') $artUrl = $cfg_phpurl . "/view.php?aid=$id";
  140. ClearMyAddon($id, $title);
  141. //返回成功信息
  142. $msg = "
  143.   请选择你的后续操作:
  144. <a href='archives_sg_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>发布新文档</a>
  145. &nbsp;&nbsp;
  146. <a href='archives_do.php?aid=" . $id . "&dopost=editArchives' class='btn btn-secondary btn-sm'>查看更改</a>
  147. &nbsp;&nbsp;
  148. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看文档</a>
  149. &nbsp;&nbsp;
  150. <a href='catalog_do.php?cid=$typeid&channelid={$channelid}&dopost=listArchives' class='btn btn-secondary btn-sm'>管理文档</a>
  151. &nbsp;&nbsp;
  152. <a href='catalog_main.php' class='btn btn-secondary btn-sm'>网站栏目管理</a>
  153. ";
  154. $wintitle = "成功更改文档!";
  155. $wecome_info = "文档管理::更改文档";
  156. $win = new OxWindow();
  157. $win->AddTitle("成功更改文档:");
  158. $win->AddMsgItem($msg);
  159. $winform = $win->GetWindow("hand", "&nbsp;", false);
  160. $win->Display();
  161. }