Commit 4e187261 authored by Gábor Hojtsy's avatar Gábor Hojtsy

#177497 by chx and Desbeers: revive Drupal 5's menu_set_location()...

#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.
parent 9d551664
......@@ -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.
*/
......
......@@ -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);
}
......
......@@ -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 = '';
......
......@@ -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();
......
......@@ -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);
......
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