function system_admin_menu_block

Provide a single block on the administration overview page.

Parameters

$item: The menu item to be displayed.

2 calls to system_admin_menu_block()
system_admin_config_page in drupal/core/modules/system/system.admin.inc
Menu callback; Provide the administration overview page.
system_admin_menu_block_page in drupal/core/modules/system/system.admin.inc
Provide a single block from the administration menu as a page.

File

drupal/core/modules/system/system.module, line 2647
Configuration system that lets administrators modify the workings of the site.

Code

function system_admin_menu_block($item) {
  $cache =& drupal_static(__FUNCTION__, array());

  // If we are calling this function for a menu item that corresponds to a
  // local task (for example, admin/tasks), then we want to retrieve the
  // parent item's child links, not this item's (since this item won't have
  // any).
  if ($item['tab_root'] != $item['path']) {
    $item = menu_get_item($item['tab_root_href']);
  }
  if (!isset($item['mlid'])) {
    $menu_links = entity_load_multiple_by_properties('menu_link', array(
      'router_path' => $item['path'],
      'module' => 'system',
    ));
    $menu_link = reset($menu_links);
    $item['mlid'] = $menu_link
      ->id();
    $item['menu_name'] = $menu_link->menu_name;
  }
  if (isset($cache[$item['mlid']])) {
    return $cache[$item['mlid']];
  }
  $content = array();
  $menu_links = entity_load_multiple_by_properties('menu_link', array(
    'plid' => $item['mlid'],
    'menu_name' => $item['menu_name'],
    'hidden' => 0,
  ));
  foreach ($menu_links as $link) {
    _menu_link_translate($link);
    if ($link['access']) {

      // The link description, either derived from 'description' in
      // hook_menu() or customized via menu module is used as title attribute.
      if (!empty($link['localized_options']['attributes']['title'])) {
        $link['description'] = $link['localized_options']['attributes']['title'];
        unset($link['localized_options']['attributes']['title']);
      }

      // Prepare for sorting as in function _menu_tree_check_access().
      // The weight is offset so it is always positive, with a uniform 5-digits.
      $key = 50000 + $link['weight'] . ' ' . drupal_strtolower($link['title']) . ' ' . $link['mlid'];
      $content[$key] = $link;
    }
  }
  ksort($content);
  $cache[$item['mlid']] = $content;
  return $content;
}