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 @@ + Index: themes/seven/style.css =================================================================== RCS file: /cvs/drupal/drupal/themes/seven/style.css,v retrieving revision 1.9 diff -u -p -r1.9 style.css --- themes/seven/style.css 12 Aug 2009 23:51:19 -0000 1.9 +++ themes/seven/style.css 17 Aug 2009 14:40:08 -0000 @@ -697,7 +697,8 @@ div.admin-options div.form-item { border: 0; } -a.node-admin-add-content { +a.node-admin-add-content, +ul.local-actions li a { padding-left: 15px; background: url(images/add.png) no-repeat 0 center; line-height: 30px; Index: themes/seven/template.php =================================================================== RCS file: /cvs/drupal/drupal/themes/seven/template.php,v retrieving revision 1.3 diff -u -p -r1.3 template.php --- themes/seven/template.php 14 Aug 2009 07:57:30 -0000 1.3 +++ themes/seven/template.php 17 Aug 2009 14:40:08 -0000 @@ -7,6 +7,7 @@ function seven_preprocess_page(&$vars) { $vars['primary_local_tasks'] = menu_primary_local_tasks(); $vars['secondary_local_tasks'] = menu_secondary_local_tasks(); + $vars['local_actions'] = menu_local_actions(); $vars['ie_styles'] = ''; $vars['back_to_site'] = l(t('Back to the front page'), ''); }