summaryrefslogtreecommitdiff
path: root/includes/installer/WebInstallerPage.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/installer/WebInstallerPage.php')
-rw-r--r--includes/installer/WebInstallerPage.php101
1 files changed, 66 insertions, 35 deletions
diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php
index ff8185a1..a193afb7 100644
--- a/includes/installer/WebInstallerPage.php
+++ b/includes/installer/WebInstallerPage.php
@@ -2,6 +2,21 @@
/**
* 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
*/
@@ -36,6 +51,7 @@ abstract class WebInstallerPage {
* 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;
@@ -68,13 +84,13 @@ abstract class WebInstallerPage {
if ( $continue ) {
// Fake submit button for enter keypress (bug 26267)
- $s .= Xml::submitButton( wfMsg( "config-$continue" ),
+ $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(),
array( 'name' => "enter-$continue", 'style' =>
'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n";
}
if ( $back ) {
- $s .= Xml::submitButton( wfMsg( "config-$back" ),
+ $s .= Xml::submitButton( wfMessage( "config-$back" )->text(),
array(
'name' => "submit-$back",
'tabindex' => $this->parent->nextTabIndex()
@@ -82,7 +98,7 @@ abstract class WebInstallerPage {
}
if ( $continue ) {
- $s .= Xml::submitButton( wfMsg( "config-$continue" ),
+ $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(),
array(
'name' => "submit-$continue",
'tabindex' => $this->parent->nextTabIndex(),
@@ -117,7 +133,7 @@ abstract class WebInstallerPage {
* @return string
*/
protected function getFieldsetStart( $legend ) {
- return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
+ return "\n<fieldset><legend>" . wfMessage( $legend )->escaped() . "</legend>\n";
}
/**
@@ -161,7 +177,7 @@ class WebInstaller_Language extends WebInstallerPage {
$userLang = $r->getVal( 'uselang' );
$contLang = $r->getVal( 'ContLang' );
- $languages = Language::getLanguageNames();
+ $languages = Language::fetchLanguageNames();
$lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
if ( !$lifetime ) {
$lifetime = 1440; // PHP default
@@ -216,7 +232,7 @@ class WebInstaller_Language extends WebInstallerPage {
}
/**
- * Get a <select> for selecting languages.
+ * Get a "<select>" for selecting languages.
*
* @param $name
* @param $label
@@ -232,7 +248,7 @@ class WebInstaller_Language extends WebInstallerPage {
$s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name,
'tabindex' => $this->parent->nextTabIndex() ) ) . "\n";
- $languages = Language::getLanguageNames();
+ $languages = Language::fetchLanguageNames();
ksort( $languages );
foreach ( $languages as $code => $lang ) {
if ( isset( $wgDummyLanguageCodes[$code] ) ) continue;
@@ -279,8 +295,8 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
}
$this->startForm();
$this->addHTML( $this->parent->getInfoBox(
- wfMsgNoTrans( 'config-upgrade-key-missing',
- "<pre dir=\"ltr\">\$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )
+ wfMessage( 'config-upgrade-key-missing', "<pre dir=\"ltr\">\$wgUpgradeKey = '" .
+ $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )->plain()
) );
$this->endForm( 'continue' );
return 'output';
@@ -317,7 +333,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
protected function showKeyForm() {
$this->startForm();
$this->addHTML(
- $this->parent->getInfoBox( wfMsgNoTrans( 'config-localsettings-upgrade' ) ).
+ $this->parent->getInfoBox( wfMessage( 'config-localsettings-upgrade' )->plain() ).
'<br />' .
$this->parent->getTextBox( array(
'var' => 'wgUpgradeKey',
@@ -341,7 +357,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
/**
* 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 ) {
@@ -394,13 +410,13 @@ class WebInstaller_Welcome extends WebInstallerPage {
return 'continue';
}
}
- $this->parent->output->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
+ $this->parent->output->addWikiText( wfMessage( 'config-welcome' )->plain() );
$status = $this->parent->doEnvironmentChecks();
if ( $status->isGood() ) {
$this->parent->output->addHTML( '<span class="success-message">' .
- wfMsgHtml( 'config-env-good' ) . '</span>' );
- $this->parent->output->addWikiText( wfMsgNoTrans( 'config-copyright',
- SpecialVersion::getCopyrightAndAuthorList() ) );
+ wfMessage( 'config-env-good' )->escaped() . '</span>' );
+ $this->parent->output->addWikiText( wfMessage( 'config-copyright',
+ SpecialVersion::getCopyrightAndAuthorList() )->plain() );
$this->startForm();
$this->endForm();
} else {
@@ -438,10 +454,10 @@ class WebInstaller_DBConnect extends WebInstallerPage {
$dbSupport = '';
foreach( $this->parent->getDBTypes() as $type ) {
$link = DatabaseBase::factory( $type )->getSoftwareLink();
- $dbSupport .= wfMsgNoTrans( "config-support-$type", $link ) . "\n";
+ $dbSupport .= wfMessage( "config-support-$type", $link )->plain() . "\n";
}
$this->addHTML( $this->parent->getInfoBox(
- wfMsg( 'config-support-info', $dbSupport ) ) );
+ wfMessage( 'config-support-info', trim( $dbSupport ) )->text() ) );
foreach ( $this->parent->getVar( '_CompiledDBs' ) as $type ) {
$installer = $this->parent->getDBInstaller( $type );
@@ -460,7 +476,7 @@ class WebInstaller_DBConnect extends WebInstallerPage {
$settings .=
Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type,
'class' => 'dbWrapper' ) ) .
- Html::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
+ Html::element( 'h3', array(), wfMessage( 'config-header-' . $type )->text() ) .
$installer->getConnectForm() .
"</div>\n";
}
@@ -539,7 +555,7 @@ class WebInstaller_Upgrade extends WebInstallerPage {
$this->startForm();
$this->addHTML( $this->parent->getInfoBox(
- wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
+ wfMessage( 'config-can-upgrade', $GLOBALS['wgVersion'] )->plain() ) );
$this->endForm();
}
@@ -554,11 +570,11 @@ class WebInstaller_Upgrade extends WebInstallerPage {
$this->parent->disableLinkPopups();
$this->addHTML(
$this->parent->getInfoBox(
- wfMsgNoTrans( $msg,
+ wfMessage( $msg,
$this->getVar( 'wgServer' ) .
$this->getVar( 'wgScriptPath' ) . '/index' .
$this->getVar( 'wgScriptExtension' )
- ), 'tick-32.png'
+ )->plain(), 'tick-32.png'
)
);
$this->parent->restoreLinkPopups();
@@ -619,7 +635,10 @@ class WebInstaller_Name extends WebInstallerPage {
// Set wgMetaNamespace to something valid before we show the form.
// $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
$metaNS = $this->getVar( 'wgMetaNamespace' );
- $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
+ $this->setVar(
+ 'wgMetaNamespace',
+ wfMessage( 'config-ns-other-default' )->inContentLanguage()->text()
+ );
$this->addHTML(
$this->parent->getTextBox( array(
@@ -667,7 +686,7 @@ class WebInstaller_Name extends WebInstallerPage {
'help' => $this->parent->getHelpBox( 'config-subscribe-help' )
) ) .
$this->getFieldSetEnd() .
- $this->parent->getInfoBox( wfMsg( 'config-almost-done' ) ) .
+ $this->parent->getInfoBox( wfMessage( 'config-almost-done' )->text() ) .
$this->parent->getRadioSet( array(
'var' => '_SkipOptional',
'itemLabelPrefix' => 'config-optional-',
@@ -705,7 +724,7 @@ class WebInstaller_Name extends WebInstallerPage {
$name = preg_replace( '/__+/', '_', $name );
$name = ucfirst( trim( $name, '_' ) );
} elseif ( $nsType == 'generic' ) {
- $name = wfMsg( 'config-ns-generic' );
+ $name = wfMessage( 'config-ns-generic' )->text();
} else { // other
$name = $this->getVar( 'wgMetaNamespace' );
}
@@ -817,7 +836,7 @@ class WebInstaller_Options extends WebInstallerPage {
'itemLabelPrefix' => 'config-profile-',
'values' => array_keys( $this->parent->rightsProfiles ),
) ) .
- $this->parent->getInfoBox( wfMsgNoTrans( 'config-profile-help' ) ) .
+ $this->parent->getInfoBox( wfMessage( 'config-profile-help' )->plain() ) .
# Licensing
$this->parent->getRadioSet( array(
@@ -1030,7 +1049,7 @@ class WebInstaller_Options extends WebInstallerPage {
'href' => $this->getCCPartnerUrl(),
'onclick' => $expandJs,
),
- wfMsg( 'config-cc-again' )
+ wfMessage( 'config-cc-again' )->text()
) .
"</p>\n" .
"<script type=\"text/javascript\">\n" .
@@ -1076,7 +1095,7 @@ class WebInstaller_Options extends WebInstallerPage {
if ( isset( $entry['text'] ) ) {
$this->setVar( 'wgRightsText', $entry['text'] );
} else {
- $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
+ $this->setVar( 'wgRightsText', wfMessage( 'config-license-' . $code )->text() );
}
$this->setVar( 'wgRightsUrl', $entry['url'] );
$this->setVar( 'wgRightsIcon', $entry['icon'] );
@@ -1149,14 +1168,14 @@ class WebInstaller_Install extends WebInstallerPage {
$this->endForm( $continue, $back );
} else {
$this->startForm();
- $this->addHTML( $this->parent->getInfoBox( wfMsgNoTrans( 'config-install-begin' ) ) );
+ $this->addHTML( $this->parent->getInfoBox( wfMessage( 'config-install-begin' )->plain() ) );
$this->endForm();
}
return true;
}
public function startStage( $step ) {
- $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
+ $this->addHTML( "<li>" . wfMessage( "config-install-$step" )->escaped() . wfMessage( 'ellipsis')->escaped() );
if ( $step == 'extension-tables' ) {
$this->startLiveBox();
}
@@ -1171,7 +1190,7 @@ class WebInstaller_Install extends WebInstallerPage {
$this->endLiveBox();
}
$msg = $status->isOk() ? 'config-install-step-done' : 'config-install-step-failed';
- $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
+ $html = wfMessage( 'word-separator' )->escaped() . wfMessage( $msg )->escaped();
if ( !$status->isOk() ) {
$html = "<span class=\"error\">$html</span>";
}
@@ -1203,13 +1222,13 @@ class WebInstaller_Complete extends WebInstallerPage {
$this->parent->disableLinkPopups();
$this->addHTML(
$this->parent->getInfoBox(
- wfMsgNoTrans( 'config-install-done',
+ wfMessage( 'config-install-done',
$lsUrl,
$this->getVar( 'wgServer' ) .
$this->getVar( 'wgScriptPath' ) . '/index' .
$this->getVar( 'wgScriptExtension' ),
'<downloadlink/>'
- ), 'tick-32.png'
+ )->plain(), 'tick-32.png'
)
);
$this->parent->restoreLinkPopups();
@@ -1230,7 +1249,7 @@ class WebInstaller_Restart extends WebInstallerPage {
}
$this->startForm();
- $s = $this->parent->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
+ $s = $this->parent->getWarningBox( wfMessage( 'config-help-restart' )->plain() );
$this->addHTML( $s );
$this->endForm( 'restart' );
}
@@ -1250,7 +1269,11 @@ abstract class WebInstaller_Document extends WebInstallerPage {
}
public function getFileContents() {
- return file_get_contents( dirname( __FILE__ ) . '/../../' . $this->getFileName() );
+ $file = __DIR__ . '/../../' . $this->getFileName();
+ if( ! file_exists( $file ) ) {
+ return wfMessage( 'config-nofile', $file )->plain();
+ }
+ return file_get_contents( $file );
}
}
@@ -1260,7 +1283,15 @@ class WebInstaller_Readme extends WebInstaller_Document {
}
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 {