function admin_menu_page_build

nittany7 admin_menu.module admin_menu_page_build(&$page)
cis7 admin_menu.module admin_menu_page_build(&$page)
mooc7 admin_menu.module admin_menu_page_build(&$page)

Implements hook_page_build().

File

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

Code

function admin_menu_page_build(&$page) {
  if (!user_access('access administration menu') || admin_menu_suppress(FALSE)) {
    return;
  }
  // Performance: Skip this entirely for AJAX requests.
  if (strpos($_GET['q'], 'js/') === 0) {
    return;
  }
  global $user, $language;
  $path = drupal_get_path('module', 'admin_menu');

  $page['page_bottom']['admin_menu'] = array(
    '#attached' => array(),
  );
  $attached = &$page['page_bottom']['admin_menu']['#attached'];
  $options = array('every_page' => TRUE);

  $attached['css'][$path . '/admin_menu.css'] = $options;
  if ($user->uid == 1) {
    $attached['css'][$path . '/admin_menu.uid1.css'] = $options;
  }
  // Previous versions used the 'defer' attribute to increase browser rendering
  // performance. At least starting with Firefox 3.6, deferred .js files are
  // loaded, but Drupal.behaviors are not contained in the DOM when drupal.js
  // executes Drupal.attachBehaviors().
  $attached['js'][$path . '/admin_menu.js'] = $options;

  // Destination query strings are applied via JS.
  $settings['destination'] = drupal_http_build_query(drupal_get_destination());

  // Determine whether we need to show all components and disable all caches.
  $complete = FALSE;
  if (current_path() == 'admin/config/administration/admin_menu' && $_SERVER['REQUEST_METHOD'] == 'GET') {
    $complete = TRUE;
  }

  // If the client supports JavaScript and we have a cached menu for the current
  // user, only output the hash for the client-side HTTP cache callback URL.
  $cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . $language->language;
  if (!$complete && !empty($_COOKIE['has_js']) && ($hash = admin_menu_cache_get($cid))) {
    $settings['hash'] = $hash;
    // The base path to use for cache requests depends on whether clean URLs
    // are enabled, whether Drupal runs in a sub-directory, and on the language
    // system configuration. url() already provides us the proper path and also
    // invokes potentially existing custom_url_rewrite() functions, which may
    // add further required components to the URL to provide context. Due to
    // those components, and since url('') returns only base_path() when clean
    // URLs are disabled, we need to use a replacement token as path.  Yuck.
    $settings['basePath'] = url('admin_menu');
  }
  // Otherwise, add the full menu to the page.
  else {
    $page['page_bottom']['admin_menu']['#markup'] = admin_menu_output($complete);
  }

  $replacements = module_invoke_all('admin_menu_replacements', $complete);
  if (!empty($replacements)) {
    $settings['replacements'] = $replacements;
  }

  if ($setting = variable_get('admin_menu_margin_top', 1)) {
    $settings['margin_top'] = $setting;
    // @todo Drupal.behaviors.adminMenuMarginTop is obsolete, but
    //   hook_page_build() does not allow to set a CSS class on the body yet.
    // @see http://drupal.org/node/1473548, http://drupal.org/node/1194528
    //$page['#attributes']['class'][] = 'admin-menu';
  }
  if ($setting = variable_get('admin_menu_position_fixed', 1)) {
    $settings['position_fixed'] = $setting;

    // In fixed positioning, supply a callback function for tableheader.js to
    // allow it to determine the top viewport offset.
    // @see admin_menu.js, toolbar.js
    $attached['js'][] = array(
      'data' => array('tableHeaderOffset' => 'Drupal.admin.height'),
      'type' => 'setting',
    );
  }
  if ($setting = variable_get('admin_menu_tweak_tabs', 0)) {
    $settings['tweak_tabs'] = $setting;
  }
  if ($_GET['q'] == 'admin/modules' || strpos($_GET['q'], 'admin/modules/list') === 0) {
    $settings['tweak_modules'] = variable_get('admin_menu_tweak_modules', 0);
  }
  if ($_GET['q'] == 'admin/people/permissions' || $_GET['q'] == 'admin/people/permissions/list') {
    $settings['tweak_permissions'] = variable_get('admin_menu_tweak_permissions', 0);
  }

  $attached['js'][] = array(
    'data' => array('admin_menu' => $settings),
    'type' => 'setting',
  );
}