diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-12-02 19:26:23 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-12-02 19:26:23 +0000 |
commit | 0baad49d620d9988837287cb5942eea764d3ed6f (patch) | |
tree | 146072f69b433cb7922572ba2ac627a83987edd4 /includes | |
parent | ef4513651e210784ba84eb310cf919e26f668bed (diff) | |
download | brdo-0baad49d620d9988837287cb5942eea764d3ed6f.tar.gz brdo-0baad49d620d9988837287cb5942eea764d3ed6f.tar.bz2 |
- Patch #635094 by plach: unify 'language neutral' language codes.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/bootstrap.inc | 7 | ||||
-rw-r--r-- | includes/language.inc | 2 | ||||
-rw-r--r-- | includes/path.inc | 23 |
3 files changed, 21 insertions, 11 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 48b287546..012d89d1d 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -179,6 +179,13 @@ define('DRUPAL_AUTHENTICATED_RID', 2); define('DRUPAL_KILOBYTE', 1024); /** + * The language code used when no language is explicitly assigned. + * + * Defined by ISO639-2 for "No linguistic content / Not applicable". + */ +define('LANGUAGE_NONE', 'zxx'); + +/** * The type of language used to define the content language. */ define('LANGUAGE_TYPE_CONTENT', 'language'); diff --git a/includes/language.inc b/includes/language.inc index bb4802df5..ec9c0f719 100644 --- a/includes/language.inc +++ b/includes/language.inc @@ -380,7 +380,7 @@ function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) { } $fallback_candidates = array_keys($fallback_candidates); - $fallback_candidates[] = FIELD_LANGUAGE_NONE; + $fallback_candidates[] = LANGUAGE_NONE; // Let other modules hook in and add/change candidates. drupal_alter('language_fallback_candidates', $fallback_candidates); diff --git a/includes/path.inc b/includes/path.inc index 12214daad..00c907204 100644 --- a/includes/path.inc +++ b/includes/path.inc @@ -43,7 +43,7 @@ function drupal_path_initialize() { * Either a Drupal system path, an aliased path, or FALSE if no path was * found. */ -function drupal_lookup_path($action, $path = '', $path_language = '') { +function drupal_lookup_path($action, $path = '', $path_language = NULL) { global $language; // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static = array(); @@ -90,9 +90,10 @@ function drupal_lookup_path($action, $path = '', $path_language = '') { // Now fetch the aliases corresponding to these system paths. // We order by ASC and overwrite array keys to ensure the correct // alias is used when there are multiple aliases per path. - $cache['map'][$path_language] = db_query("SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, '') ORDER BY language ASC, pid ASC", array( + $cache['map'][$path_language] = db_query("SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language ASC, pid ASC", array( ':system' => $cache['system_paths'], - ':language' => $path_language + ':language' => $path_language, + ':language_none' => LANGUAGE_NONE, ))->fetchAllKeyed(); // Keep a record of paths with no alias to avoid querying twice. $cache['no_aliases'][$path_language] = array_flip(array_diff_key($cache['system_paths'], array_keys($cache['map'][$path_language]))); @@ -111,9 +112,10 @@ function drupal_lookup_path($action, $path = '', $path_language = '') { // For system paths which were not cached, query aliases individually. else if (!isset($cache['no_aliases'][$path_language][$path])) { // Get the most fitting result falling back with alias without language - $alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, '') ORDER BY language DESC, pid DESC", array( + $alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", array( ':source' => $path, - ':language' => $path_language + ':language' => $path_language, + ':language_none' => LANGUAGE_NONE, ))->fetchField(); $cache['map'][$path_language][$path] = $alias; return $alias; @@ -126,9 +128,10 @@ function drupal_lookup_path($action, $path = '', $path_language = '') { $source = ''; if (!isset($cache['map'][$path_language]) || !($source = array_search($path, $cache['map'][$path_language]))) { // Get the most fitting result falling back with alias without language - if ($source = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, '') ORDER BY language DESC, pid DESC", array( + if ($source = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", array( ':alias' => $path, - ':language' => $path_language)) + ':language' => $path_language, + ':language_none' => LANGUAGE_NONE)) ->fetchField()) { $cache['map'][$path_language][$source] = $path; } @@ -186,7 +189,7 @@ function drupal_cache_system_paths() { * An aliased path if one was found, or the original path if no alias was * found. */ -function drupal_get_path_alias($path = NULL, $path_language = '') { +function drupal_get_path_alias($path = NULL, $path_language = NULL) { // If no path is specified, use the current page's path. if ($path == NULL) { $path = $_GET['q']; @@ -210,7 +213,7 @@ function drupal_get_path_alias($path = NULL, $path_language = '') { * The internal path represented by the alias, or the original alias if no * internal path was found. */ -function drupal_get_normal_path($path, $path_language = '') { +function drupal_get_normal_path($path, $path_language = NULL) { $original_path = $path; // Lookup the path alias first. @@ -445,7 +448,7 @@ function path_load($conditions) { * - language: (optional) The language of the alias. */ function path_save(&$path) { - $path += array('pid' => NULL, 'language' => ''); + $path += array('pid' => NULL, 'language' => LANGUAGE_NONE); // Insert or update the alias. $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : NULL)); |