You are here

function admin_menu_get_menu in Administration menu 5.2

Same name and namespace in other branches
  1. 5.3 admin_menu.module \admin_menu_get_menu()
  2. 5 admin_menu.inc \admin_menu_get_menu()

Return Administration Menu from cache or rebuild it.

Parameters

int $mid_admin: The menu item id to use for the administration menu.

Return value

array An array containing a complete menu structure of all cached administration menu items.

4 calls to admin_menu_get_menu()
admin_menu_footer in ./admin_menu.module
Implementation of hook_footer().
theme_admin_menu_item in ./admin_menu.module
Generate the HTML output for a single menu item.
theme_admin_menu_tree in ./admin_menu.module
Generate the HTML for a menu tree.
_admin_menu_sort in ./admin_menu.module
Comparator routine for use in sorting menu items.

File

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

Code

function &admin_menu_get_menu($mid_admin = 5) {
  static $_admin_menu;
  if (isset($_admin_menu)) {
    return $_admin_menu;
  }
  global $user, $locale;
  $cid = $user->uid . ':' . $locale . ':admin_menu';
  $cache = cache_get($cid, 'cache_menu');

  // Check if cache is an array needed to distinguish between v5.x-1.2 and later
  // versions.
  if ($cache && substr($cache->data, 0, 1) == 'a') {
    $_admin_menu = unserialize($cache->data);
  }
  else {
    require_once drupal_get_path('module', 'admin_menu') . '/admin_menu.inc';
    $_admin_menu = admin_menu_build($mid_admin);
    cache_set($cid, 'cache_menu', serialize($_admin_menu), time() + 60 * 60 * 24);
  }
  return $_admin_menu;
}