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

145 lines
5.5KB

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