system_main_admin_page
- Versions
- 5 – 7
system_main_admin_page($arg = NULL)
Menu callback; Provide the administration overview page.
Code
modules/system/system.admin.inc, line 11
<?php
function system_main_admin_page($arg = NULL) {
// If we received an argument, they probably meant some other page.
// Let's 404 them since the menu system cannot be told we do not
// accept arguments.
if (isset($arg) && substr($arg, 0, 3) != 'by-') {
return drupal_not_found();
}
// Check for status report errors.
if (system_status(TRUE) && user_access('administer site configuration')) {
drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
}
$blocks = array();
if ($admin = db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin' AND module = 'system'")->fetchAssoc()) {
$result = db_query("
SELECT m.*, ml.*
FROM {menu_links} ml
INNER JOIN {menu_router} m ON ml.router_path = m.path
WHERE ml.link_path != 'admin/help' AND menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $item) {
_menu_link_translate($item);
if (!$item['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($item['localized_options']['attributes']['title'])) {
$item['description'] = $item['localized_options']['attributes']['title'];
}
$block = $item;
$block['content'] = '';
$block['show'] = FALSE;
if ($item['block_callback'] && function_exists($item['block_callback'])) {
$function = $item['block_callback'];
$block['content'] .= $function();
}
$content = system_admin_menu_block($item);
if ((isset($item['page_callback']) && !in_array($item['page_callback'], array('system_admin_menu_block_page', 'system_admin_config_page', 'system_settings_overview'))) || count($content)) {
// Only show blocks for items which are not containers, or those which
// are containers and do have items we can show.
$block['show'] = TRUE;
if (empty($content)) {
// If no items found below, but access checks did not fail, show.
$block['title'] = l($item['title'], $item['href'], $item['localized_options']);
}
else {
// Theme items below.
$block['content'] .= theme('admin_block_content', array('content' => $content));
}
}
// Prepare for sorting as in function _menu_tree_check_access().
// The weight is offset so it is always positive, with a uniform 5-digits.
$blocks[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $block;
}
}
if ($blocks) {
ksort($blocks);
return theme('admin_page', array('blocks' => $blocks));
}
else {
return t('You do not have any administrative items.');
}
}
?>Login or register to post comments 