You are here

function admin_menu_menu in Administration menu 5.2

Same name and namespace in other branches
  1. 8.3 admin_menu.module \admin_menu_menu()
  2. 5.3 admin_menu.module \admin_menu_menu()
  3. 5 admin_menu.module \admin_menu_menu()
  4. 6.3 admin_menu.module \admin_menu_menu()
  5. 6 admin_menu.module \admin_menu_menu()
  6. 7.3 admin_menu.module \admin_menu_menu()

Implementation of hook_menu().

We can't move this into admin_menu_footer(), because 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().

File

./admin_menu.module, line 59
Renders a menu tree for administrative purposes as dropdown menu at the top of the window.

Code

function admin_menu_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/admin_menu',
      'title' => t('Administration Menu'),
      'description' => t('Adjust settings for the dropdown Administration Menu.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'admin_menu_theme_settings',
      ),
      'access' => user_access('administer site configuration'),
    );
    $items[] = array(
      'path' => 'admin_menu/toggle-modules',
      'callback' => 'admin_menu_toggle_modules',
      'access' => user_access('administer site configuration'),
      'type' => MENU_CALLBACK,
    );
  }
  elseif (user_access('access administration menu')) {
    $path = drupal_get_path('module', 'admin_menu');
    drupal_add_css($path . '/admin_menu.css', 'module', 'all', FALSE);

    // Performance: Defer execution.
    drupal_add_js($path . '/admin_menu.js', 'module', 'header', TRUE);
    if ($setting = variable_get('admin_menu_margin_top', 1)) {
      drupal_add_js(array(
        'admin_menu' => array(
          'margin_top' => $setting,
        ),
      ), 'setting');
    }
    if ($setting = variable_get('admin_menu_position_fixed', 0)) {
      drupal_add_js(array(
        'admin_menu' => array(
          'position_fixed' => $setting,
        ),
      ), 'setting');
    }
    if ($setting = variable_get('admin_menu_tweak_tabs', 0)) {
      drupal_add_js(array(
        'admin_menu' => array(
          'tweak_tabs' => $setting,
        ),
      ), 'setting');
    }
    if ($_GET['q'] == 'admin/build/menu' && variable_get('admin_menu_tweak_menu', 0)) {
      drupal_add_js($path . '/admin_menu.menu.js');
      drupal_add_js('misc/collapse.js');
    }
    if ($_GET['q'] == 'admin/build/modules' || strpos($_GET['q'], 'admin/build/modules/list') === 0) {
      drupal_add_js(array(
        'admin_menu' => array(
          'tweak_modules' => variable_get('admin_menu_tweak_modules', 0),
        ),
      ), 'setting');
    }
  }
  return $items;
}