You are here

function admin_menu_output in Administration menu 7.3

Same name and namespace in other branches
  1. 8.3 admin_menu.module \admin_menu_output()
  2. 5.3 admin_menu.module \admin_menu_output()
  3. 6.3 admin_menu.module \admin_menu_output()

Build the administration menu output.

Parameters

bool $complete: (optional) Whether to build to the complete menu including all components and ignore the cache. Defaults to FALSE. Internally used for the settings page.

2 calls to admin_menu_output()
admin_menu_js_callback_cache in ./admin_menu.module
Implements MODULE_js_callback_HOOK().
admin_menu_page_build in ./admin_menu.module
Implements hook_page_build().

File

./admin_menu.module, line 600
Render an administrative menu as a dropdown menu at the top of the window.

Code

function admin_menu_output($complete = FALSE) {

  // Building the output requires a full bootstrap so the theme system can
  // render the content properly.
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

  // Retrieve enabled components to display and make them available for others.
  $components = variable_get('admin_menu_components', array());
  $components += array(
    'admin_menu.menu' => TRUE,
    'admin_menu.icon' => TRUE,
    'admin_menu.account' => TRUE,
  );
  $content['#components'] = $components;
  $content['#complete'] = $complete;

  // 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).
  $classes = 'admin-menu-site' . drupal_strtolower(preg_replace('/[^a-zA-Z0-9-]/', '-', $GLOBALS['cookie_domain']));

  // Displace overlay.
  // @see Drupal.overlay.create
  // @see toolbar_preprocess_toolbar()
  if (module_exists('overlay')) {
    $classes .= ' overlay-displace-top';
  }

  // @todo Always output container to harden JS-less support.
  $content['#prefix'] = '<div id="admin-menu" class="' . $classes . '"><div id="admin-menu-wrapper">';
  $content['#suffix'] = '</div></div>';

  // Load menu builder functions.
  module_load_include('inc', 'admin_menu');

  // @todo Move the below callbacks into hook_admin_menu_build()
  //   implementations (and $module.admin_menu.inc).
  // Add administration menu.
  if (!empty($components['admin_menu.menu']) || $complete) {
    $content['menu'] = admin_menu_links_menu(_admin_menu_tree('management'));
    $content['menu']['#theme'] = 'admin_menu_links';
    $content['menu']['#wrapper_attributes']['id'] = 'admin-menu-menu';

    // Ensure the menu tree is rendered between the icon and user links.
    $content['menu']['#weight'] = 0;
  }

  // Add menu additions.
  if (!empty($components['admin_menu.icon']) || $complete) {
    $content['icon'] = admin_menu_links_icon();
  }
  if (!empty($components['admin_menu.account']) || $complete) {
    $content['account'] = admin_menu_links_account();
  }
  if (!empty($components['admin_menu.users']) || $complete) {
    $content['users'] = admin_menu_links_users();
  }
  if (!empty($components['admin_menu.search']) || $complete) {
    $content['search'] = admin_menu_links_search();
  }

  // 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);
  return drupal_render($content);
}