Merge "Added result properties to action=paraminfo"
[lhc/web/wiklou.git] / includes / installer / WebInstaller.php
index b18536c..4f31195 100644 (file)
@@ -1,35 +1,58 @@
 <?php
+/**
+ * Core installer web interface.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Deployment
+ */
 
 /**
  * Class for the core installer web interface.
- * 
+ *
+ * @ingroup Deployment
  * @since 1.17
  */
-class WebInstaller extends CoreInstaller {
-       
+class WebInstaller extends Installer {
+
        /**
         * @var WebInstallerOutput
         */
-       public $output; 
-       
+       public $output;
+
        /**
         * WebRequest object.
-        * 
+        *
         * @var WebRequest
         */
        public $request;
 
        /**
         * Cached session array.
-        * 
+        *
         * @var array
         */
-       public $session;
+       protected $session;
 
-       /** 
+       /**
         * Captured PHP error text. Temporary.
+        * @var array
         */
-       public $phpErrors;
+       protected $phpErrors;
 
        /**
         * The main sequence of page names. These will be displayed in turn.
@@ -37,9 +60,11 @@ class WebInstaller extends CoreInstaller {
         *    * Add it here
         *    * Add a config-page-<name> message
         *    * Add a WebInstaller_<name> class
+        * @var array
         */
        public $pageSequence = array(
                'Language',
+               'ExistingWiki',
                'Welcome',
                'DBConnect',
                'Upgrade',
@@ -52,8 +77,9 @@ class WebInstaller extends CoreInstaller {
 
        /**
         * Out of sequence pages, selectable by the user at any time.
+        * @var array
         */
-       public $otherPages = array(
+       protected $otherPages = array(
                'Restart',
                'Readme',
                'ReleaseNotes',
@@ -64,92 +90,121 @@ class WebInstaller extends CoreInstaller {
        /**
         * Array of pages which have declared that they have been submitted, have validated
         * their input, and need no further processing.
+        * @var array
         */
-       public $happyPages;
+       protected $happyPages;
 
        /**
         * List of "skipped" pages. These are pages that will automatically continue
         * to the next page on any GET request. To avoid breaking the "back" button,
         * they need to be skipped during a back operation.
+        * @var array
         */
-       public $skippedPages;
+       protected $skippedPages;
 
        /**
         * Flag indicating that session data may have been lost.
+        * @var bool
         */
        public $showSessionWarning = false;
 
-       public $helpId = 0;
-       public $tabIndex = 1;
+       /**
+        * Numeric index of the page we're on
+        * @var int
+        */
+       protected $tabIndex = 1;
 
-       public $currentPageName;
+       /**
+        * Name of the page we're on
+        * @var string
+        */
+       protected $currentPageName;
 
-       /** 
+       /**
         * Constructor.
-        * 
-        * @param WebRequest $request
+        *
+        * @param $request WebRequest
         */
        public function __construct( WebRequest $request ) {
                parent::__construct();
                $this->output = new WebInstallerOutput( $this );
                $this->request = $request;
+
+               // Add parser hooks
+               global $wgParser;
+               $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
+               $wgParser->setHook( 'doclink', array( $this, 'docLink' ) );
        }
 
        /**
         * Main entry point.
-        * 
+        *
         * @param $session Array: initial session array
-        * 
+        *
         * @return Array: new session array
         */
        public function execute( array $session ) {
                $this->session = $session;
-               
+
                if ( isset( $session['settings'] ) ) {
                        $this->settings = $session['settings'] + $this->settings;
                }
-               
+
                $this->exportVars();
                $this->setupLanguage();
 
-               if( $this->getVar( '_InstallDone' ) && $this->request->getVal( 'localsettings' ) )
+               if( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
+                       && $this->request->getVal( 'localsettings' ) )
                {
-                       $ls = new LocalSettingsGenerator( $this );
-                       $this->request->response()->header('Content-type: text/plain');
-                       
+                       $this->request->response()->header( 'Content-type: application/x-httpd-php' );
                        $this->request->response()->header(
                                'Content-Disposition: attachment; filename="LocalSettings.php"'
                        );
-                       
+
+                       $ls = InstallerOverrides::getLocalSettingsGenerator( $this );
+                       $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
+                       foreach( $rightsProfile as $group => $rightsArr ) {
+                               $ls->setGroupRights( $group, $rightsArr );
+                       }
                        echo $ls->getText();
                        return $this->session;
                }
 
+               $cssDir = $this->request->getVal( 'css' );
+               if( $cssDir ) {
+                       $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' );
+                       $this->request->response()->header( 'Content-type: text/css' );
+                       echo $this->output->getCSS( $cssDir );
+                       return $this->session;
+               }
+
                if ( isset( $session['happyPages'] ) ) {
                        $this->happyPages = $session['happyPages'];
                } else {
                        $this->happyPages = array();
                }
-               
+
                if ( isset( $session['skippedPages'] ) ) {
                        $this->skippedPages = $session['skippedPages'];
                } else {
                        $this->skippedPages = array();
                }
-               
+
                $lowestUnhappy = $this->getLowestUnhappy();
 
                # Special case for Creative Commons partner chooser box.
                if ( $this->request->getVal( 'SubmitCC' ) ) {
                        $page = $this->getPageByName( 'Options' );
                        $this->output->useShortHeader();
+                       $this->output->allowFrames();
                        $page->submitCC();
                        return $this->finish();
                }
-               
+
                if ( $this->request->getVal( 'ShowCC' ) ) {
                        $page = $this->getPageByName( 'Options' );
                        $this->output->useShortHeader();
+                       $this->output->allowFrames();
                        $this->output->addHTML( $page->getCCDoneBox() );
                        return $this->finish();
                }
@@ -177,7 +232,7 @@ class WebInstaller extends CoreInstaller {
                                        $this->showSessionWarning = true;
                                }
                        }
-                       
+
                        $pageName = $this->pageSequence[$pageId];
                        $page = $this->getPageByName( $pageName );
                }
@@ -190,7 +245,7 @@ class WebInstaller extends CoreInstaller {
                                # Main sequence page
                                # Skip the skipped pages
                                $nextPageId = $pageId;
-                               
+
                                do {
                                        $nextPageId--;
                                        $nextPage = $this->pageSequence[$nextPageId];
@@ -198,7 +253,7 @@ class WebInstaller extends CoreInstaller {
                        } else {
                                $nextPage = $this->pageSequence[$lowestUnhappy];
                        }
-                       
+
                        $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
                        return $this->finish();
                }
@@ -206,15 +261,13 @@ class WebInstaller extends CoreInstaller {
                # Execute the page.
                $this->currentPageName = $page->getName();
                $this->startPageWrapper( $pageName );
-               $localSettings = $this->getLocalSettingsStatus();
-               
-               if( !$localSettings->isGood() ) {
-                       $this->showStatusBox( $localSettings );
-                       $result = 'output';
-               } else {
-                       $result = $page->execute();
+
+               if( $page->isSlow() ) {
+                       $this->disableTimeLimit();
                }
-               
+
+               $result = $page->execute();
+
                $this->endPageWrapper();
 
                if ( $result == 'skip' ) {
@@ -231,7 +284,7 @@ class WebInstaller extends CoreInstaller {
                        if ( $pageId !== false ) {
                                $this->happyPages[$pageId] = true;
                        }
-                       
+
                        $lowestUnhappy = $this->getLowestUnhappy();
 
                        if ( $this->request->getVal( 'lastPage' ) ) {
@@ -241,17 +294,21 @@ class WebInstaller extends CoreInstaller {
                        } else {
                                $nextPage = $this->pageSequence[$lowestUnhappy];
                        }
-                       
+
                        if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
                                $nextPage = $this->pageSequence[$lowestUnhappy];
                        }
-                       
+
                        $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
                }
-               
+
                return $this->finish();
        }
 
+       /**
+        * Find the next page in sequence that hasn't been completed
+        * @return int
+        */
        public function getLowestUnhappy() {
                if ( count( $this->happyPages ) == 0 ) {
                        return 0;
@@ -262,24 +319,10 @@ class WebInstaller extends CoreInstaller {
 
        /**
         * Start the PHP session. This may be called before execute() to start the PHP session.
+        *
+        * @return bool
         */
        public function startSession() {
-               $sessPath = $this->getSessionSavePath();
-               
-               if( $sessPath != '' ) {
-                       if( strval( ini_get( 'open_basedir' ) ) != '' ) {
-                               // we need to skip the following check when open_basedir is on.
-                               // The session path probably *wont* be writable by the current
-                               // user, and telling them to change it is bad. Bug 23021.
-                       } elseif( !is_dir( $sessPath ) || !is_writeable( $sessPath ) ) {
-                               $this->showError( 'config-session-path-bad', $sessPath );
-                               return false;
-                       }
-               } else {
-                       // If the path is unset it'll default to some system bit, which *probably* is ok...
-                       // not sure how to actually get what will be used.
-               }
-               
                if( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
                        // Done already
                        return true;
@@ -289,33 +332,45 @@ class WebInstaller extends CoreInstaller {
                set_error_handler( array( $this, 'errorHandler' ) );
                session_start();
                restore_error_handler();
-               
+
                if ( $this->phpErrors ) {
                        $this->showError( 'config-session-error', $this->phpErrors[0] );
                        return false;
                }
-               
+
                return true;
        }
 
        /**
-        * Get the value of session.save_path
+        * Get a hash of data identifying this MW installation.
         *
-        * Per http://www.php.net/manual/en/session.configuration.php#ini.session.save-path,
-        * this might have some additional preceding parts which need to be
-        * ditched
+        * This is used by mw-config/index.php to prevent multiple installations of MW
+        * on the same cookie domain from interfering with each other.
         *
-        * @return String
+        * @return string
         */
-       private function getSessionSavePath() {
-               $path = ini_get( 'session.save_path' );
-               $path = ltrim( substr( $path, strrpos( $path, ';' ) ), ';');
-
-               return $path;
+       public function getFingerprint() {
+               // Get the base URL of the installation
+               $url = $this->request->getFullRequestURL();
+               if ( preg_match( '!^(.*\?)!', $url, $m) ) {
+                       // Trim query string
+                       $url = $m[1];
+               }
+               if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
+                       // This... seems to try to get the base path from
+                       // the /mw-config/index.php. Kinda scary though?
+                       $url = $m[1];
+               }
+               return md5( serialize( array(
+                       'local path' => dirname( dirname( __FILE__ ) ),
+                       'url' => $url,
+                       'version' => $GLOBALS['wgVersion']
+               ) ) );
        }
 
        /**
         * Show an error message in a box. Parameters are like wfMsg().
+        * @param $msg
         */
        public function showError( $msg /*...*/ ) {
                $args = func_get_args();
@@ -327,6 +382,8 @@ class WebInstaller extends CoreInstaller {
 
        /**
         * Temporary error handler for session start debugging.
+        * @param $errno
+        * @param $errstr string
         */
        public function errorHandler( $errno, $errstr ) {
                $this->phpErrors[] = $errstr;
@@ -334,68 +391,64 @@ class WebInstaller extends CoreInstaller {
 
        /**
         * Clean up from execute()
-        * 
+        *
         * @return array
         */
        public function finish() {
                $this->output->output();
-               
+
                $this->session['happyPages'] = $this->happyPages;
                $this->session['skippedPages'] = $this->skippedPages;
                $this->session['settings'] = $this->settings;
-               
+
                return $this->session;
        }
 
+       /**
+        * We're restarting the installation, reset the session, happyPages, etc
+        */
+       public function reset() {
+               $this->session = array();
+               $this->happyPages = array();
+               $this->settings = array();
+       }
+
        /**
         * Get a URL for submission back to the same script.
-        * 
-        * @param $query: Array
+        *
+        * @param $query array
+        * @return string
         */
        public function getUrl( $query = array() ) {
                $url = $this->request->getRequestURL();
                # Remove existing query
                $url = preg_replace( '/\?.*$/', '', $url );
-               
+
                if ( $query ) {
                        $url .= '?' . wfArrayToCGI( $query );
                }
-               
-               return $url;
-       }
 
-       /**
-        * Get a WebInstallerPage from the main sequence, by ID.
-        * 
-        * @param $id Integer
-        * 
-        * @return WebInstallerPage
-        */
-       public function getPageById( $id ) {
-               return $this->getPageByName( $this->pageSequence[$id] );
+               return $url;
        }
 
        /**
         * Get a WebInstallerPage by name.
-        * 
+        *
         * @param $pageName String
-        * 
         * @return WebInstallerPage
         */
        public function getPageByName( $pageName ) {
-               // Totally lame way to force autoload of WebInstallerPage.php
-               class_exists( 'WebInstallerPage' );
-               
                $pageClass = 'WebInstaller_' . $pageName;
-               
+
                return new $pageClass( $this );
        }
 
        /**
         * Get a session variable.
-        * 
+        *
         * @param $name String
         * @param $default
+        * @return null
         */
        public function getSession( $name, $default = null ) {
                if ( !isset( $this->session[$name] ) ) {
@@ -407,6 +460,8 @@ class WebInstaller extends CoreInstaller {
 
        /**
         * Set a session variable.
+        * @param $name String key for the variable
+        * @param $value Mixed
         */
        public function setSession( $name, $value ) {
                $this->session[$name] = $value;
@@ -414,6 +469,7 @@ class WebInstaller extends CoreInstaller {
 
        /**
         * Get the next tabindex attribute value.
+        * @return int
         */
        public function nextTabIndex() {
                return $this->tabIndex++;
@@ -424,7 +480,7 @@ class WebInstaller extends CoreInstaller {
         */
        public function setupLanguage() {
                global $wgLang, $wgContLang, $wgLanguageCode;
-               
+
                if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) {
                        $wgLanguageCode = $this->getAcceptLanguage();
                        $wgLang = $wgContLang = Language::factory( $wgLanguageCode );
@@ -432,77 +488,58 @@ class WebInstaller extends CoreInstaller {
                        $this->setVar( '_UserLang', $wgLanguageCode );
                } else {
                        $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
-                       $wgLang = Language::factory( $this->getVar( '_UserLang' ) );
                        $wgContLang = Language::factory( $wgLanguageCode );
                }
        }
 
        /**
         * Retrieves MediaWiki language from Accept-Language HTTP header.
-        * 
+        *
         * @return string
         */
        public function getAcceptLanguage() {
-               global $wgLanguageCode;
-
-               $mwLanguages = Language::getLanguageNames();
-               $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
-               
-               foreach ( explode( ';', $langs ) as $splitted ) {
-                       foreach ( explode( ',', $splitted ) as $lang ) {
-                               $lang = trim( strtolower( $lang ) );
-                               
-                               if ( $lang == '' || $lang[0] == 'q' ) {
-                                       continue;
-                               }
-                               
-                               if ( isset( $mwLanguages[$lang] ) ) {
-                                       return $lang;
-                               }
-                               
-                               $lang = preg_replace( '/^(.*?)(?=-[^-]*)$/', '\\1', $lang );
-                               
-                               if ( $lang != '' && isset( $mwLanguages[$lang] ) ) {
-                                       return $lang;
-                               }
+               global $wgLanguageCode, $wgRequest;
+
+               $mwLanguages = Language::fetchLanguageNames();
+               $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
+
+               foreach ( $headerLanguages as $lang ) {
+                       if ( isset( $mwLanguages[$lang] ) ) {
+                               return $lang;
                        }
                }
-               
+
                return $wgLanguageCode;
        }
 
        /**
         * Called by execute() before page output starts, to show a page list.
-        * 
+        *
         * @param $currentPageName String
         */
-       public function startPageWrapper( $currentPageName ) {
-               $s = "<div class=\"config-page-wrapper\">\n" .
-                       "<div class=\"config-page-list\"><ul>\n";
+       private function startPageWrapper( $currentPageName ) {
+               $s = "<div class=\"config-page-wrapper\">\n";
+               $s .= "<div class=\"config-page\">\n";
+               $s .= "<div class=\"config-page-list\"><ul>\n";
                $lastHappy = -1;
-               
+
                foreach ( $this->pageSequence as $id => $pageName ) {
                        $happy = !empty( $this->happyPages[$id] );
-                       $s .= $this->getPageListItem( 
+                       $s .= $this->getPageListItem(
                                $pageName,
                                $happy || $lastHappy == $id - 1,
                                $currentPageName
                        );
-                               
+
                        if ( $happy ) {
                                $lastHappy = $id;
                        }
                }
-               
+
                $s .= "</ul><br/><ul>\n";
-               
-               foreach ( $this->otherPages as $pageName ) {
-                       $s .= $this->getPageListItem( $pageName, true, $currentPageName );
-               }
-               
-               $s .= "</ul></div>\n". // end list pane
-                       "<div class=\"config-page\">\n" .
-                       Xml::element( 'h2', array(),
+               $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
+               $s .= "</ul></div>\n"; // end list pane
+               $s .= Html::element( 'h2', array(),
                                wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
 
                $this->output->addHTMLNoFlush( $s );
@@ -510,26 +547,26 @@ class WebInstaller extends CoreInstaller {
 
        /**
         * Get a list item for the page list.
-        * 
+        *
         * @param $pageName String
         * @param $enabled Boolean
         * @param $currentPageName String
-        * 
+        *
         * @return string
         */
-       public function getPageListItem( $pageName, $enabled, $currentPageName ) {
+       private function getPageListItem( $pageName, $enabled, $currentPageName ) {
                $s = "<li class=\"config-page-list-item\">";
                $name = wfMsg( 'config-page-' . strtolower( $pageName ) );
-               
+
                if ( $enabled ) {
                        $query = array( 'page' => $pageName );
-                       
+
                        if ( !in_array( $pageName, $this->pageSequence ) ) {
                                if ( in_array( $currentPageName, $this->pageSequence ) ) {
                                        $query['lastPage'] = $currentPageName;
                                }
-                               
-                               $link = Xml::element( 'a',
+
+                               $link = Html::element( 'a',
                                        array(
                                                'href' => $this->getUrl( $query )
                                        ),
@@ -538,33 +575,34 @@ class WebInstaller extends CoreInstaller {
                        } else {
                                $link = htmlspecialchars( $name );
                        }
-                       
+
                        if ( $pageName == $currentPageName ) {
                                $s .= "<span class=\"config-page-current\">$link</span>";
                        } else {
                                $s .= $link;
                        }
                } else {
-                       $s .= Xml::element( 'span',
+                       $s .= Html::element( 'span',
                                array(
                                        'class' => 'config-page-disabled'
                                ),
                                $name
                        );
                }
-               
+
                $s .= "</li>\n";
-               
+
                return $s;
        }
 
        /**
         * Output some stuff after a page is finished.
         */
-       public function endPageWrapper() {
+       private function endPageWrapper() {
                $this->output->addHTMLNoFlush(
-                       "</div>\n" .
-                       "<br style=\"clear:both\"/>\n" .
+                                       "<div class=\"visualClear\"></div>\n" .
+                               "</div>\n" .
+                               "<div class=\"visualClear\"></div>\n" .
                        "</div>" );
        }
 
@@ -572,6 +610,8 @@ class WebInstaller extends CoreInstaller {
         * Get HTML for an error box with an icon.
         *
         * @param $text String: wikitext, get this with wfMsgNoTrans()
+        *
+        * @return string
         */
        public function getErrorBox( $text ) {
                return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
@@ -581,6 +621,8 @@ class WebInstaller extends CoreInstaller {
         * Get HTML for a warning box with an icon.
         *
         * @param $text String: wikitext, get this with wfMsgNoTrans()
+        *
+        * @return string
         */
        public function getWarningBox( $text ) {
                return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
@@ -592,57 +634,39 @@ class WebInstaller extends CoreInstaller {
         * @param $text String: wikitext, get this with wfMsgNoTrans()
         * @param $icon String: icon name, file in skins/common/images
         * @param $class String: additional class name to add to the wrapper div
+        *
+        * @return string
         */
-       public function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
-               $s =
-                       "<div class=\"config-info $class\">\n" .
-                               "<div class=\"config-info-left\">\n" .
-                               Xml::element( 'img',
-                                       array(
-                                               'src' => '../skins/common/images/' . $icon,
-                                               'alt' => wfMsg( 'config-information' ),
-                                       )
-                               ) . "\n" .
-                               "</div>\n" .
-                               "<div class=\"config-info-right\">\n" .
-                                       $this->parse( $text ) . "\n" .
-                               "</div>\n" .
-                               "<div style=\"clear: left;\"></div>\n" .
-                       "</div>\n";
-               return $s;
+       public function getInfoBox( $text, $icon = false, $class = false ) {
+               $text = $this->parse( $text, true );
+               $icon = ( $icon == false ) ? '../skins/common/images/info-32.png' : '../skins/common/images/'.$icon;
+               $alt = wfMsg( 'config-information' );
+               return Html::infoBox( $text, $icon, $alt, $class, false );
        }
 
        /**
         * Get small text indented help for a preceding form field.
         * Parameters like wfMsg().
+        *
+        * @param $msg
+        * @return string
         */
        public function getHelpBox( $msg /*, ... */ ) {
                $args = func_get_args();
                array_shift( $args );
                $args = array_map( 'htmlspecialchars', $args );
-               
                $text = wfMsgReal( $msg, $args, false, false, false );
                $html = $this->parse( $text, true );
-               $id = $this->helpId++;
-               $alt = wfMsg( 'help' );
 
-               return
-                       "<div class=\"config-help-wrapper\">\n" .
-                       "<div class=\"config-help-message\">\n" .
-                        $html .
-                       "</div>\n" .
-                       "<div class=\"config-show-help\">\n" .
-                       "<a href=\"#\">" .
-                       wfMsgHtml( 'config-show-help' ) .
-                       "</a></div>\n" .
-                       "<div class=\"config-hide-help\">\n" .
-                       "<a href=\"#\">" .
-                       wfMsgHtml( 'config-hide-help' ) .
-                       "</a></div>\n</div>\n";
+               return "<div class=\"mw-help-field-container\">\n" .
+                       "<span class=\"mw-help-field-hint\">" . wfMsgHtml( 'config-help' ) . "</span>\n" .
+                       "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
+                       "</div>\n";
        }
 
        /**
         * Output a help box.
+        * @param $msg String key for wfMsg()
         */
        public function showHelpBox( $msg /*, ... */ ) {
                $args = func_get_args();
@@ -653,6 +677,8 @@ class WebInstaller extends CoreInstaller {
        /**
         * Show a short informational message.
         * Output looks like a list.
+        *
+        * @param $msg string
         */
        public function showMessage( $msg /*, ... */ ) {
                $args = func_get_args();
@@ -663,29 +689,50 @@ class WebInstaller extends CoreInstaller {
                $this->output->addHTML( $html );
        }
 
+       /**
+        * @param $status Status
+        */
+       public function showStatusMessage( Status $status ) {
+               $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
+               foreach ( $errors as $error ) {
+                       call_user_func_array( array( $this, 'showMessage' ), $error );
+               }
+       }
+
        /**
         * Label a control by wrapping a config-input div around it and putting a
         * label before it.
+        *
+        * @param $msg
+        * @param $forId
+        * @param $contents
+        * @param $helpData string
+        * @return string
         */
-       public function label( $msg, $forId, $contents ) {
+       public function label( $msg, $forId, $contents, $helpData = "" ) {
                if ( strval( $msg ) == '' ) {
                        $labelText = '&#160;';
                } else {
                        $labelText = wfMsgHtml( $msg );
                }
-               
+
                $attributes = array( 'class' => 'config-label' );
-               
+
                if ( $forId ) {
                        $attributes['for'] = $forId;
                }
-               
+
                return
-                       "<div class=\"config-input\">\n" .
+                       "<div class=\"config-block\">\n" .
+                       "  <div class=\"config-block-label\">\n" .
                        Xml::tags( 'label',
                                $attributes,
                                $labelText ) . "\n" .
-                       $contents .
+                               $helpData .
+                       "  </div>\n" .
+                       "  <div class=\"config-block-elements\">\n" .
+                               $contents .
+                       "  </div>\n" .
                        "</div>\n";
        }
 
@@ -699,20 +746,25 @@ class WebInstaller extends CoreInstaller {
         *      attribs:    Additional attributes for the input element (optional)
         *      controlName: The name for the input element (optional)
         *      value:      The current value of the variable (optional)
+        *      help:           The html for the help text (optional)
+        *
+        * @return string
         */
        public function getTextBox( $params ) {
                if ( !isset( $params['controlName'] ) ) {
                        $params['controlName'] = 'config_' . $params['var'];
                }
-               
+
                if ( !isset( $params['value'] ) ) {
                        $params['value'] = $this->getVar( $params['var'] );
                }
-               
+
                if ( !isset( $params['attribs'] ) ) {
                        $params['attribs'] = array();
                }
-               
+               if ( !isset( $params['help'] ) ) {
+                       $params['help'] = "";
+               }
                return
                        $this->label(
                                $params['label'],
@@ -726,7 +778,56 @@ class WebInstaller extends CoreInstaller {
                                                'class' => 'config-input-text',
                                                'tabindex' => $this->nextTabIndex()
                                        )
-                               )
+                               ),
+                               $params['help']
+                       );
+       }
+
+       /**
+        * Get a labelled textarea to configure a variable
+        *
+        * @param $params Array
+        *    Parameters are:
+        *      var:        The variable to be configured (required)
+        *      label:      The message name for the label (required)
+        *      attribs:    Additional attributes for the input element (optional)
+        *      controlName: The name for the input element (optional)
+        *      value:      The current value of the variable (optional)
+        *      help:           The html for the help text (optional)
+        *
+        * @return string
+        */
+       public function getTextArea( $params ) {
+               if ( !isset( $params['controlName'] ) ) {
+                       $params['controlName'] = 'config_' . $params['var'];
+               }
+
+               if ( !isset( $params['value'] ) ) {
+                       $params['value'] = $this->getVar( $params['var'] );
+               }
+
+               if ( !isset( $params['attribs'] ) ) {
+                       $params['attribs'] = array();
+               }
+               if ( !isset( $params['help'] ) ) {
+                       $params['help'] = "";
+               }
+               return
+                       $this->label(
+                               $params['label'],
+                               $params['controlName'],
+                               Xml::textarea(
+                                       $params['controlName'],
+                                       $params['value'],
+                                       30,
+                                       5,
+                                       $params['attribs'] + array(
+                                               'id' => $params['controlName'],
+                                               'class' => 'config-input-text',
+                                               'tabindex' => $this->nextTabIndex()
+                                       )
+                               ),
+                               $params['help']
                        );
        }
 
@@ -741,19 +842,22 @@ class WebInstaller extends CoreInstaller {
         *      attribs:    Additional attributes for the input element (optional)
         *      controlName: The name for the input element (optional)
         *      value:      The current value of the variable (optional)
+        *      help:           The html for the help text (optional)
+        *
+        * @return string
         */
        public function getPasswordBox( $params ) {
                if ( !isset( $params['value'] ) ) {
                        $params['value'] = $this->getVar( $params['var'] );
                }
-               
+
                if ( !isset( $params['attribs'] ) ) {
                        $params['attribs'] = array();
                }
-               
+
                $params['value'] = $this->getFakePassword( $params['value'] );
                $params['attribs']['type'] = 'password';
-               
+
                return $this->getTextBox( $params );
        }
 
@@ -767,35 +871,40 @@ class WebInstaller extends CoreInstaller {
         *      attribs:    Additional attributes for the input element (optional)
         *      controlName: The name for the input element (optional)
         *      value:      The current value of the variable (optional)
+        *      help:           The html for the help text (optional)
+        *
+        * @return string
         */
        public function getCheckBox( $params ) {
                if ( !isset( $params['controlName'] ) ) {
                        $params['controlName'] = 'config_' . $params['var'];
                }
-               
+
                if ( !isset( $params['value'] ) ) {
                        $params['value'] = $this->getVar( $params['var'] );
                }
-               
+
                if ( !isset( $params['attribs'] ) ) {
                        $params['attribs'] = array();
                }
-               
+               if ( !isset( $params['help'] ) ) {
+                       $params['help'] = "";
+               }
                if( isset( $params['rawtext'] ) ) {
                        $labelText = $params['rawtext'];
                } else {
                        $labelText = $this->parse( wfMsg( $params['label'] ) );
                }
-               
+
                return
                        "<div class=\"config-input-check\">\n" .
+                       $params['help'] .
                        "<label>\n" .
                        Xml::check(
                                $params['controlName'],
                                $params['value'],
                                $params['attribs'] + array(
                                        'id' => $params['controlName'],
-                                       'class' => 'config-input-text',
                                        'tabindex' => $this->nextTabIndex(),
                                )
                        ) .
@@ -817,42 +926,44 @@ class WebInstaller extends CoreInstaller {
         *      commonAttribs   Attribute array applied to all items
         *      controlName:    The name for the input element (optional)
         *      value:          The current value of the variable (optional)
+        *      help:           The html for the help text (optional)
+        *
+        * @return string
         */
        public function getRadioSet( $params ) {
                if ( !isset( $params['controlName']  ) ) {
                        $params['controlName'] = 'config_' . $params['var'];
                }
-               
+
                if ( !isset( $params['value'] ) ) {
                        $params['value'] = $this->getVar( $params['var'] );
                }
-               
+
                if ( !isset( $params['label'] ) ) {
                        $label = '';
                } else {
-                       $label = $this->parse( wfMsgNoTrans( $params['label'] ) );
+                       $label = $params['label'];
                }
-               
-               $s = "<label class=\"config-label\">\n" .
-                       $label .
-                       "</label>\n" .
-                       "<ul class=\"config-settings-block\">\n";
+               if ( !isset( $params['help'] ) ) {
+                       $params['help'] = "";
+               }
+               $s = "<ul>\n";
                foreach ( $params['values'] as $value ) {
                        $itemAttribs = array();
-                       
+
                        if ( isset( $params['commonAttribs'] ) ) {
                                $itemAttribs = $params['commonAttribs'];
                        }
-                       
+
                        if ( isset( $params['itemAttribs'][$value] ) ) {
                                $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs;
                        }
-                       
+
                        $checked = $value == $params['value'];
                        $id = $params['controlName'] . '_' . $value;
                        $itemAttribs['id'] = $id;
                        $itemAttribs['tabindex'] = $this->nextTabIndex();
-                       
+
                        $s .=
                                '<li>' .
                                Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
@@ -862,37 +973,31 @@ class WebInstaller extends CoreInstaller {
                                ) ) .
                                "</li>\n";
                }
-               
+
                $s .= "</ul>\n";
-               return $s;
+
+               return $this->label( $label, $params['controlName'], $s, $params['help'] );
        }
 
        /**
         * Output an error or warning box using a Status object.
+        *
+        * @param $status Status
         */
        public function showStatusBox( $status ) {
                if( !$status->isGood() ) {
                        $text = $status->getWikiText();
-                       
+
                        if( $status->isOk() ) {
                                $box = $this->getWarningBox( $text );
                        } else {
                                $box = $this->getErrorBox( $text );
                        }
-                       
+
                        $this->output->addHTML( $box );
                }
        }
 
-       public function showStatusMessage( $status ) {
-               $text = $status->getWikiText();
-               $this->output->addWikiText(
-                       "<div class=\"config-message\">\n" .
-                       $text .
-                       "</div>"
-               );
-       }
-
        /**
         * Convenience function to set variables based on form data.
         * Assumes that variables containing "password" in the name are (potentially
@@ -900,14 +1005,16 @@ class WebInstaller extends CoreInstaller {
         *
         * @param $varNames Array
         * @param $prefix String: the prefix added to variables to obtain form names
+        *
+        * @return array
         */
        public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
                $newValues = array();
-               
+
                foreach ( $varNames as $name ) {
                        $value = trim( $this->request->getVal( $prefix . $name ) );
                        $newValues[$name] = $value;
-                       
+
                        if ( $value === null ) {
                                // Checkbox?
                                $this->setVar( $name, false );
@@ -919,37 +1026,85 @@ class WebInstaller extends CoreInstaller {
                                }
                        }
                }
-               
+
                return $newValues;
        }
 
        /**
-        * Get the starting tags of a fieldset.
+        * Helper for Installer::docLink()
         *
-        * @param $legend String: message name
+        * @param $page
+        * @return string
         */
-       public function getFieldsetStart( $legend ) {
-               return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
+       protected function getDocUrl( $page ) {
+               $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
+
+               if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
+                       $url .= '&lastPage=' . urlencode( $this->currentPageName );
+               }
+
+               return $url;
        }
 
        /**
-        * Get the end tag of a fieldset.
+        * Extension tag hook for a documentation link.
+        *
+        * @param $linkText
+        * @param $attribs
+        * @param $parser
+        * @return string
         */
-       public function getFieldsetEnd() {
-               return "</fieldset>\n";
+       public function docLink( $linkText, $attribs, $parser ) {
+               $url = $this->getDocUrl( $attribs['href'] );
+               return '<a href="' . htmlspecialchars( $url ) . '">' .
+                       htmlspecialchars( $linkText ) .
+                       '</a>';
        }
 
        /**
-        * Helper for Installer::docLink()
+        * Helper for "Download LocalSettings" link on WebInstall_Complete
+        *
+        * @param $text
+        * @param $attribs
+        * @param $parser
+        * @return String Html for download link
         */
-       public function getDocUrl( $page ) {
-               $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
-               
-               if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
-                       $url .= '&lastPage=' . urlencode( $this->currentPageName );
+       public function downloadLinkHook( $text, $attribs, $parser  ) {
+               $img = Html::element( 'img', array(
+                       'src' => '../skins/common/images/download-32.png',
+                       'width' => '32',
+                       'height' => '32',
+               ) );
+               $anchor = Html::rawElement( 'a',
+                       array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
+                       $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) );
+               return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
+       }
+
+       /**
+        * @return bool
+        */
+       public function envCheckPath( ) {
+               // PHP_SELF isn't available sometimes, such as when PHP is CGI but
+               // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
+               // to get the path to the current script... hopefully it's reliable. SIGH
+               $path = false;
+               if ( !empty( $_SERVER['PHP_SELF'] ) ) {
+                       $path = $_SERVER['PHP_SELF'];
+               } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
+                       $path = $_SERVER['SCRIPT_NAME'];
                }
-               
-               return $url;
+               if ($path !== false) {
+                       $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
+                       $this->setVar( 'wgScriptPath', $uri );
+               } else {
+                       $this->showError( 'config-no-uri' );
+                       return false;
+               }
+               return parent::envCheckPath();
+       }
+
+       protected function envGetDefaultServer() {
+               return WebRequest::detectServer();
        }
-       
-}
\ No newline at end of file
+}