function _menu_build_visible_tree in Drupal 4
Same name and namespace in other branches
- 5 includes/menu.inc \_menu_build_visible_tree()
Find all visible items in the menu tree, for ease in displaying to user.
Since this is only for display, we only need title, path, and children for each item.
1 call to _menu_build_visible_tree()
- _menu_build in includes/
menu.inc - Build the menu by querying both modules and the database.
File
- includes/
menu.inc, line 1154 - API for the Drupal menu system.
Code
function _menu_build_visible_tree($pid = 0) {
global $_menu;
if (isset($_menu['items'][$pid])) {
$parent = $_menu['items'][$pid];
$children = array();
if (isset($parent['children'])) {
usort($parent['children'], '_menu_sort');
foreach ($parent['children'] as $mid) {
$children = array_merge($children, _menu_build_visible_tree($mid));
}
}
$visible = $parent['type'] & MENU_VISIBLE_IN_TREE || $parent['type'] & MENU_VISIBLE_IF_HAS_CHILDREN && count($children) > 0;
$allowed = _menu_item_is_accessible($pid);
if ($parent['type'] & MENU_IS_ROOT || $visible && $allowed) {
$_menu['visible'][$pid] = array(
'title' => $parent['title'],
'path' => $parent['path'],
'children' => $children,
'type' => $parent['type'],
);
foreach ($children as $mid) {
$_menu['visible'][$mid]['pid'] = $pid;
}
return array(
$pid,
);
}
else {
return $children;
}
}
return array();
}