protected $groupPermissions = array();
protected $dbSettings = '';
protected $safeMode = false;
+ protected $IP;
/**
* @var Installer
$this->installer = $installer;
$this->extensions = $installer->getVar( '_Extensions' );
+ $this->skins = $installer->getVar( '_Skins' );
+ $this->IP = $installer->getVar( 'IP' );
$db = $installer->getDBInstaller( $installer->getVar( 'wgDBtype' ) );
'wgRightsText', 'wgMainCacheType', 'wgEnableUploads',
'wgMainCacheType', '_MemCachedServers', 'wgDBserver', 'wgDBuser',
'wgDBpassword', 'wgUseInstantCommons', 'wgUpgradeKey', 'wgDefaultSkin',
- 'wgMetaNamespace', 'wgResourceLoaderMaxQueryLength', 'wgLogo',
+ 'wgMetaNamespace', 'wgLogo',
),
$db->getGlobalNames()
);
/**
* Return the full text of the generated LocalSettings.php file,
- * including the extensions
+ * including the extensions and skins.
*
* @return string
*/
public function getText() {
$localSettings = $this->getDefaultText();
+ if ( count( $this->skins ) ) {
+ $localSettings .= "
+# Enabled skins.
+# The following skins were automatically enabled:\n";
+
+ foreach ( $this->skins as $skinName ) {
+ $localSettings .= $this->generateExtEnableLine( 'skins', $skinName );
+ }
+
+ $localSettings .= "\n";
+ }
+
if ( count( $this->extensions ) ) {
$localSettings .= "
# Enabled Extensions. Most extensions are enabled by including the base extension file here
# The following extensions were automatically enabled:\n";
foreach ( $this->extensions as $extName ) {
- $encExtName = self::escapePhpString( $extName );
- $localSettings .= "require_once \"\$IP/extensions/$encExtName/$encExtName.php\";\n";
+ $localSettings .= $this->generateExtEnableLine( 'extensions', $extName );
}
+
+ $localSettings .= "\n";
}
- $localSettings .= "\n\n# End of automatically generated settings.
+ $localSettings .= "
+# End of automatically generated settings.
# Add more configuration options below.\n\n";
return $localSettings;
}
+ /**
+ * Generate the appropriate line to enable the given extension or skin
+ *
+ * @param string $dir Either "extensions" or "skins"
+ * @param string $name Name of extension/skin
+ * @throws InvalidArgumentException
+ * @return string
+ */
+ private function generateExtEnableLine( $dir, $name ) {
+ if ( $dir === 'extensions' ) {
+ $jsonFile = 'extension.json';
+ $function = 'wfLoadExtension';
+ } elseif ( $dir === 'skins' ) {
+ $jsonFile = 'skin.json';
+ $function = 'wfLoadSkin';
+ } else {
+ throw new InvalidArgumentException( '$dir was not "extensions" or "skins' );
+ }
+
+ $encName = self::escapePhpString( $name );
+
+ if ( file_exists( "{$this->IP}/$dir/$encName/$jsonFile" ) ) {
+ return "$function( '$encName' );\n";
+ } else {
+ return "require_once \"\$IP/$dir/$encName/$encName.php\";\n";
+ }
+ }
+
/**
* Write the generated LocalSettings to a file
*
$locale = '';
}
- //$rightsUrl = $this->values['wgRightsUrl'] ? '' : '#'; // @todo FIXME: I'm unused!
$hashedUploads = $this->safeMode ? '' : '#';
$metaNamespace = '';
if ( $this->values['wgMetaNamespace'] !== $this->values['wgSitename'] ) {
wfBoolToStr( $perm ) . ";\n";
}
}
+ $groupRights .= "\n";
+
if ( ( isset( $this->groupPermissions['*']['edit'] ) &&
$this->groupPermissions['*']['edit'] === false )
&& ( isset( $this->groupPermissions['*']['createaccount'] ) &&
&& ( isset( $this->groupPermissions['*']['read'] ) &&
$this->groupPermissions['*']['read'] !== false )
) {
- $noFollow = "\n# Set \$wgNoFollowLinks to true if you open up your wiki to editing by\n"
+ $noFollow = "# Set \$wgNoFollowLinks to true if you open up your wiki to editing by\n"
. "# the general public and wish to apply nofollow to external links as a\n"
. "# deterrent to spammers. Nofollow is not a comprehensive anti-spam solution\n"
. "# and open wikis will generally require other anti-spam measures; for more\n"
. "# information, see https://www.mediawiki.org/wiki/Manual:Combating_spam\n"
- . "\$wgNoFollowLinks = false;";
+ . "\$wgNoFollowLinks = false;\n\n";
}
}
# web installer while LocalSettings.php is in place
\$wgUpgradeKey = \"{$this->values['wgUpgradeKey']}\";
-## Default skin: you can change the default skin. Use the internal symbolic
-## names, ie 'vector', 'monobook':
-\$wgDefaultSkin = \"{$this->values['wgDefaultSkin']}\";
-
## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
# Path to the GNU diff3 utility. Used for conflict resolution.
\$wgDiff3 = \"{$this->values['wgDiff3']}\";
-{$groupRights}{$noFollow}";
+{$groupRights}{$noFollow}## Default skin: you can change the default skin. Use the internal symbolic
+## names, ie 'vector', 'monobook':
+\$wgDefaultSkin = \"{$this->values['wgDefaultSkin']}\";
+";
}
}