summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-09-24 00:37:45 +0000
committerDries Buytaert <dries@buytaert.net>2010-09-24 00:37:45 +0000
commitc9de4646c570a45de03d6e7ec470daf01a8d2cab (patch)
tree5d8781ec52d1cf25c5ca1a842d2a7a65bf0f7e95 /modules/system
parent4bd74a00668557ce827e4c51d7c278548518aaf8 (diff)
downloadbrdo-c9de4646c570a45de03d6e7ec470daf01a8d2cab.tar.gz
brdo-c9de4646c570a45de03d6e7ec470daf01a8d2cab.tar.bz2
- Patch #907690 by sun, pwolanin: breadcrumbs don't work for dynamic paths and local tasks #2.
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/system.api.php47
-rw-r--r--modules/system/system.module9
-rw-r--r--modules/system/system.test5
3 files changed, 50 insertions, 11 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index e7903e86d..3fc5bbfe2 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -1200,6 +1200,53 @@ function hook_menu_local_tasks_alter(&$data, $router_item, $root_path) {
}
/**
+ * Alter links in the active trail before it is rendered as the breadcrumb.
+ *
+ * This hook is invoked by menu_get_active_breadcrumb() and allows alteration
+ * of the breadcrumb links for the current page, which may be preferred instead
+ * of setting a custom breadcrumb via drupal_set_breadcrumb().
+ *
+ * Implementations should take into account that menu_get_active_breadcrumb()
+ * subsequently performs the following adjustments to the active trail *after*
+ * this hook has been invoked:
+ * - The last link in $active_trail is removed, if its 'href' is identical to
+ * the 'href' of $item. This happens, because the breadcrumb normally does
+ * not contain a link to the current page.
+ * - The (second to) last link in $active_trail is removed, if the current $item
+ * is a MENU_DEFAULT_LOCAL_TASK. This happens in order to do not show a link
+ * to the current page, when being on the path for the default local task;
+ * e.g. when being on the path node/%/view, the breadcrumb should not contain
+ * a link to node/%.
+ *
+ * Each link in the active trail must contain:
+ * - title: The localized title of the link.
+ * - href: The system path to link to.
+ * - localized_options: An array of options to pass to url().
+ *
+ * @param $active_trail
+ * An array containing breadcrumb links for the current page.
+ * @param $item
+ * The menu router item of the current page.
+ *
+ * @see drupal_set_breadcrumb()
+ * @see menu_get_active_breadcrumb()
+ * @see menu_get_active_trail()
+ * @see menu_set_active_trail()
+ */
+function hook_menu_breadcrumb_alter(&$active_trail, $item) {
+ // Always display a link to the current page by duplicating the last link in
+ // the active trail. This means that menu_get_active_breadcrumb() will remove
+ // the last link (for the current page), but since it is added once more here,
+ // it will appear.
+ if (!drupal_is_front_page()) {
+ $end = end($active_trail);
+ if ($item['href'] == $end['href']) {
+ $active_trail[] = $end;
+ }
+ }
+}
+
+/**
* Alter contextual links before they are rendered.
*
* This hook is invoked by menu_contextual_links(). The system-determined
diff --git a/modules/system/system.module b/modules/system/system.module
index 134a51e5f..865eec1f1 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -648,7 +648,6 @@ function system_menu() {
$items['admin/modules/list/confirm'] = array(
'title' => 'List',
'access arguments' => array('administer modules'),
- 'type' => MENU_CALLBACK,
);
$items['admin/modules/uninstall'] = array(
'title' => 'Uninstall',
@@ -661,7 +660,6 @@ function system_menu() {
$items['admin/modules/uninstall/confirm'] = array(
'title' => 'Uninstall',
'access arguments' => array('administer modules'),
- 'type' => MENU_CALLBACK,
'file' => 'system.admin.inc',
);
@@ -688,7 +686,6 @@ function system_menu() {
'page callback' => 'drupal_get_form',
'page arguments' => array('system_ip_blocking_delete', 5),
'access arguments' => array('block IP addresses'),
- 'type' => MENU_CALLBACK,
'file' => 'system.admin.inc',
);
@@ -829,7 +826,6 @@ function system_menu() {
$items['admin/config/regional/date-time/types/%/delete'] = array(
'title' => 'Delete date type',
'description' => 'Allow users to delete a configured date type.',
- 'type' => MENU_CALLBACK,
'page callback' => 'drupal_get_form',
'page arguments' => array('system_delete_date_format_type_form', 5),
'access arguments' => array('administer site configuration'),
@@ -857,7 +853,6 @@ function system_menu() {
$items['admin/config/regional/date-time/formats/%/edit'] = array(
'title' => 'Edit date format',
'description' => 'Allow users to edit a configured date format.',
- 'type' => MENU_CALLBACK,
'page callback' => 'drupal_get_form',
'page arguments' => array('system_configure_date_formats_form', 5),
'access arguments' => array('administer site configuration'),
@@ -866,7 +861,6 @@ function system_menu() {
$items['admin/config/regional/date-time/formats/%/delete'] = array(
'title' => 'Delete date format',
'description' => 'Allow users to delete a configured date format.',
- 'type' => MENU_CALLBACK,
'page callback' => 'drupal_get_form',
'page arguments' => array('system_date_delete_format_form', 5),
'access arguments' => array('administer site configuration'),
@@ -874,7 +868,6 @@ function system_menu() {
);
$items['admin/config/regional/date-time/formats/lookup'] = array(
'title' => 'Date and time lookup',
- 'type' => MENU_CALLBACK,
'page callback' => 'system_date_time_lookup',
'access arguments' => array('administer site configuration'),
'file' => 'system.admin.inc',
@@ -938,7 +931,6 @@ function system_menu() {
'page callback' => 'drupal_get_form',
'page arguments' => array('system_actions_configure'),
'access arguments' => array('administer actions'),
- 'type' => MENU_CALLBACK,
'file' => 'system.admin.inc',
);
$items['admin/config/system/actions/delete/%actions'] = array(
@@ -947,7 +939,6 @@ function system_menu() {
'page callback' => 'drupal_get_form',
'page arguments' => array('system_actions_delete_form', 5),
'access arguments' => array('administer actions'),
- 'type' => MENU_CALLBACK,
'file' => 'system.admin.inc',
);
$items['admin/config/system/actions/orphan'] = array(
diff --git a/modules/system/system.test b/modules/system/system.test
index 5e75910d1..3fe9ac11d 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -653,8 +653,7 @@ class AccessDeniedTestCase extends DrupalWebTestCase {
parent::setUp();
// Create an administrative user.
- $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer blocks'));
- $this->drupalLogin($this->admin_user);
+ $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer site configuration', 'administer blocks'));
}
function testAccessDenied() {
@@ -662,6 +661,7 @@ class AccessDeniedTestCase extends DrupalWebTestCase {
$this->assertText(t('Access denied'), t('Found the default 403 page'));
$this->assertResponse(403);
+ $this->drupalLogin($this->admin_user);
$edit = array(
'title' => $this->randomName(10),
'body' => array(LANGUAGE_NONE => array(array('value' => $this->randomName(100)))),
@@ -671,6 +671,7 @@ class AccessDeniedTestCase extends DrupalWebTestCase {
// Use a custom 403 page.
$this->drupalPost('admin/config/system/site-information', array('site_403' => 'node/' . $node->nid), t('Save configuration'));
+ $this->drupalLogout();
$this->drupalGet('admin');
$this->assertText($node->title, t('Found the custom 403 page'));