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) { ...@@ -185,6 +185,10 @@ function drupal_get_path_alias($path) {
elseif (function_exists("conf_url_rewrite")) { elseif (function_exists("conf_url_rewrite")) {
return conf_url_rewrite($path, 'outgoing'); 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) { ...@@ -1171,9 +1175,7 @@ function url($url = NULL, $query = NULL, $fragment = NULL, $absolute = NULL) {
$script = (strpos($_SERVER["SERVER_SOFTWARE"], "Apache") === false) ? "index.php" : ""; $script = (strpos($_SERVER["SERVER_SOFTWARE"], "Apache") === false) ? "index.php" : "";
} }
if ($alias = drupal_get_path_alias($url)) { $url = drupal_get_path_alias($url);
$url = $alias;
}
if (isset($fragment)) { if (isset($fragment)) {
$fragment = "#$fragment"; $fragment = "#$fragment";
......
...@@ -176,7 +176,7 @@ function menu_get_active_breadcrumb() { ...@@ -176,7 +176,7 @@ function menu_get_active_breadcrumb() {
$links[] = l(t('Home'), ''); $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. // The last item in the trail is the page title; don't display it here.
array_pop($trail); array_pop($trail);
...@@ -249,7 +249,7 @@ function menu_in_active_trail($mid) { ...@@ -249,7 +249,7 @@ function menu_in_active_trail($mid) {
static $trail; static $trail;
if (empty($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); return in_array($mid, $trail);
......
...@@ -175,7 +175,11 @@ function path_nodeapi(&$node, $op, $arg) { ...@@ -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 // 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. // (i.e., user has clicked preview) let them work with their current form alias.
if (is_null($node->path)) { 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 { else {
$node->path = trim($node->path); $node->path = trim($node->path);
...@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) { ...@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) {
break; break;
case 'delete': case 'delete':
if ($alias = drupal_get_path_alias("node/view/$node->nid")) { $path = "node/view/$node->nid";
path_set_alias("node/view/$node->nid"); if (drupal_get_path_alias($path) != $path) {
path_set_alias($path);
} }
break; break;
} }
......
...@@ -175,7 +175,11 @@ function path_nodeapi(&$node, $op, $arg) { ...@@ -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 // 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. // (i.e., user has clicked preview) let them work with their current form alias.
if (is_null($node->path)) { 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 { else {
$node->path = trim($node->path); $node->path = trim($node->path);
...@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) { ...@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) {
break; break;
case 'delete': case 'delete':
if ($alias = drupal_get_path_alias("node/view/$node->nid")) { $path = "node/view/$node->nid";
path_set_alias("node/view/$node->nid"); if (drupal_get_path_alias($path) != $path) {
path_set_alias($path);
} }
break; break;
} }
......
...@@ -30,11 +30,13 @@ function profile_link($type) { ...@@ -30,11 +30,13 @@ function profile_link($type) {
function profile_browse() { 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) { if ($field->fid) {
// Compile a list of fields to show: // Compile a list of fields to show
$fields = array(); $fields = array();
$result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid); $result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
while ($record = db_fetch_object($result)) { while ($record = db_fetch_object($result)) {
...@@ -47,10 +49,10 @@ function profile_browse() { ...@@ -47,10 +49,10 @@ function profile_browse() {
$query = 'v.value = 1'; $query = 'v.value = 1';
break; break;
case 'selection': case 'selection':
$query = "v.value = '". check_query(arg(2)) ."'"; $query = "v.value = '". check_query($value) ."'";
break; break;
case 'list': case 'list':
$query = "v.value LIKE '%". check_query(arg(2)) ."%'"; $query = "v.value LIKE '%". check_query($value) ."%'";
break; break;
} }
...@@ -64,7 +66,7 @@ function profile_browse() { ...@@ -64,7 +66,7 @@ function profile_browse() {
$output .= theme('pager', NULL, 20); $output .= theme('pager', NULL, 20);
if ($field->type == 'selection' || $field->type == 'list') { if ($field->type == 'selection' || $field->type == 'list') {
$title = strtr($field->page, array('%value' => arg(2))); $title = strtr($field->page, array('%value' => $value));
} }
else { else {
$title = $field->page; $title = $field->page;
......
...@@ -30,11 +30,13 @@ function profile_link($type) { ...@@ -30,11 +30,13 @@ function profile_link($type) {
function profile_browse() { 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) { if ($field->fid) {
// Compile a list of fields to show: // Compile a list of fields to show
$fields = array(); $fields = array();
$result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid); $result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
while ($record = db_fetch_object($result)) { while ($record = db_fetch_object($result)) {
...@@ -47,10 +49,10 @@ function profile_browse() { ...@@ -47,10 +49,10 @@ function profile_browse() {
$query = 'v.value = 1'; $query = 'v.value = 1';
break; break;
case 'selection': case 'selection':
$query = "v.value = '". check_query(arg(2)) ."'"; $query = "v.value = '". check_query($value) ."'";
break; break;
case 'list': case 'list':
$query = "v.value LIKE '%". check_query(arg(2)) ."%'"; $query = "v.value LIKE '%". check_query($value) ."%'";
break; break;
} }
...@@ -64,7 +66,7 @@ function profile_browse() { ...@@ -64,7 +66,7 @@ function profile_browse() {
$output .= theme('pager', NULL, 20); $output .= theme('pager', NULL, 20);
if ($field->type == 'selection' || $field->type == 'list') { if ($field->type == 'selection' || $field->type == 'list') {
$title = strtr($field->page, array('%value' => arg(2))); $title = strtr($field->page, array('%value' => $value));
} }
else { else {
$title = $field->page; $title = $field->page;
......
...@@ -903,18 +903,18 @@ function user_register($edit = array()) { ...@@ -903,18 +903,18 @@ function user_register($edit = array()) {
} }
} }
} }
if (!form_has_errors()) { if (!form_has_errors()) {
$from = variable_get('site_mail', ini_get('sendmail_from')); $from = variable_get('site_mail', ini_get('sendmail_from'));
$pass = user_password(); $pass = user_password();
// TODO: Is this necessary? Won't session_write() replicate this? // TODO: Is this necessary? Won't session_write() replicate this?
unset($edit['session']); unset($edit['session']);
$account = user_save('', array_merge(array('name' => $edit['name'], 'pass' => $pass, 'init' => $edit['mail'], 'mail' => $edit['mail'], 'rid' => array(_user_authenticated_id()), 'status' => (variable_get('user_register', 1) == 1 ? 1 : 0)), $data)); $account = user_save('', array_merge(array('name' => $edit['name'], 'pass' => $pass, 'init' => $edit['mail'], 'mail' => $edit['mail'], 'rid' => array(_user_authenticated_id()), 'status' => (variable_get('user_register', 1) == 1 ? 1 : 0)), $data));
watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>', l(t('edit user'), "admin/user/edit/$account->uid")); watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>', l(t('edit user'), "admin/user/edit/$account->uid"));
$variables = array('%username' => $edit['name'], '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $edit['mail'], '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE)); $variables = array('%username' => $edit['name'], '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $edit['mail'], '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE));
// The first user may login immediately, and receives a customized welcome e-mail. // The first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) { if ($account->uid == 1) {
user_mail($edit['mail'], t('drupal user account details for %s', array('%s' => $edit['name'])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit['mail'], t('drupal user account details for %s', array('%s' => $edit['name'])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
......
...@@ -903,18 +903,18 @@ function user_register($edit = array()) { ...@@ -903,18 +903,18 @@ function user_register($edit = array()) {
} }
} }
} }
if (!form_has_errors()) { if (!form_has_errors()) {
$from = variable_get('site_mail', ini_get('sendmail_from')); $from = variable_get('site_mail', ini_get('sendmail_from'));
$pass = user_password(); $pass = user_password();
// TODO: Is this necessary? Won't session_write() replicate this? // TODO: Is this necessary? Won't session_write() replicate this?
unset($edit['session']); unset($edit['session']);
$account = user_save('', array_merge(array('name' => $edit['name'], 'pass' => $pass, 'init' => $edit['mail'], 'mail' => $edit['mail'], 'rid' => array(_user_authenticated_id()), 'status' => (variable_get('user_register', 1) == 1 ? 1 : 0)), $data)); $account = user_save('', array_merge(array('name' => $edit['name'], 'pass' => $pass, 'init' => $edit['mail'], 'mail' => $edit['mail'], 'rid' => array(_user_authenticated_id()), 'status' => (variable_get('user_register', 1) == 1 ? 1 : 0)), $data));
watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>', l(t('edit user'), "admin/user/edit/$account->uid")); watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>', l(t('edit user'), "admin/user/edit/$account->uid"));
$variables = array('%username' => $edit['name'], '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $edit['mail'], '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE)); $variables = array('%username' => $edit['name'], '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $edit['mail'], '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE));
// The first user may login immediately, and receives a customized welcome e-mail. // The first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) { if ($account->uid == 1) {
user_mail($edit['mail'], t('drupal user account details for %s', array('%s' => $edit['name'])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit['mail'], t('drupal user account details for %s', array('%s' => $edit['name'])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
......
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