/**
* Base code for web installer pages.
*
+ * 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
*/
$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
+ * @return bool
+ */
+ public function isSlow() {
+ return false;
+ }
+
public function addHTML( $html ) {
$this->parent->output->addHTML( $html );
}
if ( $continue ) {
// Fake submit button for enter keypress (bug 26267)
$s .= Xml::submitButton( wfMsg( "config-$continue" ),
- array( 'name' => "enter-$continue", 'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n";
+ array( 'name' => "enter-$continue", 'style' =>
+ 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n";
}
if ( $back ) {
* 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";
/**
* Get the end tag of a fieldset.
+ *
+ * @return string
*/
protected function getFieldsetEnd() {
return "</fieldset>\n";
}
+
+ /**
+ * Opens a textarea used to display the progress of a long operation
+ */
+ protected function startLiveBox() {
+ $this->addHTML(
+ '<div id="config-spinner" style="display:none;">' .
+ '<img src="../skins/common/images/ajax-loader.gif" /></div>' .
+ '<script>jQuery( "#config-spinner" ).show();</script>' .
+ '<div id="config-live-log">' .
+ '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
+ );
+ $this->parent->output->flush();
+ }
+
+ /**
+ * Opposite to startLiveBox()
+ */
+ protected function endLiveBox() {
+ $this->addHTML( '</textarea></div>
+<script>jQuery( "#config-spinner" ).hide()</script>' );
+ $this->parent->output->flush();
+ }
}
class WebInstaller_Language extends WebInstallerPage {
public function execute() {
global $wgLang;
$r = $this->parent->request;
- $userLang = $r->getVal( 'UserLang' );
+ $userLang = $r->getVal( 'uselang' );
$contLang = $r->getVal( 'ContLang' );
+ $languages = Language::fetchLanguageNames();
$lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
if ( !$lifetime ) {
$lifetime = 1440; // PHP default
}
$this->parent->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
} else {
- $languages = Language::getLanguageNames();
if ( isset( $languages[$userLang] ) ) {
$this->setVar( '_UserLang', $userLang );
}
} elseif ( $this->parent->showSessionWarning ) {
# The user was knocked back from another page to the start
# This probably indicates a session expiry
- $this->parent->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
+ $this->parent->showError( 'config-session-expired',
+ $wgLang->formatTimePeriod( $lifetime ) );
}
$this->parent->setSession( 'test', true );
}
$this->startForm();
$s = Html::hidden( 'LanguageRequestTime', time() ) .
- $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang, $this->parent->getHelpBox( 'config-your-language-help' ) ) .
- $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang, $this->parent->getHelpBox( 'config-wiki-language-help' ) );
+ $this->getLanguageSelector( 'uselang', 'config-your-language', $userLang,
+ $this->parent->getHelpBox( 'config-your-language-help' ) ) .
+ $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang,
+ $this->parent->getHelpBox( 'config-wiki-language-help' ) );
$this->addHTML( $s );
$this->endForm( 'continue', false );
}
/**
* Get a <select> for selecting languages.
+ *
+ * @param $name
+ * @param $label
+ * @param $selectedCode
+ * @param $helpHtml string
+ * @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";
- $languages = Language::getLanguageNames();
+ $s = $helpHtml;
+
+ $s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name,
+ 'tabindex' => $this->parent->nextTabIndex() ) ) . "\n";
+
+ $languages = Language::fetchLanguageNames();
ksort( $languages );
- $dummies = array_flip( $wgDummyLanguageCodes );
foreach ( $languages as $code => $lang ) {
- if ( isset( $dummies[$code] ) ) continue;
+ if ( isset( $wgDummyLanguageCodes[$code] ) ) continue;
$s .= "\n" . Xml::option( "$code - $lang", $code, $code == $selectedCode );
}
$s .= "\n</select>\n";
class WebInstaller_ExistingWiki extends WebInstallerPage {
public function execute() {
// If there is no LocalSettings.php, continue to the installer welcome page
- $vars = $this->parent->getExistingLocalSettings();
+ $vars = Installer::getExistingLocalSettings();
if ( !$vars ) {
return 'skip';
}
// If there is no $wgUpgradeKey, tell the user to add one to LocalSettings.php
if ( $vars['wgUpgradeKey'] === false ) {
if ( $this->getVar( 'wgUpgradeKey', false ) === false ) {
- $this->parent->generateUpgradeKey();
+ $secretKey = $this->getVar( 'wgSecretKey' ); // preserve $wgSecretKey
+ $this->parent->generateKeys();
+ $this->setVar( 'wgSecretKey', $secretKey );
$this->setVar( '_UpgradeKeySupplied', true );
}
$this->startForm();
$this->addHTML( $this->parent->getInfoBox(
wfMsgNoTrans( 'config-upgrade-key-missing',
- "<pre>\$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )
+ "<pre dir=\"ltr\">\$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )
) );
$this->endForm( 'continue' );
return 'output';
/**
* Initiate an upgrade of the existing database
- * @param $vars Variables from LocalSettings.php and AdminSettings.php
+ * @param $vars array Variables from LocalSettings.php and AdminSettings.php
* @return Status
*/
protected function handleExistingUpgrade( $vars ) {
// Check $wgDBtype
- if ( !isset( $vars['wgDBtype'] ) || !in_array( $vars['wgDBtype'], Installer::getDBTypes() ) ) {
+ if ( !isset( $vars['wgDBtype'] ) ||
+ !in_array( $vars['wgDBtype'], Installer::getDBTypes() ) ) {
return Status::newFatal( 'config-localsettings-connection-error', '' );
}
// Set the relevant variables from LocalSettings.php
- $requiredVars = array( 'wgDBtype', 'wgDBuser', 'wgDBpassword' );
+ $requiredVars = array( 'wgDBtype' );
$status = $this->importVariables( $requiredVars , $vars );
$installer = $this->parent->getDBInstaller();
$status->merge( $this->importVariables( $installer->getGlobalNames(), $vars ) );
$r = $this->parent->request;
if ( $r->wasPosted() ) {
$status = $this->submit();
+
if ( $status->isGood() ) {
$this->setVar( '_UpgradeDone', false );
return 'continue';
$dbSupport = '';
foreach( $this->parent->getDBTypes() as $type ) {
- $db = 'Database' . ucfirst( $type );
- $dbSupport .= wfMsgNoTrans( "config-support-$type",
- call_user_func( array( $db, 'getSoftwareLink' ) ) ) . "\n";
+ $link = DatabaseBase::factory( $type )->getSoftwareLink();
+ $dbSupport .= wfMsgNoTrans( "config-support-$type", $link ) . "\n";
}
$this->addHTML( $this->parent->getInfoBox(
wfMsg( 'config-support-info', $dbSupport ) ) );
"</li>\n";
$settings .=
- Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
+ Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type,
+ 'class' => 'dbWrapper' ) ) .
Html::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
$installer->getConnectForm() .
"</div>\n";
}
- $types .= "</ul><br clear=\"left\"/>\n";
+ $types .= "</ul><br style=\"clear: left\"/>\n";
$this->addHTML(
$this->parent->label( 'config-db-type', false, $types ) .
}
class WebInstaller_Upgrade extends WebInstallerPage {
+ public function isSlow() {
+ return true;
+ }
public function execute() {
if ( $this->getVar( '_UpgradeDone' ) ) {
if ( $this->parent->request->wasPosted() ) {
$installer->preUpgrade();
- $this->addHTML(
- '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
- '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
- '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
- );
- $this->parent->output->flush();
+
+ $this->startLiveBox();
$result = $installer->doUpgrade();
- $this->addHTML( '</textarea>
-<script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
- $this->parent->output->flush();
+ $this->endLiveBox();
+
if ( $result ) {
+ // If they're going to possibly regenerate LocalSettings, we
+ // need to create the upgrade/secret keys. Bug 26481
+ if( !$this->getVar( '_ExistingDBSettings' ) ) {
+ $this->parent->generateKeys();
+ }
$this->setVar( '_UpgradeDone', true );
$this->showDoneMessage();
return 'output';
$this->addHTML(
$this->parent->getInfoBox(
wfMsgNoTrans( $msg,
- $GLOBALS['wgServer'] .
+ $this->getVar( 'wgServer' ) .
$this->getVar( 'wgScriptPath' ) . '/index' .
$this->getVar( 'wgScriptExtension' )
), 'tick-32.png'
$this->startForm();
- if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
+ // Encourage people to not name their site 'MediaWiki' by blanking the
+ // field. I think that was the intent with the original $GLOBALS['wgSitename']
+ // but these two always were the same so had the effect of making the
+ // installer forget $wgSitename when navigating back to this page.
+ if ( $this->getVar( 'wgSitename' ) == 'MediaWiki' ) {
$this->setVar( 'wgSitename', '' );
}
'label' => 'config-project-namespace',
'itemLabelPrefix' => 'config-ns-',
'values' => array( 'site-name', 'generic', 'other' ),
- 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
+ 'commonAttribs' => array( 'class' => 'enableForOther',
+ 'rel' => 'config_wgMetaNamespace' ),
'help' => $this->parent->getHelpBox( 'config-project-namespace-help' )
) ) .
$this->parent->getTextBox( array(
$retVal = true;
$this->parent->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
'_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
- '_Subscribe', '_SkipOptional' ) );
+ '_Subscribe', '_SkipOptional', 'wgMetaNamespace' ) );
// Validate site name
if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
$this->parent->showError( 'config-ns-invalid', $name );
$retVal = false;
}
+
+ // Make sure it won't conflict with any existing namespaces
+ global $wgContLang;
+ $nsIndex = $wgContLang->getNsIndex( $name );
+ if( $nsIndex !== false && $nsIndex !== NS_PROJECT ) {
+ $this->parent->showError( 'config-ns-conflict', $name );
+ $retVal = false;
+ }
+
$this->setVar( 'wgMetaNamespace', $name );
// Validate username for creation
// Validate password
$msg = false;
- $valid = false;
$pwd = $this->getVar( '_AdminPassword' );
$user = User::newFromName( $cname );
$valid = $user && $user->getPasswordValidity( $pwd );
$msg = $valid;
}
if ( $msg !== false ) {
- $this->parent->showError( $msg );
+ call_user_func_array( array( $this->parent, 'showError' ), (array)$msg );
$this->setVar( '_AdminPassword', '' );
$this->setVar( '_AdminPassword2', '' );
$retVal = false;
// 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;
}
}
}
+ $emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
$this->startForm();
$this->addHTML(
# User Rights
'itemLabelPrefix' => 'config-profile-',
'values' => array_keys( $this->parent->rightsProfiles ),
) ) .
- $this->parent->getHelpBox( 'config-profile-help' ) .
+ $this->parent->getInfoBox( wfMsgNoTrans( 'config-profile-help' ) ) .
# Licensing
$this->parent->getRadioSet( array(
'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
) ) .
$this->parent->getHelpBox( 'config-enable-email-help' ) .
- "<div id=\"emailwrapper\">" .
+ "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
$this->parent->getTextBox( array(
'var' => 'wgPasswordSender',
'label' => 'config-email-sender'
$this->addHTML( $extHtml );
}
+ // Having / in paths in Windows looks funny :)
+ $this->setVar( 'wgDeletedDirectory',
+ str_replace(
+ '/', DIRECTORY_SEPARATOR,
+ $this->getVar( 'wgDeletedDirectory' )
+ )
+ );
+
+ $uploadwrapperStyle = $this->getVar( 'wgEnableUploads' ) ? '' : 'display: none';
$this->addHTML(
# Uploading
$this->getFieldSetStart( 'config-upload-settings' ) .
'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
'help' => $this->parent->getHelpBox( 'config-upload-help' )
) ) .
- '<div id="uploadwrapper" style="display: none;">' .
+ '<div id="uploadwrapper" style="' . $uploadwrapperStyle . '">' .
$this->parent->getTextBox( array(
'var' => 'wgDeletedDirectory',
'label' => 'config-upload-deleted',
+ 'attribs' => array( 'dir' => 'ltr' ),
'help' => $this->parent->getHelpBox( 'config-upload-deleted-help' )
) ) .
'</div>' .
$this->parent->getTextBox( array(
'var' => 'wgLogo',
'label' => 'config-logo',
+ 'attribs' => array( 'dir' => 'ltr' ),
'help' => $this->parent->getHelpBox( 'config-logo-help' )
) )
);
}
$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' ) .
'label' => 'config-cache-options',
'itemLabelPrefix' => 'config-cache-',
'values' => $caches,
- 'value' => 'none',
+ 'value' => $cacheval,
) ) .
$this->parent->getHelpBox( 'config-cache-help' ) .
- '<div id="config-memcachewrapper">' .
- $this->parent->getTextBox( array(
+ "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
+ $this->parent->getTextArea( array(
'var' => '_MemCachedServers',
'label' => 'config-memcached-servers',
'help' => $this->parent->getHelpBox( 'config-memcached-help' )
$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',
'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(
} else {
$iframeAttribs['src'] = $this->getCCPartnerUrl();
}
+ $wrapperStyle = ($this->getVar('_LicenseCode') == 'cc-choose') ? '' : 'display: none';
return
- "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
+ "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
Html::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
"</div>\n";
}
}
}
$this->parent->setVar( '_Extensions', $extsToInstall );
+
+ if( $this->getVar( 'wgMainCacheType' ) == 'memcached' ) {
+ $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] ) ) ) {
+ $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 {
+ public function isSlow() {
+ return true;
+ }
public function execute() {
- if( $this->parent->request->wasPosted() ) {
- return 'continue';
- } elseif( $this->getVar( '_InstallDone' ) ) {
- $this->startForm();
- $status = new Status();
- $status->warning( 'config-install-alreadydone' );
- $this->parent->showStatusBox( $status );
- } elseif( $this->getVar( '_UpgradeDone' ) ) {
+ if( $this->getVar( '_UpgradeDone' ) ) {
return 'skip';
- } else {
+ } elseif( $this->getVar( '_InstallDone' ) ) {
+ return 'continue';
+ } elseif( $this->parent->request->wasPosted() ) {
$this->startForm();
$this->addHTML("<ul>");
- $this->parent->performInstallation(
+ $results = $this->parent->performInstallation(
array( $this, 'startStage'),
array( $this, 'endStage' )
);
$this->addHTML("</ul>");
+ // PerformInstallation bails on a fatal, so make sure the last item
+ // completed before giving 'next.' Likewise, only provide back on failure
+ $lastStep = end( $results );
+ $continue = $lastStep->isOK() ? 'continue' : false;
+ $back = $lastStep->isOK() ? false : 'back';
+ $this->endForm( $continue, $back );
+ } else {
+ $this->startForm();
+ $this->addHTML( $this->parent->getInfoBox( wfMsgNoTrans( 'config-install-begin' ) ) );
+ $this->endForm();
}
- $this->endForm();
return true;
}
public function startStage( $step ) {
$this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
+ if ( $step == 'extension-tables' ) {
+ $this->startLiveBox();
+ }
}
+ /**
+ * @param $step
+ * @param $status Status
+ */
public function endStage( $step, $status ) {
+ if ( $step == 'extension-tables' ) {
+ $this->endLiveBox();
+ }
$msg = $status->isOk() ? 'config-install-step-done' : 'config-install-step-failed';
$html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
if ( !$status->isOk() ) {
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 ) );
- $this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
+ $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=' .
+ Xml::encodeJsVar( $lsUrl) . "; } );</script>\n" );
+ } else {
+ $this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
+ }
$this->startForm();
$this->parent->disableLinkPopups();
$this->parent->getInfoBox(
wfMsgNoTrans( 'config-install-done',
$lsUrl,
- $GLOBALS['wgServer'] .
+ $this->getVar( 'wgServer' ) .
$this->getVar( 'wgScriptPath' ) . '/index' .
$this->getVar( 'wgScriptExtension' ),
'<downloadlink/>'
if ( $r->wasPosted() ) {
$really = $r->getVal( 'submit-restart' );
if ( $really ) {
- $this->parent->session = array();
- $this->parent->happyPages = array();
- $this->parent->settings = array();
+ $this->parent->reset();
}
return 'continue';
}
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() {
- 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>';
+ public function getFileContents() {
+ $file = dirname( __FILE__ ) . '/../../' . $this->getFileName();
+ if( ! file_exists( $file ) ) {
+ return wfMsgNoTrans( 'config-nofile', $file );
+ }
+ return file_get_contents( $file );
}
}
}
class WebInstaller_ReleaseNotes extends WebInstaller_Document {
- protected function getFileName() { return 'RELEASE-NOTES'; }
+ protected function getFileName() {
+ global $wgVersion;
+
+ if(! preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
+ throw new MWException('Variable $wgVersion has an invalid value.');
+ }
+
+ return 'RELEASE-NOTES-' . $result[1] . '.' . $result[2];
+ }
}
class WebInstaller_UpgradeDoc extends WebInstaller_Document {