* @ingroup Deployment
* @since 1.17
*/
-class CliInstaller extends CoreInstaller {
+class CliInstaller extends Installer {
+ private $specifiedScriptPath = false;
private $optionMap = array(
'dbtype' => 'wgDBtype',
'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. */
);
/**
* @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];
}
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'] );
$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 );
}
$this->getVar( 'wgDBuser' ) );
$this->setVar( '_InstallPassword',
$this->getVar( 'wgDBpassword' ) );
+ } else {
+ $this->setVar( '_InstallUser',
+ $option['installdbuser'] );
+ $this->setVar( '_InstallPassword',
+ $option['installdbpass'] );
}
if ( isset( $option['pass'] ) ) {
* 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" )
);
}
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 <$1>', $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 <$1>', $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 );
}
}
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;
+ }
}