Commit 663b4919 authored by tim.plunkett's avatar tim.plunkett
Browse files

Remove usage of global $language.

parent 121516b1
......@@ -128,13 +128,11 @@ function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE)
* If TRUE, the data will be cached specific to the currently active language.
*/
function views_cache_set($cid, $data, $use_language = FALSE) {
global $language;
if (variable_get('views_skip_cache', FALSE)) {
return;
}
if ($use_language) {
$cid .= ':' . $language->language;
$cid .= ':' . drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode;
}
cache('cache_views')->set($cid, $data);
......@@ -151,13 +149,11 @@ function views_cache_set($cid, $data, $use_language = FALSE) {
* If TRUE, the data will be requested specific to the currently active language.
*/
function views_cache_get($cid, $use_language = FALSE) {
global $language;
if (variable_get('views_skip_cache', FALSE)) {
return 0;
}
if ($use_language) {
$cid .= ':' . $language->language;
$cid .= ':' . drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode;
}
return cache('cache_views')->get($cid);
......
......@@ -232,10 +232,9 @@ function query($use_groupby = FALSE) {
$column = $this->table_alias . '.language';
// By the same reason as field_language the field might be LANGUAGE_NONE in reality so allow it as well.
// @see this::field_language()
global $language_content;
$default_language = language_default('language');
$language = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
array($language_content->language, $default_language),
array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_language),
$this->view->display_handler->options['field_language']);
$placeholder = $this->placeholder();
$language_fallback_candidates = array($language);
......@@ -889,12 +888,10 @@ function add_self_tokens(&$tokens, $item) {
* according to the settings.
*/
function field_language($entity_type, $entity) {
global $language_content;
if (field_is_translatable($entity_type, $this->field_info)) {
$default_language = language_default('language');
$language = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
array($language_content->language, $default_language),
array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_language),
$this->view->display_handler->options['field_language']);
// Give the Field Language API a chance to fallback to a different language
......
......@@ -30,15 +30,15 @@ function render($values) {
}
function render_link($data, $values) {
global $language;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$tnid = $this->get_value($values, 'tnid');
// Only load translations if the node isn't in the current language.
if ($this->get_value($values, 'language') != $language->language) {
if ($this->get_value($values, 'language') != $language_interface->langcode) {
$translations = translation_node_get_translations($tnid);
if (isset($translations[$language->language])) {
$values->{$this->aliases['nid']} = $translations[$language->language]->nid;
$values->{$this->aliases['title']} = $translations[$language->language]->title;
if (isset($translations[$language_interface->langcode])) {
$values->{$this->aliases['nid']} = $translations[$language_interface->langcode]->nid;
$values->{$this->aliases['title']} = $translations[$language_interface->langcode]->title;
}
}
......
......@@ -277,7 +277,7 @@ function get_results_key() {
'build_info' => $build_info,
'roles' => array_keys($user->roles),
'super-user' => $user->uid == 1, // special caching for super user.
'language' => $GLOBALS['language']->language,
'language' => drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode,
'base_url' => $GLOBALS['base_url'],
);
foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) {
......@@ -300,7 +300,7 @@ function get_output_key() {
'roles' => array_keys($user->roles),
'super-user' => $user->uid == 1, // special caching for super user.
'theme' => $GLOBALS['theme'],
'language' => $GLOBALS['language']->language,
'language' => drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode,
'base_url' => $GLOBALS['base_url'],
);
......
......@@ -39,25 +39,25 @@ function translate_string($string, $keys = array(), $format = '') {
* The input format of the string. This is optional.
*/
function save_string($string, $keys = array(), $format = '') {
global $language;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// If the current language is 'en', we need to reset the language
// in order to trigger an update.
// TODO: add test for number of languages.
if ($language->language == 'en') {
if ($language_interface->langcode == 'en') {
$changed = TRUE;
$languages = language_list();
$cached_language = $language;
$cached_language = $language_interface;
unset($languages['en']);
if (!empty($languages)) {
$language = current($languages);
drupal_container()->set(LANGUAGE_TYPE_INTERFACE, current($languages));
}
}
t($string);
if (isset($cached_language)) {
$language = $cached_language;
drupal_container()->set(LANGUAGE_TYPE_INTERFACE, $cached_language);
}
return TRUE;
}
......
......@@ -839,7 +839,6 @@ function template_preprocess_views_view_list(&$vars) {
*/
function template_preprocess_views_view_rss(&$vars) {
global $base_url;
global $language;
$view = &$vars['view'];
$options = &$vars['options'];
......@@ -885,7 +884,7 @@ function template_preprocess_views_view_rss(&$vars) {
$vars['link'] = check_url(url($path, $url_options));
}
$vars['langcode'] = check_plain($language->language);
$vars['langcode'] = check_plain(drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode);
$vars['namespaces'] = drupal_attributes($style->namespaces);
$vars['items'] = $items;
$vars['channel_elements'] = format_xml_elements($style->channel_elements);
......
......@@ -769,11 +769,10 @@ function hook_views_default_views_alter(&$views) {
*/
function hook_views_query_substitutions($view) {
// Example from views_views_query_substitutions().
global $language_content;
return array(
'***CURRENT_VERSION***' => VERSION,
'***CURRENT_TIME***' => REQUEST_TIME,
'***CURRENT_LANGUAGE***' => $language_content->language,
'***CURRENT_LANGUAGE***' => drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode,
'***DEFAULT_LANGUAGE***' => language_default('language'),
);
}
......
......@@ -2019,11 +2019,10 @@ function views_theme_functions($hook, $view, $display = NULL) {
* Substitute current time; this works with cached queries.
*/
function views_views_query_substitutions($view) {
global $language_content;
return array(
'***CURRENT_VERSION***' => VERSION,
'***CURRENT_TIME***' => REQUEST_TIME,
'***CURRENT_LANGUAGE***' => $language_content->language,
'***CURRENT_LANGUAGE***' => drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode,
'***DEFAULT_LANGUAGE***' => language_default('language'),
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment