diff options
Diffstat (limited to 'includes/menu.inc')
-rw-r--r-- | includes/menu.inc | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/includes/menu.inc b/includes/menu.inc index 0806a31cf..cfd35c794 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -14,7 +13,10 @@ * The Drupal menu system drives both the navigation system from a user * perspective and the callback system that Drupal uses to respond to URLs * passed from the browser. For this reason, a good understanding of the - * menu system is fundamental to the creation of complex modules. + * menu system is fundamental to the creation of complex modules. As a note, + * this is related to, but separate from menu.module, which allows menus + * (which in this context are hierarchical lists of links) to be customized from + * the Drupal administrative interface. * * Drupal's menu system follows a simple hierarchy defined by paths. * Implementations of hook_menu() define menu items and assign them to @@ -125,7 +127,7 @@ define('MENU_IS_LOCAL_ACTION', 0x0100); /** * @defgroup menu_item_types Menu item types * @{ - * Definitions for various menu types. + * Definitions for various menu item types. * * Menu item definitions provide one of these constants, which are shortcuts for * combinations of @link menu_flags Menu flags @endlink. @@ -1042,7 +1044,7 @@ function menu_tree_output($tree) { } // Allow menu-specific theme overrides. - $element['#theme'] = 'menu_link__' . $data['link']['menu_name']; + $element['#theme'] = 'menu_link__' . strtr($data['link']['menu_name'], '-', '_'); $element['#attributes']['class'] = $class; $element['#title'] = $data['link']['title']; $element['#href'] = $data['link']['href']; @@ -2064,7 +2066,7 @@ function menu_local_tasks($level = 0) { * node or array('system', 'navigation') for a certain block. * * @return - * A list of menu router items that are local tasks for the passed in path. + * A list of menu router items that are local tasks for the passed-in path. * * @see contextual_links_preprocess() */ @@ -2319,11 +2321,11 @@ function menu_set_active_trail($new_trail = NULL) { } list($key, $curr) = each($tree); } - // Make sure the current page is in the trail (needed for the page title), - // if the link's type allows it to be shown in the breadcrumb. Also exclude - // it if we are on the front page. + // Make sure the current page is in the trail to build the page title, by + // appending either the preferred link or the menu router item for the + // current page. Exclude it if we are on the front page. $last = end($trail); - if ($last['href'] != $preferred_link['href'] && ($preferred_link['type'] & MENU_VISIBLE_IN_BREADCRUMB) == MENU_VISIBLE_IN_BREADCRUMB && !drupal_is_front_page()) { + if ($last['href'] != $preferred_link['href'] && !drupal_is_front_page()) { $trail[] = $preferred_link; } } @@ -2891,11 +2893,12 @@ function _menu_delete_item($item, $force = FALSE) { menu_link_save($child); } } - db_delete('menu_links')->condition('mlid', $item['mlid'])->execute(); - // Notify modules we have deleted the item. + // Notify modules we are deleting the item. module_invoke_all('menu_link_delete', $item); + db_delete('menu_links')->condition('mlid', $item['mlid'])->execute(); + // Update the has_children status of the parent. _menu_update_parental_status($item); menu_cache_clear($item['menu_name']); @@ -2904,18 +2907,26 @@ function _menu_delete_item($item, $force = FALSE) { } /** - * Save a menu link. + * Saves a menu link. + * + * After calling this function, rebuild the menu cache using + * menu_cache_clear_all(). * * @param $item - * An array representing a menu link item. The only mandatory keys are - * link_path and link_title. Possible keys are: - * - menu_name: Default is navigation - * - weight: Default is 0 - * - expanded: Whether the item is expanded. - * - options: An array of options, see l() for more. - * - mlid: Set to an existing value, or 0 or NULL to insert a new link. - * - plid: The mlid of the parent. - * - router_path: The path of the relevant router item. + * An associative array representing a menu link item, with elements: + * - link_path: (required) The path of the menu item, which should be + * normalized first by calling drupal_get_normal_path() on it. + * - link_title: (required) Title to appear in menu for the link. + * - menu_name: (optional) The machine name of the menu for the link. + * Defaults to 'navigation'. + * - weight: (optional) Integer to determine position in menu. Default is 0. + * - expanded: (optional) Boolean that determines if the item is expanded. + * - options: (optional) An array of options, see l() for more. + * - mlid: (optional) Menu link identifier, the primary integer key for each + * menu link. Can be set to an existing value, or to 0 or NULL + * to insert a new link. + * - plid: (optional) The mlid of the parent. + * - router_path: (optional) The path of the relevant router item. * * @return * The mlid of the saved menu link, or FALSE if the menu link could not be |