30class LocalSettingsGenerator {
32 protected $extensions = [];
33 protected $values = [];
34 protected $groupPermissions = [];
35 protected $dbSettings =
'';
46 public function __construct(
Installer $installer ) {
49 $this->extensions = $installer->getVar(
'_Extensions' );
51 $this->
IP = $installer->getVar(
'IP' );
53 $db = $installer->getDBInstaller( $installer->getVar(
'wgDBtype' ) );
57 'wgServer',
'wgScriptPath',
58 'wgPasswordSender',
'wgImageMagickConvertCommand',
'wgShellLocale',
59 'wgLanguageCode',
'wgEnableEmail',
'wgEnableUserEmail',
'wgDiff3',
60 'wgEnotifUserTalk',
'wgEnotifWatchlist',
'wgEmailAuthentication',
61 'wgDBtype',
'wgSecretKey',
'wgRightsUrl',
'wgSitename',
'wgRightsIcon',
62 'wgRightsText',
'_MainCacheType',
'wgEnableUploads',
63 '_MemCachedServers',
'wgDBserver',
'wgDBuser',
64 'wgDBpassword',
'wgUseInstantCommons',
'wgUpgradeKey',
'wgDefaultSkin',
65 'wgMetaNamespace',
'wgLogo',
'wgAuthenticationTokenVersion',
'wgPingback',
70 $unescaped = [
'wgRightsIcon',
'wgLogo',
'_Caches' ];
72 'wgEnableEmail',
'wgEnableUserEmail',
'wgEnotifUserTalk',
73 'wgEnotifWatchlist',
'wgEmailAuthentication',
'wgEnableUploads',
'wgUseInstantCommons',
77 foreach ( $confItems as $c ) {
78 $val = $installer->getVar( $c );
84 if ( !
in_array( $c, $unescaped ) && $val !==
null ) {
91 $this->dbSettings = $db->getLocalSettings();
92 $this->
values[
'wgEmergencyContact'] = $this->
values[
'wgPasswordSender'];
136 public function getText() {
139 if ( count( $this->
skins ) ) {
142# The following skins were automatically enabled:\n";
144 foreach ( $this->
skins as $skinName ) {
148 $localSettings .=
"\n";
151 if ( count( $this->extensions ) ) {
153# Enabled extensions. Most of the extensions are enabled by adding
154# wfLoadExtensions('ExtensionName');
155# to LocalSettings.php. Check specific extension documentation for more details.
156# The following extensions were automatically enabled:\n";
158 foreach ( $this->extensions as $extName ) {
162 $localSettings .=
"\n";
166# End of automatically generated settings.
167# Add more configuration options below.\n\n";
181 if ( $dir ===
'extensions' ) {
182 $jsonFile =
'extension.json';
183 $function =
'wfLoadExtension';
184 }
elseif ( $dir ===
'skins' ) {
185 $jsonFile =
'skin.json';
186 $function =
'wfLoadSkin';
188 throw new InvalidArgumentException(
'$dir was not "extensions" or "skins"' );
193 if (
file_exists(
"{$this->IP}/$dir/$encName/$jsonFile" ) ) {
194 return "$function( '$encName' );\n";
196 return "require_once \"\$IP/$dir/$encName/$encName.php\";\n";
213 $servers = $this->
values[
'_MemCachedServers'];
219 $servers = explode(
',', $servers );
221 foreach ( $servers as $srv ) {
234 if ( !$this->
values[
'wgImageMagickConvertCommand'] ) {
235 $this->
values[
'wgImageMagickConvertCommand'] =
'/usr/bin/convert';
241 if ( !$this->
values[
'wgShellLocale'] ) {
242 $this->
values[
'wgShellLocale'] =
'C.UTF-8';
249 if ( $this->
values[
'wgMetaNamespace'] !== $this->
values[
'wgSitename'] ) {
250 $metaNamespace =
"\$wgMetaNamespace = \"{$this->values['wgMetaNamespace']}\";\n";
255 if ( $this->groupPermissions ) {
256 $groupRights .=
"# The following permissions were set based on your choice in the installer\n";
257 foreach ( $this->groupPermissions as $group => $rightArr ) {
259 foreach ( $rightArr as $right => $perm ) {
261 $groupRights .=
"\$wgGroupPermissions['$group']['$right'] = " .
265 $groupRights .=
"\n";
267 if ( (
isset( $this->groupPermissions[
'*'][
'edit'] ) &&
268 $this->groupPermissions[
'*'][
'edit'] ===
false )
269 && (
isset( $this->groupPermissions[
'*'][
'createaccount'] ) &&
270 $this->groupPermissions[
'*'][
'createaccount'] ===
false )
271 && (
isset( $this->groupPermissions[
'*'][
'read'] ) &&
272 $this->groupPermissions[
'*'][
'read'] !==
false )
274 $noFollow =
"# Set \$wgNoFollowLinks to true if you open up your wiki to editing by\n"
275 .
"# the general public and wish to apply nofollow to external links as a\n"
276 .
"# deterrent to spammers. Nofollow is not a comprehensive anti-spam solution\n"
277 .
"# and open wikis will generally require other anti-spam measures; for more\n"
278 .
"# information, see https://www.mediawiki.org/wiki/Manual:Combating_spam\n"
279 .
"\$wgNoFollowLinks = false;\n\n";
285 $serverSetting =
"\n## The protocol and server name to use in fully-qualified URLs\n";
286 $serverSetting .=
"\$wgServer = \"{$this->values['wgServer']}\";";
289 switch ( $this->
values[
'_MainCacheType'] ) {
298 $cacheType =
'CACHE_NONE';
303 $platformSettings =
"\n## Include platform/distribution defaults";
304 $platformSettings .=
"\nrequire_once \"\$IP/includes/PlatformSettings.php\";";
306 $platformSettings =
'';
310# This file was automatically generated by the MediaWiki {$GLOBALS['wgVersion']}
311# installer. If you make manual changes, please keep track in case you
312# need to recreate them later.
314# See includes/DefaultSettings.php for all configurable settings
315# and their default values, but don't forget to make changes in _this_
318# Further documentation for configuration settings may be found at:
319# https://www.mediawiki.org/wiki/Manual:Configuration_settings
321# Protect against web entry
322if ( !defined( 'MEDIAWIKI' ) ) {
327## Uncomment this to disable output compression
328# \$wgDisableOutputCompression = true;
330\$wgSitename = \"{$this->values['wgSitename']}\";
332## The URL base path to the directory containing the wiki;
333## defaults for all runtime URL paths are based off of this.
334## For more information on customizing the URLs
335## (like /w/index.php/Page_title to /wiki/Page_title) please see:
336## https://www.mediawiki.org/wiki/Manual:Short_URL
337\$wgScriptPath = \"{$this->values['wgScriptPath']}\";
340## The URL path to static resources (images, scripts, etc.)
341\$wgResourceBasePath = \$wgScriptPath;
343## The URL path to the logo. Make sure you change this from the default,
344## or else you'll overwrite your logo when you upgrade!
345\$wgLogo = \"{$this->values['wgLogo']}\";
347## UPO means: this is also a user preference option
349\$wgEnableEmail = {$this->values['wgEnableEmail']};
350\$wgEnableUserEmail = {$this->values['wgEnableUserEmail']}; # UPO
352\$wgEmergencyContact = \"{$this->values['wgEmergencyContact']}\";
353\$wgPasswordSender = \"{$this->values['wgPasswordSender']}\";
355\$wgEnotifUserTalk = {$this->values['wgEnotifUserTalk']}; # UPO
356\$wgEnotifWatchlist = {$this->values['wgEnotifWatchlist']}; # UPO
357\$wgEmailAuthentication = {$this->values['wgEmailAuthentication']};
360\$wgDBtype = \"{$this->values['wgDBtype']}\";
361\$wgDBserver = \"{$this->values['wgDBserver']}\";
362\$wgDBname = \"{$this->values['wgDBname']}\";
363\$wgDBuser = \"{$this->values['wgDBuser']}\";
364\$wgDBpassword = \"{$this->values['wgDBpassword']}\";
368## Shared memory settings
369\$wgMainCacheType = $cacheType;
370\$wgMemCachedServers = $mcservers;
372## To enable image uploads, make sure the 'images' directory
373## is writable, then set this to true:
374\$wgEnableUploads = {$this->values['wgEnableUploads']};
375{$magic}\$wgUseImageMagick = true;
376{$magic}\$wgImageMagickConvertCommand = \"{$this->values['wgImageMagickConvertCommand']}\";
378# InstantCommons allows wiki to use images from https://commons.wikimedia.org
379\$wgUseInstantCommons = {$this->values['wgUseInstantCommons']};
381# Periodically send a pingback to https://www.mediawiki.org/ with basic data
382# about this MediaWiki instance. The Wikimedia Foundation shares this data
383# with MediaWiki developers to help guide future development efforts.
384\$wgPingback = {$this->values['wgPingback']};
386## If you use ImageMagick (or any other shell command) on a
387## Linux server, this will need to be set to the name of an
388## available UTF-8 locale
389{$locale}\$wgShellLocale = \"{$this->values['wgShellLocale']}\";
391## Set \$wgCacheDirectory to a writable directory on the web server
392## to make your wiki go slightly faster. The directory should not
393## be publicly accessible from the web.
394#\$wgCacheDirectory = \"\$IP/cache\";
396# Site language code, should be one of the list in ./languages/data/Names.php
397\$wgLanguageCode = \"{$this->values['wgLanguageCode']}\";
399\$wgSecretKey = \"{$this->values['wgSecretKey']}\";
401# Changing this will log out all existing sessions.
402\$wgAuthenticationTokenVersion = \"{$this->values['wgAuthenticationTokenVersion']}\";
404# Site upgrade key. Must be set to a string (default provided) to turn on the
405# web installer while LocalSettings.php is in place
406\$wgUpgradeKey = \"{$this->values['wgUpgradeKey']}\";
408## For attaching licensing metadata to pages, and displaying an
409## appropriate copyright notice / icon. GNU Free Documentation
410## License and Creative Commons licenses are supported so far.
411\$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
412\$wgRightsUrl = \"{$this->values['wgRightsUrl']}\";
413\$wgRightsText = \"{$this->values['wgRightsText']}\";
414\$wgRightsIcon = \"{$this->values['wgRightsIcon']}\";
416# Path to the GNU diff3 utility. Used for conflict resolution.
417\$wgDiff3 = \"{$this->values['wgDiff3']}\";
419{$groupRights}{$noFollow}## Default skin: you can change the default skin. Use the internal symbolic
420## names, ie 'vector', 'monobook':
421\$wgDefaultSkin = \"{$this->values['wgDefaultSkin']}\";
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfBoolToStr( $value)
Convenience function converts boolean values into "true" or "false" (string) values.
A collection of public static functions to play with IP address and IP ranges.
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
skin txt MediaWiki includes four core skins