/**
* @param string $var
+ * @param mixed $default
*
* @return mixed
*/
- public function getVar( $var ) {
- return $this->parent->getVar( $var );
+ public function getVar( $var, $default = null ) {
+ return $this->parent->getVar( $var, $default );
}
/**
/**
* Get the starting tags of a fieldset.
*
- * @param string $legend message name
+ * @param string $legend Message name
*
* @return string
*/
*/
public function execute() {
if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
+ $this->submitSkins();
return 'skip';
}
if ( $this->parent->request->wasPosted() ) {
$this->getFieldSetEnd()
);
+ $skins = $this->parent->findExtensions( 'skins' );
+ $skinHtml = $this->getFieldSetStart( 'config-skins' );
+
+ if ( $skins ) {
+ $skinNames = array_map( 'strtolower', $skins );
+
+ $radioButtons = $this->parent->getRadioElements( array(
+ 'var' => 'wgDefaultSkin',
+ 'itemLabels' => array_fill_keys( $skinNames, 'config-skins-use-as-default' ),
+ 'values' => $skinNames,
+ 'value' => $this->getVar( 'wgDefaultSkin', $this->getDefaultSkin( $skinNames ) ),
+ ) );
+
+ foreach ( $skins as $skin ) {
+ $skinHtml .=
+ '<div class="config-skins-item">' .
+ $this->parent->getCheckBox( array(
+ 'var' => "skin-$skin",
+ 'rawtext' => $skin,
+ 'value' => $this->getVar( "skin-$skin", true ), // all found skins enabled by default
+ ) ) .
+ '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] . '</div>' .
+ '</div>';
+ }
+ } else {
+ $skinHtml .= $this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() );
+ }
+
+ $skinHtml .= $this->parent->getHelpBox( 'config-skins-help' ) .
+ $this->getFieldSetEnd();
+ $this->addHTML( $skinHtml );
+
$extensions = $this->parent->findExtensions();
if ( $extensions ) {
$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.
+ *
+ * @return bool
+ */
+ public function submitSkins() {
+ $skins = $this->parent->findExtensions( 'skins' );
+ $this->parent->setVar( '_Skins', $skins );
+
+ if ( $skins ) {
+ $skinNames = array_map( 'strtolower', $skins );
+ $this->parent->setVar( 'wgDefaultSkin', $this->getDefaultSkin( $skinNames ) );
+ }
+
+ return true;
+ }
+
/**
* @return bool
*/
'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
- 'wgUseInstantCommons' ) );
+ 'wgUseInstantCommons', 'wgDefaultSkin' ) );
$retVal = true;
$this->setVar( 'wgRightsIcon', '' );
}
+ $skinsAvailable = $this->parent->findExtensions( 'skins' );
+ $skinsToInstall = array();
+ foreach ( $skinsAvailable as $skin ) {
+ $this->parent->setVarsFromRequest( array( "skin-$skin" ) );
+ if ( $this->getVar( "skin-$skin" ) ) {
+ $skinsToInstall[] = $skin;
+ }
+ }
+ $this->parent->setVar( '_Skins', $skinsToInstall );
+
+ if ( !$skinsToInstall && $skinsAvailable ) {
+ $this->parent->showError( 'config-skins-must-enable-some' );
+ $retVal = false;
+ }
+ $defaultSkin = $this->getVar( 'wgDefaultSkin' );
+ $skinsToInstallLowercase = array_map( 'strtolower', $skinsToInstall );
+ if ( $skinsToInstall && array_search( $defaultSkin, $skinsToInstallLowercase ) === false ) {
+ $this->parent->showError( 'config-skins-must-enable-default' );
+ $retVal = false;
+ }
+
$extsAvailable = $this->parent->findExtensions();
$extsToInstall = array();
foreach ( $extsAvailable as $ext ) {