2010-07-19 04:05:44 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Base code for web installer pages.
|
|
|
|
|
*
|
|
|
|
|
* @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
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
public abstract function execute();
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-08-21 15:20:23 +00:00
|
|
|
* @param $parent WebInstaller
|
|
|
|
|
*/
|
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
|
|
|
|
|
*/
|
|
|
|
|
public function isSlow() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
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"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
2010-07-19 04:05:44 +00:00
|
|
|
$s .= Xml::submitButton( wfMsg( "config-$continue" ),
|
2010-11-23 00:04:02 +00:00
|
|
|
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 ) {
|
|
|
|
|
$s .= Xml::submitButton( wfMsg( "config-$back" ),
|
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()
|
|
|
|
|
) ) . "\n";
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $continue ) {
|
|
|
|
|
$s .= Xml::submitButton( wfMsg( "config-$continue" ),
|
|
|
|
|
array(
|
|
|
|
|
'name' => "submit-$continue",
|
|
|
|
|
'tabindex' => $this->parent->nextTabIndex(),
|
|
|
|
|
) ) . "\n";
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$s .= "</div></form></div>\n";
|
|
|
|
|
$this->addHTML( $s );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
|
return str_replace( 'WebInstaller_', '', get_class( $this ) );
|
|
|
|
|
}
|
|
|
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getVar( $var ) {
|
|
|
|
|
return $this->parent->getVar( $var );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*
|
|
|
|
|
* @param $legend String: message name
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
2010-10-26 12:05:57 +00:00
|
|
|
*/
|
|
|
|
|
protected function getFieldsetStart( $legend ) {
|
|
|
|
|
return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the end tag of a fieldset.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
|
|
|
|
* @returns 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(
|
|
|
|
|
'<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
|
|
|
|
|
'<script>jQuery( "#config-spinner" ).show();</script>' .
|
2011-06-10 20:16:42 +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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Opposite to startLiveBox()
|
|
|
|
|
*/
|
|
|
|
|
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();
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Language extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
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;
|
|
|
|
|
$userLang = $r->getVal( 'UserLang' );
|
|
|
|
|
$contLang = $r->getVal( 'ContLang' );
|
|
|
|
|
|
|
|
|
|
$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 {
|
|
|
|
|
$languages = Language::getLanguageNames();
|
|
|
|
|
if ( isset( $languages[$userLang] ) ) {
|
|
|
|
|
$this->setVar( '_UserLang', $userLang );
|
|
|
|
|
}
|
|
|
|
|
if ( isset( $languages[$contLang] ) ) {
|
|
|
|
|
$this->setVar( 'wgLanguageCode', $contLang );
|
|
|
|
|
}
|
|
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $this->parent->showSessionWarning ) {
|
|
|
|
|
# The user was knocked back from another page to the start
|
|
|
|
|
# This probably indicates a session expiry
|
|
|
|
|
$this->parent->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->parent->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() ) .
|
2010-12-06 20:04:28 +00:00
|
|
|
$this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang, $this->parent->getHelpBox( 'config-your-language-help' ) ) .
|
2010-12-07 02:09:56 +00:00
|
|
|
$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 );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 04:15:38 +00:00
|
|
|
* Get a <select> for selecting languages.
|
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;
|
|
|
|
|
|
|
|
|
|
$s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
$languages = Language::getLanguageNames();
|
|
|
|
|
ksort( $languages );
|
|
|
|
|
$dummies = array_flip( $wgDummyLanguageCodes );
|
|
|
|
|
foreach ( $languages as $code => $lang ) {
|
|
|
|
|
if ( isset( $dummies[$code] ) ) continue;
|
|
|
|
|
$s .= "\n" . Xml::option( "$code - $lang", $code, $code == $selectedCode );
|
|
|
|
|
}
|
|
|
|
|
$s .= "\n</select>\n";
|
|
|
|
|
return $this->parent->label( $label, $name, $s );
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +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
|
|
|
class WebInstaller_ExistingWiki extends WebInstallerPage {
|
|
|
|
|
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' )
|
2010-12-16 11:20:39 +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' );
|
|
|
|
|
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(
|
|
|
|
|
wfMsgNoTrans( 'config-upgrade-key-missing',
|
* 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
|
|
|
"<pre>\$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )
|
|
|
|
|
) );
|
|
|
|
|
$this->endForm( 'continue' );
|
|
|
|
|
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' );
|
|
|
|
|
if( !$key || $key !== $vars['wgUpgradeKey'] ) {
|
|
|
|
|
$this->parent->showError( 'config-localsettings-badkey' );
|
|
|
|
|
$this->showKeyForm();
|
|
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
// Key was OK
|
|
|
|
|
$status = $this->handleExistingUpgrade( $vars );
|
|
|
|
|
if ( $status->isOK() ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
} else {
|
|
|
|
|
$this->parent->showStatusBox( $status );
|
|
|
|
|
$this->showKeyForm();
|
|
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->showKeyForm();
|
|
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the "enter key" form
|
|
|
|
|
*/
|
|
|
|
|
protected function showKeyForm() {
|
|
|
|
|
$this->startForm();
|
2010-12-16 11:20:39 +00:00
|
|
|
$this->addHTML(
|
* 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->getInfoBox( wfMsgNoTrans( 'config-localsettings-upgrade' ) ).
|
|
|
|
|
'<br />' .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgUpgradeKey',
|
|
|
|
|
'label' => 'config-localsettings-key',
|
|
|
|
|
'attribs' => array( 'autocomplete' => 'off' ),
|
|
|
|
|
) )
|
|
|
|
|
);
|
|
|
|
|
$this->endForm( 'continue' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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] );
|
|
|
|
|
}
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initiate an upgrade of the existing database
|
|
|
|
|
* @param $vars Variables from LocalSettings.php and AdminSettings.php
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
protected function handleExistingUpgrade( $vars ) {
|
|
|
|
|
// Check $wgDBtype
|
|
|
|
|
if ( !isset( $vars['wgDBtype'] ) || !in_array( $vars['wgDBtype'], Installer::getDBTypes() ) ) {
|
|
|
|
|
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' );
|
* 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
|
|
|
$status = $this->importVariables( $requiredVars , $vars );
|
|
|
|
|
$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' );
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// All good
|
|
|
|
|
$this->setVar( '_ExistingDBSettings', true );
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
class WebInstaller_Welcome extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->parent->output->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
|
|
|
|
|
$status = $this->parent->doEnvironmentChecks();
|
2011-01-05 23:20:12 +00:00
|
|
|
if ( $status->isGood() ) {
|
|
|
|
|
$this->parent->output->addHTML( '<span class="success-message">' .
|
|
|
|
|
wfMsgHtml( 'config-env-good' ) . '</span>' );
|
2010-12-06 20:04:28 +00:00
|
|
|
$this->parent->output->addWikiText( wfMsgNoTrans( 'config-copyright',
|
2010-09-01 21:01:46 +00:00
|
|
|
SpecialVersion::getCopyrightAndAuthorList() ) );
|
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
|
|
|
}
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_DBConnect extends WebInstallerPage {
|
2010-12-16 11:20:39 +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 );
|
|
|
|
|
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
|
|
|
|
2010-08-22 21:52:39 +00:00
|
|
|
$dbSupport = '';
|
|
|
|
|
foreach( $this->parent->getDBTypes() as $type ) {
|
2011-06-20 07:00:50 +00:00
|
|
|
$link = DatabaseBase::factory( $type )->getSoftwareLink();
|
2011-01-24 16:31:36 +00:00
|
|
|
$dbSupport .= wfMsgNoTrans( "config-support-$type", $link ) . "\n";
|
2010-08-22 21:52:39 +00:00
|
|
|
}
|
2010-08-22 20:55:07 +00:00
|
|
|
$this->addHTML( $this->parent->getInfoBox(
|
2010-08-22 21:52:39 +00:00
|
|
|
wfMsg( 'config-support-info', $dbSupport ) ) );
|
2010-08-22 20:55:07 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
foreach ( $this->parent->getVar( '_CompiledDBs' ) as $type ) {
|
|
|
|
|
$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";
|
|
|
|
|
|
|
|
|
|
$settings .=
|
2010-11-04 23:21:24 +00:00
|
|
|
Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
|
|
|
|
|
Html::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
$installer->getConnectForm() .
|
|
|
|
|
"</div>\n";
|
|
|
|
|
}
|
|
|
|
|
$types .= "</ul><br clear=\"left\"/>\n";
|
|
|
|
|
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->label( 'config-db-type', false, $types ) .
|
|
|
|
|
$settings
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->endForm();
|
|
|
|
|
}
|
|
|
|
|
|
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' );
|
|
|
|
|
$this->setVar( 'wgDBtype', $type );
|
|
|
|
|
$installer = $this->parent->getDBInstaller( $type );
|
|
|
|
|
if ( !$installer ) {
|
|
|
|
|
return Status::newFatal( 'config-invalid-db-type' );
|
|
|
|
|
}
|
|
|
|
|
return $installer->submitConnectForm();
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Upgrade extends WebInstallerPage {
|
2011-06-21 01:13:45 +00:00
|
|
|
public function isSlow() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
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();
|
|
|
|
|
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
|
|
|
|
|
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();
|
|
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML( $this->parent->getInfoBox(
|
|
|
|
|
wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
|
|
|
|
|
$this->endForm();
|
|
|
|
|
}
|
|
|
|
|
|
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(
|
2010-12-10 03:02:03 +00:00
|
|
|
wfMsgNoTrans( $msg,
|
2011-06-15 07:35:47 +00:00
|
|
|
$this->getVar( 'wgServer' ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->getVar( 'wgScriptPath' ) . '/index' .
|
|
|
|
|
$this->getVar( 'wgScriptExtension' )
|
|
|
|
|
), 'tick-32.png'
|
|
|
|
|
)
|
|
|
|
|
);
|
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
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_DBSettings extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Name extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
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' );
|
|
|
|
|
$this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
|
|
|
|
|
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgSitename',
|
|
|
|
|
'label' => 'config-site-name',
|
2010-12-06 20:04:28 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-site-name-help' )
|
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' ),
|
|
|
|
|
'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',
|
2010-11-23 00:40:45 +00:00
|
|
|
'label' => '', //TODO: Needs a label?
|
|
|
|
|
'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' ),
|
2010-12-16 11:20:39 +00:00
|
|
|
|
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(
|
|
|
|
|
'var' => '_AdminPassword2',
|
|
|
|
|
'label' => 'config-admin-password-confirm'
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => '_AdminEmail',
|
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() .
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->getInfoBox( wfMsg( 'config-almost-done' ) ) .
|
|
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => '_SkipOptional',
|
|
|
|
|
'itemLabelPrefix' => 'config-optional-',
|
|
|
|
|
'values' => array( 'continue', 'skip' )
|
|
|
|
|
) )
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Restore the default value
|
|
|
|
|
$this->setVar( 'wgMetaNamespace', $metaNS );
|
|
|
|
|
|
|
|
|
|
$this->endForm();
|
|
|
|
|
return 'output';
|
|
|
|
|
}
|
|
|
|
|
|
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',
|
|
|
|
|
'_AdminName', '_AdminPassword', '_AdminPassword2', '_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' ) {
|
|
|
|
|
$name = wfMsg( 'config-ns-generic' );
|
|
|
|
|
} 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 );
|
|
|
|
|
if( $nsIndex !== false && $nsIndex !== NS_PROJECT ) {
|
|
|
|
|
$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 );
|
2010-12-06 15:07:12 +00:00
|
|
|
$valid = $user && $user->getPasswordValidity( $pwd );
|
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';
|
|
|
|
|
} elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
|
|
|
|
|
$msg = 'config-admin-password-mismatch';
|
|
|
|
|
} elseif ( $valid !== true ) {
|
|
|
|
|
# As of writing this will only catch the username being e.g. 'FOO' and
|
|
|
|
|
# the password 'foo'
|
|
|
|
|
$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', '' );
|
|
|
|
|
$this->setVar( '_AdminPassword2', '' );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
2011-01-05 22:37:14 +00:00
|
|
|
|
|
|
|
|
// Validate e-mail if provided
|
|
|
|
|
$email = $this->getVar( '_AdminEmail' );
|
2011-06-26 19:16:04 +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
|
|
|
|
|
if( !$email && $this->getVar( '_Subscribe' ) ) {
|
|
|
|
|
$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;
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Options extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
|
|
|
|
|
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
|
|
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => '_RightsProfile',
|
|
|
|
|
'label' => 'config-profile',
|
|
|
|
|
'itemLabelPrefix' => 'config-profile-',
|
|
|
|
|
'values' => array_keys( $this->parent->rightsProfiles ),
|
|
|
|
|
) ) .
|
2011-02-26 13:51:03 +00:00
|
|
|
$this->parent->getInfoBox( wfMsgNoTrans( 'config-profile-help' ) ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
# Licensing
|
|
|
|
|
$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
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$extensions = $this->parent->findExtensions();
|
2010-12-19 04:31:15 +00:00
|
|
|
|
2010-07-19 04:05:44 +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
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
foreach( $extensions as $ext ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$extHtml .= $this->parent->getCheckBox( array(
|
|
|
|
|
'var' => "ext-$ext",
|
|
|
|
|
'rawtext' => $ext,
|
|
|
|
|
) );
|
|
|
|
|
}
|
2010-12-19 04:31:15 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) .
|
2010-12-06 20:04:28 +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' );
|
|
|
|
|
if( count( $this->getVar( '_Caches' ) ) ) {
|
|
|
|
|
$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' );
|
|
|
|
|
if (!$cacheval) {
|
|
|
|
|
// We need to set a default here; but don't hardcode it
|
|
|
|
|
// or we lose it every time we reload the page for validation
|
|
|
|
|
// or going back!
|
|
|
|
|
$cacheval = 'none';
|
|
|
|
|
}
|
|
|
|
|
$hidden = ($cacheval == 'memcached') ? '' : 'display: none';
|
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
|
|
|
|
|
$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();
|
|
|
|
|
}
|
|
|
|
|
|
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() ) ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
'/skins/common/config-cc.css';
|
|
|
|
|
$iframeUrl = 'http://creativecommons.org/license/?' .
|
|
|
|
|
wfArrayToCGI( array(
|
|
|
|
|
'partner' => 'MediaWiki',
|
|
|
|
|
'exit_url' => $exitUrl,
|
|
|
|
|
'lang' => $this->getVar( '_UserLang' ),
|
|
|
|
|
'stylesheet' => $styleUrl,
|
|
|
|
|
) );
|
|
|
|
|
return $iframeUrl;
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
2011-03-27 20:19:24 +00:00
|
|
|
$wrapperStyle = ($this->getVar('_LicenseCode') == 'cc-choose') ? '' : 'display: none';
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
return
|
2011-03-27 20:19:24 +00:00
|
|
|
"<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";
|
|
|
|
|
}
|
|
|
|
|
|
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 );
|
|
|
|
|
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" .
|
|
|
|
|
"<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,
|
|
|
|
|
),
|
|
|
|
|
wfMsg( 'config-cc-again' )
|
|
|
|
|
) .
|
|
|
|
|
"</p>\n" .
|
|
|
|
|
"<script type=\"text/javascript\">\n" .
|
|
|
|
|
# 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' );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->setVar( '_CCDone', true );
|
|
|
|
|
$this->addHTML( $this->getCCDoneBox() );
|
|
|
|
|
}
|
|
|
|
|
|
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',
|
|
|
|
|
'wgUseInstantCommons' ) );
|
|
|
|
|
|
|
|
|
|
if ( !in_array( $this->getVar( '_RightsProfile' ),
|
|
|
|
|
array_keys( $this->parent->rightsProfiles ) ) )
|
|
|
|
|
{
|
|
|
|
|
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' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} elseif ( in_array( $code, array_keys( $this->parent->licenses ) ) ) {
|
|
|
|
|
$entry = $this->parent->licenses[$code];
|
|
|
|
|
if ( isset( $entry['text'] ) ) {
|
|
|
|
|
$this->setVar( 'wgRightsText', $entry['text'] );
|
|
|
|
|
} else {
|
|
|
|
|
$this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
|
|
|
|
|
}
|
|
|
|
|
$this->setVar( 'wgRightsUrl', $entry['url'] );
|
|
|
|
|
$this->setVar( 'wgRightsIcon', $entry['icon'] );
|
|
|
|
|
} else {
|
|
|
|
|
$this->setVar( 'wgRightsText', '' );
|
|
|
|
|
$this->setVar( 'wgRightsUrl', '' );
|
|
|
|
|
$this->setVar( 'wgRightsIcon', '' );
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-12 12:58:27 +00:00
|
|
|
$extsAvailable = $this->parent->findExtensions();
|
|
|
|
|
$extsToInstall = array();
|
|
|
|
|
foreach( $extsAvailable as $ext ) {
|
|
|
|
|
if( $this->parent->request->getCheck( 'config_ext-' . $ext ) ) {
|
|
|
|
|
$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
|
|
|
|
|
|
|
|
if( $this->getVar( 'wgMainCacheType' ) == 'memcached' ) {
|
|
|
|
|
$memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) );
|
|
|
|
|
if( !$memcServers ) {
|
|
|
|
|
$this->parent->showError( 'config-memcache-needservers' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach( $memcServers as $server ) {
|
2011-09-22 00:11:03 +00:00
|
|
|
$memcParts = explode( ":", $server, 2 );
|
|
|
|
|
if ( !isset( $memcParts[0] )
|
|
|
|
|
|| ( !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] );
|
|
|
|
|
return false;
|
|
|
|
|
} elseif( !isset( $memcParts[1] ) ) {
|
|
|
|
|
$this->parent->showError( 'config-memcache-noport', $memcParts[0] );
|
|
|
|
|
return false;
|
|
|
|
|
} elseif( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
|
|
|
|
|
$this->parent->showError( 'config-memcache-badport', 1, 65535 );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Install extends WebInstallerPage {
|
2011-06-21 01:13:45 +00:00
|
|
|
public function isSlow() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2011-01-30 18:21:37 +00:00
|
|
|
if( $this->getVar( '_UpgradeDone' ) ) {
|
2010-09-01 17:46:07 +00:00
|
|
|
return 'skip';
|
2011-01-30 18:21:37 +00:00
|
|
|
} elseif( $this->getVar( '_InstallDone' ) ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
} elseif( $this->parent->request->wasPosted() ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML("<ul>");
|
2011-01-30 18:21:37 +00:00
|
|
|
$results = $this->parent->performInstallation(
|
2010-07-19 04:05:44 +00:00
|
|
|
array( $this, 'startStage'),
|
|
|
|
|
array( $this, 'endStage' )
|
|
|
|
|
);
|
|
|
|
|
$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();
|
|
|
|
|
$this->addHTML( $this->parent->getInfoBox( wfMsgNoTrans( 'config-install-begin' ) ) );
|
|
|
|
|
$this->endForm();
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startStage( $step ) {
|
|
|
|
|
$this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
|
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
|
|
|
/**
|
|
|
|
|
* @param $step
|
|
|
|
|
* @param $status Status
|
|
|
|
|
*/
|
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';
|
2010-07-19 04:05:44 +00:00
|
|
|
$html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
|
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" );
|
2010-08-08 15:29:32 +00:00
|
|
|
if( !$status->isGood() ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent->showStatusBox( $status );
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Complete extends WebInstallerPage {
|
2010-12-16 11:20:39 +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-02-22 17:15:48 +00:00
|
|
|
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) {
|
|
|
|
|
// JS appears the only method that works consistently with IE7+
|
|
|
|
|
$this->addHtml( "\n<script type=\"" . $GLOBALS['wgJsMimeType'] . '">jQuery( document ).ready( function() { document.location='
|
|
|
|
|
. Xml::encodeJsVar( $lsUrl) . "; } );</script>\n" );
|
|
|
|
|
} else {
|
|
|
|
|
$this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
|
|
|
|
|
}
|
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(
|
|
|
|
|
wfMsgNoTrans( 'config-install-done',
|
2010-12-07 02:01:07 +00:00
|
|
|
$lsUrl,
|
2011-06-15 07:35:47 +00:00
|
|
|
$this->getVar( 'wgServer' ) .
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->getVar( 'wgScriptPath' ) . '/index' .
|
2010-12-07 03:15:51 +00:00
|
|
|
$this->getVar( 'wgScriptExtension' ),
|
|
|
|
|
'<downloadlink/>'
|
2010-07-19 04:05:44 +00:00
|
|
|
), 'tick-32.png'
|
|
|
|
|
)
|
|
|
|
|
);
|
2010-12-10 03:02:03 +00:00
|
|
|
$this->parent->restoreLinkPopups();
|
|
|
|
|
$this->endForm( false, false );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Restart extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$s = $this->parent->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
|
|
|
|
|
$this->addHTML( $s );
|
|
|
|
|
$this->endForm( 'restart' );
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abstract class WebInstaller_Document extends WebInstallerPage {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
protected abstract function getFileName();
|
2010-07-19 04:05:44 +00:00
|
|
|
|
2010-07-19 04:15:38 +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 );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-14 03:09:49 +00:00
|
|
|
public function getFileContents() {
|
2010-07-19 04:05:44 +00:00
|
|
|
return file_get_contents( dirname( __FILE__ ) . '/../../' . $this->getFileName() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Readme extends WebInstaller_Document {
|
2010-07-19 04:15:38 +00:00
|
|
|
protected function getFileName() { return 'README'; }
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_ReleaseNotes extends WebInstaller_Document {
|
2010-07-19 04:15:38 +00:00
|
|
|
protected function getFileName() { return 'RELEASE-NOTES'; }
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_UpgradeDoc extends WebInstaller_Document {
|
2010-07-19 04:15:38 +00:00
|
|
|
protected function getFileName() { return 'UPGRADE'; }
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Copying extends WebInstaller_Document {
|
2010-07-19 04:15:38 +00:00
|
|
|
protected function getFileName() { return 'COPYING'; }
|
2010-10-18 16:09:18 +00:00
|
|
|
}
|
2010-12-06 13:30:24 +00:00
|
|
|
|