/**
* 无限极分类
* @return [type] [description]
*/
protected function getSubs($categorys, $catId=0, $level=0)
{
$subs=array();
foreach ($categorys as $item)
{
if ($item['parentId']==$catId)
{
$item['level']=$level;
$subs[]=$item;
$subs=array_merge($subs, $this->getSubs($categorys, $item['id'],$level+1));
}
}
return $subs;
}
/**
* 下拉列表生成器,支持无限极分类
* @param [type] $cate [description]
* @param [type] $selectedId [description]
* @return [type] [description]
*/
protected function cateOptions($cate,$selectedId){
$str='';
if ($cate){
foreach ($cate as $c){
$selected='';
if ($c['id']==$selectedId){
$selected=' selected';
}
$str.='<option value="'.$c['id'].'"'.$selected.'>'.str_repeat(' ', $c['level']).$c['name'].'</option>';
}
}
return $str;
}