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

202 lines
7.7KB

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