Add new_name_timestamp index when upgrading from 1.1
[lhc/web/wiklou.git] / includes / installer / WebInstallerPage.php
index 510ea6c..1c95d9a 100644 (file)
@@ -89,27 +89,35 @@ abstract class WebInstallerPage {
                if ( $continue ) {
                        // Fake submit button for enter keypress (bug 26267)
                        // Messages: config-continue, config-restart, config-regenerate
-                       $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(),
-                               array( 'name' => "enter-$continue", 'style' =>
-                                       'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n";
+                       $s .= Xml::submitButton(
+                               wfMessage( "config-$continue" )->text(),
+                               array(
+                                       'name' => "enter-$continue",
+                                       'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0'
+                               )
+                       ) . "\n";
                }
 
                if ( $back ) {
                        // Message: config-back
-                       $s .= Xml::submitButton( wfMessage( "config-$back" )->text(),
+                       $s .= Xml::submitButton(
+                               wfMessage( "config-$back" )->text(),
                                array(
                                        'name' => "submit-$back",
                                        'tabindex' => $this->parent->nextTabIndex()
-                               ) ) . "\n";
+                               )
+                       ) . "\n";
                }
 
                if ( $continue ) {
                        // Messages: config-continue, config-restart, config-regenerate
-                       $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(),
+                       $s .= Xml::submitButton(
+                               wfMessage( "config-$continue" )->text(),
                                array(
                                        'name' => "submit-$continue",
                                        'tabindex' => $this->parent->nextTabIndex(),
-                               ) ) . "\n";
+                               )
+                       ) . "\n";
                }
 
                $s .= "</div></form></div>\n";
@@ -177,7 +185,6 @@ abstract class WebInstallerPage {
 }
 
 class WebInstaller_Language extends WebInstallerPage {
-
        public function execute() {
                global $wgLang;
                $r = $this->parent->request;
@@ -211,6 +218,7 @@ class WebInstaller_Language extends WebInstallerPage {
                                if ( isset( $languages[$contLang] ) ) {
                                        $this->setVar( 'wgLanguageCode', $contLang );
                                }
+
                                return 'continue';
                        }
                } elseif ( $this->parent->showSessionWarning ) {
@@ -264,9 +272,9 @@ class WebInstaller_Language extends WebInstallerPage {
                        $s .= "\n" . Xml::option( "$code - $lang", $code, $code == $selectedCode );
                }
                $s .= "\n</select>\n";
+
                return $this->parent->label( $label, $name, $s );
        }
-
 }
 
 class WebInstaller_ExistingWiki extends WebInstallerPage {
@@ -280,8 +288,8 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                // Check if the upgrade key supplied to the user has appeared in LocalSettings.php
                if ( $vars['wgUpgradeKey'] !== false
                        && $this->getVar( '_UpgradeKeySupplied' )
-                       && $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey'] )
-               {
+                       && $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey']
+               {
                        // It's there, so the user is authorized
                        $status = $this->handleExistingUpgrade( $vars );
                        if ( $status->isOK() ) {
@@ -290,6 +298,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                                $this->startForm();
                                $this->parent->showStatusBox( $status );
                                $this->endForm( 'continue' );
+
                                return 'output';
                        }
                }
@@ -308,6 +317,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                                        $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )->plain()
                        ) );
                        $this->endForm( 'continue' );
+
                        return 'output';
                }
 
@@ -319,6 +329,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                        if ( !$key || $key !== $vars['wgUpgradeKey'] ) {
                                $this->parent->showError( 'config-localsettings-badkey' );
                                $this->showKeyForm();
+
                                return 'output';
                        }
                        // Key was OK
@@ -328,10 +339,12 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                        } else {
                                $this->parent->showStatusBox( $status );
                                $this->showKeyForm();
+
                                return 'output';
                        }
                } else {
                        $this->showKeyForm();
+
                        return 'output';
                }
        }
@@ -361,6 +374,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                        }
                        $this->setVar( $name, $vars[$name] );
                }
