--- common.inc 2005-08-08 15:14:01.984153088 -0400 +++ common.inc.new 2005-08-08 15:13:40.627399808 -0400 @@ -1440,68 +1440,47 @@ * @param $absolute * Whether to force the output to be an absolute link (beginning with http:). * Useful for links that will be displayed outside the site, such as in an RSS feed. + * @param $external + * Whether to render $path as is. + * Useful for module developers who need to link to extenal sites. * @return - * an HTML string containing a link to the given path. + * an string which is a link to the given path. * * When creating links in modules, consider whether l() could be a better * alternative than url(). */ -function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) { +function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE, $external = FALSE) { global $base_url; - static $script; - - if (empty($script)) { - // On some web servers, such as IIS, we can't omit "index.php". So, we - // generate "index.php?q=foo" instead of "?q=foo" on anything that is not - // Apache. - $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : ''; + if ($external) { + //set the url + $url = $path; } + else { - $path = drupal_get_path_alias($path); + // return value for clean urls + $clean = variable_get('clean_url', '0'); - if (isset($fragment)) { - $fragment = '#'. $fragment; - } + // test webserver and set script + static $script; + $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php?q=' : ''; - $base = ($absolute ? $base_url .'/' : ''); + // set base + $base = $absolute ? $base_url . '/' : ''; - if (variable_get('clean_url', '0') == '0') { - if (isset($path)) { - if (isset($query)) { - return $base . $script .'?q='. $path .'&'. $query . $fragment; - } - else { - return $base . $script .'?q='. $path . $fragment; - } - } - else { - if (isset($query)) { - return $base . $script .'?'. $query . $fragment; - } - else { - return $base . $fragment; - } - } - } - else { - if (isset($path)) { - if (isset($query)) { - return $base . $path .'?'. $query . $fragment; - } - else { - return $base . $path . $fragment; - } - } - else { - if (isset($query)) { - return $base . $script .'?'. $query . $fragment; - } - else { - return $base . $fragment; - } + // set the fragment + $fragment = isset($fragment) ? '#'.$fragment : ''; + + // set the query + if (isset($query)) { + $query = $clean ? '?'. $query : '&'. $query ; } + + $url = $clean ? $base . $path : $base . $script . $path; + } + +return $url.$query.$fragment; } /** @@ -1547,7 +1526,7 @@ * @return * an HTML string containing a link to the given path. */ -function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) { +function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE, $external = FALSE) { if (drupal_get_normal_path($path) == $_GET['q']) { if (isset($attributes['class'])) { $attributes['class'] .= ' active'; @@ -1556,7 +1535,7 @@ $attributes['class'] = 'active'; } } - return ''. ($html ? $text : check_plain($text)) .''; + return ''. ($html ? $text : check_plain($text)) .''; } /**