From e3644ae2c4285a733c3971f8ef7a915ee405869f Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Wed, 23 Jun 2010 01:08:34 +0000 Subject: [PATCH] =?utf8?q?*=20Adapt=20install.php=20to=20a=20more=20?= =?utf8?q?=E2=80=9Ctraditional=E2=80=9D=20maintenance-style=20script=20so?= =?utf8?q?=20it=20can=20extend=20and=20use=20Maintenance=20class=20conveni?= =?utf8?q?ence=20methods.=20*=20Add=20CliInstaller=20class=20and=20put=20i?= =?utf8?q?t=20in=20the=20autoloads.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- includes/AutoLoader.php | 1 + includes/installer/CliInstaller.php | 52 ++++++++++++++++++ maintenance/install.php | 83 ++++++++++++++++------------- 3 files changed, 99 insertions(+), 37 deletions(-) create mode 100644 includes/installer/CliInstaller.php diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 2c4598dbf3..4732d77779 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -413,6 +413,7 @@ $wgAutoloadLocalClasses = array( 'UnregisteredLocalFile' => 'includes/filerepo/UnregisteredLocalFile.php', # includes/installer + 'CliInstaller' => 'includes/installer/CliInstaller.php', 'Installer' => 'includes/installer/Installer.php', 'InstallerDBType' => 'includes/installer/InstallerDBType.php', 'LBFactory_InstallerFake' => 'includes/installer/Installer.php', diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php new file mode 100644 index 0000000000..307762ee98 --- /dev/null +++ b/includes/installer/CliInstaller.php @@ -0,0 +1,52 @@ +setVar( '_UserLang', $option['lang'] ); + $wgContLang = Language::factory( $option['lang'] ); + $wgLang = Language::factory( $option['lang'] ); + $wgLanguageCode = $option['lang']; + } + + $this->setVar( 'wgSitename', $siteName ); + if ( $admin ) { + $this->setVar( '_AdminName', $admin ); + } else { + $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) ); + } + } + + /** + * Main entry point. + */ + function execute( ) { + var_dump($this->getVar('_AdminName')); + } + + function showMessage( $msg /*, ... */ ) { + echo "Message: $msg\n"; + } + + function showStatusError( $status ) { + echo "Error: $status\n"; + } +} diff --git a/maintenance/install.php b/maintenance/install.php index 96afcf7fca..d68ae27659 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -1,49 +1,58 @@ addArg( 'name', 'The name of the wiki', true); + $this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', false); + $this->addOption( 'pass', 'The password for the wiki administrator. You will be prompted for this if it isn\'t provided', false, true); + /* $this->addOption( 'email', 'The email for the wiki administrator', false, true); */ + $this->addOption( 'lang', 'The language to use (en)', false, true ); + /* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */ + $this->addOption( 'db-type', 'The type of database (mysql)', false, true ); + /* $this->addOption( 'db-host', 'The database host (localhost)', false, true ); */ + /* $this->addOption( 'db-port', 'The database port (3306 for mysql, 5432 for pg)', false, true ); */ + $this->addOption( 'db-name', 'The database name (my_wiki)', false, true ); + $this->addOption( 'db-path', 'The path for the SQLite DB (/var/data)', false, true ); + /* $this->addOption( 'db-schema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */ + /* $this->addOption( 'db-tsearch2-schema', 'The schema for the tsearch2 DB in pg (public)', false, true ); */ + /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */ + } + + public function execute() { + $installer = new CliInstaller( $this->mArgs[0], $this->mArgs[1], $this->mOptions ); + + $installer->execute(); + } } -require_once( "$IP/includes/ProfilerStub.php" ); -require_once( "$IP/includes/Defines.php" ); -require_once( "$IP/includes/GlobalFunctions.php" ); -require_once( "$IP/includes/AutoLoader.php" ); -require_once( "$IP/includes/Hooks.php" ); -require_once( "$IP/includes/DefaultSettings.php" ); -require_once( "$IP/includes/Namespace.php" ); - -$wgContLang = Language::factory( 'en' ); // will be overridden later - -// Disable the i18n cache and LoadBalancer -Language::getLocalisationCache()->disableBackend(); -LBFactory::disableBackend(); - -$installer = new CliInstaller( $argv ); - -$langCode = 'en'; - -$wgLang = Language::factory( $langCode ); - -$wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT]; - -$session = $installer->execute( $argv ); - -$_SESSION['installData'] = $session; +$maintClass = "CommandLineInstaller"; +require_once( DO_MAINTENANCE ); -- 2.20.1