You are here

admin_menu.module in Administration menu 5

File

admin_menu.module
View source
<?php

/**
 * Implementation of hook_help().
 */
function admin_menu_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t("Renders the administer menu tree as dropdown menu at the top of the window.");
  }
}

/**
 * Implementation of hook_perm().
 */
function admin_menu_perm() {
  return array(
    'access administration menu',
  );
}

/**
 * Implementation of hook_menu().
 *
 * PHP-only based themes like chameleon load and output scripts and stylesheets
 * in front of theme_closure(), so we ensure Admin menu's styles and scripts are
 * loaded on all pages via hook_menu().
 */
function admin_menu_menu($may_cache) {
  $items = array();
  if (!user_access('access administration menu')) {
    return $items;
  }
  $path = drupal_get_path('module', 'admin_menu');
  drupal_add_css($path . '/admin_menu.css', 'module', 'screen', false);

  // IE6 fix.
  $ie_header = '<!--[if lt IE 7]>';
  $ie_header .= '<script type="text/javascript" src="' . base_path() . $path . '/admin_menu.js' . '"></script>';
  $ie_header .= '<![endif]-->';
  drupal_set_html_head($ie_header);
  return $items;
}

/**
 * Implementation of hook_footer().
 *
 * Admin menu was previously output via hook_block(), but suffered from
 * theme-specific stylesheets that may be applied to layout blocks. We now
 * output Admin menu in the footer to circumvent this.
 */
function admin_menu_footer($main) {
  if (!user_access('access administration menu')) {
    return;
  }
  global $user, $locale;
  $cid = $user->uid . ':' . $locale . ':admin_menu';
  $cache = cache_get($cid, 'cache_menu');
  if ($cache) {
    $admin_menu = $cache->data;
  }
  else {
    require_once drupal_get_path('module', 'admin_menu') . '/admin_menu.inc';
    $admin_menu = admin_menu_get_menu();
    cache_set($cid, 'cache_menu', $admin_menu, time() + 60 * 60 * 24);
  }
  $content = '<div id="admin_menu">';
  $content .= theme('admin_menu_icon');
  $content .= $admin_menu;
  $content .= '</div>';
  return $content;
}

/**
 * Render an icon to display in the Administration Menu.
 *
 * @ingroup themeable
 */
function theme_admin_menu_icon() {
  $output = '<img id="admin_menu_icon" src="' . check_url(base_path() . 'misc/favicon.ico') . '" width="16" height="16" alt="" border="0" />';
  return $output;
}

/**
 * Implementation of hook_form_alter() to extend devel.module.
 */
function admin_menu_form_alter($form_id, &$form) {
  if ($form_id == 'devel_admin_settings') {

    // shift system_settings_form buttons
    $weight = $form['buttons']['#weight'];
    $form['buttons']['#weight'] = $weight + 1;
    $form['admin_menu'] = array(
      '#type' => 'fieldset',
      '#title' => t('Administration Menu settings'),
      '#collapsible' => true,
      '#collapsed' => true,
    );
    $form['admin_menu']['admin_menu_show_item_ids'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display menu item IDs in Drupal Administration Menu'),
      '#default_value' => variable_get('admin_menu_show_item_ids', 0),
      '#description' => t('If enabled, the corresponding menu item id will appear next to each menu item link.'),
    );
    $form['admin_menu']['admin_menu_show_all'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display all menu items'),
      '#default_value' => variable_get('admin_menu_show_all', 0),
      '#description' => t('Enable this option to disable user access checks for menu items, i.e. every menu item in the visible menu tree will be displayed to every user regardless of access permissions.'),
    );
  }
}

Functions

Namesort descending Description
admin_menu_footer Implementation of hook_footer().
admin_menu_form_alter Implementation of hook_form_alter() to extend devel.module.
admin_menu_help Implementation of hook_help().
admin_menu_menu Implementation of hook_menu().
admin_menu_perm Implementation of hook_perm().
theme_admin_menu_icon Render an icon to display in the Administration Menu.