* Eliminate CLIInstallerOutput per r68645 since, yes, it wasn't needed.
[lhc/web/wiklou.git] / includes / installer / CliInstaller.php
1 <?php
2
3 class CliInstaller extends Installer {
4
5 /* The maintenance class in effect */
6 private $maint;
7
8 private $optionMap = array(
9 'dbtype' => 'wgDBtype',
10 'dbserver' => 'wgDBserver',
11 'dbname' => 'wgDBname',
12 'dbuser' => 'wgDBuser',
13 'dbpass' => 'wgDBpassword',
14 'dbprefix' => 'wgDBprefix',
15 'dbtableoptions' => 'wgDBTableOptions',
16 'dbmysql5' => 'wgDBmysql5',
17 'dbserver' => 'wgDBserver',
18 'dbport' => 'wgDBport',
19 'dbname' => 'wgDBname',
20 'dbuser' => 'wgDBuser',
21 'dbpass' => 'wgDBpassword',
22 'dbschema' => 'wgDBmwschema',
23 'dbts2schema' => 'wgDBts2schema',
24 'dbpath' => 'wgSQLiteDataDir',
25 );
26
27
28 /** Constructor */
29 function __construct( $siteName, $admin = null, $option = array()) {
30 parent::__construct();
31
32 foreach ( $this->optionMap as $opt => $global ) {
33 if ( isset( $option[$opt] ) ) {
34 $GLOBALS[$global] = $option[$opt];
35 $this->setVar( $global, $option[$opt] );
36 }
37 }
38
39 if ( isset( $option['lang'] ) ) {
40 global $wgLang, $wgContLang, $wgLanguageCode;
41 $this->setVar( '_UserLang', $option['lang'] );
42 $wgContLang = Language::factory( $option['lang'] );
43 $wgLang = Language::factory( $option['lang'] );
44 $wgLanguageCode = $option['lang'];
45 }
46
47 $this->setVar( 'wgSitename', $siteName );
48 if ( $admin ) {
49 $this->setVar( '_AdminName', $admin );
50 } else {
51 $this->setVar( '_AdminName',
52 wfMsgForContent( 'config-admin-default-username' ) );
53 }
54
55 if ( !isset( $option['installdbuser'] ) ) {
56 $this->setVar( '_InstallUser',
57 $this->getVar( 'wgDBuser' ) );
58 $this->setVar( '_InstallPassword',
59 $this->getVar( 'wgDBpassword' ) );
60 }
61
62 if ( isset( $option['pass'] ) ) {
63 $this->setVar( '_AdminPassword', $option['pass'] );
64 }
65 }
66
67 /**
68 * Main entry point.
69 */
70 function execute( ) {
71 foreach( $this->getInstallSteps() as $step ) {
72 $this->showMessage("Installing $step... ");
73 $func = 'install' . ucfirst( $step );
74 $status = $this->{$func}();
75 if ( !$status->isOk() ) {
76 $this->showStatusMessage( $status );
77 exit;
78 } elseif ( !$status->isGood() ) {
79 $this->showStatusMessage( $status );
80 }
81 $this->showMessage("done\n");
82 }
83 }
84
85 function showMessage( $msg /*, ... */ ) {
86 echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES );
87 flush();
88 }
89
90 function showStatusMessage( $status ) {
91 $this->showMessage( $status->getWikiText() );
92 }
93
94 }