4 * Class for the core installer command line interface.
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',
29 function __construct( $siteName, $admin = null, $option = array() ) {
30 parent
::__construct();
32 foreach ( $this->optionMap
as $opt => $global ) {
33 if ( isset( $option[$opt] ) ) {
34 $GLOBALS[$global] = $option[$opt];
35 $this->setVar( $global, $option[$opt] );
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'];
47 $this->setVar( 'wgSitename', $siteName );
49 $this->setVar( '_AdminName', $admin );
52 if ( !isset( $option['installdbuser'] ) ) {
53 $this->setVar( '_InstallUser',
54 $this->getVar( 'wgDBuser' ) );
55 $this->setVar( '_InstallPassword',
56 $this->getVar( 'wgDBpassword' ) );
59 if ( isset( $option['pass'] ) ) {
60 $this->setVar( '_AdminPassword', $option['pass'] );
67 public function execute() {
68 $this->performInstallation(
69 array( $this, 'startStage'),
70 array( $this, 'endStage' )
74 public function startStage( $step ) {
75 $this->showMessage( wfMsg( "config-install-$step") .
76 wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
79 public function endStage( $step, $status ) {
80 $warnings = $status->getWarningsArray();
81 if ( !$status->isOk() ) {
82 $this->showStatusMessage( $status );
85 } elseif ( count($warnings) !== 0 ) {
86 foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
87 $this->showMessage( $w . wfMsg( 'ellipsis') .
88 wfMsg( 'word-separator' ) );
91 $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n");
94 public function showMessage( $msg /*, ... */ ) {
95 echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES
);
99 public function showStatusMessage( Status
$status ) {
100 $this->showMessage( $status->getWikiText() );