Renamed InstallerDBType to DatabaseInstaller
[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 /** Constructor */
28 function __construct( $siteName, $admin = null, $option = array() ) {
29 parent::__construct();
30
31 foreach ( $this->optionMap as $opt => $global ) {
32 if ( isset( $option[$opt] ) ) {
33 $GLOBALS[$global] = $option[$opt];
34 $this->setVar( $global, $option[$opt] );
35 }
36 }
37
38 if ( isset( $option['lang'] ) ) {
39 global $wgLang, $wgContLang, $wgLanguageCode;
40 $this->setVar( '_UserLang', $option['lang'] );
41 $wgContLang = Language::factory( $option['lang'] );
42 $wgLang = Language::factory( $option['lang'] );
43 $wgLanguageCode = $option['lang'];
44 }
45
46 $this->setVar( 'wgSitename', $siteName );
47 if ( $admin ) {
48 $this->setVar( '_AdminName', $admin );
49 }
50
51 if ( !isset( $option['installdbuser'] ) ) {
52 $this->setVar( '_InstallUser',
53 $this->getVar( 'wgDBuser' ) );
54 $this->setVar( '_InstallPassword',
55 $this->getVar( 'wgDBpassword' ) );
56 }
57
58 if ( isset( $option['pass'] ) ) {
59 $this->setVar( '_AdminPassword', $option['pass'] );
60 }
61 }
62
63 /**
64 * Main entry point.
65 */
66 public function execute() {
67 $this->performInstallation(
68 array( $this, 'startStage'),
69 array( $this, 'endStage' )
70 );
71 }
72
73 public function startStage( $step ) {
74 $this->showMessage( wfMsg( "config-install-$step") .
75 wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
76 }
77
78 public function endStage( $step, $status ) {
79 $warnings = $status->getWarningsArray();
80 if ( !$status->isOk() ) {
81 $this->showStatusMessage( $status );
82 echo "\n";
83 exit;
84 } elseif ( count($warnings) !== 0 ) {
85 foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
86 $this->showMessage( $w . wfMsg( 'ellipsis') .
87 wfMsg( 'word-separator' ) );
88 }
89 }
90 $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n");
91 }
92
93 public function showMessage( $msg /*, ... */ ) {
94 echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES );
95 flush();
96 }
97
98 public function showStatusMessage( $status ) {
99 $this->showMessage( $status->getWikiText() );
100 }
101
102 }