+
                return $status;
        }
 
@@ -372,7 +386,8 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
        protected function handleExistingUpgrade( $vars ) {
                // Check $wgDBtype
                if ( !isset( $vars['wgDBtype'] ) ||
-                        !in_array( $vars['wgDBtype'], Installer::getDBTypes() ) ) {
+                       !in_array( $vars['wgDBtype'], Installer::getDBTypes() )
+               ) {
                        return Status::newFatal( 'config-localsettings-connection-error', '' );
                }
 
@@ -402,11 +417,13 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                        // Adjust the error message to explain things correctly
                        $status->replaceMessage( 'config-connection-error',
                                'config-localsettings-connection-error' );
+
                        return $status;
                }
 
                // All good
                $this->setVar( '_ExistingDBSettings', true );
+
                return $status;
        }
 }
@@ -431,9 +448,9 @@ class WebInstaller_Welcome extends WebInstallerPage {
                } else {
                        $this->parent->showStatusMessage( $status );
                }
+
                return '';
        }
-
 }
 
 class WebInstaller_DBConnect extends WebInstallerPage {
@@ -449,6 +466,7 @@ class WebInstaller_DBConnect extends WebInstallerPage {
 
                        if ( $status->isGood() ) {
                                $this->setVar( '_UpgradeDone', false );
+
                                return 'continue';
                        } else {
                                $this->parent->showStatusBox( $status );
@@ -494,20 +512,21 @@ class WebInstaller_DBConnect extends WebInstallerPage {
 
                        // Messages: config-header-mysql, config-header-postgres, config-header-oracle,
                        // config-header-sqlite
-                       $settings .=
-                               Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type,
-                                               'class' => 'dbWrapper' ) ) .
+                       $settings .= Html::openElement(
+                                       'div',
+                                       array(
+                                               'id' => 'DB_wrapper_' . $type,
+                                               'class' => 'dbWrapper'
+                                       )
+                               ) .
                                Html::element( 'h3', array(), wfMessage( 'config-header-' . $type )->text() ) .
                                $installer->getConnectForm() .
                                "</div>\n";
                }
-               $types .= "</ul><br style=\"clear: left\"/>\n";
 
-               $this->addHTML(
-                       $this->parent->label( 'config-db-type', false, $types ) .
-                       $settings
-               );
+               $types .= "</ul><br style=\"clear: left\"/>\n";
 
+               $this->addHTML( $this->parent->label( 'config-db-type', false, $types ) . $settings );
                $this->endForm();
        }
 
@@ -522,9 +541,9 @@ class WebInstaller_DBConnect extends WebInstallerPage {
                if ( !$installer ) {
                        return Status::newFatal( 'config-invalid-db-type' );
                }
+
                return $installer->submitConnectForm();
        }
-
 }
 
 class WebInstaller_Upgrade extends WebInstallerPage {
@@ -545,6 +564,7 @@ class WebInstaller_Upgrade extends WebInstallerPage {
                                // Show the done message again
                                // Make them click back again if they want to do the upgrade again
                                $this->showDoneMessage();
+
                                return 'output';
                        }
                }
@@ -573,6 +593,7 @@ class WebInstaller_Upgrade extends WebInstallerPage {
                                }
                                $this->setVar( '_UpgradeDone', true );
                                $this->showDoneMessage();
+
                                return 'output';
                        }
                }
@@ -596,15 +617,14 @@ class WebInstaller_Upgrade extends WebInstallerPage {
                        $this->parent->getInfoBox(
                                wfMessage( $msg,
                                        $this->getVar( 'wgServer' ) .
-                                               $this->getVar( 'wgScriptPath' ) . '/index' .
-                                               $this->getVar( 'wgScriptExtension' )
+                                       $this->getVar( 'wgScriptPath' ) . '/index' .
+                                       $this->getVar( 'wgScriptExtension' )
                                )->plain(), 'tick-32.png'
                        )
                );
                $this->parent->restoreLinkPopups();
                $this->endForm( $regenerate ? 'regenerate' : false, false );
        }
