diff options
Diffstat (limited to 'includes/installer/WebInstallerPage.php')
-rw-r--r-- | includes/installer/WebInstallerPage.php | 114 |
1 files changed, 66 insertions, 48 deletions
diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index 5c30182b..dc9c6d27 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -32,6 +32,15 @@ abstract class WebInstallerPage { $this->parent = $parent; } + /** + * Is this a slow-running page in the installer? If so, WebInstaller will + * set_time_limit(0) before calling execute(). Right now this only applies + * to Install and Upgrade pages + */ + public function isSlow() { + return false; + } + public function addHTML( $html ) { $this->parent->output->addHTML( $html ); } @@ -103,6 +112,8 @@ abstract class WebInstallerPage { * Get the starting tags of a fieldset. * * @param $legend String: message name + * + * @return string */ protected function getFieldsetStart( $legend ) { return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n"; @@ -110,6 +121,8 @@ abstract class WebInstallerPage { /** * Get the end tag of a fieldset. + * + * @returns string */ protected function getFieldsetEnd() { return "</fieldset>\n"; @@ -122,7 +135,7 @@ abstract class WebInstallerPage { $this->addHTML( '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' . '<script>jQuery( "#config-spinner" ).show();</script>' . - '<textarea id="config-live-log" name="LiveLog" rows="10" cols="30" readonly="readonly">' + '<div id="config-live-log"><textarea name="LiveLog" rows="10" cols="30" readonly="readonly">' ); $this->parent->output->flush(); } @@ -131,7 +144,7 @@ abstract class WebInstallerPage { * Opposite to startLiveBox() */ protected function endLiveBox() { - $this->addHTML( '</textarea> + $this->addHTML( '</textarea></div> <script>jQuery( "#config-spinner" ).hide()</script>' ); $this->parent->output->flush(); } @@ -198,10 +211,15 @@ class WebInstaller_Language extends WebInstallerPage { /** * Get a <select> for selecting languages. + * + * @return string */ - public function getLanguageSelector( $name, $label, $selectedCode ) { + public function getLanguageSelector( $name, $label, $selectedCode, $helpHtml = '' ) { global $wgDummyLanguageCodes; - $s = Html::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n"; + + $s = $helpHtml; + + $s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name, 'tabindex' => $this->parent->nextTabIndex() ) ) . "\n"; $languages = Language::getLanguageNames(); ksort( $languages ); @@ -408,7 +426,7 @@ class WebInstaller_DBConnect extends WebInstallerPage { $dbSupport = ''; foreach( $this->parent->getDBTypes() as $type ) { - $link = DatabaseBase::newFromType( $type )->getSoftwareLink(); + $link = DatabaseBase::factory( $type )->getSoftwareLink(); $dbSupport .= wfMsgNoTrans( "config-support-$type", $link ) . "\n"; } $this->addHTML( $this->parent->getInfoBox( @@ -458,6 +476,9 @@ class WebInstaller_DBConnect extends WebInstallerPage { } class WebInstaller_Upgrade extends WebInstallerPage { + public function isSlow() { + return true; + } public function execute() { if ( $this->getVar( '_UpgradeDone' ) ) { @@ -522,7 +543,7 @@ class WebInstaller_Upgrade extends WebInstallerPage { $this->addHTML( $this->parent->getInfoBox( wfMsgNoTrans( $msg, - $GLOBALS['wgServer'] . + $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/index' . $this->getVar( 'wgScriptExtension' ) ), 'tick-32.png' @@ -722,7 +743,6 @@ class WebInstaller_Name extends WebInstallerPage { // Validate password $msg = false; - $valid = false; $pwd = $this->getVar( '_AdminPassword' ); $user = User::newFromName( $cname ); $valid = $user && $user->getPasswordValidity( $pwd ); @@ -746,10 +766,16 @@ class WebInstaller_Name extends WebInstallerPage { // Validate e-mail if provided $email = $this->getVar( '_AdminEmail' ); - if( $email && !User::isValidEmailAddr( $email ) ) { + if( $email && !Sanitizer::validateEmail( $email ) ) { $this->parent->showError( 'config-admin-error-bademail' ); $retVal = false; } + // If they asked to subscribe to mediawiki-announce but didn't give + // an e-mail, show an error. Bug 29332 + if( !$email && $this->getVar( '_Subscribe' ) ) { + $this->parent->showError( 'config-subscribe-noemail' ); + $retVal = false; + } return $retVal; } @@ -892,6 +918,15 @@ class WebInstaller_Options extends WebInstallerPage { } $caches[] = 'memcached'; + // We'll hide/show this on demand when the value changes, see config.js. + $cacheval = $this->getVar( 'wgMainCacheType' ); + if (!$cacheval) { + // We need to set a default here; but don't hardcode it + // or we lose it every time we reload the page for validation + // or going back! + $cacheval = 'none'; + } + $hidden = ($cacheval == 'memcached') ? '' : 'display: none'; $this->addHTML( # Advanced settings $this->getFieldSetStart( 'config-advanced-settings' ) . @@ -901,10 +936,10 @@ class WebInstaller_Options extends WebInstallerPage { 'label' => 'config-cache-options', 'itemLabelPrefix' => 'config-cache-', 'values' => $caches, - 'value' => 'none', + 'value' => $cacheval, ) ) . $this->parent->getHelpBox( 'config-cache-help' ) . - '<div id="config-memcachewrapper">' . + "<div id=\"config-memcachewrapper\" style=\"$hidden\">" . $this->parent->getTextArea( array( 'var' => '_MemCachedServers', 'label' => 'config-memcached-servers', @@ -916,9 +951,12 @@ class WebInstaller_Options extends WebInstallerPage { $this->endForm(); } + /** + * @return string + */ public function getCCPartnerUrl() { - global $wgServer; - $exitUrl = $wgServer . $this->parent->getUrl( array( + $server = $this->getVar( 'wgServer' ); + $exitUrl = $server . $this->parent->getUrl( array( 'page' => 'Options', 'SubmitCC' => 'indeed', 'config__LicenseCode' => 'cc', @@ -926,7 +964,7 @@ class WebInstaller_Options extends WebInstallerPage { 'config_wgRightsText' => '[license_name]', 'config_wgRightsIcon' => '[license_button]', ) ); - $styleUrl = $wgServer . dirname( dirname( $this->parent->getUrl() ) ) . + $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) . '/skins/common/config-cc.css'; $iframeUrl = 'http://creativecommons.org/license/?' . wfArrayToCGI( array( @@ -1050,8 +1088,10 @@ class WebInstaller_Options extends WebInstallerPage { } foreach( $memcServers as $server ) { - $memcParts = explode( ":", $server ); - if( !IP::isValid( $memcParts[0] ) ) { + $memcParts = explode( ":", $server, 2 ); + if ( !isset( $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] ) ) { @@ -1069,6 +1109,9 @@ class WebInstaller_Options extends WebInstallerPage { } class WebInstaller_Install extends WebInstallerPage { + public function isSlow() { + return true; + } public function execute() { if( $this->getVar( '_UpgradeDone' ) ) { @@ -1104,6 +1147,10 @@ class WebInstaller_Install extends WebInstallerPage { } } + /** + * @param $step + * @param $status Status + */ public function endStage( $step, $status ) { if ( $step == 'extension-tables' ) { $this->endLiveBox(); @@ -1126,7 +1173,7 @@ 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 = $GLOBALS['wgServer'] . $this->parent->getURL( array( 'localsettings' => 1 ) ); + $lsUrl = $this->getVar( 'wgServer' ) . $this->parent->getURL( array( 'localsettings' => 1 ) ); if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) { // JS appears the only method that works consistently with IE7+ $this->addHtml( "\n<script type=\"" . $GLOBALS['wgJsMimeType'] . '">jQuery( document ).ready( function() { document.location=' @@ -1141,7 +1188,7 @@ class WebInstaller_Complete extends WebInstallerPage { $this->parent->getInfoBox( wfMsgNoTrans( 'config-install-done', $lsUrl, - $GLOBALS['wgServer'] . + $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/index' . $this->getVar( 'wgScriptExtension' ), '<downloadlink/>' @@ -1179,45 +1226,16 @@ abstract class WebInstaller_Document extends WebInstallerPage { public function execute() { $text = $this->getFileContents(); - $text = $this->formatTextFile( $text ); + $text = InstallDocFormatter::format( $text ); $this->parent->output->addWikiText( $text ); $this->startForm(); $this->endForm( false ); } - public function getFileContents() { + public function getFileContents() { return file_get_contents( dirname( __FILE__ ) . '/../../' . $this->getFileName() ); } - protected function formatTextFile( $text ) { - // Use Unix line endings, escape some wikitext stuff - $text = str_replace( array( '<', '{{', '[[', "\r" ), - array( '<', '{{', '[[', '' ), $text ); - // join word-wrapped lines into one - do { - $prev = $text; - $text = preg_replace( "/\n([\\*#\t])([^\n]*?)\n([^\n#\\*:]+)/", "\n\\1\\2 \\3", $text ); - } while ( $text != $prev ); - // Replace tab indents with colons - $text = preg_replace( '/^\t\t/m', '::', $text ); - $text = preg_replace( '/^\t/m', ':', $text ); - // turn (bug nnnn) into links - $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text ); - // add links to manual to every global variable mentioned - $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text ); - return $text; - } - - private function replaceBugLinks( $matches ) { - return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' . - $matches[1] . ' bug ' . $matches[1] . ']</span>'; - } - - private function replaceConfigLinks( $matches ) { - return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' . - $matches[1] . ' ' . $matches[1] . ']</span>'; - } - } class WebInstaller_Readme extends WebInstaller_Document { |