summaryrefslogtreecommitdiff
path: root/includes/menu.inc
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-09-07 20:31:02 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-09-07 20:31:02 +0000
commit9643ec9e70da84868438946bf2a2ffef256298f5 (patch)
tree0249c48a746e8b6bd58c96eb71fcef626435d5c5 /includes/menu.inc
parentfde6b84e1f5eb12f4e556af60b677e7dbd0801ec (diff)
downloadbrdo-9643ec9e70da84868438946bf2a2ffef256298f5.tar.gz
brdo-9643ec9e70da84868438946bf2a2ffef256298f5.tar.bz2
#172754 by pwolanin: page titles were broken when outside the active menu or on a callback
Diffstat (limited to 'includes/menu.inc')
-rw-r--r--includes/menu.inc36
1 files changed, 30 insertions, 6 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index db3d1e6ad..a7aa04297 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -462,6 +462,7 @@ function _menu_translate(&$router_item, $map, $to_arg = FALSE) {
}
}
$router_item['href'] = implode('/', $link_map);
+ $router_item['options'] = array();
_menu_check_access($router_item, $map);
_menu_item_localize($router_item, $map);
@@ -1267,22 +1268,39 @@ function menu_set_active_trail($new_trail = NULL) {
$trail = array();
$trail[] = array('title' => t('Home'), 'href' => '<front>', 'options' => array(), 'type' => 0);
$item = menu_get_item();
- // We are on a tab.
+
+ // Check whether the current item is a local task (displayed as a tab).
if ($item['tab_parent']) {
- $href = $item['tab_root'];
- }
- else {
- $href = $item['href'];
+ // The title of a local task is used for the tab, never the page title.
+ // Thus, replace it with the item corresponding to the root path to get
+ // the relevant href and title. For example, the menu item corresponding
+ // to 'admin' is used when on the 'By module' tab at 'admin/by-module'.
+ $parts = explode('/', $item['tab_root']);
+ $args = arg();
+ // Replace wildcards in the root path using the current path.
+ foreach ($parts as $index => $part) {
+ if ($part == '%') {
+ $parts[$index] = $args[$index];
+ }
+ }
+ // Retrieve the menu item using the root path after wildcard replacement.
+ $root_item = menu_get_item(implode('/', $parts));
+ if ($root_item && $root_item['access']) {
+ $item = $root_item;
+ }
}
+
$tree = menu_tree_page_data(menu_get_active_menu_name());
$curr = array_shift($tree);
while ($curr) {
- if ($curr['link']['href'] == $href) {
+ // Terminate the loop when we find the current path in the active trail.
+ if ($curr['link']['href'] == $item['href']) {
$trail[] = $curr['link'];
$curr = FALSE;
}
else {
+ // Move to the child link if it's in the active trail.
if ($curr['below'] && $curr['link']['in_active_trail']) {
$trail[] = $curr['link'];
$tree = $curr['below'];
@@ -1290,6 +1308,12 @@ function menu_set_active_trail($new_trail = NULL) {
$curr = array_shift($tree);
}
}
+ // Make sure the current page is in the trail (needed for the page title),
+ // but exclude tabs and the front page.
+ $last = count($trail) - 1;
+ if ($trail[$last]['href'] != $item['href'] && !(bool)($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) {
+ $trail[] = $item;
+ }
}
return $trail;
}