-
 }
 
 class WebInstaller_DBSettings extends WebInstallerPage {
@@ -633,7 +653,6 @@ class WebInstaller_DBSettings extends WebInstallerPage {
                $this->addHTML( $form );
                $this->endForm();
        }
-
 }
 
 class WebInstaller_Name extends WebInstallerPage {
@@ -684,9 +703,8 @@ class WebInstaller_Name extends WebInstallerPage {
                        ) ) .
                        $this->parent->getTextBox( array(
                                'var' => 'wgMetaNamespace',
-                               'label' => '', //TODO: Needs a label?
-                               'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' ),
-
+                               'label' => '', // @todo Needs a label?
+                               'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' )
                        ) ) .
                        $this->getFieldSetStart( 'config-admin-box' ) .
                        $this->parent->getTextBox( array(
@@ -728,6 +746,7 @@ class WebInstaller_Name extends WebInstallerPage {
                $this->setVar( 'wgMetaNamespace', $metaNS );
 
                $this->endForm();
+
                return 'output';
        }
 
@@ -841,11 +860,9 @@ class WebInstaller_Name extends WebInstallerPage {
 
                return $retVal;
        }
-
 }
 
 class WebInstaller_Options extends WebInstallerPage {
-
        public function execute() {
                if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
                        return 'skip';
@@ -938,7 +955,7 @@ class WebInstaller_Options extends WebInstallerPage {
                        }
 
                        $extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) .
-                       $this->getFieldSetEnd();
+                               $this->getFieldSetEnd();
                        $this->addHTML( $extHtml );
                }
 
@@ -1053,6 +1070,7 @@ class WebInstaller_Options extends WebInstallerPage {
                                'lang' => $this->getVar( '_UserLang' ),
                                'stylesheet' => $styleUrl,
                        ) );
+
                return $iframeUrl;
        }
 
@@ -1082,6 +1100,7 @@ class WebInstaller_Options extends WebInstallerPage {
                // If you change this height, also change it in config.css
                $expandJs = str_replace( '$1', '54em', $js );
                $reduceJs = str_replace( '$1', '70px', $js );
+
                return '<p>' .
                        Html::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
                        '&#160;&#160;' .
@@ -1108,6 +1127,7 @@ class WebInstaller_Options extends WebInstallerPage {
                        array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
                if ( count( $newValues ) != 3 ) {
                        $this->parent->showError( 'config-cc-error' );
+
                        return;
                }
                $this->setVar( '_CCDone', true );
@@ -1122,8 +1142,8 @@ class WebInstaller_Options extends WebInstallerPage {
                        'wgUseInstantCommons' ) );
 
                if ( !in_array( $this->getVar( '_RightsProfile' ),
-                       array_keys( $this->parent->rightsProfiles ) ) )
-               {
+                       array_keys( $this->parent->rightsProfiles ) )
+               {
                        reset( $this->parent->rightsProfiles );
                        $this->setVar( '_RightsProfile', key( $this->parent->rightsProfiles ) );
                }
@@ -1132,6 +1152,7 @@ class WebInstaller_Options extends WebInstallerPage {
                if ( $code == 'cc-choose' ) {
                        if ( !$this->getVar( '_CCDone' ) ) {
                                $this->parent->showError( 'config-cc-not-chosen' );
+
                                return false;
                        }
                } elseif ( in_array( $code, array_keys( $this->parent->licenses ) ) ) {
@@ -1166,28 +1187,33 @@ class WebInstaller_Options extends WebInstallerPage {
                        $memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) );
                        if ( !$memcServers ) {
                                $this->parent->showError( 'config-memcache-needservers' );
+
                                return false;
                        }
 
                        foreach ( $memcServers as $server ) {
                                $memcParts = explode( ":", $server, 2 );
                                if ( !isset( $memcParts[0] )
-                                               || ( !IP::isValid( $memcParts[0] )
-                                                       && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) ) ) {
+                                       || ( !IP::isValid( $memcParts[0] )
+                                               && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
+                               ) {
                                        $this->parent->showError( 'config-memcache-badip', $memcParts[0] );
+
                                        return false;
                                } elseif ( !isset( $memcParts[1] ) ) {
                                        $this->parent->showError( 'config-memcache-noport', $memcParts[0] );
+
                                        return false;
                                } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
                                        $this->parent->showError( 'config-memcache-badport', 1, 65535 );
+
                                        return false;
                                }
                        }
                }
