4 * Class for the core installer command line interface.
9 class CliInstaller
extends CoreInstaller
{
11 private $optionMap = array(
12 'dbtype' => 'wgDBtype',
13 'dbserver' => 'wgDBserver',
14 'dbname' => 'wgDBname',
15 'dbuser' => 'wgDBuser',
16 'dbpass' => 'wgDBpassword',
17 'dbprefix' => 'wgDBprefix',
18 'dbtableoptions' => 'wgDBTableOptions',
19 'dbmysql5' => 'wgDBmysql5',
20 'dbserver' => 'wgDBserver',
21 'dbport' => 'wgDBport',
22 'dbname' => 'wgDBname',
23 'dbuser' => 'wgDBuser',
24 'dbpass' => 'wgDBpassword',
25 'dbschema' => 'wgDBmwschema',
26 'dbts2schema' => 'wgDBts2schema',
27 'dbpath' => 'wgSQLiteDataDir',
35 * @param $option Array
37 function __construct( $siteName, $admin = null, array $option = array() ) {
38 parent
::__construct();
40 foreach ( $this->optionMap
as $opt => $global ) {
41 if ( isset( $option[$opt] ) ) {
42 $GLOBALS[$global] = $option[$opt];
43 $this->setVar( $global, $option[$opt] );
47 if ( isset( $option['lang'] ) ) {
48 global $wgLang, $wgContLang, $wgLanguageCode;
49 $this->setVar( '_UserLang', $option['lang'] );
50 $wgContLang = Language
::factory( $option['lang'] );
51 $wgLang = Language
::factory( $option['lang'] );
52 $wgLanguageCode = $option['lang'];
55 $this->setVar( 'wgSitename', $siteName );
58 $this->setVar( '_AdminName', $admin );
61 if ( !isset( $option['installdbuser'] ) ) {
62 $this->setVar( '_InstallUser',
63 $this->getVar( 'wgDBuser' ) );
64 $this->setVar( '_InstallPassword',
65 $this->getVar( 'wgDBpassword' ) );
68 if ( isset( $option['pass'] ) ) {
69 $this->setVar( '_AdminPassword', $option['pass'] );
76 public function execute() {
77 $this->performInstallation(
78 array( $this, 'startStage' ),
79 array( $this, 'endStage' )
82 $ls = new LocalSettingsGenerator( $this );
83 file_put_contents( "LocalSettings.php", $ls->getText() );
86 public function startStage( $step ) {
87 $this->showMessage( wfMsg( "config-install-$step" ) .
88 wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
91 public function endStage( $step, $status ) {
92 $warnings = $status->getWarningsArray();
94 if ( !$status->isOk() ) {
95 $this->showStatusMessage( $status );
98 } elseif ( count($warnings) !== 0 ) {
99 foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
100 $this->showMessage( $w . wfMsg( 'ellipsis' ) .
101 wfMsg( 'word-separator' ) );
105 $this->showMessage( wfMsg( 'config-install-step-done' ) ."\n");
108 public function showMessage( $msg /*, ... */ ) {
109 echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES
);
113 public function showStatusMessage( Status
$status ) {
114 $this->showMessage( $status->getWikiText() );