SetQuery("SELECT id,typename FROM `#@__channeltype` "); $dsql->Execute('dd'); $channels = Array(); while($row = $dsql->GetObject('dd')) $channels[$row->id] = $row->typename; $OptionArrayList = ''; //当前选中的栏目 if($selid > 0) { $row = $dsql->GetOne("SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE id='$selid'"); if($row['ispart']==1) $OptionArrayList .= "\r\n"; else $OptionArrayList .= "\r\n"; } //是否限定用户管理的栏目 if( $cfg_admin_channel=='array' ) { if(count($admin_catalogs)==0) { $query = "SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE 1=2 "; } else { $admin_catalog = join(',', $admin_catalogs); $dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id IN($admin_catalog) GROUP BY reid "); $dsql->Execute('qq'); $topidstr = ''; while($row = $dsql->GetObject('qq')) { if($row->reid==0) continue; $topidstr .= ($topidstr=='' ? $row->reid : ','.$row->reid); } $admin_catalog .= ','.$topidstr; $admin_catalogs = explode(',', $admin_catalog); $admin_catalogs = array_unique($admin_catalogs); $admin_catalog = join(',', $admin_catalogs); $admin_catalog = preg_replace("#,$#", '', $admin_catalog); $query = "SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE id IN($admin_catalog) AND reid=0 AND ispart<>2 "; } } else { $query = "SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE ispart<>2 AND reid=0 ORDER BY sortrank ASC "; } $dsql->SetQuery($query); $dsql->Execute('cc'); while($row=$dsql->GetObject('cc')) { $sonCats = ''; LogicGetOptionArray($row->id, '─', $channeltype, $dsql, $sonCats); if($sonCats != '') { if($row->ispart==1) $OptionArrayList .= "\r\n"; else if($row->ispart==2) $OptionArrayList .= ''; else if( empty($channeltype) && $row->ispart != 0 ) $OptionArrayList .= "\r\n"; else $OptionArrayList .= "\r\n"; $OptionArrayList .= $sonCats; } else { if($row->ispart==0 && (!empty($channeltype) && $row->channeltype == $channeltype) ) { $OptionArrayList .= "\r\n"; } else if($row->ispart==0 && empty($channeltype) ) { // 专题 $OptionArrayList .= "\r\n"; } } } return $OptionArrayList; } function LogicGetOptionArray($id,$step,$channeltype,&$dsql, &$sonCats) { global $OptionArrayList, $channels, $cfg_admin_channel, $admin_catalogs; $dsql->SetQuery("Select id,typename,ispart,channeltype From `#@__arctype` where reid='".$id."' And ispart<>2 order by sortrank asc"); $dsql->Execute($id); while($row=$dsql->GetObject($id)) { if($cfg_admin_channel != 'all' && !in_array($row->id, $admin_catalogs)) { continue; } if($row->channeltype==$channeltype && $row->ispart==1) { $sonCats .= "\r\n"; } else if( ($row->channeltype==$channeltype && $row->ispart==0) || empty($channeltype) ) { $sonCats .= "\r\n"; } LogicGetOptionArray($row->id,$step.'─',$channeltype,$dsql, $sonCats); } }