Jump to content

User:Jasper Deng/$wgConf alternative

From mediawiki.org

Since $wgConf has its limitations, you can use the following examples for a common settings file. This is somewhat used by the Wikimedia Foundation, especially for extensions and namespaces not on all wikis.

#To exclude a wiki from a particular setting
//On wiki's LocalSettings.php:
$wgSettingExcludeWiki=true; #You must define this setting for on EVERY one of your wikis.
require_once("<path to your common settings file>");
//On your common settings file:
if($wgSettingExcludesWiki==false){
$wgSetting=true; #Example for a default setting
}
#To exclude a wiki from a particular extension
//On wiki's LocalSettings.php:
$wgExtensionExcludeWiki=true; #As before, define it on EVERY wiki
require_once("<path to your common settings file>");
//On your common settings file:
if($wgSettingExcludesWiki==false){
require_once("$IP/extensions/Extension.php");
}
#To set various settings for multiple wikis
//On every wiki's LocalSettings.php:
$wgWikiID='wikiname';
require_once("<path to your common settings file>");
//On your common settings file:
switch ($wgWikiID){
   case 'wiki1name':
    $wgSetting1='<wiki1setting>';
    $wgSetting2='<wiki1setting>';
    require_once("$IP/extensions/Wiki1OnlyExtension.php");
   break;
   case 'wiki2name':
    $wgSetting1='<wiki2setting>';
    $wgSetting2='<wiki2setting>';
   break;
   default: #For all other wikis
    $wgSetting1='<defaultsetting>';
    $wgSetting2='<defaultsetting>';
}
$wgSetting3='<setting that applies on all wikis>';
require_once("$IP/extensions/AllwikisExtension.php");

Disclaimer: This is not a substitute for $wgConf if you are using CentralAuth, and this is not officially endorsed by MediaWiki developers except for the extension management part, and for certain extensions like AbuseFilter.