国内流行的内容管理系统(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 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. //增加文档
  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) SELECT id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid FROM `#@__archives` ";
  144. $dsql->ExecuteNoneQuery($sql);
  145. //导入单表模型微数据
  146. $dsql->SetQuery("SELECT id,addtable FROM `#@__channeltype` WHERE id < -1 ");
  147. $dsql->Execute();
  148. $doarray = array();
  149. while ($row = $dsql->GetArray()) {
  150. $tb = str_replace('#@__', $cfg_dbprefix, $row['addtable']);
  151. if (empty($tb) || isset($doarray[$tb])) {
  152. continue;
  153. } else {
  154. $sql = "INSERT INTO `#@__arctiny` (id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid) SELECT aid, typeid, 0, arcrank, channel, senddate, 0, mid FROM `$tb` ";
  155. $rs = $dsql->executenonequery($sql);
  156. $doarray[$tb] = 1;
  157. }
  158. }
  159. ShowMsg("操作成功,正在返回", "catalog_main.php");
  160. exit();
  161. }
  162. /*---------------------
  163. 获取js文件
  164. function GetJs
  165. ----------------------*/
  166. else if ($dopost == "GetJs") {
  167. header("location:makehtml_js.php");
  168. exit();
  169. }
  170. /*-----------
  171. 获得子类的文档
  172. function GetSunListsMenu();
  173. -----------*/
  174. else if ($dopost == "GetSunListsMenu") {
  175. $userChannel = $cuserLogin->getUserChannel();
  176. require_once(DEDEINC."/typelink/typeunit.class.menu.php");
  177. AjaxHead();
  178. PutCookie('lastCidMenu', $cid, 3600 * 24, "/");
  179. $tu = new TypeUnit($userChannel);
  180. $tu->LogicListAllSunType($cid, " ");
  181. }
  182. /*-----------
  183. 获得子类的文档
  184. function GetSunLists();
  185. -----------*/
  186. else if ($dopost == "GetSunLists") {
  187. require_once(DEDEINC."/typelink/typeunit.class.admin.php");
  188. AjaxHead();
  189. PutCookie('lastCid', $cid, 3600 * 24, "/");
  190. $tu = new TypeUnit();
  191. $tu->dsql = $dsql;
  192. echo " <table width='100%' cellspacing='0' cellpadding='0'>\r\n";
  193. $tu->LogicListAllSunType($cid, " ");
  194. echo " </table>\r\n";
  195. $tu->Close();
  196. }
  197. /*----------------
  198. 合并栏目
  199. function unitCatalog() { }
  200. -----------------*/
  201. else if ($dopost == 'unitCatalog') {
  202. CheckPurview('t_Move');
  203. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  204. require_once(DEDEINC.'/typelink/typelink.class.php');
  205. require_once(DEDEINC.'/channelunit.func.php');
  206. if (empty($nextjob)) {
  207. $typeid = isset($typeid) ? intval($typeid) : 0;
  208. $row = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__arctype` WHERE reid='$typeid' ");
  209. $tl = new TypeLink($typeid);
  210. $typename = $tl->TypeInfos['typename'];
  211. $reid = $tl->TypeInfos['reid'];
  212. $channelid = $tl->TypeInfos['channeltype'];
  213. if (!empty($row['dd'])) {
  214. ShowMsg("栏目:$typename($typeid) 有子栏目,不能进行合并操作", '-1');
  215. exit();
  216. }
  217. $typeOptions = $tl->GetOptionArray(0, 0, $channelid);
  218. $wintitle = '合并栏目';
  219. $wecome_info = "<a href='catalog_main.php'>栏目管理</a> &gt; 合并栏目";
  220. $win = new OxWindow();
  221. $win->Init('catalog_do.php', 'js/blank.js', 'POST');
  222. $win->AddHidden('dopost', 'unitCatalog');
  223. $win->AddHidden('typeid', $typeid);
  224. $win->AddHidden('channelid', $channelid);
  225. $win->AddHidden('nextjob', 'unitok');
  226. $win->AddTitle("合并目录时不会删除原来的栏目目录,合并后需手动更新目标栏目的文档网页和列表网页");
  227. $win->AddItem('您选择的栏目是:', "<span class='text-primary'>$typename($typeid)</span>");
  228. $win->AddItem('您希望合并到那个栏目', "<select name='unittype'>{$typeOptions}</select>");
  229. $win->AddItem('注意事项:', '栏目不能有下级子栏目,只允许子级到更高级或同级或不同父级的情况');
  230. $winform = $win->GetWindow('ok');
  231. $win->Display();
  232. exit();
  233. } else {
  234. if ($typeid == $unittype) {
  235. ShowMsg("同一栏目无法合并,请后退重试", '-1');
  236. exit();
  237. }
  238. if (IsParent($unittype, $typeid)) {
  239. ShowMsg('不能从父类合并到子类', 'catalog_main.php');
  240. exit();
  241. }
  242. $row = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  243. $addtable = (empty($row['addtable']) ? '#@__addonarticle' : $row['addtable']);
  244. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$unittype' WHERE typeid='$typeid' ");
  245. $dsql->ExecuteNoneQuery("UPDATE `#@__feedback` SET typeid='$unittype' WHERE typeid='$typeid' ");
  246. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET typeid='$unittype' WHERE typeid='$typeid' ");
  247. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET typeid2='$unittype' WHERE typeid2='$typeid' ");
  248. $dsql->ExecuteNoneQuery("UPDATE `#@__addonspec` SET typeid='$unittype' WHERE typeid='$typeid' ");
  249. $dsql->ExecuteNoneQuery("UPDATE `$addtable` SET typeid='$unittype' WHERE typeid='$typeid' ");
  250. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctype` WHERE id='$typeid' ");
  251. UpDateCatCache();
  252. ShowMsg('成功合并指定栏目', 'catalog_main.php');
  253. exit();
  254. }
  255. }
  256. /*----------------
  257. 移动栏目
  258. function moveCatalog() { }
  259. -----------------*/
  260. else if ($dopost == 'moveCatalog') {
  261. CheckPurview('t_Move');
  262. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  263. require_once(DEDEINC.'/typelink/typelink.class.php');
  264. require_once(DEDEINC.'/channelunit.func.php');
  265. if (empty($nextjob)) {
  266. $tl = new TypeLink($typeid);
  267. $typename = $tl->TypeInfos['typename'];
  268. $reid = $tl->TypeInfos['reid'];
  269. $channelid = $tl->TypeInfos['channeltype'];
  270. $typeOptions = $tl->GetOptionArray(0, 0, $channelid);
  271. $wintitle = "移动栏目";
  272. $wecome_info = "<a href='catalog_main.php'>栏目管理</a> &gt; 移动栏目";
  273. $win = new OxWindow();
  274. $win->Init('catalog_do.php', 'js/blank.js', 'POST');
  275. $win->AddHidden('dopost', 'moveCatalog');
  276. $win->AddHidden('typeid', $typeid);
  277. $win->AddHidden('channelid', $channelid);
  278. $win->AddHidden('nextjob', 'unitok');
  279. $win->AddTitle("移动目录时不会删除原来已创建的列表,移动后需重新对栏目创建HTML");
  280. $win->AddItem('您选择的栏目是:', "$typename($typeid)");
  281. $win->AddItem('您希望移动到那个栏目', "<select name='movetype'>\r\n<option value='0'>移动为顶级栏目</option>\r\n$typeOptions\r\n</select>");
  282. $win->AddItem('注意事项:', '不允许从父级移动到子级目录,只允许子级到更高级或同级或不同父级的情况');
  283. $winform = $win->GetWindow('ok');
  284. $win->Display();
  285. exit();
  286. } else {
  287. if ($typeid == $movetype) {
  288. ShowMsg('移对对象和目标位置相同', 'catalog_main.php');
  289. exit();
  290. }
  291. if (IsParent($movetype, $typeid)) {
  292. ShowMsg('不能从父类移动到子类', 'catalog_main.php');
  293. exit();
  294. }
  295. $topid = GetTopid($movetype);
  296. $dsql->ExecuteNoneQuery("UPDATE `#@__arctype` SET reid='$movetype',topid='$topid' WHERE id='$typeid' ");
  297. UpDateCatCache();
  298. ShowMsg('成功移动目录', 'catalog_main.php');
  299. exit();
  300. }
  301. }
  302. ?>