Manual talk:$wgSkipSkins

From MediaWiki.org
Jump to: navigation, search

m:Skins#Ensure users using skipped skins use the default instead

[edit] Ensure users using skipped skins use the default instead of any others

(for MediaWiki 1.9.0)


This piece of code ensures that if you have removed a skin, and have specified this in the $wgSkipSkins array in LocalPreferences.php, users who have previously selected the removed skin, will now use $wgDefaultSkin instead. This is an easy way to ensure all of your users are running the same skin, merely put all of the other skins in $wgSkipSkins.

The middle section needs to be inserted into the "normalizeKey( $key )" function in the "includes/Skin.php" file.

        /**
         * Normalize a skin preference value to a form that can be loaded.
         * If a skin can't be found, it will fall back to the configured
         * default (or the old 'Classic' skin if that's broken).
         * @param string $key
         * @return string
         * @static
         */
        static function normalizeKey( $key ) {
                global $wgDefaultSkin, $wgSkipSkins;
                $skinNames = Skin::getSkinNames();
                if( $key == '' ) {
                        // Don't return the default immediately;
                        // in a misconfiguration we need to fall back.
                        $key = $wgDefaultSkin;
                }
 
                if( in_array( $key , $wgSkipSkins ) ) {
                        $key = $wgDefaultSkin;
                }
 
                if( isset( $skinNames[$key] ) ) {
                        return $key;
                }
                // Older versions of the software used a numeric setting
                // in the user preferences.
                $fallback = array(
                        0 => $wgDefaultSkin,
                        1 => 'nostalgia',
                        2 => 'cologneblue' );
                if( isset( $fallback[$key] ) ){
                        $key = $fallback[$key];
                }
                if( isset( $skinNames[$key] ) ) {
                        return $key;
                } else {
                        // The old built-in skin
                        return 'standard';
                }
        }

Hopefully this will be merged with the release version in the future (However I have not submitted it as yet!)


Additionally, the final if-then-else statement appears to default to a specific skin when all else fails. I believe this should try $wgDefaultSkin before using 'standard'. If I were a better man, I would have implemented this whilst I was at it. If enough people want this, they can contact me on the email above, and I will implement it.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox