Introduce a config variable to enable Compact language links by default
Configuration: ULSCompactLanguageLinksBetaFeature Default value: True Bug: T134145 Change-Id: I8d4e97653daf7fcee9175c6d7cefb5c5abb22305
This commit is contained in:
committed by
Nikerabbit
parent
b871779a41
commit
aa4e4b417d
@@ -43,6 +43,44 @@ class UniversalLanguageSelectorHooks {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether ULS Compact interlanguage links enabled
|
||||
*
|
||||
* @param User $user
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCompactLinksEnabled( $user ) {
|
||||
global $wgULSEnable, $wgULSEnableAnon, $wgInterwikiMagic,
|
||||
$wgHideInterlanguageLinks, $wgULSCompactLanguageLinksBetaFeature;
|
||||
|
||||
// Whether any user visible features are enabled
|
||||
if ( !$wgULSEnable ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !$wgULSEnableAnon && $user->isAnon() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $wgULSCompactLanguageLinksBetaFeature === true &&
|
||||
$wgInterwikiMagic === true &&
|
||||
$wgHideInterlanguageLinks === false &&
|
||||
class_exists( 'BetaFeatures' ) &&
|
||||
BetaFeatures::isFeatureEnabled( $user, 'uls-compact-links' )
|
||||
) {
|
||||
// Compact language links is a beta feature in this wiki. Check the user's
|
||||
// preference.
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $wgULSCompactLanguageLinksBetaFeature === false ) {
|
||||
// Compact language links is a default feature in this wiki.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OutputPage $out
|
||||
* @param Skin $skin
|
||||
@@ -50,8 +88,7 @@ class UniversalLanguageSelectorHooks {
|
||||
* Hook: BeforePageDisplay
|
||||
*/
|
||||
public static function addModules( $out, $skin ) {
|
||||
global $wgULSPosition, $wgULSGeoService, $wgULSEventLogging,
|
||||
$wgInterwikiMagic, $wgHideInterlanguageLinks;
|
||||
global $wgULSPosition, $wgULSGeoService, $wgULSEventLogging;
|
||||
|
||||
// Load the style for users without JS, to hide the useless links
|
||||
$out->addModuleStyles( 'ext.uls.nojs' );
|
||||
@@ -68,13 +105,7 @@ class UniversalLanguageSelectorHooks {
|
||||
// If the extension is enabled, basic features (API, language data) available.
|
||||
$out->addModules( 'ext.uls.init' );
|
||||
|
||||
// If compact ULS beta feature is enabled and is actually functional
|
||||
// (see onGetBetaFeaturePreferences)
|
||||
if ( $wgInterwikiMagic === true &&
|
||||
$wgHideInterlanguageLinks === false &&
|
||||
class_exists( 'BetaFeatures' ) &&
|
||||
BetaFeatures::isFeatureEnabled( $out->getUser(), 'uls-compact-links' )
|
||||
) {
|
||||
if ( self::isCompactLinksEnabled( $out->getUser() ) ) {
|
||||
$out->addModules( 'ext.uls.compactlinks' );
|
||||
}
|
||||
|
||||
@@ -327,10 +358,11 @@ class UniversalLanguageSelectorHooks {
|
||||
}
|
||||
|
||||
public static function onGetBetaFeaturePreferences( $user, &$prefs ) {
|
||||
global $wgExtensionAssetsPath,
|
||||
global $wgExtensionAssetsPath, $wgULSCompactLanguageLinksBetaFeature,
|
||||
$wgHideInterlanguageLinks, $wgInterwikiMagic;
|
||||
|
||||
if ( $wgInterwikiMagic === true &&
|
||||
if ( $wgULSCompactLanguageLinksBetaFeature === true &&
|
||||
$wgInterwikiMagic === true &&
|
||||
$wgHideInterlanguageLinks === false
|
||||
) {
|
||||
$imagesDir = "$wgExtensionAssetsPath/UniversalLanguageSelector/resources/images";
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
"config": {
|
||||
"@ULSGeoService": "ULS can use geolocation services to suggest languages based on the country the user is vising from. Setting this to false will prevent builtin geolocation from being used. You can provide your own geolocation by setting window.Geo to object which has key \"country_code\" or \"country\". If set to true, it will query Wikimedia's geoip service. The service should return jsonp that uses the supplied callback parameter.",
|
||||
"ULSGeoService": true,
|
||||
"@ULSEnable": "Enable language selection, input methods and webfonts for everyone, unless the behavior is overridden by the configuration variables below. Even if false the classes and resource loader modules are registered for the use of other extensions. Language changing via cookie or setlang query parameter is not possible.",
|
||||
"@ULSEnable": "Enable language selection, compact language links, input methods and webfonts for everyone, unless the behavior is overridden by the configuration variables below. Even if false the classes and resource loader modules are registered for the use of other extensions. Language changing via cookie or setlang query parameter is not possible.",
|
||||
"ULSEnable": true,
|
||||
"@ULSEnableAnon": "Equivalent to $wgULSEnable for anonymous users only. Does not have any effect if $wgULSEnable is false.",
|
||||
"ULSEnableAnon": true,
|
||||
@@ -89,7 +89,9 @@
|
||||
"#p-lang li.interlanguage-link > a"
|
||||
],
|
||||
"@ULSFontRepositoryBasePath": "Base path of ULS font repository. If not set, will be set to 'UniversalLanguageSelector/data/fontrepo/fonts/', relative to $wgExtensionAssetsPath. @since 2013.10",
|
||||
"ULSFontRepositoryBasePath": false
|
||||
"ULSFontRepositoryBasePath": false,
|
||||
"ULSCompactLanguageLinksBetaFeature": true,
|
||||
"@ULSCompactLanguageLinksBetaFeature": "Set compact interlanguage links as beta feature or not. If set false, compact interlanguage links will be available by default to all users."
|
||||
},
|
||||
"callback": "UniversalLanguageSelectorHooks::setVersionConstant",
|
||||
"ResourceModules": {
|
||||
|
||||
Reference in New Issue
Block a user