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

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