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

156 lines
5.7KB

  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 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 TypeUnitSelector
  16. * @subpackage DedeCMS.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. * @access public
  38. * @param string $channel 频道ID
  39. * @return void
  40. */
  41. function ListAllType($channel=0)
  42. {
  43. global $cfg_admin_channel, $admin_catalogs, $targetid, $oldvalue;
  44. $oldvalues = array();
  45. if(!empty($oldvalue)) $oldvalues = explode(',', $oldvalue);
  46. //检测用户有权限的顶级栏目
  47. if($cfg_admin_channel=='array')
  48. {
  49. $admin_catalog = join(',', $admin_catalogs);
  50. $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id IN($admin_catalog) GROUP BY reid ");
  51. $this->dsql->Execute();
  52. $topidstr = '';
  53. while($row = $this->dsql->GetObject())
  54. {
  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. {
  67. if( $cfg_admin_channel=='array' && !in_array($row->id, $admin_catalogs) )
  68. {
  69. continue;
  70. }
  71. $typeDir = $row->typedir;
  72. $typeName = $row->typename;
  73. $ispart = $row->ispart;
  74. $id = $row->id;
  75. $channeltype = $row->channeltype;
  76. $ischeck = in_array($id, $oldvalues) ? ' checked' : '';
  77. $chackRadio = "<input type='radio' name='seltypeid' value='{$id}' $ischeck />";
  78. if($targetid=='typeid2') $chackRadio = "<input type='checkbox' name='seltypeid' id='seltypeid{$id}' value='{$id}' $ischeck />";
  79. if((!empty($channel) && $channeltype !=$channel) || $ispart!=0)
  80. {
  81. $chackRadio = '';
  82. }
  83. $soncat = '';
  84. $this->LogicListAllSunType($id, $channel, $soncat);
  85. if($chackRadio=='' && $soncat=='') continue;
  86. echo "<div class='quickselItem'>\r\n";
  87. echo " <div class='topcat'>{$chackRadio}{$typeName}</div>\r\n";
  88. if($soncat!='') echo " <div class='soncat'>{$soncat}</div>\r\n";
  89. echo "</div>\r\n";
  90. }
  91. }
  92. /**
  93. * 获得子类目的递归调用
  94. *
  95. * @access public
  96. * @param int $id 栏目ID
  97. * @param int $channel 频道ID
  98. * @param int $soncat 子级分类
  99. * @return string
  100. */
  101. function LogicListAllSunType($id, $channel=0, &$soncat)
  102. {
  103. global $cfg_admin_channel, $admin_catalogs, $targetid, $oldvalue;
  104. $fid = $id;
  105. $oldvalues = array();
  106. if(!empty($oldvalue)) $oldvalues = explode(',', $oldvalue);
  107. $this->dsql->SetQuery("SELECT id,reid,typedir,typename,ispart,channeltype FROM `#@__arctype` WHERE reid='".$id."' ORDER BY sortrank");
  108. $this->dsql->Execute($fid);
  109. while($row=$this->dsql->GetObject($fid))
  110. {
  111. if($cfg_admin_channel=='array' && !in_array($row->id, $admin_catalogs) )
  112. {
  113. continue;
  114. }
  115. $typeDir = $row->typedir;
  116. $typeName = $row->typename;
  117. $reid = $row->reid;
  118. $id = $row->id;
  119. $ispart = $row->ispart;
  120. $channeltype = $row->channeltype;
  121. $ischeck = in_array($id, $oldvalues) ? ' checked' : '';
  122. $chackRadio = "<input type='radio' name='seltypeid' value='{$row->id}' $ischeck />";
  123. if($targetid=='typeid2') $chackRadio = "<input type='checkbox' name='seltypeid' id='seltypeid{$id}' value='{$id}' $ischeck />";
  124. if($ispart!=0)
  125. {
  126. $chackRadio = '';
  127. }
  128. if($channeltype!=$channel && !empty($channel))
  129. {
  130. continue;
  131. }
  132. if($chackRadio !='' )
  133. {
  134. $soncat .= " <div class='item'>".$chackRadio.$typeName."</div>\r\n";
  135. $this->LogicListAllSunType($id, $channel, $soncat);
  136. }
  137. else
  138. {
  139. $soncat .= " <br style='clear:both' /><div class='item'><b>".$typeName.":</b></div>\r\n";
  140. $this->LogicListAllSunType($id, $channel, $soncat);
  141. $soncat .= " <br style='clear:both' />";
  142. }
  143. }
  144. }
  145. }//End Class