Reduce use of globals

Or reduce the scope where they are available.

Change-Id: Idce74bda8f64cc6be62b58b2624629408ca18d4b
This commit is contained in:
Siebrand Mazeland
2013-05-26 11:46:12 +02:00
parent 64b3ff6cde
commit 264652b1fd

View File

@@ -83,20 +83,22 @@ class UniversalLanguageSelectorHooks {
* Hook: PersonalUrls
*/
static function addPersonalBarTrigger( array &$personal_urls, &$title ) {
global $wgLang, $wgUser, $wgULSPosition;
global $wgULSPosition;
if ( $wgULSPosition !== 'personal' ) {
return true;
}
if ( !self::isToolbarEnabled( $wgUser ) ) {
$context = RequestContext::getMain();
if ( !self::isToolbarEnabled( $context->getUser() ) ) {
return true;
}
// The element id will be 'pt-uls'
$lang = $context->getLanguage();
$personal_urls = array(
'uls' => array(
'text' => $wgLang->getLanguageName( $wgLang->getCode() ),
'text' => $lang->getLanguageName( $lang->getCode() ),
'href' => '#',
'class' => 'uls-trigger',
'active' => true
@@ -160,7 +162,8 @@ class UniversalLanguageSelectorHooks {
* @return bool
*/
public static function getLanguage( $user, &$code, $context = null ) {
global $wgUser, $wgRequest, $wgULSAnonCanChangeLanguage, $wgULSLanguageDetection;
global $wgULSAnonCanChangeLanguage, $wgULSLanguageDetection;
if ( !self::isToolbarEnabled( $user ) ) {
return true;
}
@@ -169,6 +172,8 @@ class UniversalLanguageSelectorHooks {
* name matches the current user name to detect if we are not
* running in the primary request context. See bug 44010 */
if ( !$context instanceof RequestContext ) {
global $wgUser, $wgRequest;
if ( $wgUser->getName() !== $user->getName() ) {
return true;
}