From: Bartosz DziewoƄski Date: Thu, 7 Dec 2017 18:56:48 +0000 (+0100) Subject: Preferences: Display the default skin first in the list X-Git-Tag: 1.31.0-rc.0~1249^2 X-Git-Url: http://git.cyclocoop.org/%22%20%20.%20generer_url_ecrire%28%22mots_tous%22%29%20.%20%22?a=commitdiff_plain;h=4ca2866a93f1806b80c10e7abbedd587ce11c12e;p=lhc%2Fweb%2Fwiklou.git Preferences: Display the default skin first in the list Bug: T181112 Change-Id: If3de084b2a5f214f7d6d05b86daed151a23678a4 --- diff --git a/includes/Preferences.php b/includes/Preferences.php index e6a8bcc6a3..878462db21 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1177,15 +1177,25 @@ class Preferences { $skinname = htmlspecialchars( $msg->text() ); } } - # Sort by the internal name, so that the ordering is the same for each display language, - # especially if some skin names are translated to use a different alphabet and some are not. - ksort( $validSkinNames ); $config = $context->getConfig(); $defaultSkin = $config->get( 'DefaultSkin' ); $allowUserCss = $config->get( 'AllowUserCss' ); $allowUserJs = $config->get( 'AllowUserJs' ); + # Sort by the internal name, so that the ordering is the same for each display language, + # especially if some skin names are translated to use a different alphabet and some are not. + uksort( $validSkinNames, function ( $a, $b ) use ( $defaultSkin ) { + # Display the default first in the list by comparing it as lesser than any other. + if ( strcasecmp( $a, $defaultSkin ) === 0 ) { + return -1; + } + if ( strcasecmp( $b, $defaultSkin ) === 0 ) { + return 1; + } + return strcasecmp( $a, $b ); + } ); + $foundDefault = false; foreach ( $validSkinNames as $skinkey => $sn ) { $linkTools = [];