Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
663b4919
Commit
663b4919
authored
May 15, 2012
by
tim.plunkett
Browse files
Remove usage of global $language.
parent
121516b1
Changes
8
Hide whitespace changes
Inline
Side-by-side
includes/cache.inc
View file @
663b4919
...
...
@@ -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
->
lang
uag
e
;
$cid
.
=
':'
.
drupal_container
()
->
get
(
LANGUAGE_TYPE_INTERFACE
)
->
lang
cod
e
;
}
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
->
lang
uag
e
;
$cid
.
=
':'
.
drupal_container
()
->
get
(
LANGUAGE_TYPE_INTERFACE
)
->
lang
cod
e
;
}
return
cache
(
'cache_views'
)
->
get
(
$cid
);
...
...
modules/field/views_handler_field_field.inc
View file @
663b4919
...
...
@@ -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
->
lang
uag
e
,
$default_language
),
array
(
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
lang
cod
e
,
$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
->
lang
uag
e
,
$default_language
),
array
(
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
lang
cod
e
,
$default_language
),
$this
->
view
->
display_handler
->
options
[
'field_language'
]);
// Give the Field Language API a chance to fallback to a different language
...
...
modules/translation/views_handler_field_node_translation_link.inc
View file @
663b4919
...
...
@@ -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
->
lang
uag
e
)
{
if
(
$this
->
get_value
(
$values
,
'language'
)
!=
$language
_interface
->
lang
cod
e
)
{
$translations
=
translation_node_get_translations
(
$tnid
);
if
(
isset
(
$translations
[
$language
->
lang
uag
e
]))
{
$values
->
{
$this
->
aliases
[
'nid'
]}
=
$translations
[
$language
->
lang
uag
e
]
->
nid
;
$values
->
{
$this
->
aliases
[
'title'
]}
=
$translations
[
$language
->
lang
uag
e
]
->
title
;
if
(
isset
(
$translations
[
$language
_interface
->
lang
cod
e
]))
{
$values
->
{
$this
->
aliases
[
'nid'
]}
=
$translations
[
$language
_interface
->
lang
cod
e
]
->
nid
;
$values
->
{
$this
->
aliases
[
'title'
]}
=
$translations
[
$language
_interface
->
lang
cod
e
]
->
title
;
}
}
...
...
plugins/views_plugin_cache.inc
View file @
663b4919
...
...
@@ -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'
]
->
lang
uag
e
,
'language'
=>
drupal_container
()
->
get
(
LANGUAGE_TYPE_INTERFACE
)
->
lang
cod
e
,
'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'
]
->
lang
uag
e
,
'language'
=>
drupal_container
()
->
get
(
LANGUAGE_TYPE_INTERFACE
)
->
lang
cod
e
,
'base_url'
=>
$GLOBALS
[
'base_url'
],
);
...
...
plugins/views_plugin_localization_core.inc
View file @
663b4919
...
...
@@ -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
->
lang
uag
e
==
'en'
)
{
if
(
$language
_interface
->
lang
cod
e
==
'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
;
}
...
...
theme/theme.inc
View file @
663b4919
...
...
@@ -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
->
lang
uag
e
);
$vars
[
'langcode'
]
=
check_plain
(
drupal_container
()
->
get
(
LANGUAGE_TYPE_INTERFACE
)
->
lang
cod
e
);
$vars
[
'namespaces'
]
=
drupal_attributes
(
$style
->
namespaces
);
$vars
[
'items'
]
=
$items
;
$vars
[
'channel_elements'
]
=
format_xml_elements
(
$style
->
channel_elements
);
...
...
views.api.php
View file @
663b4919
...
...
@@ -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
->
lang
uag
e
,
'***CURRENT_LANGUAGE***'
=>
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
lang
cod
e
,
'***DEFAULT_LANGUAGE***'
=>
language_default
(
'language'
),
);
}
...
...
views.module
View file @
663b4919
...
...
@@ -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
->
lang
uag
e
,
'***CURRENT_LANGUAGE***'
=>
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
lang
cod
e
,
'***DEFAULT_LANGUAGE***'
=>
language_default
(
'language'
),
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment