2010-07-19 04:05:44 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Base code for web installer pages.
|
|
|
|
|
*
|
2012-05-06 05:50:15 +00:00
|
|
|
* 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
|
|
|
|
|
*
|
2010-08-21 18:20:09 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Deployment
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Abstract class to define pages for the web installer.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-29 18:36:39 +00:00
|
|
|
* @ingroup Deployment
|
|
|
|
|
* @since 1.17
|
2010-07-19 04:05:44 +00:00
|
|
|
*/
|
|
|
|
|
abstract class WebInstallerPage {
|
2010-11-05 13:14:24 +00:00
|
|
|
|
2010-07-20 13:53:03 +00:00
|
|
|
/**
|
|
|
|
|
* The WebInstaller object this WebInstallerPage belongs to.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-20 13:53:03 +00:00
|
|
|
* @var WebInstaller
|
|
|
|
|
*/
|
|
|
|
|
public $parent;
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function execute();
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param WebInstaller $parent
|
2010-08-21 15:20:23 +00:00
|
|
|
*/
|
2010-07-20 13:53:03 +00:00
|
|
|
public function __construct( WebInstaller $parent ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent = $parent;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-21 01:13:45 +00:00
|
|
|
/**
|
|
|
|
|
* 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
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @return bool Always false in this default implementation.
|
2011-06-21 01:13:45 +00:00
|
|
|
*/
|
|
|
|
|
public function isSlow() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $html
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function addHTML( $html ) {
|
|
|
|
|
$this->parent->output->addHTML( $html );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startForm() {
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
"<div class=\"config-section\">\n" .
|
2010-11-04 23:21:24 +00:00
|
|
|
Html::openElement(
|
2010-07-19 04:05:44 +00:00
|
|
|
'form',
|
|
|
|
|
array(
|
|
|
|
|
'method' => 'post',
|
|
|
|
|
'action' => $this->parent->getUrl( array( 'page' => $this->getName() ) )
|
|
|
|
|
)
|
|
|
|
|
) . "\n"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 00:38:27 +00:00
|
|
|
/**
|
|
|
|
|
* @param string|bool $continue
|
|
|
|
|
* @param string|bool $back
|
|
|
|
|
*/
|
2010-12-10 03:02:03 +00:00
|
|
|
public function endForm( $continue = 'continue', $back = 'back' ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$s = "<div class=\"config-submit\">\n";
|
|
|
|
|
$id = $this->getId();
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $id === false ) {
|
2010-10-31 16:20:48 +00:00
|
|
|
$s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $continue ) {
|
2010-12-06 13:21:46 +00:00
|
|
|
// Fake submit button for enter keypress (bug 26267)
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: config-continue, config-restart, config-regenerate
|
2013-10-08 11:43:42 +00:00
|
|
|
$s .= Xml::submitButton(
|
|
|
|
|
wfMessage( "config-$continue" )->text(),
|
|
|
|
|
array(
|
|
|
|
|
'name' => "enter-$continue",
|
|
|
|
|
'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0'
|
|
|
|
|
)
|
|
|
|
|
) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-12-10 03:02:03 +00:00
|
|
|
if ( $back ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Message: config-back
|
2013-10-08 11:43:42 +00:00
|
|
|
$s .= Xml::submitButton(
|
|
|
|
|
wfMessage( "config-$back" )->text(),
|
2010-07-19 04:05:44 +00:00
|
|
|
array(
|
2010-12-10 03:02:03 +00:00
|
|
|
'name' => "submit-$back",
|
2010-07-19 04:05:44 +00:00
|
|
|
'tabindex' => $this->parent->nextTabIndex()
|
2013-10-08 11:43:42 +00:00
|
|
|
)
|
|
|
|
|
) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $continue ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: config-continue, config-restart, config-regenerate
|
2013-10-08 11:43:42 +00:00
|
|
|
$s .= Xml::submitButton(
|
|
|
|
|
wfMessage( "config-$continue" )->text(),
|
2010-07-19 04:05:44 +00:00
|
|
|
array(
|
|
|
|
|
'name' => "submit-$continue",
|
|
|
|
|
'tabindex' => $this->parent->nextTabIndex(),
|
2013-10-08 11:43:42 +00:00
|
|
|
)
|
|
|
|
|
) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$s .= "</div></form></div>\n";
|
|
|
|
|
$this->addHTML( $s );
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function getName() {
|
2014-05-12 16:32:46 +00:00
|
|
|
return str_replace( 'WebInstaller', '', get_class( $this ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-11-10 12:58:22 +00:00
|
|
|
protected function getId() {
|
2010-07-19 04:05:44 +00:00
|
|
|
return array_search( $this->getName(), $this->parent->pageSequence );
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $var
|
2014-06-10 11:41:29 +00:00
|
|
|
* @param mixed $default
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2014-06-10 11:41:29 +00:00
|
|
|
public function getVar( $var, $default = null ) {
|
|
|
|
|
return $this->parent->getVar( $var, $default );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @param mixed $value
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function setVar( $name, $value ) {
|
|
|
|
|
$this->parent->setVar( $name, $value );
|
|
|
|
|
}
|
2010-10-26 12:05:57 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the starting tags of a fieldset.
|
|
|
|
|
*
|
2014-07-24 17:43:03 +00:00
|
|
|
* @param string $legend Message name
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
2010-10-26 12:05:57 +00:00
|
|
|
*/
|
|
|
|
|
protected function getFieldsetStart( $legend ) {
|
2012-08-21 19:58:47 +00:00
|
|
|
return "\n<fieldset><legend>" . wfMessage( $legend )->escaped() . "</legend>\n";
|
2010-10-26 12:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the end tag of a fieldset.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2011-10-13 18:44:26 +00:00
|
|
|
* @return string
|
2010-10-26 12:05:57 +00:00
|
|
|
*/
|
|
|
|
|
protected function getFieldsetEnd() {
|
|
|
|
|
return "</fieldset>\n";
|
|
|
|
|
}
|
2011-03-30 17:32:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Opens a textarea used to display the progress of a long operation
|
|
|
|
|
*/
|
|
|
|
|
protected function startLiveBox() {
|
|
|
|
|
$this->addHTML(
|
2011-11-06 21:31:52 +00:00
|
|
|
'<div id="config-spinner" style="display:none;">' .
|
2014-08-11 01:59:22 +00:00
|
|
|
'<img src="images/ajax-loader.gif" /></div>' .
|
2011-03-30 17:32:20 +00:00
|
|
|
'<script>jQuery( "#config-spinner" ).show();</script>' .
|
2011-11-06 21:31:52 +00:00
|
|
|
'<div id="config-live-log">' .
|
|
|
|
|
'<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
|
2011-03-30 17:32:20 +00:00
|
|
|
);
|
|
|
|
|
$this->parent->output->flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* Opposite to WebInstallerPage::startLiveBox
|
2011-03-30 17:32:20 +00:00
|
|
|
*/
|
|
|
|
|
protected function endLiveBox() {
|
2011-06-10 20:16:42 +00:00
|
|
|
$this->addHTML( '</textarea></div>
|
2011-03-30 17:32:20 +00:00
|
|
|
<script>jQuery( "#config-spinner" ).hide()</script>' );
|
|
|
|
|
$this->parent->output->flush();
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerLanguage extends WebInstallerPage {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
global $wgLang;
|
|
|
|
|
$r = $this->parent->request;
|
2011-11-23 00:03:42 +00:00
|
|
|
$userLang = $r->getVal( 'uselang' );
|
2010-07-19 04:05:44 +00:00
|
|
|
$contLang = $r->getVal( 'ContLang' );
|
|
|
|
|
|
2012-03-08 20:56:26 +00:00
|
|
|
$languages = Language::fetchLanguageNames();
|
2010-07-19 04:05:44 +00:00
|
|
|
$lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
|
|
|
|
|
if ( !$lifetime ) {
|
|
|
|
|
$lifetime = 1440; // PHP default
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $r->wasPosted() ) {
|
|
|
|
|
# Do session test
|
|
|
|
|
if ( $this->parent->getSession( 'test' ) === null ) {
|
|
|
|
|
$requestTime = $r->getVal( 'LanguageRequestTime' );
|
|
|
|
|
if ( !$requestTime ) {
|
|
|
|
|
// The most likely explanation is that the user was knocked back
|
|
|
|
|
// from another page on POST due to session expiry
|
|
|
|
|
$msg = 'config-session-expired';
|
|
|
|
|
} elseif ( time() - $requestTime > $lifetime ) {
|
|
|
|
|
$msg = 'config-session-expired';
|
|
|
|
|
} else {
|
|
|
|
|
$msg = 'config-no-session';
|
|
|
|
|
}
|
|
|
|
|
$this->parent->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
|
|
|
|
|
} else {
|
|
|
|
|
if ( isset( $languages[$userLang] ) ) {
|
|
|
|
|
$this->setVar( '_UserLang', $userLang );
|
|
|
|
|
}
|
|
|
|
|
if ( isset( $languages[$contLang] ) ) {
|
|
|
|
|
$this->setVar( 'wgLanguageCode', $contLang );
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $this->parent->showSessionWarning ) {
|
|
|
|
|
# The user was knocked back from another page to the start
|
|
|
|
|
# This probably indicates a session expiry
|
2011-11-06 21:31:52 +00:00
|
|
|
$this->parent->showError( 'config-session-expired',
|
|
|
|
|
$wgLang->formatTimePeriod( $lifetime ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->parent->setSession( 'test', true );
|
|
|
|
|
|
|
|
|
|
if ( !isset( $languages[$userLang] ) ) {
|
|
|
|
|
$userLang = $this->getVar( '_UserLang', 'en' );
|
|
|
|
|
}
|
|
|
|
|
if ( !isset( $languages[$contLang] ) ) {
|
|
|
|
|
$contLang = $this->getVar( 'wgLanguageCode', 'en' );
|
|
|
|
|
}
|
|
|
|
|
$this->startForm();
|
2010-10-31 16:33:48 +00:00
|
|
|
$s = Html::hidden( 'LanguageRequestTime', time() ) .
|
2011-11-23 00:03:42 +00:00
|
|
|
$this->getLanguageSelector( 'uselang', 'config-your-language', $userLang,
|
2011-11-06 21:31:52 +00:00
|
|
|
$this->parent->getHelpBox( 'config-your-language-help' ) ) .
|
|
|
|
|
$this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang,
|
|
|
|
|
$this->parent->getHelpBox( 'config-wiki-language-help' ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML( $s );
|
2010-12-10 03:02:03 +00:00
|
|
|
$this->endForm( 'continue', false );
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
return null;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-07-10 12:48:06 +00:00
|
|
|
* Get a "<select>" for selecting languages.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @param string $label
|
|
|
|
|
* @param string $selectedCode
|
|
|
|
|
* @param string $helpHtml
|
|
|
|
|
*
|
2011-05-02 16:58:29 +00:00
|
|
|
* @return string
|
2010-07-19 04:05:44 +00:00
|
|
|
*/
|
2011-05-20 23:36:26 +00:00
|
|
|
public function getLanguageSelector( $name, $label, $selectedCode, $helpHtml = '' ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
global $wgDummyLanguageCodes;
|
2011-05-20 23:36:26 +00:00
|
|
|
|
|
|
|
|
$s = $helpHtml;
|
|
|
|
|
|
2011-11-06 21:31:52 +00:00
|
|
|
$s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name,
|
|
|
|
|
'tabindex' => $this->parent->nextTabIndex() ) ) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2012-03-08 20:56:26 +00:00
|
|
|
$languages = Language::fetchLanguageNames();
|
2010-07-19 04:05:44 +00:00
|
|
|
ksort( $languages );
|
|
|
|
|
foreach ( $languages as $code => $lang ) {
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( isset( $wgDummyLanguageCodes[$code] ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
$s .= "\n" . Xml::option( "$code - $lang", $code, $code == $selectedCode );
|
|
|
|
|
}
|
|
|
|
|
$s .= "\n</select>\n";
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return $this->parent->label( $label, $name, $s );
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerExistingWiki extends WebInstallerPage {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
public function execute() {
|
|
|
|
|
// If there is no LocalSettings.php, continue to the installer welcome page
|
2011-06-05 19:52:03 +00:00
|
|
|
$vars = Installer::getExistingLocalSettings();
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
if ( !$vars ) {
|
|
|
|
|
return 'skip';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if the upgrade key supplied to the user has appeared in LocalSettings.php
|
|
|
|
|
if ( $vars['wgUpgradeKey'] !== false
|
|
|
|
|
&& $this->getVar( '_UpgradeKeySupplied' )
|
2013-10-08 11:43:42 +00:00
|
|
|
&& $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey']
|
|
|
|
|
) {
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
// It's there, so the user is authorized
|
|
|
|
|
$status = $this->handleExistingUpgrade( $vars );
|
|
|
|
|
if ( $status->isOK() ) {
|
|
|
|
|
return 'skip';
|
|
|
|
|
} else {
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->parent->showStatusBox( $status );
|
|
|
|
|
$this->endForm( 'continue' );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If there is no $wgUpgradeKey, tell the user to add one to LocalSettings.php
|
|
|
|
|
if ( $vars['wgUpgradeKey'] === false ) {
|
|
|
|
|
if ( $this->getVar( 'wgUpgradeKey', false ) === false ) {
|
2011-05-05 08:20:15 +00:00
|
|
|
$secretKey = $this->getVar( 'wgSecretKey' ); // preserve $wgSecretKey
|
|
|
|
|
$this->parent->generateKeys();
|
|
|
|
|
$this->setVar( 'wgSecretKey', $secretKey );
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
$this->setVar( '_UpgradeKeySupplied', true );
|
|
|
|
|
}
|
|
|
|
|
$this->startForm();
|
2010-12-16 11:20:39 +00:00
|
|
|
$this->addHTML( $this->parent->getInfoBox(
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( 'config-upgrade-key-missing', "<pre dir=\"ltr\">\$wgUpgradeKey = '" .
|
|
|
|
|
$this->getVar( 'wgUpgradeKey' ) . "';</pre>" )->plain()
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
) );
|
|
|
|
|
$this->endForm( 'continue' );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If there is an upgrade key, but it wasn't supplied, prompt the user to enter it
|
2010-12-16 11:20:39 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
$r = $this->parent->request;
|
|
|
|
|
if ( $r->wasPosted() ) {
|
|
|
|
|
$key = $r->getText( 'config_wgUpgradeKey' );
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( !$key || $key !== $vars['wgUpgradeKey'] ) {
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
$this->parent->showError( 'config-localsettings-badkey' );
|
|
|
|
|
$this->showKeyForm();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
// Key was OK
|
|
|
|
|
$status = $this->handleExistingUpgrade( $vars );
|
|
|
|
|
if ( $status->isOK() ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
} else {
|
|
|
|
|
$this->parent->showStatusBox( $status );
|
|
|
|
|
$this->showKeyForm();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->showKeyForm();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the "enter key" form
|
|
|
|
|
*/
|
|
|
|
|
protected function showKeyForm() {
|
|
|
|
|
$this->startForm();
|
2010-12-16 11:20:39 +00:00
|
|
|
$this->addHTML(
|
2013-04-13 11:36:24 +00:00
|
|
|
$this->parent->getInfoBox( wfMessage( 'config-localsettings-upgrade' )->plain() ) .
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
'<br />' .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgUpgradeKey',
|
|
|
|
|
'label' => 'config-localsettings-key',
|
|
|
|
|
'attribs' => array( 'autocomplete' => 'off' ),
|
|
|
|
|
) )
|
|
|
|
|
);
|
|
|
|
|
$this->endForm( 'continue' );
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string[] $names
|
|
|
|
|
* @param mixed[] $vars
|
|
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
protected function importVariables( $names, $vars ) {
|
|
|
|
|
$status = Status::newGood();
|
|
|
|
|
foreach ( $names as $name ) {
|
|
|
|
|
if ( !isset( $vars[$name] ) ) {
|
|
|
|
|
$status->fatal( 'config-localsettings-incomplete', $name );
|
|
|
|
|
}
|
|
|
|
|
$this->setVar( $name, $vars[$name] );
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initiate an upgrade of the existing database
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @param mixed[] $vars Variables from LocalSettings.php
|
|
|
|
|
*
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
protected function handleExistingUpgrade( $vars ) {
|
|
|
|
|
// Check $wgDBtype
|
2011-11-06 21:31:52 +00:00
|
|
|
if ( !isset( $vars['wgDBtype'] ) ||
|
2013-10-08 11:43:42 +00:00
|
|
|
!in_array( $vars['wgDBtype'], Installer::getDBTypes() )
|
|
|
|
|
) {
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return Status::newFatal( 'config-localsettings-connection-error', '' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the relevant variables from LocalSettings.php
|
2011-01-14 07:05:21 +00:00
|
|
|
$requiredVars = array( 'wgDBtype' );
|
2013-02-03 19:28:43 +00:00
|
|
|
$status = $this->importVariables( $requiredVars, $vars );
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
$installer = $this->parent->getDBInstaller();
|
|
|
|
|
$status->merge( $this->importVariables( $installer->getGlobalNames(), $vars ) );
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $vars['wgDBadminuser'] ) ) {
|
|
|
|
|
$this->setVar( '_InstallUser', $vars['wgDBadminuser'] );
|
|
|
|
|
} else {
|
|
|
|
|
$this->setVar( '_InstallUser', $vars['wgDBuser'] );
|
|
|
|
|
}
|
|
|
|
|
if ( isset( $vars['wgDBadminpassword'] ) ) {
|
|
|
|
|
$this->setVar( '_InstallPassword', $vars['wgDBadminpassword'] );
|
|
|
|
|
} else {
|
|
|
|
|
$this->setVar( '_InstallPassword', $vars['wgDBpassword'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test the database connection
|
|
|
|
|
$status = $installer->getConnection();
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
// Adjust the error message to explain things correctly
|
2010-12-16 11:20:39 +00:00
|
|
|
$status->replaceMessage( 'config-connection-error',
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
'config-localsettings-connection-error' );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// All good
|
|
|
|
|
$this->setVar( '_ExistingDBSettings', true );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerWelcome extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $this->parent->request->wasPosted() ) {
|
|
|
|
|
if ( $this->getVar( '_Environment' ) ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-21 19:58:47 +00:00
|
|
|
$this->parent->output->addWikiText( wfMessage( 'config-welcome' )->plain() );
|
2010-07-19 04:05:44 +00:00
|
|
|
$status = $this->parent->doEnvironmentChecks();
|
2011-01-05 23:20:12 +00:00
|
|
|
if ( $status->isGood() ) {
|
|
|
|
|
$this->parent->output->addHTML( '<span class="success-message">' .
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( 'config-env-good' )->escaped() . '</span>' );
|
|
|
|
|
$this->parent->output->addWikiText( wfMessage( 'config-copyright',
|
|
|
|
|
SpecialVersion::getCopyrightAndAuthorList() )->plain() );
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->startForm();
|
|
|
|
|
$this->endForm();
|
2011-01-05 23:20:12 +00:00
|
|
|
} else {
|
|
|
|
|
$this->parent->showStatusMessage( $status );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2012-12-09 02:59:04 +00:00
|
|
|
return '';
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerDBConnect extends WebInstallerPage {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2013-12-27 17:01:34 +00:00
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* @return string|null When string, "skip" or "continue"
|
2013-12-27 17:01:34 +00:00
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
if ( $this->getVar( '_ExistingDBSettings' ) ) {
|
|
|
|
|
return 'skip';
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$r = $this->parent->request;
|
|
|
|
|
if ( $r->wasPosted() ) {
|
|
|
|
|
$status = $this->submit();
|
2011-02-12 04:06:22 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $status->isGood() ) {
|
|
|
|
|
$this->setVar( '_UpgradeDone', false );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return 'continue';
|
|
|
|
|
} else {
|
|
|
|
|
$this->parent->showStatusBox( $status );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
|
|
|
|
|
$types = "<ul class=\"config-settings-block\">\n";
|
|
|
|
|
$settings = '';
|
|
|
|
|
$defaultType = $this->getVar( 'wgDBtype' );
|
2010-08-22 20:55:07 +00:00
|
|
|
|
2014-01-09 01:50:21 +00:00
|
|
|
// Messages: config-dbsupport-mysql, config-dbsupport-postgres, config-dbsupport-oracle,
|
2014-02-23 23:40:20 +00:00
|
|
|
// config-dbsupport-sqlite, config-dbsupport-mssql
|
2010-08-22 21:52:39 +00:00
|
|
|
$dbSupport = '';
|
2014-01-11 22:57:47 +00:00
|
|
|
foreach ( Installer::getDBTypes() as $type ) {
|
2014-01-09 01:50:21 +00:00
|
|
|
$dbSupport .= wfMessage( "config-dbsupport-$type" )->plain() . "\n";
|
2010-08-22 21:52:39 +00:00
|
|
|
}
|
2010-08-22 20:55:07 +00:00
|
|
|
$this->addHTML( $this->parent->getInfoBox(
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( 'config-support-info', trim( $dbSupport ) )->text() ) );
|
2010-08-22 20:55:07 +00:00
|
|
|
|
2013-04-23 03:15:39 +00:00
|
|
|
// It's possible that the library for the default DB type is not compiled in.
|
|
|
|
|
// In that case, instead select the first supported DB type in the list.
|
2013-05-25 10:59:13 +00:00
|
|
|
$compiledDBs = $this->parent->getCompiledDBs();
|
2013-04-23 03:15:39 +00:00
|
|
|
if ( !in_array( $defaultType, $compiledDBs ) ) {
|
|
|
|
|
$defaultType = $compiledDBs[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ( $compiledDBs as $type ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$installer = $this->parent->getDBInstaller( $type );
|
|
|
|
|
$types .=
|
|
|
|
|
'<li>' .
|
|
|
|
|
Xml::radioLabel(
|
|
|
|
|
$installer->getReadableName(),
|
|
|
|
|
'DBType',
|
|
|
|
|
$type,
|
|
|
|
|
"DBType_$type",
|
|
|
|
|
$type == $defaultType,
|
|
|
|
|
array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
|
|
|
|
|
) .
|
|
|
|
|
"</li>\n";
|
|
|
|
|
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: config-header-mysql, config-header-postgres, config-header-oracle,
|
|
|
|
|
// config-header-sqlite
|
2013-10-08 11:43:42 +00:00
|
|
|
$settings .= Html::openElement(
|
|
|
|
|
'div',
|
|
|
|
|
array(
|
|
|
|
|
'id' => 'DB_wrapper_' . $type,
|
|
|
|
|
'class' => 'dbWrapper'
|
|
|
|
|
)
|
|
|
|
|
) .
|
2012-08-21 19:58:47 +00:00
|
|
|
Html::element( 'h3', array(), wfMessage( 'config-header-' . $type )->text() ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
$installer->getConnectForm() .
|
|
|
|
|
"</div>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-08 11:43:42 +00:00
|
|
|
$types .= "</ul><br style=\"clear: left\"/>\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2013-10-08 11:43:42 +00:00
|
|
|
$this->addHTML( $this->parent->label( 'config-db-type', false, $types ) . $settings );
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->endForm();
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
return null;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function submit() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$r = $this->parent->request;
|
|
|
|
|
$type = $r->getVal( 'DBType' );
|
2013-04-23 03:15:39 +00:00
|
|
|
if ( !$type ) {
|
|
|
|
|
return Status::newFatal( 'config-invalid-db-type' );
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->setVar( 'wgDBtype', $type );
|
|
|
|
|
$installer = $this->parent->getDBInstaller( $type );
|
|
|
|
|
if ( !$installer ) {
|
|
|
|
|
return Status::newFatal( 'config-invalid-db-type' );
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return $installer->submitConnectForm();
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerUpgrade extends WebInstallerPage {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return bool Always true.
|
|
|
|
|
*/
|
2011-06-21 01:13:45 +00:00
|
|
|
public function isSlow() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $this->getVar( '_UpgradeDone' ) ) {
|
2010-12-19 04:31:15 +00:00
|
|
|
// Allow regeneration of LocalSettings.php, unless we are working
|
2010-12-10 03:02:03 +00:00
|
|
|
// from a pre-existing LocalSettings.php file and we want to avoid
|
|
|
|
|
// leaking its contents
|
|
|
|
|
if ( $this->parent->request->wasPosted() && !$this->getVar( '_ExistingDBSettings' ) ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
// Done message acknowledged
|
|
|
|
|
return 'continue';
|
|
|
|
|
} else {
|
|
|
|
|
// Back button click
|
|
|
|
|
// Show the done message again
|
|
|
|
|
// Make them click back again if they want to do the upgrade again
|
|
|
|
|
$this->showDoneMessage();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wgDBtype is generally valid here because otherwise the previous page
|
|
|
|
|
// (connect) wouldn't have declared its happiness
|
|
|
|
|
$type = $this->getVar( 'wgDBtype' );
|
|
|
|
|
$installer = $this->parent->getDBInstaller( $type );
|
|
|
|
|
|
|
|
|
|
if ( !$installer->needsUpgrade() ) {
|
|
|
|
|
return 'skip';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->parent->request->wasPosted() ) {
|
2010-08-22 10:37:27 +00:00
|
|
|
$installer->preUpgrade();
|
2011-03-30 17:32:20 +00:00
|
|
|
|
|
|
|
|
$this->startLiveBox();
|
2010-07-19 04:05:44 +00:00
|
|
|
$result = $installer->doUpgrade();
|
2011-03-30 17:32:20 +00:00
|
|
|
$this->endLiveBox();
|
|
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $result ) {
|
2011-03-29 17:06:26 +00:00
|
|
|
// If they're going to possibly regenerate LocalSettings, we
|
|
|
|
|
// need to create the upgrade/secret keys. Bug 26481
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( !$this->getVar( '_ExistingDBSettings' ) ) {
|
2011-03-29 19:00:23 +00:00
|
|
|
$this->parent->generateKeys();
|
2011-03-29 17:06:26 +00:00
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->setVar( '_UpgradeDone', true );
|
|
|
|
|
$this->showDoneMessage();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML( $this->parent->getInfoBox(
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( 'config-can-upgrade', $GLOBALS['wgVersion'] )->plain() ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->endForm();
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
return null;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function showDoneMessage() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->startForm();
|
2010-12-10 03:02:03 +00:00
|
|
|
$regenerate = !$this->getVar( '_ExistingDBSettings' );
|
|
|
|
|
if ( $regenerate ) {
|
|
|
|
|
$msg = 'config-upgrade-done';
|
|
|
|
|
} else {
|
|
|
|
|
$msg = 'config-upgrade-done-no-regenerate';
|
|
|
|
|
}
|
|
|
|
|
$this->parent->disableLinkPopups();
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getInfoBox(
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( $msg,
|
2011-06-15 07:35:47 +00:00
|
|
|
$this->getVar( 'wgServer' ) .
|
2013-10-08 11:43:42 +00:00
|
|
|
$this->getVar( 'wgScriptPath' ) . '/index' .
|
|
|
|
|
$this->getVar( 'wgScriptExtension' )
|
2012-08-21 19:58:47 +00:00
|
|
|
)->plain(), 'tick-32.png'
|
2010-07-19 04:05:44 +00:00
|
|
|
)
|
|
|
|
|
);
|
2010-12-10 03:02:03 +00:00
|
|
|
$this->parent->restoreLinkPopups();
|
|
|
|
|
$this->endForm( $regenerate ? 'regenerate' : false, false );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerDBSettings extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$installer = $this->parent->getDBInstaller( $this->getVar( 'wgDBtype' ) );
|
|
|
|
|
|
|
|
|
|
$r = $this->parent->request;
|
|
|
|
|
if ( $r->wasPosted() ) {
|
|
|
|
|
$status = $installer->submitSettingsForm();
|
|
|
|
|
if ( $status === false ) {
|
|
|
|
|
return 'skip';
|
|
|
|
|
} elseif ( $status->isGood() ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
} else {
|
|
|
|
|
$this->parent->showStatusBox( $status );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$form = $installer->getSettingsForm();
|
|
|
|
|
if ( $form === false ) {
|
|
|
|
|
return 'skip';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML( $form );
|
|
|
|
|
$this->endForm();
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
return null;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerName extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$r = $this->parent->request;
|
|
|
|
|
if ( $r->wasPosted() ) {
|
|
|
|
|
if ( $this->submit() ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
|
2011-03-06 19:52:23 +00:00
|
|
|
// 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' ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->setVar( 'wgSitename', '' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set wgMetaNamespace to something valid before we show the form.
|
|
|
|
|
// $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
|
|
|
|
|
$metaNS = $this->getVar( 'wgMetaNamespace' );
|
2012-08-21 19:58:47 +00:00
|
|
|
$this->setVar(
|
|
|
|
|
'wgMetaNamespace',
|
|
|
|
|
wfMessage( 'config-ns-other-default' )->inContentLanguage()->text()
|
|
|
|
|
);
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgSitename',
|
|
|
|
|
'label' => 'config-site-name',
|
2013-02-03 19:28:43 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-site-name-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2013-03-18 10:26:57 +00:00
|
|
|
// getRadioSet() builds a set of labeled radio buttons.
|
|
|
|
|
// For grep: The following messages are used as the item labels:
|
|
|
|
|
// config-ns-site-name, config-ns-generic, config-ns-other
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => '_NamespaceType',
|
|
|
|
|
'label' => 'config-project-namespace',
|
|
|
|
|
'itemLabelPrefix' => 'config-ns-',
|
|
|
|
|
'values' => array( 'site-name', 'generic', 'other' ),
|
2011-11-06 21:31:52 +00:00
|
|
|
'commonAttribs' => array( 'class' => 'enableForOther',
|
|
|
|
|
'rel' => 'config_wgMetaNamespace' ),
|
2010-12-06 20:04:28 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-project-namespace-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgMetaNamespace',
|
2013-10-23 12:16:03 +00:00
|
|
|
'label' => '', // @todo Needs a label?
|
|
|
|
|
'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetStart( 'config-admin-box' ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => '_AdminName',
|
2010-11-08 20:40:55 +00:00
|
|
|
'label' => 'config-admin-name',
|
|
|
|
|
'help' => $this->parent->getHelpBox( 'config-admin-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
|
|
|
|
$this->parent->getPasswordBox( array(
|
|
|
|
|
'var' => '_AdminPassword',
|
|
|
|
|
'label' => 'config-admin-password',
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getPasswordBox( array(
|
2013-05-26 09:41:10 +00:00
|
|
|
'var' => '_AdminPasswordConfirm',
|
2010-07-19 04:05:44 +00:00
|
|
|
'label' => 'config-admin-password-confirm'
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => '_AdminEmail',
|
2014-09-06 12:12:33 +00:00
|
|
|
'attribs' => array(
|
|
|
|
|
'dir' => 'ltr',
|
|
|
|
|
),
|
2010-12-06 20:04:28 +00:00
|
|
|
'label' => 'config-admin-email',
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-admin-email-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2011-01-05 22:37:14 +00:00
|
|
|
$this->parent->getCheckBox( array(
|
2010-07-19 04:05:44 +00:00
|
|
|
'var' => '_Subscribe',
|
2010-12-06 20:04:28 +00:00
|
|
|
'label' => 'config-subscribe',
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-subscribe-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetEnd() .
|
2012-08-21 19:58:47 +00:00
|
|
|
$this->parent->getInfoBox( wfMessage( 'config-almost-done' )->text() ) .
|
2013-03-18 10:26:57 +00:00
|
|
|
// getRadioSet() builds a set of labeled radio buttons.
|
|
|
|
|
// For grep: The following messages are used as the item labels:
|
|
|
|
|
// config-optional-continue, config-optional-skip
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => '_SkipOptional',
|
|
|
|
|
'itemLabelPrefix' => 'config-optional-',
|
|
|
|
|
'values' => array( 'continue', 'skip' )
|
|
|
|
|
) )
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Restore the default value
|
|
|
|
|
$this->setVar( 'wgMetaNamespace', $metaNS );
|
|
|
|
|
|
|
|
|
|
$this->endForm();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function submit() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$retVal = true;
|
|
|
|
|
$this->parent->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
|
2013-05-26 09:41:10 +00:00
|
|
|
'_AdminName', '_AdminPassword', '_AdminPasswordConfirm', '_AdminEmail',
|
2011-01-28 21:02:36 +00:00
|
|
|
'_Subscribe', '_SkipOptional', 'wgMetaNamespace' ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
// Validate site name
|
|
|
|
|
if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
|
|
|
|
|
$this->parent->showError( 'config-site-name-blank' );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fetch namespace
|
|
|
|
|
$nsType = $this->getVar( '_NamespaceType' );
|
|
|
|
|
if ( $nsType == 'site-name' ) {
|
|
|
|
|
$name = $this->getVar( 'wgSitename' );
|
|
|
|
|
// Sanitize for namespace
|
|
|
|
|
// This algorithm should match the JS one in WebInstallerOutput.php
|
|
|
|
|
$name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
|
|
|
|
|
$name = str_replace( '&', '&', $name );
|
|
|
|
|
$name = preg_replace( '/__+/', '_', $name );
|
|
|
|
|
$name = ucfirst( trim( $name, '_' ) );
|
|
|
|
|
} elseif ( $nsType == 'generic' ) {
|
2012-08-21 19:58:47 +00:00
|
|
|
$name = wfMessage( 'config-ns-generic' )->text();
|
2010-07-19 04:05:44 +00:00
|
|
|
} else { // other
|
|
|
|
|
$name = $this->getVar( 'wgMetaNamespace' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate namespace
|
|
|
|
|
if ( strpos( $name, ':' ) !== false ) {
|
|
|
|
|
$good = false;
|
|
|
|
|
} else {
|
|
|
|
|
// Title-style validation
|
|
|
|
|
$title = Title::newFromText( $name );
|
|
|
|
|
if ( !$title ) {
|
2010-09-27 14:24:13 +00:00
|
|
|
$good = $nsType == 'site-name';
|
2010-07-19 04:05:44 +00:00
|
|
|
} else {
|
|
|
|
|
$name = $title->getDBkey();
|
|
|
|
|
$good = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( !$good ) {
|
|
|
|
|
$this->parent->showError( 'config-ns-invalid', $name );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
2011-02-28 23:15:14 +00:00
|
|
|
|
|
|
|
|
// Make sure it won't conflict with any existing namespaces
|
|
|
|
|
global $wgContLang;
|
|
|
|
|
$nsIndex = $wgContLang->getNsIndex( $name );
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $nsIndex !== false && $nsIndex !== NS_PROJECT ) {
|
2011-02-28 23:15:14 +00:00
|
|
|
$this->parent->showError( 'config-ns-conflict', $name );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->setVar( 'wgMetaNamespace', $name );
|
|
|
|
|
|
|
|
|
|
// Validate username for creation
|
|
|
|
|
$name = $this->getVar( '_AdminName' );
|
|
|
|
|
if ( strval( $name ) === '' ) {
|
|
|
|
|
$this->parent->showError( 'config-admin-name-blank' );
|
|
|
|
|
$cname = $name;
|
|
|
|
|
$retVal = false;
|
|
|
|
|
} else {
|
|
|
|
|
$cname = User::getCanonicalName( $name, 'creatable' );
|
|
|
|
|
if ( $cname === false ) {
|
|
|
|
|
$this->parent->showError( 'config-admin-name-invalid', $name );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
} else {
|
|
|
|
|
$this->setVar( '_AdminName', $cname );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate password
|
|
|
|
|
$msg = false;
|
|
|
|
|
$pwd = $this->getVar( '_AdminPassword' );
|
|
|
|
|
$user = User::newFromName( $cname );
|
2014-01-28 13:31:48 +00:00
|
|
|
if ( $user ) {
|
|
|
|
|
$valid = $user->getPasswordValidity( $pwd );
|
|
|
|
|
} else {
|
|
|
|
|
$valid = 'config-admin-name-invalid';
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( strval( $pwd ) === '' ) {
|
|
|
|
|
# $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
|
|
|
|
|
# This message is more specific and helpful.
|
|
|
|
|
$msg = 'config-admin-password-blank';
|
2013-05-26 09:41:10 +00:00
|
|
|
} elseif ( $pwd !== $this->getVar( '_AdminPasswordConfirm' ) ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$msg = 'config-admin-password-mismatch';
|
|
|
|
|
} elseif ( $valid !== true ) {
|
|
|
|
|
$msg = $valid;
|
|
|
|
|
}
|
|
|
|
|
if ( $msg !== false ) {
|
2011-01-25 15:36:36 +00:00
|
|
|
call_user_func_array( array( $this->parent, 'showError' ), (array)$msg );
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->setVar( '_AdminPassword', '' );
|
2013-05-26 09:41:10 +00:00
|
|
|
$this->setVar( '_AdminPasswordConfirm', '' );
|
2010-07-19 04:05:44 +00:00
|
|
|
$retVal = false;
|
|
|
|
|
}
|
2011-01-05 22:37:14 +00:00
|
|
|
|
|
|
|
|
// Validate e-mail if provided
|
|
|
|
|
$email = $this->getVar( '_AdminEmail' );
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $email && !Sanitizer::validateEmail( $email ) ) {
|
2011-01-05 22:37:14 +00:00
|
|
|
$this->parent->showError( 'config-admin-error-bademail' );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
2011-06-10 03:27:37 +00:00
|
|
|
// If they asked to subscribe to mediawiki-announce but didn't give
|
|
|
|
|
// an e-mail, show an error. Bug 29332
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( !$email && $this->getVar( '_Subscribe' ) ) {
|
2011-06-10 03:27:37 +00:00
|
|
|
$this->parent->showError( 'config-subscribe-noemail' );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
2011-01-05 22:37:14 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return $retVal;
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerOptions extends WebInstallerPage {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
|
2014-06-10 11:41:29 +00:00
|
|
|
$this->submitSkins();
|
2010-07-19 04:05:44 +00:00
|
|
|
return 'skip';
|
|
|
|
|
}
|
|
|
|
|
if ( $this->parent->request->wasPosted() ) {
|
|
|
|
|
if ( $this->submit() ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-27 19:22:14 +00:00
|
|
|
$emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
# User Rights
|
2013-03-18 10:26:57 +00:00
|
|
|
// getRadioSet() builds a set of labeled radio buttons.
|
|
|
|
|
// For grep: The following messages are used as the item labels:
|
|
|
|
|
// config-profile-wiki, config-profile-no-anon, config-profile-fishbowl, config-profile-private
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => '_RightsProfile',
|
|
|
|
|
'label' => 'config-profile',
|
|
|
|
|
'itemLabelPrefix' => 'config-profile-',
|
|
|
|
|
'values' => array_keys( $this->parent->rightsProfiles ),
|
|
|
|
|
) ) .
|
2012-08-21 19:58:47 +00:00
|
|
|
$this->parent->getInfoBox( wfMessage( 'config-profile-help' )->plain() ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
# Licensing
|
2013-03-18 10:26:57 +00:00
|
|
|
// getRadioSet() builds a set of labeled radio buttons.
|
|
|
|
|
// For grep: The following messages are used as the item labels:
|
|
|
|
|
// config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa,
|
|
|
|
|
// config-license-cc-0, config-license-pd, config-license-gfdl,
|
|
|
|
|
// config-license-none, config-license-cc-choose
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => '_LicenseCode',
|
|
|
|
|
'label' => 'config-license',
|
|
|
|
|
'itemLabelPrefix' => 'config-license-',
|
|
|
|
|
'values' => array_keys( $this->parent->licenses ),
|
|
|
|
|
'commonAttribs' => array( 'class' => 'licenseRadio' ),
|
|
|
|
|
) ) .
|
|
|
|
|
$this->getCCChooser() .
|
|
|
|
|
$this->parent->getHelpBox( 'config-license-help' ) .
|
|
|
|
|
|
|
|
|
|
# E-mail
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetStart( 'config-email-settings' ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => 'wgEnableEmail',
|
|
|
|
|
'label' => 'config-enable-email',
|
|
|
|
|
'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-enable-email-help' ) .
|
2011-03-27 19:22:14 +00:00
|
|
|
"<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgPasswordSender',
|
|
|
|
|
'label' => 'config-email-sender'
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-email-sender-help' ) .
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => 'wgEnableUserEmail',
|
|
|
|
|
'label' => 'config-email-user',
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-email-user-help' ) .
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => 'wgEnotifUserTalk',
|
|
|
|
|
'label' => 'config-email-usertalk',
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-email-usertalk-help' ) .
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => 'wgEnotifWatchlist',
|
|
|
|
|
'label' => 'config-email-watchlist',
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-email-watchlist-help' ) .
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => 'wgEmailAuthentication',
|
|
|
|
|
'label' => 'config-email-auth',
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-email-auth-help' ) .
|
|
|
|
|
"</div>" .
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetEnd()
|
2010-07-19 04:05:44 +00:00
|
|
|
);
|
|
|
|
|
|
2014-06-10 11:41:29 +00:00
|
|
|
$skins = $this->parent->findExtensions( 'skins' );
|
|
|
|
|
$skinHtml = $this->getFieldSetStart( 'config-skins' );
|
|
|
|
|
|
|
|
|
|
if ( $skins ) {
|
|
|
|
|
$skinNames = array_map( 'strtolower', $skins );
|
|
|
|
|
|
|
|
|
|
$radioButtons = $this->parent->getRadioElements( array(
|
|
|
|
|
'var' => 'wgDefaultSkin',
|
|
|
|
|
'itemLabels' => array_fill_keys( $skinNames, 'config-skins-use-as-default' ),
|
|
|
|
|
'values' => $skinNames,
|
2014-09-13 18:34:52 +00:00
|
|
|
'value' => $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) ),
|
2014-06-10 11:41:29 +00:00
|
|
|
) );
|
|
|
|
|
|
|
|
|
|
foreach ( $skins as $skin ) {
|
|
|
|
|
$skinHtml .=
|
|
|
|
|
'<div class="config-skins-item">' .
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => "skin-$skin",
|
|
|
|
|
'rawtext' => $skin,
|
|
|
|
|
'value' => $this->getVar( "skin-$skin", true ), // all found skins enabled by default
|
|
|
|
|
) ) .
|
2014-07-21 12:47:42 +00:00
|
|
|
'<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] . '</div>' .
|
2014-06-10 11:41:29 +00:00
|
|
|
'</div>';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$skinHtml .= $this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$skinHtml .= $this->parent->getHelpBox( 'config-skins-help' ) .
|
|
|
|
|
$this->getFieldSetEnd();
|
|
|
|
|
$this->addHTML( $skinHtml );
|
|
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$extensions = $this->parent->findExtensions();
|
2010-12-19 04:31:15 +00:00
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $extensions ) {
|
2010-10-26 12:05:57 +00:00
|
|
|
$extHtml = $this->getFieldSetStart( 'config-extensions' );
|
2010-12-19 04:31:15 +00:00
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
foreach ( $extensions as $ext ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$extHtml .= $this->parent->getCheckBox( array(
|
2014-01-12 23:59:44 +00:00
|
|
|
'var' => "ext-$ext",
|
|
|
|
|
'rawtext' => $ext,
|
|
|
|
|
) );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-19 04:31:15 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) .
|
2013-10-08 11:43:42 +00:00
|
|
|
$this->getFieldSetEnd();
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML( $extHtml );
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-21 14:37:00 +00:00
|
|
|
// Having / in paths in Windows looks funny :)
|
|
|
|
|
$this->setVar( 'wgDeletedDirectory',
|
|
|
|
|
str_replace(
|
|
|
|
|
'/', DIRECTORY_SEPARATOR,
|
|
|
|
|
$this->getVar( 'wgDeletedDirectory' )
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2011-03-27 19:22:14 +00:00
|
|
|
$uploadwrapperStyle = $this->getVar( 'wgEnableUploads' ) ? '' : 'display: none';
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML(
|
|
|
|
|
# Uploading
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetStart( 'config-upload-settings' ) .
|
2010-12-06 20:04:28 +00:00
|
|
|
$this->parent->getCheckBox( array(
|
2010-07-19 04:05:44 +00:00
|
|
|
'var' => 'wgEnableUploads',
|
|
|
|
|
'label' => 'config-upload-enable',
|
|
|
|
|
'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-upload-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2011-03-27 19:22:14 +00:00
|
|
|
'<div id="uploadwrapper" style="' . $uploadwrapperStyle . '">' .
|
2010-12-06 20:04:28 +00:00
|
|
|
$this->parent->getTextBox( array(
|
2010-07-19 04:05:44 +00:00
|
|
|
'var' => 'wgDeletedDirectory',
|
|
|
|
|
'label' => 'config-upload-deleted',
|
2011-09-05 00:56:54 +00:00
|
|
|
'attribs' => array( 'dir' => 'ltr' ),
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-upload-deleted-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
|
|
|
|
'</div>' .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgLogo',
|
2010-12-06 20:04:28 +00:00
|
|
|
'label' => 'config-logo',
|
2011-09-05 00:56:54 +00:00
|
|
|
'attribs' => array( 'dir' => 'ltr' ),
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-logo-help' )
|
2010-12-06 20:04:28 +00:00
|
|
|
) )
|
2010-07-19 04:05:44 +00:00
|
|
|
);
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => 'wgUseInstantCommons',
|
|
|
|
|
'label' => 'config-instantcommons',
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-instantcommons-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetEnd()
|
2010-07-19 04:05:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$caches = array( 'none' );
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( count( $this->getVar( '_Caches' ) ) ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$caches[] = 'accel';
|
|
|
|
|
}
|
|
|
|
|
$caches[] = 'memcached';
|
|
|
|
|
|
2011-09-22 00:35:55 +00:00
|
|
|
// We'll hide/show this on demand when the value changes, see config.js.
|
|
|
|
|
$cacheval = $this->getVar( 'wgMainCacheType' );
|
2013-02-03 19:28:43 +00:00
|
|
|
if ( !$cacheval ) {
|
2011-09-22 00:35:55 +00:00
|
|
|
// 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';
|
|
|
|
|
}
|
2013-04-20 21:11:46 +00:00
|
|
|
$hidden = ( $cacheval == 'memcached' ) ? '' : 'display: none';
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML(
|
|
|
|
|
# Advanced settings
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetStart( 'config-advanced-settings' ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
# Object cache settings
|
2013-03-18 10:26:57 +00:00
|
|
|
// getRadioSet() builds a set of labeled radio buttons.
|
|
|
|
|
// For grep: The following messages are used as the item labels:
|
|
|
|
|
// config-cache-none, config-cache-accel, config-cache-memcached
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => 'wgMainCacheType',
|
|
|
|
|
'label' => 'config-cache-options',
|
|
|
|
|
'itemLabelPrefix' => 'config-cache-',
|
|
|
|
|
'values' => $caches,
|
2011-09-22 00:35:55 +00:00
|
|
|
'value' => $cacheval,
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-cache-help' ) .
|
2011-09-22 00:35:55 +00:00
|
|
|
"<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
|
2011-02-23 17:54:45 +00:00
|
|
|
$this->parent->getTextArea( array(
|
2010-07-19 04:05:44 +00:00
|
|
|
'var' => '_MemCachedServers',
|
|
|
|
|
'label' => 'config-memcached-servers',
|
2010-12-06 20:04:28 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-memcached-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2010-12-06 20:04:28 +00:00
|
|
|
'</div>' .
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetEnd()
|
2010-07-19 04:05:44 +00:00
|
|
|
);
|
|
|
|
|
$this->endForm();
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
return null;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-28 14:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getCCPartnerUrl() {
|
2011-06-15 07:35:47 +00:00
|
|
|
$server = $this->getVar( 'wgServer' );
|
|
|
|
|
$exitUrl = $server . $this->parent->getUrl( array(
|
2010-07-19 04:05:44 +00:00
|
|
|
'page' => 'Options',
|
|
|
|
|
'SubmitCC' => 'indeed',
|
|
|
|
|
'config__LicenseCode' => 'cc',
|
|
|
|
|
'config_wgRightsUrl' => '[license_url]',
|
|
|
|
|
'config_wgRightsText' => '[license_name]',
|
|
|
|
|
'config_wgRightsIcon' => '[license_button]',
|
|
|
|
|
) );
|
2011-06-15 07:35:47 +00:00
|
|
|
$styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
|
2014-08-11 01:59:22 +00:00
|
|
|
'/mw-config/config-cc.css';
|
2010-07-19 04:05:44 +00:00
|
|
|
$iframeUrl = 'http://creativecommons.org/license/?' .
|
2013-01-28 18:04:20 +00:00
|
|
|
wfArrayToCgi( array(
|
2010-07-19 04:05:44 +00:00
|
|
|
'partner' => 'MediaWiki',
|
|
|
|
|
'exit_url' => $exitUrl,
|
|
|
|
|
'lang' => $this->getVar( '_UserLang' ),
|
|
|
|
|
'stylesheet' => $styleUrl,
|
|
|
|
|
) );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return $iframeUrl;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getCCChooser() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$iframeAttribs = array(
|
|
|
|
|
'class' => 'config-cc-iframe',
|
|
|
|
|
'name' => 'config-cc-iframe',
|
|
|
|
|
'id' => 'config-cc-iframe',
|
|
|
|
|
'frameborder' => 0,
|
|
|
|
|
'width' => '100%',
|
|
|
|
|
'height' => '100%',
|
|
|
|
|
);
|
|
|
|
|
if ( $this->getVar( '_CCDone' ) ) {
|
|
|
|
|
$iframeAttribs['src'] = $this->parent->getUrl( array( 'ShowCC' => 'yes' ) );
|
|
|
|
|
} else {
|
|
|
|
|
$iframeAttribs['src'] = $this->getCCPartnerUrl();
|
|
|
|
|
}
|
2013-04-20 21:11:46 +00:00
|
|
|
$wrapperStyle = ( $this->getVar( '_LicenseCode' ) == 'cc-choose' ) ? '' : 'display: none';
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2013-03-24 10:01:51 +00:00
|
|
|
return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
|
2010-11-04 23:21:24 +00:00
|
|
|
Html::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
"</div>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getCCDoneBox() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
|
|
|
|
|
// If you change this height, also change it in config.css
|
|
|
|
|
$expandJs = str_replace( '$1', '54em', $js );
|
|
|
|
|
$reduceJs = str_replace( '$1', '70px', $js );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2013-04-13 11:36:24 +00:00
|
|
|
return '<p>' .
|
2010-11-04 23:21:24 +00:00
|
|
|
Html::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
'  ' .
|
|
|
|
|
htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
|
|
|
|
|
"</p>\n" .
|
2013-05-20 21:47:56 +00:00
|
|
|
"<p style=\"text-align: center;\">" .
|
2010-11-04 23:21:24 +00:00
|
|
|
Html::element( 'a',
|
2010-07-19 04:05:44 +00:00
|
|
|
array(
|
|
|
|
|
'href' => $this->getCCPartnerUrl(),
|
|
|
|
|
'onclick' => $expandJs,
|
|
|
|
|
),
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( 'config-cc-again' )->text()
|
2010-07-19 04:05:44 +00:00
|
|
|
) .
|
|
|
|
|
"</p>\n" .
|
2013-05-20 21:47:56 +00:00
|
|
|
"<script>\n" .
|
2010-07-19 04:05:44 +00:00
|
|
|
# Reduce the wrapper div height
|
|
|
|
|
htmlspecialchars( $reduceJs ) .
|
|
|
|
|
"\n" .
|
|
|
|
|
"</script>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function submitCC() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$newValues = $this->parent->setVarsFromRequest(
|
|
|
|
|
array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
|
|
|
|
|
if ( count( $newValues ) != 3 ) {
|
|
|
|
|
$this->parent->showError( 'config-cc-error' );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->setVar( '_CCDone', true );
|
|
|
|
|
$this->addHTML( $this->getCCDoneBox() );
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 11:41:29 +00:00
|
|
|
/**
|
|
|
|
|
* If the user skips this installer page, we still need to set up the default skins, but ignore
|
|
|
|
|
* everything else.
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function submitSkins() {
|
|
|
|
|
$skins = $this->parent->findExtensions( 'skins' );
|
|
|
|
|
$this->parent->setVar( '_Skins', $skins );
|
|
|
|
|
|
|
|
|
|
if ( $skins ) {
|
|
|
|
|
$skinNames = array_map( 'strtolower', $skins );
|
2014-09-13 18:34:52 +00:00
|
|
|
$this->parent->setVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
|
2014-06-10 11:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function submit() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
|
2010-08-12 13:00:31 +00:00
|
|
|
'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
|
2010-07-19 04:05:44 +00:00
|
|
|
'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
|
|
|
|
|
'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
|
2014-06-10 11:41:29 +00:00
|
|
|
'wgUseInstantCommons', 'wgDefaultSkin' ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2014-07-02 18:29:42 +00:00
|
|
|
$retVal = true;
|
|
|
|
|
|
2014-11-16 19:18:00 +00:00
|
|
|
if ( !array_key_exists( $this->getVar( '_RightsProfile' ), $this->parent->rightsProfiles ) ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
reset( $this->parent->rightsProfiles );
|
|
|
|
|
$this->setVar( '_RightsProfile', key( $this->parent->rightsProfiles ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$code = $this->getVar( '_LicenseCode' );
|
|
|
|
|
if ( $code == 'cc-choose' ) {
|
|
|
|
|
if ( !$this->getVar( '_CCDone' ) ) {
|
|
|
|
|
$this->parent->showError( 'config-cc-not-chosen' );
|
2014-07-02 18:29:42 +00:00
|
|
|
$retVal = false;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-01 21:44:03 +00:00
|
|
|
} elseif ( array_key_exists( $code, $this->parent->licenses ) ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages:
|
2013-03-18 10:26:57 +00:00
|
|
|
// config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa,
|
2013-08-28 00:38:27 +00:00
|
|
|
// config-license-cc-0, config-license-pd, config-license-gfdl, config-license-none,
|
|
|
|
|
// config-license-cc-choose
|
2010-07-19 04:05:44 +00:00
|
|
|
$entry = $this->parent->licenses[$code];
|
|
|
|
|
if ( isset( $entry['text'] ) ) {
|
|
|
|
|
$this->setVar( 'wgRightsText', $entry['text'] );
|
|
|
|
|
} else {
|
2012-08-21 19:58:47 +00:00
|
|
|
$this->setVar( 'wgRightsText', wfMessage( 'config-license-' . $code )->text() );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
$this->setVar( 'wgRightsUrl', $entry['url'] );
|
|
|
|
|
$this->setVar( 'wgRightsIcon', $entry['icon'] );
|
|
|
|
|
} else {
|
|
|
|
|
$this->setVar( 'wgRightsText', '' );
|
|
|
|
|
$this->setVar( 'wgRightsUrl', '' );
|
|
|
|
|
$this->setVar( 'wgRightsIcon', '' );
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 11:41:29 +00:00
|
|
|
$skinsAvailable = $this->parent->findExtensions( 'skins' );
|
|
|
|
|
$skinsToInstall = array();
|
|
|
|
|
foreach ( $skinsAvailable as $skin ) {
|
|
|
|
|
$this->parent->setVarsFromRequest( array( "skin-$skin" ) );
|
|
|
|
|
if ( $this->getVar( "skin-$skin" ) ) {
|
|
|
|
|
$skinsToInstall[] = $skin;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->parent->setVar( '_Skins', $skinsToInstall );
|
|
|
|
|
|
|
|
|
|
if ( !$skinsToInstall && $skinsAvailable ) {
|
|
|
|
|
$this->parent->showError( 'config-skins-must-enable-some' );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
|
|
|
|
$defaultSkin = $this->getVar( 'wgDefaultSkin' );
|
|
|
|
|
$skinsToInstallLowercase = array_map( 'strtolower', $skinsToInstall );
|
|
|
|
|
if ( $skinsToInstall && array_search( $defaultSkin, $skinsToInstallLowercase ) === false ) {
|
|
|
|
|
$this->parent->showError( 'config-skins-must-enable-default' );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-12 23:59:44 +00:00
|
|
|
$extsAvailable = $this->parent->findExtensions();
|
2010-08-12 12:58:27 +00:00
|
|
|
$extsToInstall = array();
|
2014-01-12 23:59:44 +00:00
|
|
|
foreach ( $extsAvailable as $ext ) {
|
2014-07-02 18:21:02 +00:00
|
|
|
$this->parent->setVarsFromRequest( array( "ext-$ext" ) );
|
|
|
|
|
if ( $this->getVar( "ext-$ext" ) ) {
|
2014-01-12 23:59:44 +00:00
|
|
|
$extsToInstall[] = $ext;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-08-12 12:58:27 +00:00
|
|
|
$this->parent->setVar( '_Extensions', $extsToInstall );
|
2011-02-23 17:54:45 +00:00
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $this->getVar( 'wgMainCacheType' ) == 'memcached' ) {
|
2011-02-23 17:54:45 +00:00
|
|
|
$memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) );
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( !$memcServers ) {
|
2011-02-23 17:54:45 +00:00
|
|
|
$this->parent->showError( 'config-memcache-needservers' );
|
2014-07-02 18:29:42 +00:00
|
|
|
$retVal = false;
|
2011-02-23 17:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
foreach ( $memcServers as $server ) {
|
2011-09-22 00:11:03 +00:00
|
|
|
$memcParts = explode( ":", $server, 2 );
|
|
|
|
|
if ( !isset( $memcParts[0] )
|
2013-10-08 11:43:42 +00:00
|
|
|
|| ( !IP::isValid( $memcParts[0] )
|
|
|
|
|
&& ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
|
|
|
|
|
) {
|
2011-02-23 17:54:45 +00:00
|
|
|
$this->parent->showError( 'config-memcache-badip', $memcParts[0] );
|
2014-07-02 18:29:42 +00:00
|
|
|
$retVal = false;
|
2013-04-20 21:11:46 +00:00
|
|
|
} elseif ( !isset( $memcParts[1] ) ) {
|
2011-02-23 17:54:45 +00:00
|
|
|
$this->parent->showError( 'config-memcache-noport', $memcParts[0] );
|
2014-07-02 18:29:42 +00:00
|
|
|
$retVal = false;
|
2013-04-20 21:11:46 +00:00
|
|
|
} elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
|
2011-02-23 17:54:45 +00:00
|
|
|
$this->parent->showError( 'config-memcache-badport', 1, 65535 );
|
2014-07-02 18:29:42 +00:00
|
|
|
$retVal = false;
|
2011-02-23 17:54:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2014-07-02 18:29:42 +00:00
|
|
|
return $retVal;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerInstall extends WebInstallerPage {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return bool Always true.
|
|
|
|
|
*/
|
2011-06-21 01:13:45 +00:00
|
|
|
public function isSlow() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string|bool
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $this->getVar( '_UpgradeDone' ) ) {
|
2010-09-01 17:46:07 +00:00
|
|
|
return 'skip';
|
2013-04-20 21:11:46 +00:00
|
|
|
} elseif ( $this->getVar( '_InstallDone' ) ) {
|
2011-01-30 18:21:37 +00:00
|
|
|
return 'continue';
|
2013-04-20 21:11:46 +00:00
|
|
|
} elseif ( $this->parent->request->wasPosted() ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->startForm();
|
2013-02-03 19:28:43 +00:00
|
|
|
$this->addHTML( "<ul>" );
|
2011-01-30 18:21:37 +00:00
|
|
|
$results = $this->parent->performInstallation(
|
2013-02-09 22:03:53 +00:00
|
|
|
array( $this, 'startStage' ),
|
2010-07-19 04:05:44 +00:00
|
|
|
array( $this, 'endStage' )
|
|
|
|
|
);
|
2013-02-03 19:28:43 +00:00
|
|
|
$this->addHTML( "</ul>" );
|
2011-01-30 18:21:37 +00:00
|
|
|
// 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();
|
2012-08-21 19:58:47 +00:00
|
|
|
$this->addHTML( $this->parent->getInfoBox( wfMessage( 'config-install-begin' )->plain() ) );
|
2011-01-30 18:21:37 +00:00
|
|
|
$this->endForm();
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $step
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function startStage( $step ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: config-install-database, config-install-tables, config-install-interwiki,
|
|
|
|
|
// config-install-stats, config-install-keys, config-install-sysop, config-install-mainpage
|
2013-10-23 12:16:03 +00:00
|
|
|
$this->addHTML( "<li>" . wfMessage( "config-install-$step" )->escaped() .
|
|
|
|
|
wfMessage( 'ellipsis' )->escaped() );
|
|
|
|
|
|
2011-03-30 17:32:20 +00:00
|
|
|
if ( $step == 'extension-tables' ) {
|
|
|
|
|
$this->startLiveBox();
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-28 14:52:55 +00:00
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param string $step
|
|
|
|
|
* @param Status $status
|
2011-05-28 14:52:55 +00:00
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function endStage( $step, $status ) {
|
2011-03-30 17:32:20 +00:00
|
|
|
if ( $step == 'extension-tables' ) {
|
|
|
|
|
$this->endLiveBox();
|
|
|
|
|
}
|
2010-08-08 15:29:32 +00:00
|
|
|
$msg = $status->isOk() ? 'config-install-step-done' : 'config-install-step-failed';
|
2012-08-21 19:58:47 +00:00
|
|
|
$html = wfMessage( 'word-separator' )->escaped() . wfMessage( $msg )->escaped();
|
2010-08-08 15:29:32 +00:00
|
|
|
if ( !$status->isOk() ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$html = "<span class=\"error\">$html</span>";
|
|
|
|
|
}
|
|
|
|
|
$this->addHTML( $html . "</li>\n" );
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( !$status->isGood() ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->showStatusBox( $status );
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerComplete extends WebInstallerPage {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
public function execute() {
|
2010-12-19 04:31:15 +00:00
|
|
|
// Pop up a dialog box, to make it difficult for the user to forget
|
2010-12-07 02:01:07 +00:00
|
|
|
// to download the file
|
2011-06-15 07:35:47 +00:00
|
|
|
$lsUrl = $this->getVar( 'wgServer' ) . $this->parent->getURL( array( 'localsettings' => 1 ) );
|
2011-11-06 21:31:52 +00:00
|
|
|
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
|
2013-10-08 11:43:42 +00:00
|
|
|
strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false
|
|
|
|
|
) {
|
2013-07-16 22:08:49 +00:00
|
|
|
// JS appears to be the only method that works consistently with IE7+
|
2014-11-19 00:11:04 +00:00
|
|
|
$this->addHtml( "\n<script>jQuery( function () { location.href = " .
|
2014-02-05 11:02:29 +00:00
|
|
|
Xml::encodeJsVar( $lsUrl ) . "; } );</script>\n" );
|
2011-02-22 17:15:48 +00:00
|
|
|
} else {
|
|
|
|
|
$this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
|
|
|
|
|
}
|
2010-12-07 02:01:07 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->startForm();
|
2010-12-10 03:02:03 +00:00
|
|
|
$this->parent->disableLinkPopups();
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getInfoBox(
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( 'config-install-done',
|
2010-12-07 02:01:07 +00:00
|
|
|
$lsUrl,
|
2011-06-15 07:35:47 +00:00
|
|
|
$this->getVar( 'wgServer' ) .
|
2013-10-08 11:43:42 +00:00
|
|
|
$this->getVar( 'wgScriptPath' ) . '/index' .
|
|
|
|
|
$this->getVar( 'wgScriptExtension' ),
|
2010-12-07 03:15:51 +00:00
|
|
|
'<downloadlink/>'
|
2012-08-21 19:58:47 +00:00
|
|
|
)->plain(), 'tick-32.png'
|
2010-07-19 04:05:44 +00:00
|
|
|
)
|
|
|
|
|
);
|
2013-04-16 14:13:38 +00:00
|
|
|
$this->addHTML( $this->parent->getInfoBox(
|
|
|
|
|
wfMessage( 'config-extension-link' )->text() ) );
|
|
|
|
|
|
2010-12-10 03:02:03 +00:00
|
|
|
$this->parent->restoreLinkPopups();
|
|
|
|
|
$this->endForm( false, false );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerRestart extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$r = $this->parent->request;
|
|
|
|
|
if ( $r->wasPosted() ) {
|
|
|
|
|
$really = $r->getVal( 'submit-restart' );
|
|
|
|
|
if ( $really ) {
|
2011-01-28 15:00:18 +00:00
|
|
|
$this->parent->reset();
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
2012-08-21 19:58:47 +00:00
|
|
|
$s = $this->parent->getWarningBox( wfMessage( 'config-help-restart' )->plain() );
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML( $s );
|
|
|
|
|
$this->endForm( 'restart' );
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
return null;
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
abstract class WebInstallerDocument extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract protected function getFileName();
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2013-03-18 19:44:43 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$text = $this->getFileContents();
|
2011-06-14 03:09:49 +00:00
|
|
|
$text = InstallDocFormatter::format( $text );
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->output->addWikiText( $text );
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->endForm( false );
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2011-06-14 03:09:49 +00:00
|
|
|
public function getFileContents() {
|
2012-08-27 19:03:15 +00:00
|
|
|
$file = __DIR__ . '/../../' . $this->getFileName();
|
2013-10-08 11:43:42 +00:00
|
|
|
if ( !file_exists( $file ) ) {
|
2012-08-21 19:58:47 +00:00
|
|
|
return wfMessage( 'config-nofile', $file )->plain();
|
2012-02-10 20:37:21 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2012-02-10 20:37:21 +00:00
|
|
|
return file_get_contents( $file );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerReadme extends WebInstallerDocument {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-04-11 05:29:05 +00:00
|
|
|
protected function getFileName() {
|
|
|
|
|
return 'README';
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerReleaseNotes extends WebInstallerDocument {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws MWException
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2012-02-10 20:37:21 +00:00
|
|
|
protected function getFileName() {
|
|
|
|
|
global $wgVersion;
|
|
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( !preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
|
2013-02-03 19:28:43 +00:00
|
|
|
throw new MWException( 'Variable $wgVersion has an invalid value.' );
|
2012-02-10 20:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 'RELEASE-NOTES-' . $result[1] . '.' . $result[2];
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerUpgradeDoc extends WebInstallerDocument {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-04-11 05:29:05 +00:00
|
|
|
protected function getFileName() {
|
|
|
|
|
return 'UPGRADE';
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-12 16:32:46 +00:00
|
|
|
class WebInstallerCopying extends WebInstallerDocument {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-04-11 05:29:05 +00:00
|
|
|
protected function getFileName() {
|
|
|
|
|
return 'COPYING';
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-10-18 16:09:18 +00:00
|
|
|
}
|