Commit fbbf5105 authored by Dries's avatar Dries
Browse files

- Patch #8105 by mathias: made the menu system aware of path aliases.

parent 6482708f
......@@ -185,6 +185,10 @@ function drupal_get_path_alias($path) {
elseif (function_exists("conf_url_rewrite")) {
return conf_url_rewrite($path, 'outgoing');
}
else {
// No alias found. Return the normal path.
return $path;
}
}
/**
......@@ -1171,9 +1175,7 @@ function url($url = NULL, $query = NULL, $fragment = NULL, $absolute = NULL) {
$script = (strpos($_SERVER["SERVER_SOFTWARE"], "Apache") === false) ? "index.php" : "";
}
if ($alias = drupal_get_path_alias($url)) {
$url = $alias;
}
$url = drupal_get_path_alias($url);
if (isset($fragment)) {
$fragment = "#$fragment";
......
......@@ -176,7 +176,7 @@ function menu_get_active_breadcrumb() {
$links[] = l(t('Home'), '');
$trail = menu_get_trail($_GET['q']);
$trail = menu_get_trail(drupal_get_path_alias($_GET['q']));
// The last item in the trail is the page title; don't display it here.
array_pop($trail);
......@@ -249,7 +249,7 @@ function menu_in_active_trail($mid) {
static $trail;
if (empty($trail)) {
$trail = menu_get_trail($_GET['q']);
$trail = menu_get_trail(drupal_get_path_alias($_GET['q']));
}
return in_array($mid, $trail);
......
......@@ -175,7 +175,11 @@ function path_nodeapi(&$node, $op, $arg) {
// viewing of the form. If it is the first time, load the alias, if it isn't
// (i.e., user has clicked preview) let them work with their current form alias.
if (is_null($node->path)) {
$node->path = drupal_get_path_alias("node/view/$node->nid");
$path = "node/view/$node->nid";
$alias = drupal_get_path_alias($path);
if ($alias != $path) {
$node->path = $alias;
}
}
else {
$node->path = trim($node->path);
......@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) {
break;
case 'delete':
if ($alias = drupal_get_path_alias("node/view/$node->nid")) {
path_set_alias("node/view/$node->nid");
$path = "node/view/$node->nid";
if (drupal_get_path_alias($path) != $path) {
path_set_alias($path);
}
break;
}
......
......@@ -175,7 +175,11 @@ function path_nodeapi(&$node, $op, $arg) {
// viewing of the form. If it is the first time, load the alias, if it isn't
// (i.e., user has clicked preview) let them work with their current form alias.
if (is_null($node->path)) {
$node->path = drupal_get_path_alias("node/view/$node->nid");
$path = "node/view/$node->nid";
$alias = drupal_get_path_alias($path);
if ($alias != $path) {
$node->path = $alias;
}
}
else {
$node->path = trim($node->path);
......@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) {
break;
case 'delete':
if ($alias = drupal_get_path_alias("node/view/$node->nid")) {
path_set_alias("node/view/$node->nid");
$path = "node/view/$node->nid";
if (drupal_get_path_alias($path) != $path) {
path_set_alias($path);
}
break;
}
......
......@@ -30,11 +30,13 @@ function profile_link($type) {
function profile_browse() {
$name = strip_tags(arg(1));
$value = strip_tags(arg(2));
$field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", arg(1)));
$field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", $name));
if ($field->fid) {
// Compile a list of fields to show:
// Compile a list of fields to show
$fields = array();
$result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
while ($record = db_fetch_object($result)) {
......@@ -47,10 +49,10 @@ function profile_browse() {
$query = 'v.value = 1';
break;
case 'selection':
$query = "v.value = '". check_query(arg(2)) ."'";
$query = "v.value = '". check_query($value) ."'";
break;
case 'list':
$query = "v.value LIKE '%". check_query(arg(2)) ."%'";
$query = "v.value LIKE '%". check_query($value) ."%'";
break;
}
......@@ -64,7 +66,7 @@ function profile_browse() {
$output .= theme('pager', NULL, 20);
if ($field->type == 'selection' || $field->type == 'list') {
$title = strtr($field->page, array('%value' => arg(2)));
$title = strtr($field->page, array('%value' => $value));
}
else {
$title = $field->page;
......
......@@ -30,11 +30,13 @@ function profile_link($type) {
function profile_browse() {
$name = strip_tags(arg(1));
$value = strip_tags(arg(2));
$field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", arg(1)));
$field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", $name));
if ($field->fid) {
// Compile a list of fields to show:
// Compile a list of fields to show
$fields = array();
$result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
while ($record = db_fetch_object($result)) {
......@@ -47,10 +49,10 @@ function profile_browse() {
$query = 'v.value = 1';
break;
case 'selection':
$query = "v.value = '". check_query(arg(2)) ."'";
$query = "v.value = '". check_query($value) ."'";
break;
case 'list':
$query = "v.value LIKE '%". check_query(arg(2)) ."%'";
$query = "v.value LIKE '%". check_query($value) ."%'";
break;
}
......@@ -64,7 +66,7 @@ function profile_browse() {
$output .= theme('pager', NULL, 20);
if ($field->type == 'selection' || $field->type == 'list') {
$title = strtr($field->page, array('%value' => arg(2)));
$title = strtr($field->page, array('%value' => $value));
}
else {
$title = $field->page;
......
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