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

300 lines
12KB

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