Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.333 diff -u -p -r1.333 menu.inc --- includes/menu.inc 11 Aug 2009 17:26:33 -0000 1.333 +++ includes/menu.inc 17 Aug 2009 14:40:08 -0000 @@ -113,6 +113,11 @@ define('MENU_CREATED_BY_ADMIN', 0x0040); define('MENU_IS_LOCAL_TASK', 0x0080); /** + * Internal menu flag -- menu item is a local action. + */ +define('MENU_IS_LOCAL_ACTION', 0x0100); + +/** * @} End of "Menu flags". */ @@ -168,6 +173,15 @@ define('MENU_LOCAL_TASK', MENU_IS_LOCAL_ define('MENU_DEFAULT_LOCAL_TASK', MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT); /** + * Menu type -- An action specific to the parent item. + * + * Local actions are menu items that describe actions to be performed on their + * parent item. An example is the path "admin/structure/block/add", which + * adds a block. + */ +define('MENU_LOCAL_ACTION', MENU_IS_LOCAL_ACTION | MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB); + +/** * @} End of "Menu item types". */ @@ -1611,6 +1625,48 @@ function theme_menu_local_tasks() { } /** + * Collects the local actions for the current menu item. + * + * @return + * Themed output corresponding to the actions on the current menu item. + */ +function menu_local_actions() { + $actions = &drupal_static(__FUNCTION__); + + if (!isset($actions)) { + $actions = ''; + + $router_item = menu_get_item(); + if (!$router_item || !$router_item['access']) { + return array(); + } + + // Get all local actions children. + // @todo: this query might return more then one item when % menu + // placeholders are at play. + if ($mlid = db_select('menu_links')->fields('menu_links', array('mlid'))->condition('link_path', $router_item['path'])->execute()->fetchField()) { + $query = db_select('menu_router', 'mr', array('fetch' => PDO::FETCH_ASSOC)); + $query->leftJoin('menu_links', 'ml', 'mr.path = ml.router_path'); + $query->fields('mr') + ->condition('mr.type', MENU_LOCAL_ACTION) + ->condition('ml.plid', $mlid) + ->orderBy('weight') + ->orderBy('title'); + + $result = $query->execute(); + $map = arg(); + + foreach ($result as $item) { + _menu_translate($item, $map, TRUE); + $actions .= theme('menu_local_task', theme('menu_item_link', $item)); + } + } + } + + return $actions; +} + +/** * Set (or get) the active menu for the current page - determines the active trail. */ function menu_set_active_menu_names($menu_names = NULL) { Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.195 diff -u -p -r1.195 menu.module --- modules/menu/menu.module 20 Jul 2009 18:51:33 -0000 1.195 +++ modules/menu/menu.module 17 Aug 2009 14:40:08 -0000 @@ -65,7 +65,7 @@ function menu_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('menu_edit_menu', 'add'), 'access arguments' => array('administer menu'), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_LOCAL_ACTION, ); $items['admin/structure/menu/settings'] = array( 'title' => 'Settings', @@ -94,7 +94,7 @@ function menu_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('menu_edit_item', 'add', NULL, 3), 'access arguments' => array('administer menu'), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_LOCAL_ACTION, ); $items['admin/structure/menu-customize/%menu/edit'] = array( 'title' => 'Edit menu', Index: themes/seven/page.tpl.php =================================================================== RCS file: /cvs/drupal/drupal/themes/seven/page.tpl.php,v retrieving revision 1.1 diff -u -p -r1.1 page.tpl.php --- themes/seven/page.tpl.php 31 Jul 2009 19:35:57 -0000 1.1 +++ themes/seven/page.tpl.php 17 Aug 2009 14:40:08 -0000 @@ -33,6 +33,7 @@ +