1 admin_bar.inc | admin_bar_links_menu($tree) |
Build the administration bar as renderable menu links.
Parameters
$tree: A data structure representing the administration bar tree as returned from menu_tree_all_data().
Return value
The complete administration bar, suitable for theme_admin_bar_links().:
See also
File
- core/
modules/ admin_bar/ admin_bar.inc, line 482 - Menu builder functions for Administration bar.
Code
function admin_bar_links_menu($tree) {
$links = array();
foreach ($tree as $data) {
// Skip items that are inaccessible, invisible, or only appear in the
// breadcrumb
if (!$data['link']['access'] || $data['link']['hidden'] == 1 || $data['link']['type'] == MENU_VISIBLE_IN_BREADCRUMB) {
continue;
}
// Hide 'Administer' and make child links appear on this level.
// @todo Make this configurable.
if ($data['link']['router_path'] == 'admin') {
if ($data['below']) {
$links = array_merge($links, admin_bar_links_menu($data['below']));
}
continue;
}
// Remove description to prevent mouseover tooltip clashes.
unset($data['link']['localized_options']['attributes']['title']);
// Move local action links to the appropriate position based on the
// respective setting. Defaults to 'top'.
$local_actions_bottom = config_get('admin_bar.settings', 'local_actions_bottom');
if ($data['link']['type'] & MENU_IS_LOCAL_ACTION) {
if (config_get('admin_bar.settings', 'local_action_position') == 'bottom') {
$data['link']['weight'] += 9999;
}
else {
$data['link']['weight'] -= 9999;
}
}
$links[$data['link']['href']] = array(
'#title' => $data['link']['title'],
'#href' => $data['link']['href'],
'#options' => $data['link']['localized_options'],
'#weight' => $data['link']['weight'],
);
// Recurse to add any child links.
$children = array();
if ($data['below']) {
$children = admin_bar_links_menu($data['below']);
$links[$data['link']['href']] += $children;
}
// Handle links pointing to category/overview pages.
if ($data['link']['page_callback'] == 'system_admin_menu_block_page' || $data['link']['page_callback'] == 'system_admin_config_page') {
// Apply a marker for others to consume.
$links[$data['link']['href']]['#is_category'] = TRUE;
// Automatically hide empty categories.
// Check for empty children first for performance. Only when non-empty
// (typically 'admin/config'), check whether children are accessible.
if (empty($children) || !element_get_visible_children($children)) {
$links[$data['link']['href']]['#access'] = FALSE;
}
}
}
return $links;
}