Logic for $wgSkipSkins should be in Skin.php, where it's usable by things other than...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 6 Aug 2008 17:41:17 +0000 (17:41 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 6 Aug 2008 17:41:17 +0000 (17:41 +0000)
includes/Skin.php
includes/specials/SpecialPreferences.php

index 71ada4c..b09bed1 100644 (file)
@@ -60,6 +60,21 @@ class Skin extends Linker {
                }
                return $wgValidSkinNames;
        }
+       
+       /**
+        * Fetch the list of usable skins in regards to $wgSkipSkins.
+        * Useful for Special:Preferences and other places where you
+        * only want to show skins users _can_ use.
+        * @return array of strings
+        */
+       public static function getUsableSkins() {
+               global $wgSkipSkins;
+               $usableSkins = self::getSkinNames();
+               foreach ( $wgSkipSkins as $skip ) {
+                       unset( $usableSkins[$skip] );
+               }
+               return $usableSkins;
+       }
 
        /**
         * Normalize a skin preference value to a form that can be loaded.
index 3747785..4528296 100644 (file)
@@ -517,7 +517,7 @@ class PreferencesForm {
                global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
                global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
                global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
-               global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
+               global $wgContLanguageCode, $wgDefaultSkin, $wgAuth;
                global $wgEmailConfirmToEdit, $wgAjaxSearch, $wgEnableMWSuggest;
 
                $wgOut->setPageTitle( wfMsg( 'preferences' ) );
@@ -819,7 +819,7 @@ class PreferencesForm {
                $previewtext = wfMsg('skin-preview');
                # Only show members of Skin::getSkinNames() rather than
                # $skinNames (skins is all skin names from Language.php)
-               $validSkinNames = Skin::getSkinNames();
+               $validSkinNames = Skin::getUsableSkins();
                # Sort by UI skin name. First though need to update validSkinNames as sometimes
                # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
                foreach ($validSkinNames as $skinkey => & $skinname ) {
@@ -829,9 +829,6 @@ class PreferencesForm {
                }
                asort($validSkinNames);
                foreach ($validSkinNames as $skinkey => $sn ) {
-                       if ( in_array( $skinkey, $wgSkipSkins ) ) {
-                               continue;
-                       }
                        $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
 
                        $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));