#150049 by Moshe Weitzman: empower custom url rewriting with url() options
parent
64707c09e9
commit
d0c9795c33
|
@ -1227,11 +1227,18 @@ function url($path = NULL, $options = array()) {
|
|||
|
||||
$base = $options['absolute'] ? $base_url .'/' : base_path();
|
||||
|
||||
// Preserve the original path before aliasing.
|
||||
$original_path = $path;
|
||||
|
||||
// The special path '<front>' links to the default front page.
|
||||
if (!empty($path) && $path != '<front>') {
|
||||
if (!$options['alias']) {
|
||||
$path = drupal_get_path_alias($path);
|
||||
}
|
||||
if (function_exists('custom_url_rewrite_outbound')) {
|
||||
// Modules may alter outbound links by reference.
|
||||
custom_url_rewrite_outbound($path, $options, $original_path);
|
||||
}
|
||||
$path = drupal_urlencode($path);
|
||||
if (!$clean_url) {
|
||||
if ($options['query']) {
|
||||
|
|
|
@ -110,9 +110,6 @@ function drupal_get_path_alias($path, $path_language = '') {
|
|||
if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
|
||||
$result = $alias;
|
||||
}
|
||||
if (function_exists('custom_url_rewrite')) {
|
||||
$result = custom_url_rewrite('alias', $result, $path, $path_language);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -133,8 +130,9 @@ function drupal_get_normal_path($path, $path_language = '') {
|
|||
if ($src = drupal_lookup_path('source', $path, $path_language)) {
|
||||
$result = $src;
|
||||
}
|
||||
if (function_exists('custom_url_rewrite')) {
|
||||
$result = custom_url_rewrite('source', $result, $path, $path_language);
|
||||
if (function_exists('custom_url_rewrite_inbound')) {
|
||||
// Modules may alter the inbound request path by reference.
|
||||
custom_url_rewrite_inbound($result, $path, $path_language);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -233,11 +233,10 @@ function path_nodeapi(&$node, $op, $arg) {
|
|||
|
||||
case 'load':
|
||||
$path = "node/$node->nid";
|
||||
// We don't use drupal_get_path_alias() to avoid custom rewrite functions.
|
||||
// We only care about exact aliases.
|
||||
$result = db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path);
|
||||
if (db_num_rows($result)) {
|
||||
$node->path = db_result($result);
|
||||
$language = isset($node->language) ? $node->language : '';
|
||||
$alias = drupal_get_path_alias($path, $language);
|
||||
if ($path != $alias) {
|
||||
$node->path = $alias;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue