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.
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 