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

203 lines
7.6KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 栏目单元,主要用户管理后台管理菜单处
  5. *
  6. * @version $Id: typeunit.class.menu.php 1 15:21 2010年7月5日Z tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(DEDEDATA."/cache/inc_catalog_base.inc");
  13. /**
  14. * 栏目单元,主要用户管理后台管理菜单处
  15. *
  16. * @package TypeUnit
  17. * @subpackage DedeBIZ.Libraries
  18. * @link https://www.dedebiz.com
  19. */
  20. class TypeUnit
  21. {
  22. var $dsql;
  23. var $aChannels;
  24. var $isAdminAll;
  25. //php5构造函数
  26. function __construct($catlogs = '')
  27. {
  28. global $cfg_Cs;
  29. $this->dsql = $GLOBALS['dsql'];
  30. $this->aChannels = array();
  31. $this->isAdminAll = false;
  32. if (!empty($catlogs) && $catlogs != '-1') {
  33. $this->aChannels = explode(',', $catlogs);
  34. foreach ($this->aChannels as $cid) {
  35. if ($cfg_Cs[$cid][0] == 0) {
  36. $this->dsql->SetQuery("Select id,ispart From `#@__arctype` where reid=$cid");
  37. $this->dsql->Execute();
  38. while ($row = $this->dsql->GetObject()) {
  39. //if($row->ispart==1)
  40. $this->aChannels[] = $row->id;
  41. }
  42. }
  43. }
  44. } else {
  45. $this->isAdminAll = true;
  46. }
  47. }
  48. function TypeUnit($catlogs = '')
  49. {
  50. $this->__construct($catlogs);
  51. }
  52. //清理类
  53. function Close()
  54. {
  55. }
  56. /**
  57. * 读出所有分类,在类目管理页(list_type)中使用
  58. *
  59. * @access public
  60. * @param int $channel 频道ID
  61. * @param int $nowdir 当前操作ID
  62. * @return string
  63. */
  64. function ListAllType($channel = 0, $nowdir = 0)
  65. {
  66. global $cfg_admin_channel, $admin_catalogs;
  67. //检测用户有权限的顶级栏目
  68. if ($cfg_admin_channel == 'array') {
  69. $admin_catalog = join(',', $admin_catalogs);
  70. $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id IN($admin_catalog) GROUP BY reid ");
  71. $this->dsql->Execute();
  72. $topidstr = '';
  73. while ($row = $this->dsql->GetObject()) {
  74. if ($row->reid == 0) continue;
  75. $topidstr .= ($topidstr == '' ? $row->reid : ','.$row->reid);
  76. }
  77. $admin_catalog .= ','.$topidstr;
  78. $admin_catalogs = explode(',', $admin_catalog);
  79. $admin_catalogs = array_unique($admin_catalogs);
  80. }
  81. $this->dsql->SetQuery("SELECT id,typedir,typename,ispart,channeltype FROM `#@__arctype` WHERE reid=0 ORDER BY sortrank");
  82. $this->dsql->Execute(0);
  83. $lastid = GetCookie('lastCidMenu');
  84. while ($row = $this->dsql->GetObject(0)) {
  85. if ($cfg_admin_channel == 'array' && !in_array($row->id, $admin_catalogs)) {
  86. continue;
  87. }
  88. $typeDir = $row->typedir;
  89. $typeName = $row->typename;
  90. $ispart = $row->ispart;
  91. $id = $row->id;
  92. $channeltype = $row->channeltype;
  93. //普通栏目
  94. if ($ispart == 0) {
  95. $smenu = " oncontextmenu=\"CommonMenu(event,this,$id,'".urlencode($typeName)."')\"";
  96. }
  97. //封面频道
  98. else if ($ispart == 1) {
  99. $smenu = " oncontextmenu=\"CommonMenuPart(event,this,$id,'".urlencode($typeName)."')\"";
  100. }
  101. //独立页面
  102. //else if($ispart==2)
  103. //{
  104. //$smenu = " oncontextmenu=\"SingleMenu(event,this,$id,'".urlencode($typeName)."')\"";
  105. //}
  106. //跳转网址
  107. else {
  108. continue;
  109. $smenu = " oncontextmenu=\"JumpMenu(event,this,$id,'".urlencode($typeName)."')\" ";
  110. }
  111. echo "<dl class='topcc'>\r\n";
  112. echo " <dd class='dlf'><img style='cursor:pointer' onClick=\"LoadSuns('suns{$id}',{$id});\" src='images/tree_explode.gif' width='11' height='11'></dd>\r\n";
  113. echo " <dd class='dlr'><a href='catalog_do.php?cid=".$id."&dopost=listArchives'{$smenu}>".$typeName."</a></dd>\r\n";
  114. echo "</dl>\r\n";
  115. echo "<div id='suns".$id."' class='sunct'>";
  116. if ($lastid == $id || $cfg_admin_channel == 'array') {
  117. $this->LogicListAllSunType($id, " ");
  118. }
  119. echo "</div>\r\n";
  120. }
  121. }
  122. /**
  123. * 获得子类目的递归调用
  124. *
  125. * @access public
  126. * @param int $id 栏目ID
  127. * @param string $step 层级标志
  128. * @param bool $needcheck 权限
  129. * @return string
  130. */
  131. function LogicListAllSunType($id, $step, $needcheck = true)
  132. {
  133. global $cfg_admin_channel, $admin_catalogs;
  134. $fid = $id;
  135. $this->dsql->SetQuery("SELECT id,reid,typedir,typename,ispart,channeltype FROM `#@__arctype` WHERE reid='".$id."' ORDER BY sortrank");
  136. $this->dsql->Execute($fid);
  137. if ($this->dsql->GetTotalRow($fid) > 0) {
  138. while ($row = $this->dsql->GetObject($fid)) {
  139. if ($cfg_admin_channel == 'array' && !in_array($row->id, $admin_catalogs)) {
  140. continue;
  141. }
  142. $typeDir = $row->typedir;
  143. $typeName = $row->typename;
  144. $reid = $row->reid;
  145. $id = $row->id;
  146. $ispart = $row->ispart;
  147. $channeltype = $row->channeltype;
  148. if ($step == " ") {
  149. $stepdd = 2;
  150. } else {
  151. $stepdd = 3;
  152. }
  153. //有权限栏目
  154. if (in_array($id, $this->aChannels) || $needcheck === false || $this->isAdminAll === true) {
  155. //普通列表
  156. if ($ispart == 0 || empty($ispart)) {
  157. $smenu = " oncontextmenu=\"CommonMenu(event,this,$id,'".urlencode($typeName)."')\"";
  158. $timg = " <img src='images/tree_page.gif'> ";
  159. }
  160. //封面频道
  161. else if ($ispart == 1) {
  162. $smenu = " oncontextmenu=\"CommonMenuPart(event,this,$id,'".urlencode($typeName)."')\"";
  163. $timg = " <img src='images/tree_part.gif'> ";
  164. }
  165. //独立页面
  166. //else if($ispart==2)
  167. //{
  168. //$timg = " <img src='img/tree_page.gif'> ";
  169. //$smenu = " oncontextmenu=\"SingleMenu(event,this,$id,'".urlencode($typeName)."')\" ";
  170. //}
  171. //跳转网址
  172. else {
  173. continue;
  174. $timg = " <img src='img/tree_page.gif'> ";
  175. $smenu = " oncontextmenu=\"JumpMenu(event,this,$id,'".urlencode($typeName)."')\" ";
  176. }
  177. echo " <table class='sunlist'>\r\n";
  178. echo " <tr>\r\n";
  179. echo " <td align='left'>".$step.$timg."<a href='catalog_do.php?cid=".$id."&dopost=listArchives'{$smenu}>".$typeName."</a></td>\r\n";
  180. echo " </tr>\r\n";
  181. echo " </table>\r\n";
  182. $this->LogicListAllSunType($id, $step." ", false);
  183. }
  184. }
  185. }
  186. }
  187. }//End Class