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

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