Index: trunk/phase3/maintenance/install.php |
— | — | @@ -1,49 +1,58 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -if ( php_sapi_name() != 'cli' ) { |
5 | | - echo "This is a command-line script.\n"; |
6 | | - exit( 1 ); |
7 | | -} |
| 4 | +/** |
| 5 | + * This program is free software; you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation; either version 2 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License along |
| 16 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | + * http://www.gnu.org/copyleft/gpl.html |
| 19 | + * |
| 20 | + * @ingroup Maintenance |
| 21 | + * @see wfWaitForSlaves() |
| 22 | + */ |
8 | 23 | |
9 | | -define( 'MEDIAWIKI', 1 ); |
10 | 24 | define( 'MW_NO_DB', 1 ); |
11 | 25 | define( 'MW_NO_SESSION', 1 ); |
12 | 26 | define( 'MW_CONFIG_CALLBACK', 'wfInstallerConfig' ); |
13 | 27 | |
14 | 28 | $IP = dirname( dirname( __FILE__ ) ); |
15 | 29 | |
16 | | -function wfInstallerConfig() { |
17 | | - // Don't access the database |
18 | | - $GLOBALS['wgUseDatabaseMessages'] = false; |
19 | | - // Debug-friendly |
20 | | - $GLOBALS['wgShowExceptionDetails'] = true; |
21 | | - // Don't break forms |
22 | | - $GLOBALS['wgExternalLinkTarget'] = '_blank'; |
23 | | -} |
| 30 | +require_once( "$IP/maintenance/Maintenance.php" ); |
24 | 31 | |
25 | | -require_once( "$IP/includes/ProfilerStub.php" ); |
26 | | -require_once( "$IP/includes/Defines.php" ); |
27 | | -require_once( "$IP/includes/GlobalFunctions.php" ); |
28 | | -require_once( "$IP/includes/AutoLoader.php" ); |
29 | | -require_once( "$IP/includes/Hooks.php" ); |
30 | | -require_once( "$IP/includes/DefaultSettings.php" ); |
31 | | -require_once( "$IP/includes/Namespace.php" ); |
| 32 | +class CommandLineInstaller extends Maintenance { |
| 33 | + public function __construct() { |
| 34 | + $this->addArg( 'name', 'The name of the wiki', true); |
| 35 | + $this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', false); |
| 36 | + $this->addOption( 'pass', 'The password for the wiki administrator. You will be prompted for this if it isn\'t provided', false, true); |
| 37 | + /* $this->addOption( 'email', 'The email for the wiki administrator', false, true); */ |
| 38 | + $this->addOption( 'lang', 'The language to use (en)', false, true ); |
| 39 | + /* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */ |
| 40 | + $this->addOption( 'db-type', 'The type of database (mysql)', false, true ); |
| 41 | + /* $this->addOption( 'db-host', 'The database host (localhost)', false, true ); */ |
| 42 | + /* $this->addOption( 'db-port', 'The database port (3306 for mysql, 5432 for pg)', false, true ); */ |
| 43 | + $this->addOption( 'db-name', 'The database name (my_wiki)', false, true ); |
| 44 | + $this->addOption( 'db-path', 'The path for the SQLite DB (/var/data)', false, true ); |
| 45 | + /* $this->addOption( 'db-schema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */ |
| 46 | + /* $this->addOption( 'db-tsearch2-schema', 'The schema for the tsearch2 DB in pg (public)', false, true ); */ |
| 47 | + /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */ |
| 48 | + } |
32 | 49 | |
33 | | -$wgContLang = Language::factory( 'en' ); // will be overridden later |
| 50 | + public function execute() { |
| 51 | + $installer = new CliInstaller( $this->mArgs[0], $this->mArgs[1], $this->mOptions ); |
34 | 52 | |
35 | | -// Disable the i18n cache and LoadBalancer |
36 | | -Language::getLocalisationCache()->disableBackend(); |
37 | | -LBFactory::disableBackend(); |
| 53 | + $installer->execute(); |
| 54 | + } |
| 55 | +} |
38 | 56 | |
39 | | -$installer = new CliInstaller( $argv ); |
| 57 | +$maintClass = "CommandLineInstaller"; |
40 | 58 | |
41 | | -$langCode = 'en'; |
42 | | - |
43 | | -$wgLang = Language::factory( $langCode ); |
44 | | - |
45 | | -$wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT]; |
46 | | - |
47 | | -$session = $installer->execute( $argv ); |
48 | | - |
49 | | -$_SESSION['installData'] = $session; |
50 | | - |
| 59 | +require_once( DO_MAINTENANCE ); |
Index: trunk/phase3/includes/installer/CliInstaller.php |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +function wfInstallerConfig() { |
| 5 | + // Don't access the database |
| 6 | + $GLOBALS['wgUseDatabaseMessages'] = false; |
| 7 | + // Debug-friendly |
| 8 | + $GLOBALS['wgShowExceptionDetails'] = true; |
| 9 | + // Don't break forms |
| 10 | + $GLOBALS['wgExternalLinkTarget'] = '_blank'; |
| 11 | + |
| 12 | + // Extended debugging. Maybe disable before release? |
| 13 | + $GLOBALS['wgShowSQLErrors'] = true; |
| 14 | + $GLOBALS['wgShowDBErrorBacktrace'] = true; |
| 15 | +} |
| 16 | + |
| 17 | +class CliInstaller extends Installer { |
| 18 | + |
| 19 | + /** Constructor */ |
| 20 | + function __construct( $siteName, $admin = null, $option = array()) { |
| 21 | + parent::__construct(); |
| 22 | + |
| 23 | + if ( isset( $option['lang'] ) ) { |
| 24 | + global $wgLang, $wgContLang, $wgLanguageCode; |
| 25 | + $this->setVar( '_UserLang', $option['lang'] ); |
| 26 | + $wgContLang = Language::factory( $option['lang'] ); |
| 27 | + $wgLang = Language::factory( $option['lang'] ); |
| 28 | + $wgLanguageCode = $option['lang']; |
| 29 | + } |
| 30 | + |
| 31 | + $this->setVar( 'wgSitename', $siteName ); |
| 32 | + if ( $admin ) { |
| 33 | + $this->setVar( '_AdminName', $admin ); |
| 34 | + } else { |
| 35 | + $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) ); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * Main entry point. |
| 41 | + */ |
| 42 | + function execute( ) { |
| 43 | + var_dump($this->getVar('_AdminName')); |
| 44 | + } |
| 45 | + |
| 46 | + function showMessage( $msg /*, ... */ ) { |
| 47 | + echo "Message: $msg\n"; |
| 48 | + } |
| 49 | + |
| 50 | + function showStatusError( $status ) { |
| 51 | + echo "Error: $status\n"; |
| 52 | + } |
| 53 | +} |
Property changes on: trunk/phase3/includes/installer/CliInstaller.php |
___________________________________________________________________ |
Name: svn:eol-syle |
1 | 54 | + native |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -413,6 +413,7 @@ |
414 | 414 | 'UnregisteredLocalFile' => 'includes/filerepo/UnregisteredLocalFile.php', |
415 | 415 | |
416 | 416 | # includes/installer |
| 417 | + 'CliInstaller' => 'includes/installer/CliInstaller.php', |
417 | 418 | 'Installer' => 'includes/installer/Installer.php', |
418 | 419 | 'InstallerDBType' => 'includes/installer/InstallerDBType.php', |
419 | 420 | 'LBFactory_InstallerFake' => 'includes/installer/Installer.php', |