Work on the tree
This commit is contained in:
parent
8a8fbec9de
commit
7876a16413
@ -42,6 +42,10 @@ class Controller_Tree extends Controller_lnApp_Tree {
|
|||||||
array_push($data,array('id'=>$id,'name'=>$mo->name,'state'=>'closed'));
|
array_push($data,array('id'=>$id,'name'=>$mo->name,'state'=>'closed'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$idx = NULL;
|
||||||
|
if (preg_match('/:/',$id))
|
||||||
|
list($id,$idx) = explode(':',$id,2);
|
||||||
|
|
||||||
$mo = ORM::factory('module',$id);
|
$mo = ORM::factory('module',$id);
|
||||||
|
|
||||||
$methods = array();
|
$methods = array();
|
||||||
@ -54,6 +58,7 @@ class Controller_Tree extends Controller_lnApp_Tree {
|
|||||||
|
|
||||||
Sort::MASort($modules,'name');
|
Sort::MASort($modules,'name');
|
||||||
|
|
||||||
|
$subdata = array();
|
||||||
foreach ($methods as $id => $mmo) {
|
foreach ($methods as $id => $mmo) {
|
||||||
if (preg_match('/_/',$mmo->name)) {
|
if (preg_match('/_/',$mmo->name)) {
|
||||||
list($mode,$action) = explode('_',$mmo->name);
|
list($mode,$action) = explode('_',$mmo->name);
|
||||||
@ -62,6 +67,16 @@ class Controller_Tree extends Controller_lnApp_Tree {
|
|||||||
$url = URL::site(sprintf('%s/%s',$mmo->module->name,$mmo->name));
|
$url = URL::site(sprintf('%s/%s',$mmo->module->name,$mmo->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We can split our menus into sub menus using the _ char.
|
||||||
|
if (preg_match('/_/',$mmo->name)) {
|
||||||
|
list($sub,$name) = explode('_',$mmo->name,2);
|
||||||
|
$subdata[$sub][$name]['name'] = preg_replace('/^(.*: )/','',$mmo->notes);
|
||||||
|
$subdata[$sub][$name]['id'] = sprintf('%s_%s',$mmo->module_id,$id);
|
||||||
|
$subdata[$sub][$name]['href'] = (empty($details['page']) ? $url : $details['page']);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// We dont want to show these items again, if we can through on a submenu
|
||||||
|
if (! $idx)
|
||||||
array_push($data,array(
|
array_push($data,array(
|
||||||
'id'=>sprintf('%s_%s',$mmo->module_id,$id),
|
'id'=>sprintf('%s_%s',$mmo->module_id,$id),
|
||||||
'name'=>$mmo->name,
|
'name'=>$mmo->name,
|
||||||
@ -71,6 +86,29 @@ class Controller_Tree extends Controller_lnApp_Tree {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If our sub menus only have 1 branch, then we'll display it as normal.
|
||||||
|
if (count($subdata) == 1) {
|
||||||
|
$sk = array_keys($subdata);
|
||||||
|
$idx = array_shift($sk);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($idx)
|
||||||
|
foreach ($subdata[$idx] as $k=>$v) {
|
||||||
|
array_push($data,array(
|
||||||
|
'id'=>$v['id'],
|
||||||
|
'name'=>$v['name'],
|
||||||
|
'state'=>'none',
|
||||||
|
'attr_id'=>$v['id'],
|
||||||
|
'attr_href'=>$v['href']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
foreach ($subdata as $t=>$x)
|
||||||
|
array_push($data,array('id'=>$mmo->module_id.':'.$t,'name'=>$t,'state'=>'closed'));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user