diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-12-27 10:36:16 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-12-27 10:36:16 +0000 |
commit | 34a5d46022b47be3ef30f32ce1187081918c7ab0 (patch) | |
tree | d67a98692037be7a34ecc3e4dba14147efe79c29 /includes/common.inc | |
parent | 2fe78b84f314a598fb6b45ee7624d4b320a47074 (diff) | |
download | brdo-34a5d46022b47be3ef30f32ce1187081918c7ab0.tar.gz brdo-34a5d46022b47be3ef30f32ce1187081918c7ab0.tar.bz2 |
- Patch #36465 by chx / Richard: made it possible to link to the front page.
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/includes/common.inc b/includes/common.inc index cf194cbc5..5af1f5be2 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -954,6 +954,7 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { global $base_url; static $script; + static $clean_url; if (empty($script)) { // On some web servers, such as IIS, we can't omit "index.php". So, we @@ -962,8 +963,10 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : ''; } - $path = drupal_get_path_alias($path); - $path = drupal_urlencode($path); + // Cache the clean_url variable to improve performance. + if ($clean_url === NULL) { + $clean_url = (variable_get('clean_url', '0') == '0') ? false : true; + } if (isset($fragment)) { $fragment = '#'. $fragment; @@ -971,8 +974,11 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { $base = ($absolute ? $base_url .'/' : ''); - if (variable_get('clean_url', '0') == '0') { - if (isset($path)) { + // The special path '<front>' links to the default front page. + if (isset($path) && $path != '<front>') { + $path = drupal_get_path_alias($path); + $path = drupal_urlencode($path); + if (!$clean_url) { if (isset($query)) { return $base . $script .'?q='. $path .'&'. $query . $fragment; } @@ -982,29 +988,19 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { } else { if (isset($query)) { - return $base . $script .'?'. $query . $fragment; + return $base . $path .'?'. $query . $fragment; } else { - return $base . $fragment; + return $base . $path . $fragment; } } } else { - if (isset($path)) { - if (isset($query)) { - return $base . $path .'?'. $query . $fragment; - } - else { - return $base . $path . $fragment; - } + if (isset($query)) { + return $base . $script .'?'. $query . $fragment; } else { - if (isset($query)) { - return $base . $script .'?'. $query . $fragment; - } - else { - return $base . $fragment; - } + return $base . $fragment; } } } |