Removed showStatusMessage from the Installer and WebInstaller classes as it's only...
[lhc/web/wiklou.git] / includes / installer / CliInstaller.php
1 <?php
2
3 /**
4 * Class for the core installer command line interface.
5 *
6 * @since 1.17
7 */
8 class CliInstaller extends CoreInstaller {
9 private $optionMap = array(
10 'dbtype' => 'wgDBtype',
11 'dbserver' => 'wgDBserver',
12 'dbname' => 'wgDBname',
13 'dbuser' => 'wgDBuser',
14 'dbpass' => 'wgDBpassword',
15 'dbprefix' => 'wgDBprefix',
16 'dbtableoptions' => 'wgDBTableOptions',
17 'dbmysql5' => 'wgDBmysql5',
18 'dbserver' => 'wgDBserver',
19 'dbport' => 'wgDBport',
20 'dbname' => 'wgDBname',
21 'dbuser' => 'wgDBuser',
22 'dbpass' => 'wgDBpassword',
23 'dbschema' => 'wgDBmwschema',
24 'dbts2schema' => 'wgDBts2schema',
25 'dbpath' => 'wgSQLiteDataDir',
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 }
51
52 if ( !isset( $option['installdbuser'] ) ) {
53 $this->setVar( '_InstallUser',
54 $this->getVar( 'wgDBuser' ) );
55 $this->setVar( '_InstallPassword',
56 $this->getVar( 'wgDBpassword' ) );
57 }
58
59 if ( isset( $option['pass'] ) ) {
60 $this->setVar( '_AdminPassword', $option['pass'] );
61 }
62 }
63
64 /**
65 * Main entry point.
66 */
67 public function execute() {
68 $this->performInstallation(
69 array( $this, 'startStage'),
70 array( $this, 'endStage' )
71 );
72 }
73
74 public function startStage( $step ) {
75 $this->showMessage( wfMsg( "config-install-$step") .
76 wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
77 }
78
79 public function endStage( $step, $status ) {
80 $warnings = $status->getWarningsArray();
81 if ( !$status->isOk() ) {
82 $this->showStatusMessage( $status );
83 echo "\n";
84 exit;
85 } elseif ( count($warnings) !== 0 ) {
86 foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
87 $this->showMessage( $w . wfMsg( 'ellipsis') .
88 wfMsg( 'word-separator' ) );
89 }
90 }
91 $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n");
92 }
93
94 public function showMessage( $msg /*, ... */ ) {
95 echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES );
96 flush();
97 }
98
99 public function showStatusMessage( Status $status ) {
100 $this->showMessage( $status->getWikiText() );
101 }
102
103 }