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

123 lines
5.0KB

  1. <?php
  2. /**
  3. * 栏目选项函数
  4. *
  5. * @version $Id: inc_catalog_options.php 1 10:32 2010年7月21日Z tianya $
  6. * @package DedeCMS.Administrator
  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. /**
  13. * 获取选项列表
  14. *
  15. * @access public
  16. * @param string $selid 选择ID
  17. * @param string $userCatalog 用户类目
  18. * @param string $channeltype 频道类型
  19. * @return string
  20. */
  21. function GetOptionList($selid=0, $userCatalog=0, $channeltype=0)
  22. {
  23. global $OptionArrayList, $channels, $dsql, $cfg_admin_channel, $admin_catalogs;
  24. $dsql->SetQuery("SELECT id,typename FROM `#@__channeltype` ");
  25. $dsql->Execute('dd');
  26. $channels = Array();
  27. while($row = $dsql->GetObject('dd')) $channels[$row->id] = $row->typename;
  28. $OptionArrayList = '';
  29. //当前选中的栏目
  30. if($selid > 0)
  31. {
  32. $row = $dsql->GetOne("SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE id='$selid'");
  33. if($row['ispart']==1) $OptionArrayList .= "<option value='".$row['id']."' class='option1' selected='selected'>".$row['typename']."(封面频道)</option>\r\n";
  34. else $OptionArrayList .= "<option value='".$row['id']."' selected='selected'>".$row['typename']."</option>\r\n";
  35. }
  36. //是否限定用户管理的栏目
  37. if( $cfg_admin_channel=='array' )
  38. {
  39. if(count($admin_catalogs)==0)
  40. {
  41. $query = "SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE 1=2 ";
  42. }
  43. else
  44. {
  45. $admin_catalog = join(',', $admin_catalogs);
  46. $dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id IN($admin_catalog) GROUP BY reid ");
  47. $dsql->Execute('qq');
  48. $topidstr = '';
  49. while($row = $dsql->GetObject('qq'))
  50. {
  51. if($row->reid==0) continue;
  52. $topidstr .= ($topidstr=='' ? $row->reid : ','.$row->reid);
  53. }
  54. $admin_catalog .= ','.$topidstr;
  55. $admin_catalogs = explode(',', $admin_catalog);
  56. $admin_catalogs = array_unique($admin_catalogs);
  57. $admin_catalog = join(',', $admin_catalogs);
  58. $admin_catalog = preg_replace("#,$#", '', $admin_catalog);
  59. $query = "SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE id IN($admin_catalog) AND reid=0 AND ispart<>2 ";
  60. }
  61. }
  62. else
  63. {
  64. $query = "SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE ispart<>2 AND reid=0 ORDER BY sortrank ASC ";
  65. }
  66. $dsql->SetQuery($query);
  67. $dsql->Execute('cc');
  68. while($row=$dsql->GetObject('cc'))
  69. {
  70. $sonCats = '';
  71. LogicGetOptionArray($row->id, '─', $channeltype, $dsql, $sonCats);
  72. if($sonCats != '')
  73. {
  74. if($row->ispart==1) $OptionArrayList .= "<option value='".$row->id."' class='option1'>".$row->typename."(封面频道)</option>\r\n";
  75. else if($row->ispart==2) $OptionArrayList .= '';
  76. else if( empty($channeltype) && $row->ispart != 0 ) $OptionArrayList .= "<option value='".$row->id."' class='option2'>".$row->typename."(".$channels[$row->channeltype].")</option>\r\n";
  77. else $OptionArrayList .= "<option value='".$row->id."' class='option3'>".$row->typename."</option>\r\n";
  78. $OptionArrayList .= $sonCats;
  79. }
  80. else
  81. {
  82. if($row->ispart==0 && (!empty($channeltype) && $row->channeltype == $channeltype) )
  83. {
  84. $OptionArrayList .= "<option value='".$row->id."' class='option3'>".$row->typename."</option>\r\n";
  85. } else if($row->ispart==0 && empty($channeltype) )
  86. {
  87. // 专题
  88. $OptionArrayList .= "<option value='".$row->id."' class='option3'>".$row->typename."</option>\r\n";
  89. }
  90. }
  91. }
  92. return $OptionArrayList;
  93. }
  94. function LogicGetOptionArray($id,$step,$channeltype,&$dsql, &$sonCats)
  95. {
  96. global $OptionArrayList, $channels, $cfg_admin_channel, $admin_catalogs;
  97. $dsql->SetQuery("Select id,typename,ispart,channeltype From `#@__arctype` where reid='".$id."' And ispart<>2 order by sortrank asc");
  98. $dsql->Execute($id);
  99. while($row=$dsql->GetObject($id))
  100. {
  101. if($cfg_admin_channel != 'all' && !in_array($row->id, $admin_catalogs))
  102. {
  103. continue;
  104. }
  105. if($row->channeltype==$channeltype && $row->ispart==1)
  106. {
  107. $sonCats .= "<option value='".$row->id."' class='option1'>$step".$row->typename."</option>\r\n";
  108. }
  109. else if( ($row->channeltype==$channeltype && $row->ispart==0) || empty($channeltype) )
  110. {
  111. $sonCats .= "<option value='".$row->id."' class='option3'>$step".$row->typename."</option>\r\n";
  112. }
  113. LogicGetOptionArray($row->id,$step.'─',$channeltype,$dsql, $sonCats);
  114. }
  115. }