From: jdlrobson Date: Sat, 18 May 2019 17:19:54 +0000 (+0200) Subject: Allow hidden skins to show up in preferences X-Git-Tag: 1.34.0-rc.0~1650^2 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=b2b204eeafc86206a563642554c0bc8e440a8f2b;p=lhc%2Fweb%2Fwiklou.git Allow hidden skins to show up in preferences It should be possible for power users to reveal hidden preferences using the useskin query parameter. In future this will allow us to use wgSkipSkins to deprecate poorly supported skins for new users whilst not hard deprecating and removing skin support for users who strongly want to continue to use them. Change-Id: I1bbd4a09dff72f513c9413e0f826d8db38a5e04c --- diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 1f21c1bbbc..b18088f481 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -1294,6 +1294,23 @@ class DefaultPreferencesFactory implements PreferencesFactory { # Only show skins that aren't disabled in $wgSkipSkins $validSkinNames = Skin::getAllowedSkins(); + $allInstalledSkins = Skin::getSkinNames(); + + // Display the installed skin the user has specifically requested via useskin=…. + $useSkin = $context->getRequest()->getRawVal( 'useskin' ); + if ( isset( $allInstalledSkins[$useSkin] ) + && $context->msg( "skinname-$useSkin" )->exists() + ) { + $validSkinNames[$useSkin] = $useSkin; + } + + // Display the skin if the user has set it as a preference already before it was hidden. + $currentUserSkin = $user->getOption( 'skin' ); + if ( isset( $allInstalledSkins[$currentUserSkin] ) + && $context->msg( "skinname-$useSkin" )->exists() + ) { + $validSkinNames[$currentUserSkin] = $currentUserSkin; + } foreach ( $validSkinNames as $skinkey => &$skinname ) { $msg = $context->msg( "skinname-{$skinkey}" ); @@ -1505,6 +1522,14 @@ class DefaultPreferencesFactory implements PreferencesFactory { */ $htmlForm = new $formClass( $formDescriptor, $context, 'prefs' ); + // This allows users to opt-in to hidden skins. While this should be discouraged and is not + // discoverable, this allows users to still use hidden skins while preventing new users from + // adopting unsupported skins. If no useskin=… parameter was provided, it will not show up + // in the resulting URL. + $htmlForm->setAction( $context->getTitle()->getLocalURL( [ + 'useskin' => $context->getRequest()->getRawVal( 'useskin' ) + ] ) ); + $htmlForm->setModifiedUser( $user ); $htmlForm->setId( 'mw-prefs-form' ); $htmlForm->setAutocomplete( 'off' );