function admin_menu_output in Administration menu 6.3
Same name and namespace in other branches
- 8.3 admin_menu.module \admin_menu_output()
- 5.3 admin_menu.module \admin_menu_output()
- 7.3 admin_menu.module \admin_menu_output()
Build the administration menu output.
2 calls to admin_menu_output()
- admin_menu_footer in ./
admin_menu.module - Implements hook_footer().
- admin_menu_js_cache in ./
admin_menu.module - Menu callback; Output administration menu for HTTP caching via AJAX request.
File
- ./
admin_menu.module, line 448 - Render an administrative menu as a dropdown menu at the top of the window.
Code
function admin_menu_output() {
if (!user_access('access administration menu') || admin_menu_suppress(FALSE)) {
return;
}
global $user, $language;
$cache_server_enabled = variable_get('admin_menu_cache_server', TRUE);
$cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . $language->language;
// Do nothing at all here if the client supports client-side caching, the user
// has a hash, and is NOT requesting the cache update path. Consult the hash
// cache last, since it requires a DB request.
// @todo Implement a sanity-check to prevent permanent double requests; i.e.
// what if the client-side cache fails for any reason and performs a second
// request on every page?
if (!empty($_COOKIE['has_js']) && strpos($_GET['q'], 'js/admin_menu/cache') !== 0) {
if (admin_menu_cache_get($cid)) {
return;
}
}
// Try to load and output administration menu from server-side cache.
if ($cache_server_enabled) {
$cache = cache_get($cid, 'cache_menu');
if ($cache && isset($cache->data)) {
$content = $cache->data;
}
}
// Rebuild the output.
if (!isset($content)) {
// Add site name as CSS class for development/staging theming purposes. We
// leverage the cookie domain instead of HTTP_HOST to account for many (but
// not all) multi-domain setups (e.g. language-based sub-domains).
$class_site = 'admin-menu-site' . drupal_strtolower(preg_replace('/[^a-zA-Z0-9-]/', '-', $GLOBALS['cookie_domain']));
// @todo Always output container to harden JS-less support.
$content['#prefix'] = '<div id="admin-menu" class="' . $class_site . '"><div id="admin-menu-wrapper"><ul>';
$content['#suffix'] = '</ul></div></div>';
// Load menu builder functions.
module_load_include('inc', 'admin_menu');
// Add administration menu.
$content['menu'] = admin_menu_links_menu(menu_tree_all_data('admin_menu'));
$content['menu']['#theme'] = 'admin_menu_links';
// Ensure the menu tree is rendered between the icon and user links.
$content['menu']['#weight'] = 0;
// Add menu additions.
$content['icon'] = admin_menu_links_icon();
$content['user'] = admin_menu_links_user();
// Allow modules to enhance the menu.
// Uses '_output' suffix for consistency with the alter hook (see below).
foreach (module_implements('admin_menu_output_build') as $module) {
$function = $module . '_admin_menu_output_build';
$function($content);
}
// Allow modules to alter the output.
// The '_output' suffix is required to prevent hook implementation function
// name clashes with the contributed Admin module.
drupal_alter('admin_menu_output', $content);
$content = drupal_render($content);
// Cache the menu for this user.
if ($cache_server_enabled) {
cache_set($cid, $content, 'cache_menu');
}
}
// Store the new hash for this user.
if (!empty($_COOKIE['has_js'])) {
admin_menu_cache_set($cid, md5($content));
}
return $content;
}