summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-02-11 19:21:14 +0000
committerDries Buytaert <dries@buytaert.net>2004-02-11 19:21:14 +0000
commitf137b26979754e3e94bec73ea947cd87d08594a2 (patch)
tree7d7f2d5eb2646d61a57e1fb04f835d92823ed0d7 /includes
parentd795565c32530d6af7e895ca769423eb230b73bb (diff)
downloadbrdo-f137b26979754e3e94bec73ea947cd87d08594a2.tar.gz
brdo-f137b26979754e3e94bec73ea947cd87d08594a2.tar.bz2
- Patch 4902 by Goba:
+ only adds an optional parameter to url() and l(), so individual links can be set to be absolute + modifies drupal_goto() to accept the parameters of url() without the $absolute parameter, so cleaner invocations can be used + rework of some code in node_feed, making it much better to look at (the current code uses foreach with an immediate brake to get the first key of the associative array, geeeeez) + added xml:base to the rss tag generated by node_feed() + set all user mail URLs to be absolute + fix a small fragmented URL in user.module
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc34
1 files changed, 19 insertions, 15 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 3f20e3f15..82c665179 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -209,15 +209,17 @@ function drupal_get_headers() {
*
* @note This function ends the request.
*
- * @param $url A string containing a fully qualified URI.
+ * @param $url A Drupal URL
+ * @param $query Query string component
+ * @param $fragment Fragment identifier
*/
-function drupal_goto($url) {
+function drupal_goto($url = NULL, $query = NULL, $fragment = NULL) {
/*
- ** Translate &amp; to simply &
+ ** Translate &amp; to simply & in the absolute URL
*/
- $url = str_replace("&amp;", "&", $url);
+ $url = str_replace("&amp;", "&", url($url, $query, $fragment, TRUE));
/*
** It is advised to use "drupal_goto()" instead of PHP's "header()" as
@@ -1028,7 +1030,7 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $
}
/* @} */
-function url($url = NULL, $query = NULL, $fragment = NULL) {
+function url($url = NULL, $query = NULL, $fragment = NULL, $absolute = NULL) {
global $base_url;
static $script;
@@ -1050,39 +1052,41 @@ function url($url = NULL, $query = NULL, $fragment = NULL) {
$fragment = "#$fragment";
}
+ $base = ($absolute ? $base_url . '/' : '');
+
if (variable_get("clean_url", "0") == "0") {
if (isset($url)) {
if (isset($query)) {
- return "$base_url/$script?q=$url&amp;$query$fragment";
+ return "$base$script?q=$url&amp;$query$fragment";
}
else {
- return "$base_url/$script?q=$url$fragment";
+ return "$base$script?q=$url$fragment";
}
}
else {
if (isset($query)) {
- return "$base_url/$script?$query$fragment";
+ return "$base$script?$query$fragment";
}
else {
- return "$base_url/$fragment";
+ return "$base$fragment";
}
}
}
else {
if (isset($url)) {
if (isset($query)) {
- return "$base_url/$url?$query$fragment";
+ return "$base$url?$query$fragment";
}
else {
- return "$base_url/$url$fragment";
+ return "$base$url$fragment";
}
}
else {
if (isset($query)) {
- return "$base_url/$script?$query$fragment";
+ return "$base$script?$query$fragment";
}
else {
- return "$base_url/$fragment";
+ return "$base$fragment";
}
}
}
@@ -1098,7 +1102,7 @@ function drupal_attributes($attributes = NULL) {
}
}
-function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL) {
+function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = NULL) {
if ($url == $_GET['q']) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' active';
@@ -1107,7 +1111,7 @@ function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL)
$attributes['class'] = 'active';
}
}
- return "<a href=\"". url($url, $query, $fragment) ."\"". drupal_attributes($attributes) .">$text</a>";
+ return "<a href=\"". url($url, $query, $fragment, $absolute) ."\"". drupal_attributes($attributes) .">$text</a>";
}
function field_get($string, $name) {