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

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