Commit ceb9859d authored by Dries's avatar Dries

- Patch #29030 by Goba, chx, Jose, et al: reworked the URL rewrite hook so...

- Patch #29030 by Goba, chx, Jose, et al: reworked the URL rewrite hook so URLs can be rewritten dynamically.
parent f0cc7b4e
......@@ -476,8 +476,8 @@ function drupal_load($type, $name) {
* @param $action
* One of the following values:
* - wipe: delete the alias cache.
* - source: indicates that given a Drupal system URL, return an alias if one exists.
* - alias: indicates that given an path alias, return the Drupal system URL if one exists.
* - alias: return an alias for a given Drupal system path (if one exists).
* - source: return the Drupal system URL for a path alias (if one exists).
* @param $path
* The path to investigate for corresponding aliases or system URLs.
*/
......@@ -494,7 +494,7 @@ function drupal_lookup_path($action, $path = '') {
$map = array();
}
elseif ($count > 0 && $path != '') {
if ($action == 'source') {
if ($action == 'alias') {
if (isset($map[$path])) {
return $map[$path];
}
......@@ -506,7 +506,7 @@ function drupal_lookup_path($action, $path = '') {
$map[$path] = $path;
}
}
elseif ($action == 'alias') {
elseif ($action == 'source') {
if ($alias = array_search($path, $map)) {
return $alias;
}
......@@ -529,16 +529,14 @@ function drupal_lookup_path($action, $path = '') {
* Given an internal Drupal path, return the alias set by the administrator.
*/
function drupal_get_path_alias($path) {
if ($alias = drupal_lookup_path('source', $path)) {
return $alias;
$result = $path;
if ($alias = drupal_lookup_path('alias', $path)) {
$result = $alias;
}
elseif (function_exists('conf_url_rewrite')) {
return conf_url_rewrite($path, 'outgoing');
}
else {
// No alias found. Return the normal path.
return $path;
if (function_exists('custom_url_rewrite')) {
$result = custom_url_rewrite('alias', $result, $path);
}
return $result;
}
/**
......@@ -682,6 +680,7 @@ function arg($index) {
if (empty($arguments) || $q != $_GET['q']) {
$arguments = explode('/', $_GET['q']);
$q = $_GET['q'];
}
if (isset($arguments[$index])) {
......
......@@ -134,16 +134,14 @@ function drupal_clear_path_cache() {
* Given a path alias, return the internal path it represents.
*/
function drupal_get_normal_path($path) {
//drupal_get_path_alias($path);
if ($src = drupal_lookup_path('alias', $path)) {
return $src;
$result = $path;
if ($src = drupal_lookup_path('source', $path)) {
$result = $src;
}
elseif (function_exists('conf_url_rewrite')) {
return conf_url_rewrite($path, 'incoming');
}
else {
return $path;
if (function_exists('custom_url_rewrite')) {
$result = custom_url_rewrite('source', $result, $path);
}
return $result;
}
/**
......
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