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

226 lines
8.0KB

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