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

197 lines
6.8KB

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