3 class CliInstaller
extends Installer
{
5 /* The maintenance class in effect */
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',
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 );
51 $this->setVar( '_AdminName',
52 wfMsgForContent( 'config-admin-default-username' ) );
55 if ( !isset( $option['installdbuser'] ) ) {
56 $this->setVar( '_InstallUser',
57 $this->getVar( 'wgDBuser' ) );
58 $this->setVar( '_InstallPassword',
59 $this->getVar( 'wgDBpassword' ) );
62 if ( isset( $option['pass'] ) ) {
63 $this->setVar( '_AdminPassword', $option['pass'] );
71 foreach( $this->getInstallSteps() as $stepObj ) {
72 $step = is_array( $stepObj ) ?
$stepObj['name'] : $stepObj;
73 $this->showMessage( wfMsg( "config-install-$step") .
74 wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
75 $func = 'install' . ucfirst( $step );
76 $status = $this->{$func}();
77 $warnings = $status->getWarningsArray();
78 if ( !$status->isOk() ) {
79 $this->showStatusMessage( $status );
82 } elseif ( count($warnings) !== 0 ) {
83 foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
84 $this->showMessage( $w . wfMsg( 'ellipsis') .
85 wfMsg( 'word-separator' ) );
88 $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n");
92 function showMessage( $msg /*, ... */ ) {
93 echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES
);
97 function showStatusMessage( $status ) {
98 $this->showMessage( $status->getWikiText() );