Allow access to display and input settings in new vector

Light refactor of existing code into reusable method to support
this.

Use Extension attributes to allow skins to provide ULS
additional configuration.

Bug: T274396
Change-Id: I7dcd49f05fae83fbc0c15768bee8ca93eab17bcc
This commit is contained in:
jdlrobson
2021-02-10 09:46:25 -08:00
committed by jenkins-bot
parent 5ec30a6f63
commit 96656c5f41
2 changed files with 41 additions and 11 deletions

View File

@@ -348,8 +348,9 @@ class UniversalLanguageSelectorHooks {
/**
* Hook: ResourceLoaderGetConfigVars
* @param array &$vars
* @param string $skin
*/
public static function addConfig( array &$vars ) {
public static function addConfig( array &$vars, $skin ) {
global $wgULSGeoService,
$wgULSIMEEnabled, $wgULSWebfontsEnabled,
$wgULSNoWebfontsSelectors,
@@ -360,6 +361,8 @@ class UniversalLanguageSelectorHooks {
$wgExtensionAssetsPath,
$wgInterwikiSortingSortPrepend;
$extRegistry = ExtensionRegistry::getInstance();
$skinConfig = $extRegistry->getAttribute( 'UniversalLanguageSelectorSkinConfig' )[ $skin ] ?? [];
// Place constant stuff here (not depending on request context)
if ( is_string( $wgULSGeoService ) ) {
@@ -369,11 +372,11 @@ class UniversalLanguageSelectorHooks {
$vars['wgULSIMEEnabled'] = $wgULSIMEEnabled;
$vars['wgULSWebfontsEnabled'] = $wgULSWebfontsEnabled;
$vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage;
$vars['wgULSEventLogging'] = $wgULSEventLogging
&& ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' );
$vars['wgULSEventLogging'] = $wgULSEventLogging && $extRegistry->isLoaded( 'EventLogging' );
$vars['wgULSImeSelectors'] = $wgULSImeSelectors;
$vars['wgULSNoImeSelectors'] = $wgULSNoImeSelectors;
$vars['wgULSNoWebfontsSelectors'] = $wgULSNoWebfontsSelectors;
$vars['wgULSDisplaySettingsInInterlanguage'] = $skinConfig['ULSDisplaySettingsInInterlanguage'] ?? false;
if ( is_string( $wgULSFontRepositoryBasePath ) ) {
$vars['wgULSFontRepositoryBasePath'] = $wgULSFontRepositoryBasePath;