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-11-01 21:17:15 +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-11-01 21:17:15 +00:00
|
|
|
*
|
2010-07-20 13:53:03 +00:00
|
|
|
* @var WebInstaller
|
|
|
|
|
*/
|
|
|
|
|
public $parent;
|
|
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
public abstract function execute();
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor.
|
2010-11-01 21:17:15 +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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function endForm( $continue = 'continue' ) {
|
|
|
|
|
$s = "<div class=\"config-submit\">\n";
|
|
|
|
|
$id = $this->getId();
|
2010-07-20 13:53:03 +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-07-20 13:53:03 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $continue ) {
|
|
|
|
|
// Fake submit button for enter keypress
|
|
|
|
|
$s .= Xml::submitButton( wfMsg( "config-$continue" ),
|
|
|
|
|
array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
|
|
|
|
|
}
|
2010-07-20 13:53:03 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $id !== 0 ) {
|
|
|
|
|
$s .= Xml::submitButton( wfMsg( 'config-back' ),
|
|
|
|
|
array(
|
|
|
|
|
'name' => 'submit-back',
|
|
|
|
|
'tabindex' => $this->parent->nextTabIndex()
|
|
|
|
|
) ) . "\n";
|
|
|
|
|
}
|
2010-07-20 13:53:03 +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-07-20 13:53:03 +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 ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getId() {
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
protected function getFieldsetStart( $legend ) {
|
|
|
|
|
return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the end tag of a fieldset.
|
|
|
|
|
*/
|
|
|
|
|
protected function getFieldsetEnd() {
|
|
|
|
|
return "</fieldset>\n";
|
|
|
|
|
}
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-25 23:18:47 +00:00
|
|
|
class WebInstaller_Locked extends WebInstallerPage {
|
|
|
|
|
|
|
|
|
|
// The status of Installer::getLocalSettingsStatus()
|
|
|
|
|
private $status;
|
|
|
|
|
|
|
|
|
|
public function setLocalSettingsStatus( Status $s ) {
|
|
|
|
|
$this->status = $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
$r = $this->parent->request;
|
|
|
|
|
if( !$r->wasPosted() || !$this->status->isOK() ) {
|
|
|
|
|
$this->display();
|
|
|
|
|
return 'output';
|
|
|
|
|
} else {
|
|
|
|
|
$key = $r->getText( 'config_wpUpgradeKey' );
|
|
|
|
|
if( !$key || $key !== $this->getVar( '_UpgradeKey' ) ) {
|
2010-10-26 11:45:21 +00:00
|
|
|
$this->parent->showError( 'config-localsettings-badkey' );
|
|
|
|
|
$this->display();
|
2010-10-25 23:18:47 +00:00
|
|
|
return 'output';
|
|
|
|
|
} else {
|
|
|
|
|
$this->setVar( '_LocalSettingsLocked', false );
|
|
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Display stuff to the end user
|
|
|
|
|
*/
|
2010-10-26 11:45:21 +00:00
|
|
|
private function display() {
|
2010-10-25 23:18:47 +00:00
|
|
|
$this->startForm();
|
2010-10-26 11:45:21 +00:00
|
|
|
$this->parent->showStatusBox( $this->status );
|
2010-10-25 23:18:47 +00:00
|
|
|
if( $this->status->isOK() && !$this->status->isGood() ) {
|
|
|
|
|
$this->addHTML( "<br />" .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wpUpgradeKey',
|
|
|
|
|
'label' => 'config-localsettings-key',
|
|
|
|
|
) )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$this->endForm();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
class WebInstaller_Language extends WebInstallerPage {
|
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 );
|
|
|
|
|
}
|
2010-11-01 14:29:17 +00:00
|
|
|
$this->setVar( '_ExternalHTTP', $r->getBool( 'config__ExternalHTTP' ) );
|
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
|
|
|
|
|
$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-11-01 21:17:15 +00:00
|
|
|
$this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang, $this->parent->getHelpBox( 'config-your-language-help' ) ) .
|
|
|
|
|
$this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang, $this->parent->getHelpBox( 'config-wiki-language-help' ) ) .
|
|
|
|
|
$this->parent->getCheckBox(
|
|
|
|
|
array(
|
|
|
|
|
'var' => '_ExternalHTTP',
|
|
|
|
|
'label' => 'config-allow-requests',
|
|
|
|
|
'help' => $this->parent->getHelpBox( 'config-allow-requests-help' )
|
|
|
|
|
)
|
|
|
|
|
);
|
2010-07-19 04:05:44 +00:00
|
|
|
|
|
|
|
|
$this->addHTML( $s );
|
|
|
|
|
$this->endForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 04:15:38 +00:00
|
|
|
* Get a <select> for selecting languages.
|
2010-07-19 04:05:44 +00:00
|
|
|
*/
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getLanguageSelector( $name, $label, $selectedCode ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
global $wgDummyLanguageCodes;
|
2010-11-04 23:21:24 +00:00
|
|
|
$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-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Welcome extends WebInstallerPage {
|
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();
|
|
|
|
|
if ( $status ) {
|
2010-11-01 21:17:15 +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();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_DBConnect extends WebInstallerPage {
|
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() ) {
|
|
|
|
|
$status = $this->submit();
|
|
|
|
|
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 ) {
|
|
|
|
|
$db = 'Database' . ucfirst( $type );
|
2010-11-01 21:17:15 +00:00
|
|
|
$dbSupport .= wfMsgNoTrans( "config-support-$type",
|
2010-10-17 17:09:45 +00:00
|
|
|
call_user_func( array( $db, 'getSoftwareLink' ) ) ) . "\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-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Upgrade extends WebInstallerPage {
|
2010-07-19 04:15:38 +00:00
|
|
|
|
|
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $this->getVar( '_UpgradeDone' ) ) {
|
|
|
|
|
if ( $this->parent->request->wasPosted() ) {
|
|
|
|
|
// 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();
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML(
|
|
|
|
|
'<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
|
|
|
|
|
'<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
|
|
|
|
|
'<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
|
|
|
|
|
);
|
|
|
|
|
$this->parent->output->flush();
|
|
|
|
|
$result = $installer->doUpgrade();
|
|
|
|
|
$this->addHTML( '</textarea>
|
|
|
|
|
<script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
|
|
|
|
|
$this->parent->output->flush();
|
|
|
|
|
if ( $result ) {
|
|
|
|
|
$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();
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getInfoBox(
|
|
|
|
|
wfMsgNoTrans( 'config-upgrade-done',
|
|
|
|
|
$GLOBALS['wgServer'] .
|
|
|
|
|
$this->getVar( 'wgScriptPath' ) . '/index' .
|
|
|
|
|
$this->getVar( 'wgScriptExtension' )
|
|
|
|
|
), 'tick-32.png'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$this->endForm( 'regenerate' );
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_DBSettings extends WebInstallerPage {
|
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-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();
|
|
|
|
|
|
|
|
|
|
if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
|
|
|
|
|
$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-11-01 21:17:15 +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-11-01 21:17:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-project-namespace-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => 'wgMetaNamespace',
|
|
|
|
|
'label' => '',
|
|
|
|
|
'attribs' => array( 'disabled' => '' ),
|
2010-11-01 21:17:15 +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-11-01 21:17:15 +00:00
|
|
|
'label' => 'config-admin-email',
|
|
|
|
|
'help' => $this->parent->getHelpBox( 'config-admin-email-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => '_Subscribe',
|
2010-11-01 21:17:15 +00:00
|
|
|
'label' => 'config-subscribe',
|
|
|
|
|
'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',
|
|
|
|
|
'_Subscribe', '_SkipOptional' ) );
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
$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;
|
2010-11-01 21:17:15 +00:00
|
|
|
$valid = false;
|
2010-07-19 04:05:44 +00:00
|
|
|
$pwd = $this->getVar( '_AdminPassword' );
|
|
|
|
|
$user = User::newFromName( $cname );
|
2010-11-01 21:17:15 +00:00
|
|
|
if ( ( isset ( $pwd ) ) && ( $user != null ) ) {
|
|
|
|
|
$valid = $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 ) {
|
|
|
|
|
$this->parent->showError( $msg );
|
|
|
|
|
$this->setVar( '_AdminPassword', '' );
|
|
|
|
|
$this->setVar( '_AdminPassword2', '' );
|
|
|
|
|
$retVal = false;
|
|
|
|
|
}
|
|
|
|
|
return $retVal;
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Options extends WebInstallerPage {
|
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';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
# User Rights
|
|
|
|
|
$this->parent->getRadioSet( array(
|
|
|
|
|
'var' => '_RightsProfile',
|
|
|
|
|
'label' => 'config-profile',
|
|
|
|
|
'itemLabelPrefix' => 'config-profile-',
|
|
|
|
|
'values' => array_keys( $this->parent->rightsProfiles ),
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-profile-help' ) .
|
|
|
|
|
|
|
|
|
|
# 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' ) .
|
|
|
|
|
"<div id=\"emailwrapper\">" .
|
|
|
|
|
$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-07-22 17:58:26 +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-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-07-22 17:58:26 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) .
|
2010-11-01 21:17:15 +00:00
|
|
|
$this->getFieldSetEnd();
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->addHTML( $extHtml );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
# Uploading
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetStart( 'config-upload-settings' ) .
|
2010-11-01 21:17:15 +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-11-01 21:17:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-upload-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
|
|
|
|
'<div id="uploadwrapper" style="display: none;">' .
|
2010-11-01 21:17:15 +00:00
|
|
|
$this->parent->getTextBox( array(
|
2010-07-19 04:05:44 +00:00
|
|
|
'var' => 'wgDeletedDirectory',
|
|
|
|
|
'label' => 'config-upload-deleted',
|
2010-11-01 21:17: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-11-01 21:17:15 +00:00
|
|
|
'label' => 'config-logo',
|
|
|
|
|
'help' => $this->parent->getHelpBox( 'config-logo-help' )
|
|
|
|
|
) )
|
2010-07-19 04:05:44 +00:00
|
|
|
);
|
|
|
|
|
$canUse = $this->getVar( '_ExternalHTTP' ) ?
|
|
|
|
|
'config-instantcommons-good' : 'config-instantcommons-bad';
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getCheckBox( array(
|
|
|
|
|
'var' => 'wgUseInstantCommons',
|
|
|
|
|
'label' => 'config-instantcommons',
|
2010-11-01 21:17:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) )
|
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';
|
|
|
|
|
|
|
|
|
|
$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,
|
|
|
|
|
'value' => 'none',
|
|
|
|
|
) ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-cache-help' ) .
|
|
|
|
|
'<div id="config-memcachewrapper">' .
|
|
|
|
|
$this->parent->getTextBox( array(
|
|
|
|
|
'var' => '_MemCachedServers',
|
|
|
|
|
'label' => 'config-memcached-servers',
|
2010-11-01 21:17:15 +00:00
|
|
|
'help' => $this->parent->getHelpBox( 'config-memcached-help' )
|
2010-07-19 04:05:44 +00:00
|
|
|
) ) .
|
2010-11-01 21:17:15 +00:00
|
|
|
'</div>' .
|
2010-10-26 12:05:57 +00:00
|
|
|
$this->getFieldSetEnd()
|
2010-07-19 04:05:44 +00:00
|
|
|
);
|
|
|
|
|
$this->endForm();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getCCPartnerUrl() {
|
2010-07-19 04:05:44 +00:00
|
|
|
global $wgServer;
|
|
|
|
|
$exitUrl = $wgServer . $this->parent->getUrl( array(
|
|
|
|
|
'page' => 'Options',
|
|
|
|
|
'SubmitCC' => 'indeed',
|
|
|
|
|
'config__LicenseCode' => 'cc',
|
|
|
|
|
'config_wgRightsUrl' => '[license_url]',
|
|
|
|
|
'config_wgRightsText' => '[license_name]',
|
|
|
|
|
'config_wgRightsIcon' => '[license_button]',
|
|
|
|
|
) );
|
|
|
|
|
$styleUrl = $wgServer . dirname( dirname( $this->parent->getUrl() ) ) .
|
|
|
|
|
'/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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
"<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\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 );
|
2010-07-19 04:05:44 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Install extends WebInstallerPage {
|
|
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function execute() {
|
2010-07-19 04:05:44 +00:00
|
|
|
if( $this->parent->request->wasPosted() ) {
|
|
|
|
|
return 'continue';
|
|
|
|
|
} elseif( $this->getVar( '_InstallDone' ) ) {
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$status = new Status();
|
|
|
|
|
$status->warning( 'config-install-alreadydone' );
|
|
|
|
|
$this->parent->showStatusBox( $status );
|
2010-09-01 17:46:07 +00:00
|
|
|
} elseif( $this->getVar( '_UpgradeDone' ) ) {
|
|
|
|
|
return 'skip';
|
2010-07-19 04:05:44 +00:00
|
|
|
} else {
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML("<ul>");
|
|
|
|
|
$this->parent->performInstallation(
|
|
|
|
|
array( $this, 'startStage'),
|
|
|
|
|
array( $this, 'endStage' )
|
|
|
|
|
);
|
|
|
|
|
$this->addHTML("</ul>");
|
|
|
|
|
}
|
|
|
|
|
$this->endForm();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startStage( $step ) {
|
|
|
|
|
$this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function endStage( $step, $status ) {
|
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-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Complete extends WebInstallerPage {
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
public function execute() {
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
$this->parent->getInfoBox(
|
|
|
|
|
wfMsgNoTrans( 'config-install-done',
|
|
|
|
|
$GLOBALS['wgServer'] . $this->parent->getURL( array( 'localsettings' => 1 ) ),
|
|
|
|
|
$GLOBALS['wgServer'] .
|
|
|
|
|
$this->getVar( 'wgScriptPath' ) . '/index' .
|
|
|
|
|
$this->getVar( 'wgScriptExtension' )
|
|
|
|
|
), 'tick-32.png'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$this->endForm( false );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WebInstaller_Restart extends WebInstallerPage {
|
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 ) {
|
|
|
|
|
$this->parent->session = array();
|
|
|
|
|
$this->parent->happyPages = array();
|
|
|
|
|
$this->parent->settings = array();
|
|
|
|
|
}
|
|
|
|
|
return 'continue';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$s = $this->parent->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
|
|
|
|
|
$this->addHTML( $s );
|
|
|
|
|
$this->endForm( 'restart' );
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abstract class WebInstaller_Document extends WebInstallerPage {
|
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();
|
|
|
|
|
$this->parent->output->addWikiText( $text );
|
|
|
|
|
$this->startForm();
|
|
|
|
|
$this->endForm( false );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getFileContents() {
|
2010-07-19 04:05:44 +00:00
|
|
|
return file_get_contents( dirname( __FILE__ ) . '/../../' . $this->getFileName() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function formatTextFile( $text ) {
|
|
|
|
|
$text = str_replace( array( '<', '{{', '[[' ),
|
|
|
|
|
array( '<', '{{', '[[' ), $text );
|
|
|
|
|
// replace numbering with [1], [2], etc with MW-style numbering
|
|
|
|
|
$text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
|
|
|
|
|
// join word-wrapped lines into one
|
|
|
|
|
do {
|
|
|
|
|
$prev = $text;
|
|
|
|
|
$text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
|
|
|
|
|
} while ( $text != $prev );
|
|
|
|
|
// turn (bug nnnn) into links
|
|
|
|
|
$text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
|
|
|
|
|
// add links to manual to every global variable mentioned
|
|
|
|
|
$text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
|
|
|
|
|
// special case for <pre> - formatted links
|
|
|
|
|
do {
|
|
|
|
|
$prev = $text;
|
|
|
|
|
$text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
|
|
|
|
|
} while ( $text != $prev );
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function replaceBugLinks( $matches ) {
|
|
|
|
|
return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
|
|
|
|
|
$matches[1] . ' bug ' . $matches[1] . ']</span>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function replaceConfigLinks( $matches ) {
|
|
|
|
|
return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
|
|
|
|
|
$matches[1] . ' ' . $matches[1] . ']</span>';
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getFileContents() {
|
2010-07-19 04:05:44 +00:00
|
|
|
return $this->formatTextFile( parent::getFileContents() );
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
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
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getFileContents() {
|
2010-07-19 04:05:44 +00:00
|
|
|
return $this->formatTextFile( parent::getFileContents() );
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
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
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getFileContents() {
|
2010-07-19 04:05:44 +00:00
|
|
|
return $this->formatTextFile( parent::getFileContents() );
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
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-07-19 04:05:44 +00:00
|
|
|
|
2010-07-19 04:15:38 +00:00
|
|
|
public function getFileContents() {
|
2010-07-19 04:05:44 +00:00
|
|
|
$text = parent::getFileContents();
|
|
|
|
|
$text = str_replace( "\x0C", '', $text );
|
|
|
|
|
$text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
|
|
|
|
|
$text = '<tt>' . nl2br( $text ) . '</tt>';
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static function replaceLeadingSpaces( $matches ) {
|
|
|
|
|
return "\n" . str_repeat( ' ', strlen( $matches[0] ) );
|
|
|
|
|
}
|
2010-07-19 04:15:38 +00:00
|
|
|
|
2010-10-18 16:09:18 +00:00
|
|
|
}
|