From 6abb1b3d4a80d149e56e4022d542da5866086f7f Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 15 Nov 2012 16:27:23 +1100 Subject: [PATCH] Allow the main functionality of ULS to be disabled Allow the cache-breaking toolbar and cookie-based user language selection features to be disabled, while still allowing Wikibase to have its language autocompletion drop-downs on special pages. Change-Id: Iba18f666fdcf5b87b7068ab6b1537c868c8fe861 --- UniversalLanguageSelector.hooks.php | 17 +++++++++++++++-- UniversalLanguageSelector.php | 8 ++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php index 31e8acc9..84310558 100644 --- a/UniversalLanguageSelector.hooks.php +++ b/UniversalLanguageSelector.hooks.php @@ -26,6 +26,11 @@ class UniversalLanguageSelectorHooks { * @return bool */ public static function addModules( $out, $skin ) { + global $wgULSEnable; + if ( !$wgULSEnable ) { + return true; + } + $out->addModules( 'ext.uls.init' ); $out->addModules( 'ext.uls.geoclient' ); @@ -54,7 +59,11 @@ class UniversalLanguageSelectorHooks { * Hooks: SkinTemplateNavigation, SkinTemplateTabs */ static function addTrigger( array &$personal_urls, &$title ) { - global $wgLang; + global $wgULSEnable, $wgLang; + if ( !$wgULSEnable ) { + return true; + } + $personal_urls = array( 'uls' => array( 'text' => $wgLang->getLanguageName( $wgLang->getCode() ), @@ -113,7 +122,11 @@ class UniversalLanguageSelectorHooks { * @return bool */ public static function getLanguage( $user, &$code ) { - global $wgRequest, $wgULSLanguageDetection; + global $wgULSEnable, $wgRequest, $wgULSLanguageDetection; + + if ( !$wgULSEnable ) { + return true; + } $languageToSave = $wgRequest->getVal( 'setlang' ); if ( $wgRequest->getVal( 'uselang' ) && !$languageToSave ) { diff --git a/UniversalLanguageSelector.php b/UniversalLanguageSelector.php index 95cb1feb..8cb7581a 100644 --- a/UniversalLanguageSelector.php +++ b/UniversalLanguageSelector.php @@ -68,6 +68,14 @@ $wgULSIMEEnabled = true; */ $wgULSLanguageDetection = true; +/** + * Enable language selection. If language selection is disabled, the classes + * and RL modules are registered for the use of other extensions, but no + * language selection toolbar is shown, and it will not be possible to change + * the interface language using a cookie. + */ +$wgULSEnable = true; + $dir = __DIR__; // Internationalization