Merge "Do not flip margin of magnify icon on user interface language"
[lhc/web/wiklou.git] / includes / Preferences.php
index 1eddd25..eb29e41 100644 (file)
@@ -579,12 +579,16 @@ class Preferences {
                ## Skin #####################################
                global $wgAllowUserCss, $wgAllowUserJs;
 
-               $defaultPreferences['skin'] = array(
-                       'type' => 'radio',
-                       'options' => self::generateSkinOptions( $user, $context ),
-                       'label' => ' ',
-                       'section' => 'rendering/skin',
-               );
+               // Skin selector, if there is at least one valid skin
+               $skinOptions = self::generateSkinOptions( $user, $context );
+               if ( $skinOptions ) {
+                       $defaultPreferences['skin'] = array(
+                               'type' => 'radio',
+                               'options' => $skinOptions,
+                               'label' => ' ',
+                               'section' => 'rendering/skin',
+                       );
+               }
 
                # Create links to user CSS/JS pages for all skins
                # This code is basically copied from generateSkinOptions().  It'd
@@ -989,10 +993,15 @@ class Preferences {
                        $watchTypes['read'] = 'watchcreations';
                }
 
+               if ( $user->isAllowed( 'rollback' ) ) {
+                       $watchTypes['rollback'] = 'watchrollback';
+               }
+
                foreach ( $watchTypes as $action => $pref ) {
                        if ( $user->isAllowed( $action ) ) {
                                // Messages:
                                // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations
+                               // tog-watchrollback
                                $defaultPreferences[$pref] = array(
                                        'type' => 'toggle',
                                        'section' => 'watchlist/advancedwatchlist',
@@ -1059,12 +1068,14 @@ class Preferences {
                }
                asort( $validSkinNames );
 
+               $foundDefault = false;
                foreach ( $validSkinNames as $skinkey => $sn ) {
                        $linkTools = array();
 
                        # Mark the default skin
                        if ( $skinkey == $wgDefaultSkin ) {
                                $linkTools[] = $context->msg( 'default' )->escaped();
+                               $foundDefault = true;
                        }
 
                        # Create preview link
@@ -1089,6 +1100,12 @@ class Preferences {
                        $ret[$display] = $skinkey;
                }
 
+               if ( !$foundDefault ) {
+                       // If the default skin is not available, things are going to break horribly because the
+                       // default value for skin selector will not be a valid value. Let's just not show it then.
+                       return array();
+               }
+
                return $ret;
        }