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

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