Go to the documentation of this file.
34 private $specifiedScriptPath =
false;
36 private $optionMap = [
37 'dbtype' =>
'wgDBtype',
38 'dbserver' =>
'wgDBserver',
39 'dbname' =>
'wgDBname',
40 'dbuser' =>
'wgDBuser',
41 'dbpass' =>
'wgDBpassword',
42 'dbprefix' =>
'wgDBprefix',
43 'dbtableoptions' =>
'wgDBTableOptions',
44 'dbport' =>
'wgDBport',
45 'dbschema' =>
'wgDBmwschema',
46 'dbpath' =>
'wgSQLiteDataDir',
47 'server' =>
'wgServer',
48 'scriptpath' =>
'wgScriptPath',
57 function __construct( $siteName, $admin =
null, array $options = [] ) {
60 parent::__construct();
62 if ( isset( $options[
'scriptpath'] ) ) {
63 $this->specifiedScriptPath =
true;
66 foreach ( $this->optionMap as $opt => $global ) {
67 if ( isset( $options[$opt] ) ) {
69 $this->
setVar( $global, $options[$opt] );
73 if ( isset( $options[
'lang'] ) ) {
75 $this->
setVar(
'_UserLang', $options[
'lang'] );
77 $this->
setVar(
'wgLanguageCode', $wgLanguageCode );
78 $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
83 $this->
setVar(
'wgSitename', $siteName );
85 $metaNS =
$wgContLang->ucfirst( str_replace(
' ',
'_', $siteName ) );
86 if ( $metaNS ==
'MediaWiki' ) {
89 $this->
setVar(
'wgMetaNamespace', $metaNS );
92 $this->
setVar(
'_AdminName', $admin );
95 if ( !isset( $options[
'installdbuser'] ) ) {
96 $this->
setVar(
'_InstallUser',
97 $this->
getVar(
'wgDBuser' ) );
98 $this->
setVar(
'_InstallPassword',
99 $this->
getVar(
'wgDBpassword' ) );
101 $this->
setVar(
'_InstallUser',
102 $options[
'installdbuser'] );
103 $this->
setVar(
'_InstallPassword',
104 $options[
'installdbpass'] ??
"" );
107 $this->
setVar(
'_CreateDBAccount',
true );
110 if ( isset( $options[
'pass'] ) ) {
111 $this->
setVar(
'_AdminPassword', $options[
'pass'] );
115 if ( isset( $options[
'extensions'] ) ) {
116 $status = $this->validateExtensions(
117 'extension',
'extensions', $options[
'extensions'] );
121 $this->
setVar(
'_Extensions', $status->value );
122 } elseif ( isset( $options[
'with-extensions'] ) ) {
124 if ( !$status->
isOK() ) {
127 $this->
setVar(
'_Extensions', array_keys(
$status->value ) );
131 if ( isset( $options[
'skins'] ) ) {
132 $status = $this->validateExtensions(
'skin',
'skins', $options[
'skins'] );
139 if ( !$status->
isOK() ) {
142 $skins = array_keys(
$status->value );
144 $this->
setVar(
'_Skins', $skins );
147 $skinNames = array_map(
'strtolower', $skins );
152 private function validateExtensions(
$type, $directory, $nameLists ) {
155 foreach ( (array)$nameLists as $nameList ) {
156 foreach ( explode(
',', $nameList ) as $name ) {
157 $name = trim( $name );
158 if ( $name ===
'' ) {
162 if ( $extStatus->isOK() ) {
163 $extensions[] = $name;
169 $extensions = array_unique( $extensions );
177 public function execute() {
182 if ( count( $this->
getVar(
'_Caches' ) ) ) {
184 $this->
setVar(
'_MainCacheType',
'accel' );
195 [ $this,
'startStage' ],
196 [ $this,
'endStage' ]
200 $lastStepStatus = end( $result );
201 if ( $lastStepStatus->isOK() ) {
204 return $lastStepStatus;
213 public function writeConfigurationFile(
$path ) {
215 $ls->writeFile(
"$path/LocalSettings.php" );
218 public function startStage( $step ) {
225 public function endStage( $step,
$status ) {
231 echo $this->getMessageText( $msg, $params ) .
"\n";
235 public function showError( $msg, ...$params ) {
236 echo
"***{$this->getMessageText( $msg, $params )}***\n";
246 protected function getMessageText( $msg, $params ) {
247 $text =
wfMessage( $msg, $params )->parse();
249 $text = preg_replace(
'/<a href="(.*?)".*?>(.*?)<\/a>/',
'$2 <$1>', $text );
251 return Sanitizer::stripAllTags( $text );
257 public function showHelpBox( $msg ) {
261 $warnings = array_merge(
$status->getWarningsArray(),
264 if ( count( $warnings ) !== 0 ) {
265 foreach ( $warnings as $w ) {
272 if ( !$this->specifiedScriptPath ) {
276 return parent::envCheckPath();
281 return 'http://localhost';
285 $this->
showMessage(
'config-no-cli-uploads-check', $dir );
__construct()
Constructor, always call this from child classes.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
dirIsExecutable( $dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
performInstallation( $startCB, $endCB)
Actually perform the installation.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
envGetDefaultServer()
Helper function to be called from envPrepServer()
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
showMessage( $msg,... $params)
UI interface for displaying a short message The parameters are like parameters to wfMessage().
isOK()
Returns whether the operation completed.
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
envCheckPath()
Environment check to inform user which paths we've assumed.
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings,...
findExtensions( $directory='extensions')
Find extensions or skins in a subdirectory of $IP.
static newGood( $value=null)
Factory function for good results.
$wgLanguageCode
Site language code.
static getMain()
Get the RequestContext object associated with the main request.
static factory( $code)
Get a cached or new language object for a given language code.
showError( $msg,... $params)
Same as showMessage(), but for displaying errors.
getExtensionInfo( $type, $parentRelPath, $name)