Commit 34afaf8f authored by Gábor Hojtsy's avatar Gábor Hojtsy

#176748 follow up by pwolanin: fix bad breadcrumbs and missing/wrong titles

parent 2d128fc0
...@@ -464,7 +464,7 @@ function _menu_item_localize(&$item, $map) { ...@@ -464,7 +464,7 @@ function _menu_item_localize(&$item, $map) {
$item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map)); $item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map));
} }
} }
else { elseif ($callback) {
if (empty($item['title_arguments'])) { if (empty($item['title_arguments'])) {
$item['title'] = $callback($item['title']); $item['title'] = $callback($item['title']);
} }
...@@ -579,6 +579,7 @@ function menu_tail_to_arg($arg, $map, $index) { ...@@ -579,6 +579,7 @@ function menu_tail_to_arg($arg, $map, $index) {
* $item['title'] is generated from link_title, and may be localized. * $item['title'] is generated from link_title, and may be localized.
*/ */
function _menu_link_translate(&$item) { function _menu_link_translate(&$item) {
$item['options'] = unserialize($item['options']);
if ($item['external']) { if ($item['external']) {
$item['access'] = 1; $item['access'] = 1;
$map = array(); $map = array();
...@@ -604,16 +605,33 @@ function _menu_link_translate(&$item) { ...@@ -604,16 +605,33 @@ function _menu_link_translate(&$item) {
} }
_menu_check_access($item, $map); _menu_check_access($item, $map);
} }
// If the link title matches that of a router item, localize it.
if (!empty($item['title']) && (($item['title'] == $item['link_title']) || ($item['title_callback'] != 't'))) { // If the link title matches that of its router item, localize it.
_menu_item_localize($item, $map); if (!empty($item['title']) && ($item['title'] == $item['link_title'])){
if (!empty($item['title_arguments']) && $item['title_callback'] == 't') {
$item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map));
}
else {
$item['title'] = t($item['title']);
}
} }
else { else {
$item['title'] = $item['link_title']; $item['title'] = $item['link_title'];
} }
// Localize the description and title attribute.
if (!empty($item['description'])) {
$original_description = $item['description'];
$item['description'] = t($item['description']);
// Localize the title attribute only if it matches the description.
if ($item['options']['attributes']['title'] == $original_description) {
$item['options']['attributes']['title'] = $item['description'];
}
}
// Store the map if it may be needed for use later by a title callback.
if (!empty($item['title_callback']) && ($item['title_callback'] != 't')) {
$item['map'] = $map;
}
} }
$item['options'] = unserialize($item['options']);
return $map; return $map;
} }
...@@ -759,7 +777,7 @@ function menu_tree_all_data($menu_name = 'navigation', $item = NULL) { ...@@ -759,7 +777,7 @@ function menu_tree_all_data($menu_name = 'navigation', $item = NULL) {
// LEFT JOIN since there is no match in {menu_router} for an external // LEFT JOIN since there is no match in {menu_router} for an external
// link. // link.
$data['tree'] = menu_tree_data(db_query(" $data['tree'] = menu_tree_data(db_query("
SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.* SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
WHERE ml.menu_name = '%s'". $where ." WHERE ml.menu_name = '%s'". $where ."
ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents); ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
...@@ -849,7 +867,7 @@ function menu_tree_page_data($menu_name = 'navigation') { ...@@ -849,7 +867,7 @@ function menu_tree_page_data($menu_name = 'navigation') {
// LEFT JOIN since there is no match in {menu_router} for an external // LEFT JOIN since there is no match in {menu_router} for an external
// link. // link.
$data['tree'] = menu_tree_data(db_query(" $data['tree'] = menu_tree_data(db_query("
SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.* SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .") WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .")
ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents); ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
...@@ -1445,6 +1463,12 @@ function menu_set_active_trail($new_trail = NULL) { ...@@ -1445,6 +1463,12 @@ function menu_set_active_trail($new_trail = NULL) {
if ($trail[$last]['href'] != $item['href'] && !(bool)($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) { if ($trail[$last]['href'] != $item['href'] && !(bool)($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) {
$trail[] = $item; $trail[] = $item;
} }
// Apply title callbacks for items in the active trail (breadcrumb).
foreach ($trail as $key => $item) {
if (!empty($item['title_callback']) && $item['title_callback'] != 't') {
_menu_item_localize($trail[$key], $item['map']);
}
}
} }
return $trail; return $trail;
} }
......
...@@ -74,16 +74,13 @@ function theme_filter_admin_overview($form) { ...@@ -74,16 +74,13 @@ function theme_filter_admin_overview($form) {
} }
/** /**
* Display a filter format form. * Menu callback; Display a filter format form.
*/ */
function filter_admin_format_page($format = NULL) { function filter_admin_format_page($format = NULL) {
if (!isset($format->name)) { if (!isset($format->name)) {
drupal_set_title(t("Add input format")); drupal_set_title(t("Add input format"));
$format = (object)array('name' => '', 'roles' => '', 'format' => ''); $format = (object)array('name' => '', 'roles' => '', 'format' => '');
} }
else {
drupal_set_title(t("%format input format", array('%format' => $format->name)));
}
return drupal_get_form('filter_admin_format_form', $format); return drupal_get_form('filter_admin_format_form', $format);
} }
......
...@@ -102,6 +102,8 @@ function filter_menu() { ...@@ -102,6 +102,8 @@ function filter_menu() {
); );
$items['admin/settings/filters/%filter_format'] = array( $items['admin/settings/filters/%filter_format'] = array(
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'title callback' => 'filter_admin_format_title',
'title arguments' => array(3),
'page callback' => 'filter_admin_format_page', 'page callback' => 'filter_admin_format_page',
'page arguments' => array(3), 'page arguments' => array(3),
'access arguments' => array('administer filters'), 'access arguments' => array('administer filters'),
...@@ -137,6 +139,13 @@ function filter_format_load($arg) { ...@@ -137,6 +139,13 @@ function filter_format_load($arg) {
return filter_formats($arg); return filter_formats($arg);
} }
/**
* Display a filter format form title.
*/
function filter_admin_format_title($format) {
return $format->name;
}
/** /**
* Implementation of hook_perm(). * Implementation of hook_perm().
*/ */
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* Menu callback; presents the node editing form, or redirects to delete confirmation. * Menu callback; presents the node editing form, or redirects to delete confirmation.
*/ */
function node_page_edit($node) { function node_page_edit($node) {
drupal_set_title($node->title);
return drupal_get_form($node->type .'_node_form', $node); return drupal_get_form($node->type .'_node_form', $node);
} }
......
...@@ -1029,6 +1029,8 @@ function user_menu() { ...@@ -1029,6 +1029,8 @@ function user_menu() {
$items['user/%user_current'] = array( $items['user/%user_current'] = array(
'title' => 'My account', 'title' => 'My account',
'title callback' => 'user_page_title',
'title arguments' => array(1),
'page callback' => 'user_view', 'page callback' => 'user_view',
'page arguments' => array(1), 'page arguments' => array(1),
'access callback' => 'user_view_access', 'access callback' => 'user_view_access',
...@@ -1151,6 +1153,16 @@ function user_current_to_arg($arg) { ...@@ -1151,6 +1153,16 @@ function user_current_to_arg($arg) {
return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg; return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
} }
/**
* Menu item title callback - use the user name if it's not the current user.
*/
function user_page_title($account) {
if ($account->uid == $GLOBALS['user']->uid) {
return t('My account');
}
return $account->name;
}
/** /**
* Accepts an user object, $account, or a DA name and returns an associative * Accepts an user object, $account, or a DA name and returns an associative
* array of modules and DA names. Called at external login. * array of modules and DA names. Called at external login.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment