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

269 lines
11KB

  1. <?php
  2. /**
  3. * 栏目操作
  4. *
  5. * @version $id:catalog_do.php 14:31 2010年7月12日 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. if (empty($dopost)) {
  13. ShowMsg("请指定栏目参数", "catalog_main.php");
  14. exit();
  15. }
  16. $cid = empty($cid) ? 0 : intval($cid);
  17. $unittype = empty($unittype) ? 0 : intval($unittype);
  18. $channelid = empty($channelid) ? 0 : intval($channelid);
  19. //添加文档
  20. if ($dopost == "addArchives") {
  21. //默认文档调用发布表单
  22. if (empty($cid) && empty($channelid)) {
  23. header("location:article_add.php");
  24. exit();
  25. }
  26. if (!empty($channelid)) {
  27. //根据模型调用发布表单
  28. $row = $dsql->GetOne("SELECT addcon FROM `#@__channeltype` WHERE id='$channelid'");
  29. } else {
  30. //根据栏目调用发布表单
  31. $row = $dsql->GetOne("SELECT ch.addcon FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$cid' ");
  32. }
  33. $gurl = $row["addcon"];
  34. if ($gurl == "") {
  35. ShowMsg("您指的栏目可能有误", "catalog_main.php");
  36. exit();
  37. }
  38. //跳转并传递参数
  39. header("location:{$gurl}?channelid={$channelid}&cid={$cid}");
  40. exit();
  41. }
  42. //管理文档
  43. else if ($dopost == "listArchives") {
  44. if (!empty($gurl)) {
  45. if (empty($arcrank)) {
  46. $arcrank = '';
  47. }
  48. $gurl = str_replace('..', '', $gurl);
  49. header("location:{$gurl}?arcrank={$arcrank}&cid={$cid}");
  50. exit();
  51. }
  52. if ($cid > 0) {
  53. $row = $dsql->GetOne("SELECT `#@__arctype`.typename,`#@__channeltype`.typename AS channelname,`#@__channeltype`.id,`#@__channeltype`.mancon FROM `#@__arctype` LEFT JOIN `#@__channeltype` on `#@__channeltype`.id=`#@__arctype`.channeltype WHERE `#@__arctype`.id='$cid'");
  54. $gurl = $row["mancon"];
  55. $channelid = $row["id"];
  56. $typename = $row["typename"];
  57. $channelname = $row["channelname"];
  58. if ($gurl == "") {
  59. ShowMsg("您指的栏目可能有误", "catalog_main.php");
  60. exit();
  61. }
  62. } else if ($channelid > 0) {
  63. $row = $dsql->GetOne("SELECT typename,id,mancon FROM `#@__channeltype` WHERE id='$channelid'");
  64. $gurl = $row["mancon"];
  65. $channelid = $row["id"];
  66. $typename = "";
  67. $channelname = $row["typename"];
  68. }
  69. if (empty($gurl)) $gurl = 'content_list.php';
  70. header("location:{$gurl}?channelid={$channelid}&cid={$cid}");
  71. exit();
  72. }
  73. //浏览通用模板目录
  74. else if ($dopost == "viewTemplet") {
  75. header("location:tpl.php?path=/".$cfg_df_style);
  76. exit();
  77. }
  78. //浏览单个页面的栏目
  79. else if ($dopost == "viewSgPage") {
  80. require_once(DEDEINC."/archive/listview.class.php");
  81. $lv = new ListView($cid);
  82. $pageurl = $lv->MakeHtml();
  83. ShowMsg("更新缓冲,请稍后", $pageurl);
  84. exit();
  85. }
  86. //修改栏目排列顺序
  87. else if ($dopost == "upRank") {
  88. //检查权限许可
  89. CheckPurview('t_Edit,t_AccEdit');
  90. //检查栏目操作许可
  91. CheckCatalog($cid, "您无权修改本栏目");
  92. $row = $dsql->GetOne("SELECT reid,sortrank FROM `#@__arctype` WHERE id='$cid'");
  93. $reid = $row['reid'];
  94. $sortrank = $row['sortrank'];
  95. $row = $dsql->GetOne("SELECT sortrank FROM `#@__arctype` WHERE sortrank<=$sortrank AND reid=$reid ORDER BY sortrank DESC ");
  96. if (is_array($row)) {
  97. $sortrank = $row['sortrank'] - 1;
  98. $dsql->ExecuteNoneQuery("UPDATE `#@__arctype` SET sortrank='$sortrank' WHERE id='$cid'");
  99. }
  100. UpDateCatCache();
  101. ShowMsg("操作成功,返回目录", "catalog_main.php");
  102. exit();
  103. } else if ($dopost == "upRankAll") {
  104. //检查权限许可
  105. CheckPurview('t_Edit');
  106. $row = $dsql->GetOne("SELECT id FROM `#@__arctype` ORDER BY id DESC");
  107. if (is_array($row)) {
  108. $maxID = $row['id'];
  109. for ($i = 1; $i <= $maxID; $i++) {
  110. if (isset(${'sortrank'.$i})) {
  111. $dsql->ExecuteNoneQuery("UPDATE `#@__arctype` SET sortrank='".(${'sortrank'.$i})."' WHERE id='{$i}';");
  112. }
  113. }
  114. }
  115. UpDateCatCache();
  116. ShowMsg("操作成功,正在返回", "catalog_main.php");
  117. exit();
  118. }
  119. //更新栏目缓存
  120. else if ($dopost == "upcatcache") {
  121. UpDateCatCache();
  122. $sql = " TRUNCATE TABLE `#@__arctiny`";
  123. $dsql->ExecuteNoneQuery($sql);
  124. //导入普通模型微数据
  125. $sql = "INSERT INTO `#@__arctiny` (id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid) SELECT id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid FROM `#@__archives` ";
  126. $dsql->ExecuteNoneQuery($sql);
  127. //导入自定义模型微数据
  128. $dsql->SetQuery("SELECT id,addtable FROM `#@__channeltype` WHERE id < -1 ");
  129. $dsql->Execute();
  130. $doarray = array();
  131. while ($row = $dsql->GetArray()) {
  132. $tb = str_replace('#@__', $cfg_dbprefix, $row['addtable']);
  133. if (empty($tb) || isset($doarray[$tb])) {
  134. continue;
  135. } else {
  136. $sql = "INSERT INTO `#@__arctiny` (id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid) SELECT aid, typeid, 0, arcrank, channel, senddate, 0, mid FROM `$tb` ";
  137. $rs = $dsql->executenonequery($sql);
  138. $doarray[$tb] = 1;
  139. }
  140. }
  141. ShowMsg("操作成功,正在返回", "catalog_main.php");
  142. exit();
  143. }
  144. //获取js文件
  145. else if ($dopost == "GetJs") {
  146. header("location:makehtml_js.php");
  147. exit();
  148. }
  149. //获得子类的文档
  150. else if ($dopost == "GetSunListsMenu") {
  151. $userChannel = $cuserLogin->getUserChannel();
  152. require_once(DEDEINC."/typelink/typeunit.class.menu.php");
  153. AjaxHead();
  154. PutCookie('lastCidMenu', $cid, 3600 * 24, "/");
  155. $tu = new TypeUnit($userChannel);
  156. $tu->LogicListAllSunType($cid, " ");
  157. } else if ($dopost == "GetSunLists") {
  158. require_once(DEDEINC."/typelink/typeunit.class.admin.php");
  159. AjaxHead();
  160. PutCookie('lastCid', $cid, 3600 * 24, "/");
  161. $tu = new TypeUnit();
  162. $tu->dsql = $dsql;
  163. echo "<table width='100%' cellspacing='0' cellpadding='0'>\r\n";
  164. $tu->LogicListAllSunType($cid, " ");
  165. echo "</table>\r\n";
  166. $tu->Close();
  167. }
  168. //合并栏目
  169. else if ($dopost == 'unitCatalog') {
  170. CheckPurview('t_Move');
  171. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  172. require_once(DEDEINC.'/typelink/typelink.class.php');
  173. require_once(DEDEINC.'/channelunit.func.php');
  174. if (empty($nextjob)) {
  175. $typeid = isset($typeid) ? intval($typeid) : 0;
  176. $row = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__arctype` WHERE reid='$typeid' ");
  177. $tl = new TypeLink($typeid);
  178. $typename = $tl->TypeInfos['typename'];
  179. $reid = $tl->TypeInfos['reid'];
  180. $channelid = $tl->TypeInfos['channeltype'];
  181. if (!empty($row['dd'])) {
  182. ShowMsg("栏目:$typename($typeid) 有子栏目,不能进行合并操作", '-1');
  183. exit();
  184. }
  185. $typeOptions = $tl->GetOptionArray(0, 0, $channelid);
  186. $wintitle = '合并栏目';
  187. $wecome_info = "<a href='catalog_main.php'>栏目管理</a> &gt; 合并栏目";
  188. $win = new OxWindow();
  189. $win->Init('catalog_do.php', 'js/blank.js', 'POST');
  190. $win->AddHidden('dopost', 'unitCatalog');
  191. $win->AddHidden('typeid', $typeid);
  192. $win->AddHidden('channelid', $channelid);
  193. $win->AddHidden('nextjob', 'unitok');
  194. $win->AddTitle("合并目录时不会删除原来的栏目目录,合并后需手动更新目标栏目的文档网页和列表网页");
  195. $win->AddItem('您选择的栏目是:', "<span class='text-primary'>$typename($typeid)</span>");
  196. $win->AddItem('您希望合并到那个栏目', "<select name='unittype'>{$typeOptions}</select>");
  197. $win->AddItem('注意事项:', '栏目不能有下级子栏目,只允许子级到更高级或同级或不同父级的情况');
  198. $winform = $win->GetWindow('ok');
  199. $win->Display();
  200. exit();
  201. } else {
  202. if ($typeid == $unittype) {
  203. ShowMsg("同一栏目无法合并,请后退重试", '-1');
  204. exit();
  205. }
  206. if (IsParent($unittype, $typeid)) {
  207. ShowMsg('不能从父类合并到子类', 'catalog_main.php');
  208. exit();
  209. }
  210. $row = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  211. $addtable = (empty($row['addtable']) ? '#@__addonarticle' : $row['addtable']);
  212. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$unittype' WHERE typeid='$typeid' ");
  213. $dsql->ExecuteNoneQuery("UPDATE `#@__feedback` SET typeid='$unittype' WHERE typeid='$typeid' ");
  214. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET typeid='$unittype' WHERE typeid='$typeid' ");
  215. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET typeid2='$unittype' WHERE typeid2='$typeid' ");
  216. $dsql->ExecuteNoneQuery("UPDATE `#@__addonspec` SET typeid='$unittype' WHERE typeid='$typeid' ");
  217. $dsql->ExecuteNoneQuery("UPDATE `$addtable` SET typeid='$unittype' WHERE typeid='$typeid' ");
  218. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctype` WHERE id='$typeid' ");
  219. UpDateCatCache();
  220. ShowMsg('成功合并指定栏目', 'catalog_main.php');
  221. exit();
  222. }
  223. }
  224. //移动栏目
  225. else if ($dopost == 'moveCatalog') {
  226. CheckPurview('t_Move');
  227. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  228. require_once(DEDEINC.'/typelink/typelink.class.php');
  229. require_once(DEDEINC.'/channelunit.func.php');
  230. if (empty($nextjob)) {
  231. $tl = new TypeLink($typeid);
  232. $typename = $tl->TypeInfos['typename'];
  233. $reid = $tl->TypeInfos['reid'];
  234. $channelid = $tl->TypeInfos['channeltype'];
  235. $typeOptions = $tl->GetOptionArray(0, 0, $channelid);
  236. $wintitle = "移动栏目";
  237. $wecome_info = "<a href='catalog_main.php'>栏目管理</a> &gt; 移动栏目";
  238. $win = new OxWindow();
  239. $win->Init('catalog_do.php', 'js/blank.js', 'POST');
  240. $win->AddHidden('dopost', 'moveCatalog');
  241. $win->AddHidden('typeid', $typeid);
  242. $win->AddHidden('channelid', $channelid);
  243. $win->AddHidden('nextjob', 'unitok');
  244. $win->AddTitle("移动目录时不会删除原来已创建的列表,移动后需重新对栏目创建网页");
  245. $win->AddItem('您选择的栏目是:', "$typename($typeid)");
  246. $win->AddItem('您希望移动到那个栏目', "<select name='movetype'>\r\n<option value='0'>移动为顶级栏目</option>\r\n$typeOptions\r\n</select>");
  247. $win->AddItem('注意事项:', '不允许从父级移动到子级目录,只允许子级到更高级或同级或不同父级的情况');
  248. $winform = $win->GetWindow('ok');
  249. $win->Display();
  250. exit();
  251. } else {
  252. if ($typeid == $movetype) {
  253. ShowMsg('移对对象和目标位置相同', 'catalog_main.php');
  254. exit();
  255. }
  256. if (IsParent($movetype, $typeid)) {
  257. ShowMsg('不能从父类移动到子类', 'catalog_main.php');
  258. exit();
  259. }
  260. $topid = GetTopid($movetype);
  261. $dsql->ExecuteNoneQuery("UPDATE `#@__arctype` SET reid='$movetype',topid='$topid' WHERE id='$typeid' ");
  262. UpDateCatCache();
  263. ShowMsg('成功移动目录', 'catalog_main.php');
  264. exit();
  265. }
  266. }
  267. ?>