Commit ceb9859d authored by Dries's avatar Dries
Browse files

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