system_admin_menu_block

Versions
5
system_admin_menu_block($block)
6 – 7
system_admin_menu_block($item)

Provide a single block on the administration overview page.

Parameters

$item The menu item to be displayed.

▾ 5 functions call system_admin_menu_block()

node_add_page in modules/node/node.pages.inc
system_admin_config_page in modules/system/system.admin.inc
Menu callback; Provide the administration overview page.
system_admin_menu_block_page in modules/system/system.admin.inc
Provide a single block from the administration menu as a page. This function is often a destination for these blocks. For example, 'admin/structure/types' needs to have a destination to be valid in the Drupal menu system, but too much...
system_main_admin_page in modules/system/system.admin.inc
Menu callback; Provide the administration overview page.
system_settings_overview in modules/system/system.admin.inc
Menu callback; displays a module's settings page.

Code

modules/system/system.module, line 1908

<?php
function system_admin_menu_block($item) {
  $cache = &drupal_static(__FUNCTION__, array());
  if (!isset($item['mlid'])) {
    $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc();
  }

  if (isset($cache[$item['mlid']])) {
    return $cache[$item['mlid']];
  }

  $content = array();
  $default_task = NULL;
  $has_subitems = FALSE;
  $result = db_query("
    SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.delivery_callback, m.title, m.title_callback, m.title_arguments, m.theme_callback, m.theme_arguments, m.type, m.description, m.path, m.weight as router_weight, ml.*
    FROM {menu_router} m
    LEFT JOIN {menu_links} ml ON m.path = ml.router_path
    WHERE (ml.plid = :plid AND ml.menu_name = :name AND hidden = 0) OR (m.tab_parent = :path AND m.type IN (:local_task, :default_task))", array(':plid' => $item['mlid'], ':name' => $item['menu_name'], ':path' => $item['path'], ':local_task' => MENU_LOCAL_TASK, ':default_task' => MENU_DEFAULT_LOCAL_TASK), array('fetch' => PDO::FETCH_ASSOC));
  foreach ($result as $link) {
    if (!isset($link['link_path'])) {
      // If this was not an actual link, fake the tab as a menu link, so we
      // don't need to special case it beyond this point.
      $link['link_title'] = $link['title'];
      $link['link_path'] = $link['path'];
      $link['options'] = 'a:0:{}';
      $link['weight'] = $link['router_weight'];
    }
    else {
      // We found a non-tab subitem, remember that.
      $has_subitems = TRUE;
    }
    _menu_link_translate($link);
    if (!$link['access']) {
      continue;
    }
    // The link 'description' either derived from the hook_menu 'description' or
    // entered by the user via menu module is saved as the title attribute.
    if (!empty($link['localized_options']['attributes']['title'])) {
      $link['description'] = $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;
    if ($link['type'] == MENU_DEFAULT_LOCAL_TASK) {
      $default_task = $key;
    }
  }
  if ($has_subitems) {
    // If we've had at least one non-tab subitem, remove the link for the
    // default task, since that is already broken down to subitems.
    unset($content[$default_task]);
  }
  ksort($content);
  $cache[$item['mlid']] = $content;
  return $content;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.