http://git.oschina.net/qiawei/qwadmin
App/Qwadmin/Controller/ComController.class.php
protected function getMenu($items,$id='id',$pid='pid',$son = 'children'){
$tree = array();
$tmpMap = array();
$father_ids = array();
//修复父类设置islink=0,但是子类仍然显示的bug by shaoneng
foreach( $items as $item ){
if( $item['pid']==0 ){
$father_ids[] = $item['id'];
}
}
//----
foreach ($items as $item) {
$tmpMap[$item[$id]] = $item;
}
foreach ($items as $item) {
//修复父类设置islink=0,但是子类仍然显示的bug by shaoneng
if( $item['pid']<>0 && !in_array( $item['pid'], $father_ids )){
continue;
}
//----
if (isset($tmpMap[$item[$pid]])) {
$tmpMap[$item[$pid]][$son][] = &$tmpMap[$item[$id]];
} else {
$tree[] = &$tmpMap[$item[$id]];
}
}
return $tree;
}