From: Bartosz DziewoƄski Date: Sat, 13 Sep 2014 18:34:52 +0000 (+0200) Subject: Support for enabling skins in the command-line installer X-Git-Tag: 1.31.0-rc.0~13957 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=358a2347b24444d33e368221463b92a74cfbb45d;p=lhc%2Fweb%2Fwiklou.git Support for enabling skins in the command-line installer Whoops, I kind of forgot that this exists. Follow-up to a957836f. Bug: 70815 Change-Id: I6944fe1b1f7a8b77d32fafbca2349645320571f5 --- diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 1c7762b836..72907408ce 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -107,6 +107,15 @@ class CliInstaller extends Installer { if ( isset( $option['pass'] ) ) { $this->setVar( '_AdminPassword', $option['pass'] ); } + + // Set up the default skins + $skins = $this->findExtensions( 'skins' ); + $this->setVar( '_Skins', $skins ); + + if ( $skins ) { + $skinNames = array_map( 'strtolower', $skins ); + $this->setVar( 'wgDefaultSkin', $this->getDefaultSkin( $skinNames ) ); + } } /** diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index f23dfc95c2..f84ed0005d 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -1468,6 +1468,22 @@ abstract class Installer { return $exts; } + /** + * Returns a default value to be used for $wgDefaultSkin: the preferred skin, if available among + * the installed skins, or any other one otherwise. + * + * @param string[] $skinNames Names of installed skins. + * @return string + */ + public function getDefaultSkin( array $skinNames ) { + $defaultSkin = $GLOBALS['wgDefaultSkin']; + if ( in_array( $defaultSkin, $skinNames ) ) { + return $defaultSkin; + } else { + return $skinNames[0]; + } + } + /** * Installs the auto-detected extensions. * diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index 2a9c54ce1f..2e31e41301 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -1037,7 +1037,7 @@ class WebInstallerOptions extends WebInstallerPage { 'var' => 'wgDefaultSkin', 'itemLabels' => array_fill_keys( $skinNames, 'config-skins-use-as-default' ), 'values' => $skinNames, - 'value' => $this->getVar( 'wgDefaultSkin', $this->getDefaultSkin( $skinNames ) ), + 'value' => $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) ), ) ); foreach ( $skins as $skin ) { @@ -1254,22 +1254,6 @@ class WebInstallerOptions extends WebInstallerPage { $this->addHTML( $this->getCCDoneBox() ); } - /** - * Returns a default value to be used for $wgDefaultSkin: the preferred skin, if available among - * the installed skins, or any other one otherwise. - * - * @param string[] $skinNames Names of installed skins. - * @return string - */ - public function getDefaultSkin( array $skinNames ) { - $defaultSkin = $GLOBALS['wgDefaultSkin']; - if ( in_array( $defaultSkin, $skinNames ) ) { - return $defaultSkin; - } else { - return $skinNames[0]; - } - } - /** * If the user skips this installer page, we still need to set up the default skins, but ignore * everything else. @@ -1282,7 +1266,7 @@ class WebInstallerOptions extends WebInstallerPage { if ( $skins ) { $skinNames = array_map( 'strtolower', $skins ); - $this->parent->setVar( 'wgDefaultSkin', $this->getDefaultSkin( $skinNames ) ); + $this->parent->setVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) ); } return true;