summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-12-05 16:34:07 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-12-05 16:34:07 +0000
commit5bb6927e18d4496395dea37cc5b14bb15cb42cad (patch)
treeb3142f8a63bb7defa33ddca8cb6dd23d0c306b22 /includes
parentc99dd5c2064df28932f13e5182676f281a699d48 (diff)
downloadbrdo-5bb6927e18d4496395dea37cc5b14bb15cb42cad.tar.gz
brdo-5bb6927e18d4496395dea37cc5b14bb15cb42cad.tar.bz2
#196410 report by daniel.soneira, patch by myself, tested by Freso: several fixes to url() generation and path aliasing, fixing path aliases for node paths and front page links in themes
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc50
-rw-r--r--includes/language.inc23
-rw-r--r--includes/theme.inc1
3 files changed, 45 insertions, 29 deletions
diff --git a/includes/common.inc b/includes/common.inc
index fe41d29ce..a6128675d 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1220,6 +1220,15 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
* Whether the given path is an alias already.
* 'external'
* Whether the given path is an external URL.
+ * 'language'
+ * An optional language object. Used to build the URL to link to and
+ * look up the proper alias for the link.
+ * 'base_url'
+ * Only used internally, to modify the base URL when a language dependent
+ * URL requires so.
+ * 'prefix'
+ * Only used internally, to modify the path when a language dependent URL
+ * requires so.
* @return
* A string containing a URL to the given path.
*
@@ -1233,6 +1242,7 @@ function url($path = NULL, $options = array()) {
'query' => '',
'absolute' => FALSE,
'alias' => FALSE,
+ 'prefix' => ''
);
if (!isset($options['external'])) {
// Return an external link if $path contains an allowed absolute URL.
@@ -1297,33 +1307,39 @@ function url($path = NULL, $options = array()) {
// The special path '<front>' links to the default front page.
if (!empty($path) && $path != '<front>') {
if (!$options['alias']) {
- $path = drupal_get_path_alias($path, isset($options['langcode']) ? $options['langcode'] : '');
+ $path = drupal_get_path_alias($path, isset($options['language']) ? $options['language']->language : '');
}
if (function_exists('custom_url_rewrite_outbound')) {
// Modules may alter outbound links by reference.
custom_url_rewrite_outbound($path, $options, $original_path);
}
- $path = drupal_urlencode($path);
- if (!$clean_url) {
- if ($options['query']) {
- return $base . $script .'?q='. $path .'&'. $options['query'] . $options['fragment'];
- }
- else {
- return $base . $script .'?q='. $path . $options['fragment'];
- }
+ $path = drupal_urlencode($options['prefix'] . $path);
+ }
+ else {
+ // Will be empty if there is no language prefix.
+ $path = trim($options['prefix'], '/');
+ }
+
+ if ($clean_url) {
+ // With Clean URLs.
+ if ($options['query']) {
+ return $base . $path .'?'. $options['query'] . $options['fragment'];
}
else {
- if ($options['query']) {
- return $base . $path .'?'. $options['query'] . $options['fragment'];
- }
- else {
- return $base . $path . $options['fragment'];
- }
+ return $base . $path . $options['fragment'];
}
}
else {
- if ($options['query']) {
- return $base . $script .'?'. $options['query'] . $options['fragment'];
+ // Without Clean URLs.
+ $variables = array();
+ if (!empty($path)) {
+ $variables[] = 'q='. $path;
+ }
+ if (!empty($options['query'])) {
+ $variables[] = $options['query'];
+ }
+ if ($query = join('&', $variables)) {
+ return $base . $script .'?'. $query . $options['fragment'];
}
else {
return $base . $options['fragment'];
diff --git a/includes/language.inc b/includes/language.inc
index de4ef393a..c36ba7c01 100644
--- a/includes/language.inc
+++ b/includes/language.inc
@@ -103,37 +103,36 @@ function language_url_rewrite(&$path, &$options) {
if (!$options['external']) {
// Language can be passed as an option, or we go for current language.
- $path_language = isset($options['language']) ? $options['language'] : $language;
+ if (!isset($options['language'])) {
+ $options['language'] = $language;
+ }
+
switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
-
case LANGUAGE_NEGOTIATION_NONE:
+ // No language dependent path allowed in this mode.
+ unset($options['language']);
break;
case LANGUAGE_NEGOTIATION_DOMAIN:
- if ($path_language->domain) {
+ if ($options['language']->domain) {
// Ask for an absolute URL with our modified base_url.
$options['absolute'] = TRUE;
- $options['base_url'] = $path_language->domain;
- // Ensure that path alias generation will use this language.
- $options['langcode'] = $path_language->language;
+ $options['base_url'] = $options['language']->domain;
}
break;
case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
$default = language_default();
- if ($path_language->language == $default->language) {
+ if ($options['language']->language == $default->language) {
break;
}
// Intentionally no break here.
case LANGUAGE_NEGOTIATION_PATH:
- if (isset($path_language->prefix) && $path_language->prefix) {
- // Ensure that path alias generation will use this language.
- $options['langcode'] = $path_language->language;
- $path = (empty($path) || ($path == '<front>')) ? $path_language->prefix : $path_language->prefix .'/'. $path;
+ if (!empty($options['language']->prefix)) {
+ $options['prefix'] = $options['language']->prefix .'/';
}
break;
-
}
}
}
diff --git a/includes/theme.inc b/includes/theme.inc
index e46f7f411..04271ae1c 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1701,6 +1701,7 @@ function template_preprocess_page(&$variables) {
}
$variables['head_title'] = implode(' | ', $head_title);
$variables['base_path'] = base_path();
+ $variables['front_page'] = url();
$variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb());
$variables['feed_icons'] = drupal_get_feeds();
$variables['footer_message'] = filter_xss_admin(variable_get('site_footer', FALSE));