- Added $fragment identifier to url() and l(). Patch by Goba.

4.4.x
Dries Buytaert 2003-12-29 19:10:26 +00:00
parent 286f618878
commit be2f405818
1 changed files with 18 additions and 11 deletions

View File

@ -817,7 +817,7 @@ function drupal_get_normal_path($path) {
return $map[$path] ? $map[$path] : $path; return $map[$path] ? $map[$path] : $path;
} }
function url($url = NULL, $query = NULL) { function url($url = NULL, $query = NULL, $fragment = NULL) {
global $base_url; global $base_url;
static $script; static $script;
@ -835,39 +835,46 @@ function url($url = NULL, $query = NULL) {
$url = $alias; $url = $alias;
} }
if (isset($fragment)) {
$fragment = "#$fragment";
}
else {
$fragment = '';
}
if (variable_get("clean_url", "0") == "0") { if (variable_get("clean_url", "0") == "0") {
if (isset($url)) { if (isset($url)) {
if (isset($query)) { if (isset($query)) {
return "$base_url/$script?q=$url&$query"; return "$base_url/$script?q=$url&$query$fragment";
} }
else { else {
return "$base_url/$script?q=$url"; return "$base_url/$script?q=$url$fragment";
} }
} }
else { else {
if (isset($query)) { if (isset($query)) {
return "$base_url/$script?$query"; return "$base_url/$script?$query$fragment";
} }
else { else {
return "$base_url/"; return "$base_url/$fragment";
} }
} }
} }
else { else {
if (isset($url)) { if (isset($url)) {
if (isset($query)) { if (isset($query)) {
return "$base_url/$url?$query"; return "$base_url/$url?$query$fragment";
} }
else { else {
return "$base_url/$url"; return "$base_url/$url$fragment";
} }
} }
else { else {
if (isset($query)) { if (isset($query)) {
return "$base_url/$script?$query"; return "$base_url/$script?$query$fragment";
} }
else { else {
return "$base_url/"; return "$base_url/$fragment";
} }
} }
} }
@ -883,8 +890,8 @@ function drupal_attributes($attributes = NULL) {
} }
} }
function l($text, $url, $attributes = array(), $query = NULL) { function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL) {
return "<a href=\"". url($url, $query) ."\"". drupal_attributes($attributes) .">$text</a>"; return "<a href=\"". url($url, $query, $fragment) ."\"". drupal_attributes($attributes) .">$text</a>";
} }
function field_get($string, $name) { function field_get($string, $name) {