function admin_menu_admin_menu_output_build in Administration menu 7.3
Same name and namespace in other branches
- 8.3 admin_menu.module \admin_menu_admin_menu_output_build()
- 6.3 admin_menu.module \admin_menu_admin_menu_output_build()
Implements hook_admin_menu_output_build().
File
- ./
admin_menu.module, line 676 - Render an administrative menu as a dropdown menu at the top of the window.
Code
function admin_menu_admin_menu_output_build(&$content) {
if (!isset($content['menu'])) {
return;
}
// Unassign weights for categories below Configuration.
// An alphabetical order is more natural for a dropdown menu.
if (isset($content['menu']['admin/config'])) {
foreach (element_children($content['menu']['admin/config']) as $key) {
$content['menu']['admin/config'][$key]['#weight_original'] = $content['menu']['admin/config'][$key]['#weight'];
unset($content['menu']['admin/config'][$key]['#weight']);
}
}
// Retrieve the "Add content" link tree.
$link = db_query("SELECT * FROM {menu_links} WHERE router_path = 'node/add' AND module = 'system'")
->fetchAssoc();
$conditions = array();
for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
if (!empty($link["p{$i}"])) {
$conditions["p{$i}"] = $link["p{$i}"];
}
}
$tree = menu_build_tree($link['menu_name'], array(
'conditions' => $conditions,
'min_depth' => $link['depth'],
));
$links = admin_menu_links_menu($tree);
if (!empty($links)) {
// If the user has access to the top-level "Content" category, insert the
// "Add content" link tree there.
if (isset($content['menu']['admin/content'])) {
$content['menu']['admin/content'] += $links;
}
else {
$key = key($links);
$links[$key]['#weight'] = -100;
$content['menu'] += $links;
}
}
}