* @since 1.17
*/
abstract class DatabaseInstaller {
-
+
/**
* The Installer object.
*
* @return Status
*/
public abstract function getConnection();
-
+
/**
* Create the database and return a Status object indicating success or
* failure.
* @return String
*/
public abstract function getLocalSettings();
-
+
/**
* Perform database upgrades
*
ob_end_flush();
return $ret;
}
-
+
/**
* Allow DB installers a chance to make last-minute changes before installation
* occurs. This happens before setupDatabase() or createTables() is called, but
* long after the constructor. Helpful for things like modifying setup steps :)
*/
public function preInstall() {
-
+
}
/**
* Allow DB installers a chance to make checks before upgrade.
*/
public function preUpgrade() {
-
+
}
/**
public function getReadableName() {
return wfMsg( 'config-type-' . $this->getName() );
}
-
+
/**
* Get a name=>value map of MW configuration globals that overrides.
* DefaultSettings.php
$this->setVarsFromRequest(
array( 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' )
);
-
+
if ( $this->getVar( '_SameAccount' ) ) {
$this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
$this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
}
-
+
return Status::newGood();
}
/*
* Class for handling database updates. Roughly based off of updaters.inc, with
* a few improvements :)
- *
+ *
* @ingroup Deployment
* @since 1.17
*/
public function restoreLinkPopups() {
global $wgExternalLinkTarget;
$this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
- }
+ }
/**
* TODO: document
if( $status->isOK() ) {
LBFactory::enableBackend();
}
-
+
return $status;
}
* @since 1.17
*/
class LocalSettingsGenerator {
-
+
private $extensions = array();
private $values = array();
private $dbSettings = '';
private $safeMode = false;
-
+
/**
* @var Installer
*/
/**
* Constructor.
- *
+ *
* @param $installer Installer subclass
*/
public function __construct( Installer $installer ) {
),
$db->getGlobalNames()
);
-
+
$unescaped = array( 'wgRightsIcon' );
- $boolItems = array(
+ $boolItems = array(
'wgEnableEmail', 'wgEnableUserEmail', 'wgEnotifUserTalk',
'wgEnotifWatchlist', 'wgEmailAuthentication', 'wgEnableUploads', 'wgUseInstantCommons'
);
-
+
foreach( $confItems as $c ) {
$val = $installer->getVar( $c );
-
+
if( in_array( $c, $boolItems ) ) {
$val = wfBoolToStr( $val );
}
-
+
if ( !in_array( $c, $unescaped ) ) {
$val = self::escapePhpString( $val );
}
-
+
$this->values[$c] = $val;
}
-
+
$this->dbSettings = $db->getLocalSettings();
$this->safeMode = $installer->getVar( '_SafeMode' );
$this->values['wgEmergencyContact'] = $this->values['wgPasswordSender'];
/**
* Returns the escaped version of a string of php code.
- *
+ *
* @param $string String
- *
+ *
* @return String
*/
public static function escapePhpString( $string ) {
if ( is_array( $string ) || is_object( $string ) ) {
return false;
}
-
+
return strtr(
$string,
array(
/**
* Return the full text of the generated LocalSettings.php file,
* including the extensions
- *
+ *
* @return String
*/
public function getText() {
$localSettings = $this->getDefaultText();
-
+
if( count( $this->extensions ) ) {
$localSettings .= "\n# The following extensions were automatically enabled:\n";
-
+
foreach( $this->extensions as $extName ) {
$encExtName = self::escapePhpString( $extName );
$localSettings .= "require( \"extensions/$encExtName/$encExtName.php\" );\n";
*/
private function buildMemcachedServerList() {
$servers = $this->values['_MemCachedServers'];
-
+
if( !$servers ) {
return 'array()';
} else {
$ret = 'array( ';
$servers = explode( ',', $servers );
-
+
foreach( $servers as $srv ) {
$srv = trim( $srv );
$ret .= "'$srv', ";
}
-
+
return rtrim( $ret, ', ' ) . ' )';
}
}
/**
* @return String
- */
+ */
private function getDefaultText() {
if( !$this->values['wgImageMagickConvertCommand'] ) {
$this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert';
} else {
$magic = '';
}
-
+
if( !$this->values['wgShellLocale'] ) {
$this->values['wgShellLocale'] = 'en_US.UTF-8';
$locale = '#';
} else {
$locale = '';
}
-
+
$rights = $this->values['wgRightsUrl'] ? '' : '#';
$hashedUploads = $this->safeMode ? '' : '#';
-
+
switch( $this->values['wgMainCacheType'] ) {
case 'anything':
case 'db':
default:
$cacheType = 'CACHE_NONE';
}
-
+
$mcservers = $this->buildMemcachedServerList();
return "<?php
# This file was automatically generated by the MediaWiki {$GLOBALS['wgVersion']}
# but check specific extension documentation for more details
";
}
-
+
}
* @since 1.17
*/
class MysqlInstaller extends DatabaseInstaller {
-
+
protected $globalNames = array(
'wgDBserver',
'wgDBname',
/**
* Mysql update list and mysql-specific update functions.
- *
+ *
* @ingroup Deployment
* @since 1.17
*/
class MysqlUpdater extends DatabaseUpdater {
-
+
protected function getCoreUpdateList() {
return array(
// 1.2
* @see bug 3946
*/
protected function doPageRandomUpdate() {
-
-
$page = $this->db->tableName( 'page' );
$this->db->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", __METHOD__ );
$rows = $this->db->affectedRows();
$this->output( "...page_restrictions table already exists.\n" );
return;
}
-
+
$this->output( "Creating page_restrictions table..." );
$this->applyPatch( 'patch-page_restrictions.sql' );
$this->applyPatch( 'patch-page_restrictions_sortkey.sql' );
* @file
* @ingroup Deployment
*/
-
+
/**
* Class for setting up the MediaWiki database using SQLLite.
*
* @since 1.17
*/
class SqliteInstaller extends DatabaseInstaller {
-
+
protected $globalNames = array(
'wgDBname',
'wgSQLiteDataDir',
"# SQLite-specific settings
\$wgSQLiteDataDir = \"{$dir}\";";
}
-}
\ No newline at end of file
+}
* @file
* @ingroup Deployment
*/
-
+
/**
* Class for handling updates to Sqlite databases.
- *
+ *
* @ingroup Deployment
* @since 1.17
*/
class SqliteUpdater extends DatabaseUpdater {
-
+
protected function getCoreUpdateList() {
return array(
// 1.14
// Add parser hook for WebInstaller_Complete
global $wgParser;
- $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
+ $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
}
/**
$text = wfMsgReal( $msg, $args, false, false, false );
$html = htmlspecialchars( $text );
$html = $this->parse( $text, true );
-
-
+
return "<div class=\"mw-help-field-container\">\n" .
"<span class=\"mw-help-field-hint\">" . wfMsgHtml( 'config-help' ) . "</span>\n" .
"<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
}
public function downloadLinkHook( $text, $attribs, $parser ) {
- $img = Html::element( 'img', array(
+ $img = Html::element( 'img', array(
'src' => '../skins/common/images/download-32.png',
'width' => '32',
'height' => '32',
) );
- $anchor = Html::rawElement( 'a',
+ $anchor = Html::rawElement( 'a',
array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
$img . ' ' . wfMsgHtml( 'config-download-localsettings' ) );
return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
* @var WebInstaller
*/
public $parent;
-
+
public abstract function execute();
-
+
/**
* Constructor.
*
public function endForm( $continue = 'continue', $back = 'back' ) {
$s = "<div class=\"config-submit\">\n";
$id = $this->getId();
-
+
if ( $id === false ) {
$s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
}
-
+
if ( $continue ) {
// Fake submit button for enter keypress (bug 26267)
$s .= Xml::submitButton( wfMsg( "config-$continue" ),
array( 'name' => "enter-$continue", 'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n";
}
-
+
if ( $back ) {
$s .= Xml::submitButton( wfMsg( "config-$back" ),
array(
'tabindex' => $this->parent->nextTabIndex()
) ) . "\n";
}
-
+
if ( $continue ) {
$s .= Xml::submitButton( wfMsg( "config-$continue" ),
array(
'tabindex' => $this->parent->nextTabIndex(),
) ) . "\n";
}
-
+
$s .= "</div></form></div>\n";
$this->addHTML( $s );
}
}
class WebInstaller_Language extends WebInstallerPage {
-
+
public function execute() {
global $wgLang;
$r = $this->parent->request;
$s .= "\n</select>\n";
return $this->parent->label( $label, $name, $s );
}
-
+
}
class WebInstaller_ExistingWiki extends WebInstallerPage {
// Check if the upgrade key supplied to the user has appeared in LocalSettings.php
if ( $vars['wgUpgradeKey'] !== false
&& $this->getVar( '_UpgradeKeySupplied' )
- && $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey'] )
+ && $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey'] )
{
// It's there, so the user is authorized
$status = $this->handleExistingUpgrade( $vars );
$this->setVar( '_UpgradeKeySupplied', true );
}
$this->startForm();
- $this->addHTML( $this->parent->getInfoBox(
- wfMsgNoTrans( 'config-upgrade-key-missing',
+ $this->addHTML( $this->parent->getInfoBox(
+ wfMsgNoTrans( 'config-upgrade-key-missing',
"<pre>\$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )
) );
$this->endForm( 'continue' );
}
// If there is an upgrade key, but it wasn't supplied, prompt the user to enter it
-
+
$r = $this->parent->request;
if ( $r->wasPosted() ) {
$key = $r->getText( 'config_wgUpgradeKey' );
*/
protected function showKeyForm() {
$this->startForm();
- $this->addHTML(
+ $this->addHTML(
$this->parent->getInfoBox( wfMsgNoTrans( 'config-localsettings-upgrade' ) ).
'<br />' .
$this->parent->getTextBox( array(
$status = $installer->getConnection();
if ( !$status->isOK() ) {
// Adjust the error message to explain things correctly
- $status->replaceMessage( 'config-connection-error',
+ $status->replaceMessage( 'config-connection-error',
'config-localsettings-connection-error' );
return $status;
}
}
class WebInstaller_Welcome extends WebInstallerPage {
-
+
public function execute() {
if ( $this->parent->request->wasPosted() ) {
if ( $this->getVar( '_Environment' ) ) {
$this->endForm();
}
}
-
+
}
class WebInstaller_DBConnect extends WebInstallerPage {
-
+
public function execute() {
if ( $this->getVar( '_ExistingDBSettings' ) ) {
return 'skip';
}
return $installer->submitConnectForm();
}
-
+
}
class WebInstaller_Upgrade extends WebInstallerPage {
-
+
public function execute() {
if ( $this->getVar( '_UpgradeDone' ) ) {
// Allow regeneration of LocalSettings.php, unless we are working
$this->parent->restoreLinkPopups();
$this->endForm( $regenerate ? 'regenerate' : false, false );
}
-
+
}
class WebInstaller_DBSettings extends WebInstallerPage {
-
+
public function execute() {
$installer = $this->parent->getDBInstaller( $this->getVar( 'wgDBtype' ) );
}
class WebInstaller_Name extends WebInstallerPage {
-
+
public function execute() {
$r = $this->parent->request;
if ( $r->wasPosted() ) {
'var' => 'wgMetaNamespace',
'label' => '', //TODO: Needs a label?
'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' ),
-
+
) ) .
$this->getFieldSetStart( 'config-admin-box' ) .
$this->parent->getTextBox( array(
}
return $retVal;
}
-
+
}
class WebInstaller_Options extends WebInstallerPage {
-
+
public function execute() {
if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
return 'skip';
$this->parent->setVar( '_Extensions', $extsToInstall );
return true;
}
-
+
}
class WebInstaller_Install extends WebInstallerPage {
$this->parent->showStatusBox( $status );
}
}
-
+
}
class WebInstaller_Complete extends WebInstallerPage {
-
+
public function execute() {
// Pop up a dialog box, to make it difficult for the user to forget
// to download the file
}
class WebInstaller_Restart extends WebInstallerPage {
-
+
public function execute() {
$r = $this->parent->request;
if ( $r->wasPosted() ) {
$this->addHTML( $s );
$this->endForm( 'restart' );
}
-
+
}
abstract class WebInstaller_Document extends WebInstallerPage {
-
+
protected abstract function getFileName();
public function execute() {
return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
$matches[1] . ' ' . $matches[1] . ']</span>';
}
-
+
}
class WebInstaller_Readme extends WebInstaller_Document {