summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGábor Hojtsy2007-10-25 08:24:43 (GMT)
committerGábor Hojtsy2007-10-25 08:24:43 (GMT)
commit4e187261abc63432130bd3b5661b622ba095ffeb (patch)
tree9fd4b59b53cd8a3b1fb2c0e04b65c9f6eb998d71
parent9d5516644c5e6b607d01d6349a2890668a354efb (diff)
#177497 by chx and Desbeers: revive Drupal 5's menu_set_location() functionality by introducing menu_set_item() (for consistency in function naming), thus fixing a regression in the current development code. Also fixing some misuse of menu_set_location() by using drupal_set_breadcrumb() instead.
-rw-r--r--includes/menu.inc38
-rw-r--r--modules/blog/blog.module5
-rw-r--r--modules/comment/comment.module3
-rw-r--r--modules/forum/forum.module21
-rw-r--r--modules/taxonomy/taxonomy.pages.inc9
5 files changed, 47 insertions, 29 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index 74694c8..ac835c2 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -267,17 +267,46 @@ function menu_unserialize($data, $map) {
}
}
+
+
/**
- * Get the menu callback for the a path.
+ * Replaces the statically cached item for a given path.
*
* @param $path
- * A path, or NULL for the current path
+ * The path.
+ * @param $router_item
+ * The router item. Usually you take a router entry from menu_get_item and
+ * set it back either modified or to a different path. This lets you modify the
+ * navigation block, the page title, the breadcrumb and the page help in one
+ * call.
*/
-function menu_get_item($path = NULL) {
+function menu_set_item($path, $router_item) {
+ menu_get_item($path, $router_item);
+}
+
+/**
+ * Get a router item.
+ *
+ * @param $path
+ * The path, for example node/5. The function will find the corresponding
+ * node/% item and return that.
+ * @param $router_item
+ * Internal use only.
+ * @return
+ * The router item, an associate array corresponding to one row in the
+ * menu_router table. The value of key map holds the loaded objects. The
+ * value of key access is TRUE if the current user can access this page.
+ * The values for key title, page_arguments, access_arguments will be
+ * filled in based on the database values and the objects loaded.
+ */
+function menu_get_item($path = NULL, $router_item = NULL) {
static $router_items;
if (!isset($path)) {
$path = $_GET['q'];
}
+ if (isset($router_item)) {
+ $router_items[$path] = $router_item;
+ }
if (!isset($router_items[$path])) {
$original_map = arg(NULL, $path);
$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
@@ -1385,9 +1414,6 @@ function menu_get_active_trail() {
return menu_set_active_trail();
}
-function menu_set_location() {
-}
-
/**
* Get the breadcrumb for the current page, as determined by the active trail.
*/
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index e43a804..5642611 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -107,10 +107,7 @@ function blog_form(&$node) {
function blog_view($node, $teaser = FALSE, $page = FALSE) {
if ($page) {
// Breadcrumb navigation
- $breadcrumb[] = array('path' => 'blog', 'title' => t('Blogs'));
- $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t("@name's blog", array('@name' => $node->name)));
- $breadcrumb[] = array('path' => 'node/'. $node->nid);
- menu_set_location($breadcrumb);
+ drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("@name's blog", array('@name' => $node->name)), 'blog/'. $node->uid)));
}
return node_prepare($node, $teaser);
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 86b8741..877be28 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -681,8 +681,7 @@ function comment_edit($cid) {
*/
function comment_reply($node, $pid = NULL) {
// Set the breadcrumb trail.
- menu_set_location(array(array('path' => "node/$node->nid", 'title' => $node->title), array('path' => "comment/reply/$node->nid")));
-
+ drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/'. $node->nid)));
$op = isset($_POST['op']) ? $_POST['op'] : '';
$output = '';
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 600ae5a..e7b3bb6 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -184,16 +184,15 @@ function forum_nodeapi(&$node, $op, $teaser, $page) {
}
}
// Breadcrumb navigation
- $breadcrumb = array();
- $breadcrumb[] = array('path' => 'forum', 'title' => $vocabulary->name);
+ $breadcrumb[] = l(t('Home'), NULL);
+ $breadcrumb[] = l($vocabulary->name, 'forum');
if ($parents = taxonomy_get_parents_all($node->tid)) {
$parents = array_reverse($parents);
foreach ($parents as $p) {
- $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
+ $breadcrumb[] = l($p->name, 'forum/'.$p->tid);
}
}
- $breadcrumb[] = array('path' => 'node/'. $node->nid);
- menu_set_location($breadcrumb);
+ drupal_set_breadcrumb($breadcrumb);
if (!$teaser) {
$node->content['forum_navigation'] = array(
@@ -628,11 +627,10 @@ function template_preprocess_forums(&$variables) {
$title = !empty($vocabulary->name) ? $vocabulary->name : '';
// Breadcrumb navigation:
- $breadcrumb = array();
+ $breadcrumb[] = l(t('Home'), NULL);
if ($variables['tid']) {
- $breadcrumb[] = array('path' => 'forum', 'title' => $title);
+ $breadcrumb[] = l($vocabulary->name, 'forum');
}
-
if ($variables['parents']) {
$variables['parents'] = array_reverse($variables['parents']);
foreach ($variables['parents'] as $p) {
@@ -640,16 +638,13 @@ function template_preprocess_forums(&$variables) {
$title = $p->name;
}
else {
- $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
+ $breadcrumb[] = l($p->name, 'forum/'. $p->tid);
}
}
}
-
+ drupal_set_breadcrumb($breadcrumb);
drupal_set_title(check_plain($title));
- $breadcrumb[] = array('path' => $_GET['q']);
- menu_set_location($breadcrumb);
-
if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
// Format the "post new content" links listing.
$forum_types = array();
diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc
index 5ff9cff..4f86441 100644
--- a/modules/taxonomy/taxonomy.pages.inc
+++ b/modules/taxonomy/taxonomy.pages.inc
@@ -32,13 +32,14 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
case 'page':
// Build breadcrumb based on first hierarchy of first term:
$current->tid = $tids[0];
- $breadcrumbs = array(array('path' => $_GET['q'], 'title' => $names[0]));
+ $breadcrumb = array();
while ($parents = taxonomy_get_parents($current->tid)) {
$current = array_shift($parents);
- $breadcrumbs[] = array('path' => 'taxonomy/term/'. $current->tid, 'title' => $current->name);
+ $breadcrumb[] = l($current->name, 'taxonomy/term/'. $current->tid);
}
- $breadcrumbs = array_reverse($breadcrumbs);
- menu_set_location($breadcrumbs);
+ $breadcrumb[] = l(t('Home'), NULL);
+ $breadcrumb = array_reverse($breadcrumb);
+ drupal_set_breadcrumb($breadcrumb);
$output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $terms['operator'], $depth, TRUE));
drupal_add_feed(url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed'), 'RSS - '. $title);