+
                return true;
        }
-
 }
 
 class WebInstaller_Install extends WebInstallerPage {
@@ -1219,13 +1245,16 @@ class WebInstaller_Install extends WebInstallerPage {
                        $this->addHTML( $this->parent->getInfoBox( wfMessage( 'config-install-begin' )->plain() ) );
                        $this->endForm();
                }
+
                return true;
        }
 
        public function startStage( $step ) {
                // Messages: config-install-database, config-install-tables, config-install-interwiki,
                // config-install-stats, config-install-keys, config-install-sysop, config-install-mainpage
-               $this->addHTML( "<li>" . wfMessage( "config-install-$step" )->escaped() . wfMessage( 'ellipsis' )->escaped() );
+               $this->addHTML( "<li>" . wfMessage( "config-install-$step" )->escaped() .
+                       wfMessage( 'ellipsis' )->escaped() );
+
                if ( $step == 'extension-tables' ) {
                        $this->startLiveBox();
                }
@@ -1249,20 +1278,19 @@ class WebInstaller_Install extends WebInstallerPage {
                        $this->parent->showStatusBox( $status );
                }
        }
-
 }
 
 class WebInstaller_Complete extends WebInstallerPage {
-
        public function execute() {
                // Pop up a dialog box, to make it difficult for the user to forget
                // to download the file
                $lsUrl = $this->getVar( 'wgServer' ) . $this->parent->getURL( array( 'localsettings' => 1 ) );
                if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
-                        strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) {
+                       strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false
+               ) {
                        // JS appears to be the only method that works consistently with IE7+
                        $this->addHtml( "\n<script>jQuery( function () { document.location = " .
-                               Xml::encodeJsVar( $lsUrl ) . "; } );</script>\n" );
+                       Xml::encodeJsVar( $lsUrl ) . "; } );</script>\n" );
                } else {
                        $this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
                }
@@ -1274,8 +1302,8 @@ class WebInstaller_Complete extends WebInstallerPage {
                                wfMessage( 'config-install-done',
                                        $lsUrl,
                                        $this->getVar( 'wgServer' ) .
-                                               $this->getVar( 'wgScriptPath' ) . '/index' .
-                                               $this->getVar( 'wgScriptExtension' ),
+                                       $this->getVar( 'wgScriptPath' ) . '/index' .
+                                       $this->getVar( 'wgScriptExtension' ),
                                        '<downloadlink/>'
                                )->plain(), 'tick-32.png'
                        )
@@ -1297,6 +1325,7 @@ class WebInstaller_Restart extends WebInstallerPage {
                        if ( $really ) {
                                $this->parent->reset();
                        }
+
                        return 'continue';
                }
 
@@ -1305,7 +1334,6 @@ class WebInstaller_Restart extends WebInstallerPage {
                $this->addHTML( $s );
                $this->endForm( 'restart' );
        }
-
 }
 
 abstract class WebInstaller_Document extends WebInstallerPage {
@@ -1322,12 +1350,12 @@ abstract class WebInstaller_Document extends WebInstallerPage {
 
        public function getFileContents() {
                $file = __DIR__ . '/../../' . $this->getFileName();
-               if ( ! file_exists( $file ) ) {
+               if ( !file_exists( $file ) ) {
                        return wfMessage( 'config-nofile', $file )->plain();
                }
+
                return file_get_contents( $file );
        }
-
 }
 
 class WebInstaller_Readme extends WebInstaller_Document {