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

138 lines
5.4KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 后台栏目管理选择框
  5. *
  6. * @version $id:typeunit.class.selector.php 15:21 2010年7月5日 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 TypeUnitSelector
  17. * @subpackage DedeBIZ.Libraries
  18. * @link https://www.dedebiz.com
  19. */
  20. class TypeUnitSelector
  21. {
  22. var $dsql;
  23. //php5构造函数
  24. function __construct()
  25. {
  26. global $cfg_Cs;
  27. $this->dsql = $GLOBALS['dsql'];
  28. }
  29. function TypeUnitSelector()
  30. {
  31. $this->__construct();
  32. }
  33. //清理类
  34. function Close()
  35. {
  36. }
  37. /**
  38. * 列出某一栏目下的所有栏目
  39. *
  40. * @access public
  41. * @param string $channel 栏目id
  42. * @return void
  43. */
  44. function ListAllType($channel = 0)
  45. {
  46. global $cfg_admin_channel, $admin_catalogs, $targetid, $oldvalue;
  47. $oldvalues = array();
  48. if (!empty($oldvalue)) $oldvalues = explode(',', $oldvalue);
  49. //检测用户有权限的顶级栏目
  50. if ($cfg_admin_channel == 'array') {
  51. $admin_catalog = join(',', $admin_catalogs);
  52. $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id IN($admin_catalog) GROUP BY reid ");
  53. $this->dsql->Execute();
  54. $topidstr = '';
  55. while ($row = $this->dsql->GetObject()) {
  56. if ($row->reid == 0) continue;
  57. $topidstr .= ($topidstr == '' ? $row->reid : ','.$row->reid);
  58. }
  59. $admin_catalog .= ','.$topidstr;
  60. $admin_catalogs = explode(',', $admin_catalog);
  61. $admin_catalogs = array_unique($admin_catalogs);
  62. }
  63. $this->dsql->SetQuery("SELECT id,typedir,typename,ispart,channeltype FROM `#@__arctype` WHERE reid=0 ORDER BY sortrank");
  64. $this->dsql->Execute(0);
  65. $lastid = GetCookie('lastCidMenu');
  66. while ($row = $this->dsql->GetObject(0)) {
  67. if ($cfg_admin_channel == 'array' && !in_array($row->id, $admin_catalogs)) {
  68. continue;
  69. }
  70. $typeDir = $row->typedir;
  71. $typeName = $row->typename;
  72. $ispart = $row->ispart;
  73. $id = $row->id;
  74. $channeltype = $row->channeltype;
  75. $ischeck = in_array($id, $oldvalues) ? ' checked' : '';
  76. $chackRadio = "<input type='radio' name='seltypeid' value='{$id}' $ischeck />";
  77. if ($targetid == 'typeid2') $chackRadio = "<input type='checkbox' name='seltypeid' id='seltypeid{$id}' value='{$id}' $ischeck />";
  78. if ((!empty($channel) && $channeltype != $channel) || $ispart != 0) {
  79. $chackRadio = '';
  80. }
  81. $soncat = '';
  82. $this->LogicListAllSunType($id, $channel, $soncat);
  83. if ($chackRadio == '' && $soncat == '') continue;
  84. echo "<div class='quickselItem'>\r\n";
  85. echo "<div class='topcat'><label>{$chackRadio} {$typeName}</label></div>\r\n";
  86. if ($soncat != '') echo "<div class='soncat'>{$soncat}</div>\r\n";
  87. echo "</div>\r\n";
  88. }
  89. }
  90. /**
  91. * 获得子类目的递归调用
  92. *
  93. * @access public
  94. * @param int $id 栏目id
  95. * @param int $channel 栏目id
  96. * @param int $soncat 子级分类
  97. * @return string
  98. */
  99. function LogicListAllSunType($id, $channel = 0, &$soncat=0)
  100. {
  101. global $cfg_admin_channel, $admin_catalogs, $targetid, $oldvalue;
  102. $fid = $id;
  103. $oldvalues = array();
  104. if (!empty($oldvalue)) $oldvalues = explode(',', $oldvalue);
  105. $this->dsql->SetQuery("SELECT id,reid,typedir,typename,ispart,channeltype FROM `#@__arctype` WHERE reid='".$id."' ORDER BY sortrank");
  106. $this->dsql->Execute($fid);
  107. while ($row = $this->dsql->GetObject($fid)) {
  108. if ($cfg_admin_channel == 'array' && !in_array($row->id, $admin_catalogs)) {
  109. continue;
  110. }
  111. $typeDir = $row->typedir;
  112. $typeName = $row->typename;
  113. $reid = $row->reid;
  114. $id = $row->id;
  115. $ispart = $row->ispart;
  116. $channeltype = $row->channeltype;
  117. $ischeck = in_array($id, $oldvalues) ? ' checked' : '';
  118. $chackRadio = "<input type='radio' name='seltypeid' value='{$row->id}' $ischeck />";
  119. if ($targetid == 'typeid2') $chackRadio = "<input type='checkbox' name='seltypeid' id='seltypeid{$id}' value='{$id}' $ischeck />";
  120. if ($ispart != 0) {
  121. $chackRadio = '';
  122. }
  123. if ($channeltype != $channel && !empty($channel)) {
  124. continue;
  125. }
  126. if ($chackRadio != '') {
  127. $soncat .= "<div class='item'><label>".$chackRadio .' '. $typeName."</label></div>\r\n";
  128. $this->LogicListAllSunType($id, $channel, $soncat);
  129. } else {
  130. $soncat .= "<div class='item'>".$typeName."</div>\r\n";
  131. $this->LogicListAllSunType($id, $channel, $soncat);
  132. }
  133. }
  134. }
  135. }//End Class
  136. ?>