? .DS_Store ? menu_item_grouping_00.patch ? menu_item_grouping_01.patch ? menu_item_grouping_02.patch ? modules/.DS_Store ? sites/default/.DS_Store ? sites/default/settings.php Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.856 diff -u -p -r1.856 common.inc --- includes/common.inc 23 Jan 2009 14:23:27 -0000 1.856 +++ includes/common.inc 25 Jan 2009 16:16:43 -0000 @@ -3476,6 +3476,9 @@ function drupal_common_theme() { 'arguments' => array('form' => NULL), ), // from menu.inc + 'menu_item_grouping' => array( + 'arguments' => array('items' => NULL), + ), 'menu_item_link' => array( 'arguments' => array('item' => NULL), ), Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.310 diff -u -p -r1.310 menu.inc --- includes/menu.inc 4 Jan 2009 20:04:32 -0000 1.310 +++ includes/menu.inc 25 Jan 2009 16:16:44 -0000 @@ -141,7 +141,16 @@ define('MENU_NORMAL_ITEM', MENU_VISIBLE_ define('MENU_CALLBACK', MENU_VISIBLE_IN_BREADCRUMB); /** - * Menu type -- A normal menu item, hidden until enabled by an administrator. + * Menu type -- A menu item that lists all its children. + * + * If a menu item's sole purpose is to serve as a "container" for other menu + * items, it's callback is an item grouping. They act as normal items, the + * difference is that page and access callbacks are applied automatically. + */ +define('MENU_ITEM_GROUPING', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB | 0x0010); + +/** + * Menu type -- A "normal" menu item, hidden until enabled by an administrator. * * Modules may "suggest" menu items that the administrator may enable. They act * just as callbacks do until enabled, at which time they act like normal items. @@ -1222,6 +1231,44 @@ function _menu_tree_data($result, $paren } /** + * List a menu item's children. + * + * @return string + */ +function menu_item_grouping() { + $item = menu_get_item(); + $items = system_admin_menu_block($item); + // Bypass the listing if only one child is available. + if (count($items) == 1) { + $item = array_shift($items); + drupal_goto($item['href']); + } + return theme('menu_item_grouping', $items); +} + +/** + * Theme a list of menu items. + * + * @param $items + * The items as returned from system_admin_menu_block(). + * + * @return string + */ +function theme_menu_item_grouping($items) { + $output = ''; + + if ($items) { + $output = ''; + } + return $output; +} + +/** * Generate the HTML output for a single menu link. * * @ingroup themeable @@ -2569,6 +2616,10 @@ function _menu_router_build($callbacks) $item['access callback'] = intval($item['access callback']); } + if ($item['type'] == MENU_ITEM_GROUPING) { + $item['page callback'] = 'menu_item_grouping'; + } + $item += array( 'access arguments' => array(), 'access callback' => '', Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1018 diff -u -p -r1.1018 node.module --- modules/node/node.module 22 Jan 2009 12:46:06 -0000 1.1018 +++ modules/node/node.module 25 Jan 2009 16:16:48 -0000 @@ -1656,7 +1656,7 @@ function node_menu() { ); $items['node/add'] = array( 'title' => 'Create content', - 'page callback' => 'node_add_page', + 'type' => MENU_ITEM_GROUPING, 'access callback' => '_node_add_access', 'weight' => 1, ); Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.122 diff -u -p -r1.122 system.admin.inc --- modules/system/system.admin.inc 22 Jan 2009 12:46:07 -0000 1.122 +++ modules/system/system.admin.inc 25 Jan 2009 16:16:50 -0000 @@ -59,28 +59,6 @@ function system_main_admin_page($arg = N } } - -/** - * Provide a single block from the administration menu as a page. - * This function is often a destination for these blocks. - * For example, 'admin/build/types' needs to have a destination to be valid - * in the Drupal menu system, but too much information there might be - * hidden, so we supply the contents of the block. - * - * @return - * The output HTML. - */ -function system_admin_menu_block_page() { - $item = menu_get_item(); - if ($content = system_admin_menu_block($item)) { - $output = theme('admin_block_content', $content); - } - else { - $output = t('You do not have any administrative items.'); - } - return $output; -} - /** * Menu callback; prints a listing of admin tasks for each installed module. */ @@ -116,23 +94,6 @@ function system_admin_by_module() { } /** - * Menu callback; displays a module's settings page. - */ -function system_settings_overview() { - // Check database setup if necessary - if (function_exists('db_check_setup') && empty($_POST)) { - db_check_setup(); - } - - $item = menu_get_item('admin/settings'); - $content = system_admin_menu_block($item); - - $output = theme('admin_block_content', $content); - - return $output; -} - -/** * Form builder; This function allows selection of the theme to show in administration sections. * * @ingroup forms Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.660 diff -u -p -r1.660 system.module --- modules/system/system.module 21 Jan 2009 14:22:32 -0000 1.660 +++ modules/system/system.module 25 Jan 2009 16:16:51 -0000 @@ -421,28 +421,28 @@ function system_menu() { ); $items['admin/content'] = array( 'title' => 'Content management', + 'type' => MENU_ITEM_GROUPING, 'description' => "Manage your site's content.", 'position' => 'left', 'weight' => -10, - 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), ); // menu items that are basically just menu blocks $items['admin/settings'] = array( 'title' => 'Site configuration', + 'type' => MENU_ITEM_GROUPING, 'description' => 'Configure site settings.', 'position' => 'right', 'weight' => -5, - 'page callback' => 'system_settings_overview', 'access arguments' => array('access administration pages'), ); $items['admin/build'] = array( 'title' => 'Site building', + 'type' => MENU_ITEM_GROUPING, 'description' => 'Control how your site looks and feels.', 'position' => 'right', 'weight' => -10, - 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), ); $items['admin/settings/admin'] = array( @@ -665,8 +665,8 @@ function system_menu() { // Reports: $items['admin/reports'] = array( 'title' => 'Reports', + 'type' => MENU_ITEM_GROUPING, 'description' => 'View reports from system logs and other status information.', - 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access site reports'), 'weight' => 5, 'position' => 'left', Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.960 diff -u -p -r1.960 user.module --- modules/user/user.module 22 Jan 2009 12:46:07 -0000 1.960 +++ modules/user/user.module 25 Jan 2009 16:16:53 -0000 @@ -1133,10 +1133,9 @@ function user_menu() { // User administration pages. $items['admin/user'] = array( 'title' => 'User management', + 'type' => MENU_ITEM_GROUPING, 'description' => "Manage your site's users, groups and access to site features.", 'position' => 'left', - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), ); $items['admin/user/user'] = array( 'title' => 'Users',