Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/285902

Change subject: Introduce a config variable to enable Compact language links by 
default
......................................................................

Introduce a config variable to enable Compact language links by default

Configuration: ULSCompactLanguageLinksBetaFeature
Default value: True

Change-Id: I8d4e97653daf7fcee9175c6d7cefb5c5abb22305
---
M UniversalLanguageSelector.hooks.php
M extension.json
2 files changed, 45 insertions(+), 12 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/02/285902/1

diff --git a/UniversalLanguageSelector.hooks.php 
b/UniversalLanguageSelector.hooks.php
index 6152011..7ce5885 100644
--- a/UniversalLanguageSelector.hooks.php
+++ b/UniversalLanguageSelector.hooks.php
@@ -44,14 +44,50 @@
        }
 
        /**
+        * Whether ULS Compact interlanguage links enabled
+        *
+        * @param User $user
+        * @return bool
+        */
+       public static function isCompactLinksEnabled( $user ) {
+               global $wgULSEnable, $wgULSEnableAnon, $wgInterwikiMagic,
+                       $wgHideInterlanguageLinks, 
$wgULSCompactLanguageLinksBetaFeature;
+
+               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
         * @return bool
         * 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 +104,7 @@
                // 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 +357,11 @@
        }
 
        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";
diff --git a/extension.json b/extension.json
index 7596576..3655e26 100644
--- a/extension.json
+++ b/extension.json
@@ -88,7 +88,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": {

-- 
To view, visit https://gerrit.wikimedia.org/r/285902
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d4e97653daf7fcee9175c6d7cefb5c5abb22305
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to