Followup r89564
[lhc/web/wiklou.git] / includes / installer / CliInstaller.php
index af50f80..b579a77 100644 (file)
@@ -12,7 +12,8 @@
  * @ingroup Deployment
  * @since 1.17
  */
-class CliInstaller extends CoreInstaller {
+class CliInstaller extends Installer {
+       private $specifiedScriptPath = false;
 
        private $optionMap = array(
                'dbtype' => 'wgDBtype',
@@ -29,12 +30,8 @@ class CliInstaller extends CoreInstaller {
                'dbuser' => 'wgDBuser',
                'dbpass' => 'wgDBpassword',
                'dbschema' => 'wgDBmwschema',
-               'dbts2schema' => 'wgDBts2schema',
                'dbpath' => 'wgSQLiteDataDir',
                'scriptpath' => 'wgScriptPath',
-               'upgrade' => 'cliUpgrade', /* As long as it isn't $confItems
-                                                                       * in LocalSettingsGenerator, we
-                                                                       * should be fine. */
        );
 
        /**
@@ -45,8 +42,14 @@ class CliInstaller extends CoreInstaller {
         * @param $option Array
         */
        function __construct( $siteName, $admin = null, array $option = array() ) {
+               global $wgContLang;
+
                parent::__construct();
 
+               if ( isset( $option['scriptpath'] ) ) {
+                       $this->specifiedScriptPath = true;
+               }
+
                foreach ( $this->optionMap as $opt => $global ) {
                        if ( isset( $option[$opt] ) ) {
                                $GLOBALS[$global] = $option[$opt];
@@ -55,7 +58,7 @@ class CliInstaller extends CoreInstaller {
                }
 
                if ( isset( $option['lang'] ) ) {
-                       global $wgLang, $wgContLang, $wgLanguageCode;
+                       global $wgLang, $wgLanguageCode;
                        $this->setVar( '_UserLang', $option['lang'] );
                        $wgContLang = Language::factory( $option['lang'] );
                        $wgLang = Language::factory( $option['lang'] );
@@ -64,6 +67,12 @@ class CliInstaller extends CoreInstaller {
 
                $this->setVar( 'wgSitename', $siteName );
 
+               $metaNS = $wgContLang->ucfirst( str_replace( ' ', '_', $siteName ) );
+               if ( $metaNS == 'MediaWiki' ) {
+                       $metaNS = 'Project';
+               }
+               $this->setVar( 'wgMetaNamespace', $metaNS );
+
                if ( $admin ) {
                        $this->setVar( '_AdminName', $admin );
                }
@@ -73,6 +82,11 @@ class CliInstaller extends CoreInstaller {
                                $this->getVar( 'wgDBuser' ) );
                        $this->setVar( '_InstallPassword',
                                $this->getVar( 'wgDBpassword' ) );
+               } else {
+                       $this->setVar( '_InstallUser',
+                               $option['installdbuser'] );
+                       $this->setVar( '_InstallPassword',
+                               $option['installdbpass'] );
                }
 
                if ( isset( $option['pass'] ) ) {
@@ -84,10 +98,8 @@ class CliInstaller extends CoreInstaller {
         * Main entry point.
         */
        public function execute() {
-               global $cliUpgrade;
-
-               $vars = $this->getExistingLocalSettings();
-               if( $vars && ( !isset( $cliUpgrade ) || $cliUpgrade !== "yes" )  ) {
+               $vars = Installer::getExistingLocalSettings();
+               if( $vars ) {
                        $this->showStatusMessage(
                                Status::newFatal( "config-localsettings-cli-upgrade" )
                        );
@@ -110,36 +122,51 @@ class CliInstaller extends CoreInstaller {
        }
 
        public function startStage( $step ) {
-               $this->showMessage( wfMsg( "config-install-$step" ) .
-                       wfMsg( 'ellipsis' ) . wfMsg( 'word-separator' ) );
+               $this->showMessage( "config-install-$step" );
        }
 
        public function endStage( $step, $status ) {
                $this->showStatusMessage( $status );
-               $this->showMessage( wfMsg( 'config-install-step-done' ) . "\n" );
+               $this->showMessage( 'config-install-step-done' );
        }
 
        public function showMessage( $msg /*, ... */ ) {
-               $params = func_get_args();
-               array_shift( $params );
+               echo $this->getMessageText( func_get_args() ) . "\n";
+               flush();
+       }
 
-               /* parseinline has the nasty side-effect of putting encoded
-                * angle brackets, around the message, so the substr removes
-                * them. */
-               $text = substr( wfMsgExt( $msg, array( 'parseinline' ), $params ), 4, -4 );
-               $text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 &lt;$1&gt;', $text );
-               echo html_entity_decode( strip_tags( $text ), ENT_QUOTES ) . "\n";
+       public function showError( $msg /*, ... */ ) {
+               echo "***{$this->getMessageText( func_get_args() )}***\n";
                flush();
        }
 
+       /**
+        * @param $params array
+        *
+        * @return string
+        */
+       protected function getMessageText( $params ) {
+               $msg = array_shift( $params );
+
+               $text = wfMsgExt( $msg, array( 'parseinline' ), $params );
+
+               $text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 &lt;$1&gt;', $text );
+               return html_entity_decode( strip_tags( $text ), ENT_QUOTES );
+       }
+
+       /**
+        * Dummy
+        */
+       public function showHelpBox( $msg /*, ... */ ) {
+       }
+
        public function showStatusMessage( Status $status ) {
                $warnings = array_merge( $status->getWarningsArray(),
                        $status->getErrorsArray() );
 
                if ( count( $warnings ) !== 0 ) {
-                       foreach ( $status->getWikiTextArray( $warnings ) as $w ) {
-                               $this->showMessage( $w . wfMsg( 'ellipsis' ) .
-                                       wfMsg( 'word-separator' ) );
+                       foreach ( $warnings as $w ) {
+                               call_user_func_array( array( $this, 'showMessage' ), $w );
                        }
                }
 
@@ -148,4 +175,16 @@ class CliInstaller extends CoreInstaller {
                        exit;
                }
        }
+
+       public function envCheckPath( ) {
+               if ( !$this->specifiedScriptPath ) {
+                       $this->showMessage( 'config-no-cli-uri', $this->getVar("wgScriptPath") );
+               }
+               return parent::envCheckPath();
+       }
+
+       public function dirIsExecutable( $dir, $url ) {
+               $this->showMessage( 'config-no-cli-uploads-check', $dir );
+               return false;
+       }
 }