var $settings = array();
var $localVHosts = array();
- /** */
+ /**
+ * Retrieves a configuration setting for a given wiki.
+ * @param $settingName String ID of the setting name to retrieve
+ * @param $wiki String Wiki ID of the wiki in question.
+ * @param $suffix String The suffix of the wiki in question.
+ * @param $params Array List of parameters. $.'key' is replaced by $value in all returned data.
+ * @param $wikiTags Array The tags assigned to the wiki.
+ * @return Mixed the value of the setting requested.
+ */
function get( $settingName, $wiki, $suffix, $params = array(), $wikiTags = array() ) {
if ( array_key_exists( $settingName, $this->settings ) ) {
$thisSetting =& $this->settings[$settingName];
do {
+ // Do individual wiki settings
if ( array_key_exists( $wiki, $thisSetting ) ) {
$retval = $thisSetting[$wiki];
break;
+ } elseif ( array_key_exists( "+$wiki", $thisSetting ) && is_array($thisSetting["+$wiki"]) ) {
+ $retval = $thisSetting["+$wiki"];
}
+
+ // Do tag settings
foreach ( $wikiTags as $tag ) {
if ( array_key_exists( $tag, $thisSetting ) ) {
- $retval = $thisSetting[$tag];
+ if ( is_array($retval) && is_array($thisSetting[$tag]) ) {
+ $retval = array_merge( $retval, $thisSetting[$tag] );
+ } else {
+ $retval = $thisSetting[$tag];
+ }
break 2;
+ } elseif ( array_key_exists( "+$tag", $thisSetting ) && is_array($thisSetting["+$tag"]) ) {
+ if (!isset($retval))
+ $retval = array();
+ $retval = array_merge( $retval, $thisSetting["+$tag"] );
}
}
+
+ // Do suffix settings
if ( array_key_exists( $suffix, $thisSetting ) ) {
- $retval = $thisSetting[$suffix];
+ if ( is_array($retval) && is_array($thisSetting[$suffix]) ) {
+ $retval = array_merge( $retval, $thisSetting[$suffix] );
+ } else {
+ $retval = $thisSetting[$suffix];
+ }
break;
+ } elseif ( array_key_exists( "+$suffix", $thisSetting ) && is_array($thisSetting["+$suffix"]) ) {
+ if (!isset($retval))
+ $retval = array();
+ $retval = array_merge( $retval, $thisSetting["+$suffix"] );
}
+
+ // Fall back to default.
if ( array_key_exists( 'default', $thisSetting ) ) {
- $retval = $thisSetting['default'];
+ if ( is_array($retval) && is_array($thisSetting['default']) ) {
+ $retval = array_merge( $retval, $thisSetting['default'] );
+ } else {
+ $retval = $thisSetting['default'];
+ }
break;
}
$retval = null;
}
}
- /** */
+ /**
+ * Gets all settings for a wiki
+ * @param $wiki String Wiki ID of the wiki in question.
+ * @param $suffix String The suffix of the wiki in question.
+ * @param $params Array List of parameters. $.'key' is replaced by $value in all returned data.
+ * @param $wikiTags Array The tags assigned to the wiki.
+ * @return Array Array of settings requested.
+ */
function getAll( $wiki, $suffix, $params, $wikiTags = array() ) {
$localSettings = array();
foreach ( $this->settings as $varname => $stuff ) {
return $localSettings;
}
- /** */
+ /**
+ * Retrieves a configuration setting for a given wiki, forced to a boolean.
+ * @param $settingName String ID of the setting name to retrieve
+ * @param $wiki String Wiki ID of the wiki in question.
+ * @param $suffix String The suffix of the wiki in question.
+ * @param $params Array List of parameters. $.'key' is replaced by $value in all returned data.
+ * @param $wikiTags Array The tags assigned to the wiki.
+ * @return bool The value of the setting requested.
+ */
function getBool( $setting, $wiki, $suffix, $wikiTags = array() ) {
return (bool)($this->get( $setting, $wiki, $suffix, array(), $wikiTags ) );
}
- /** */
+ /** Retrieves an array of local databases */
function &getLocalDatabases() {
return $this->wikis;
}
- /** */
+ /** A no-op */
function initialise() {
}
- /** */
+ /**
+ * Retrieves the value of a given setting, and places it in a variable passed by reference.
+ * @param $settingName String ID of the setting name to retrieve
+ * @param $wiki String Wiki ID of the wiki in question.
+ * @param $suffix String The suffix of the wiki in question.
+ * @param $var Reference The variable to insert the value into.
+ * @param $params Array List of parameters. $.'key' is replaced by $value in all returned data.
+ * @param $wikiTags Array The tags assigned to the wiki.
+ */
function extractVar( $setting, $wiki, $suffix, &$var, $params, $wikiTags = array() ) {
$value = $this->get( $setting, $wiki, $suffix, $params, $wikiTags );
if ( !is_null( $value ) ) {
}
}
- /** */
+ /**
+ * Retrieves the value of a given setting, and places it in its corresponding global variable.
+ * @param $settingName String ID of the setting name to retrieve
+ * @param $wiki String Wiki ID of the wiki in question.
+ * @param $suffix String The suffix of the wiki in question.
+ * @param $params Array List of parameters. $.'key' is replaced by $value in all returned data.
+ * @param $wikiTags Array The tags assigned to the wiki.
+ */
function extractGlobal( $setting, $wiki, $suffix, $params, $wikiTags = array() ) {
$value = $this->get( $setting, $wiki, $suffix, $params, $wikiTags );
if ( !is_null( $value ) ) {
}
}
- /** */
+ /**
+ * Retrieves the values of all settings, and places them in their corresponding global variables.
+ * @param $wiki String Wiki ID of the wiki in question.
+ * @param $suffix String The suffix of the wiki in question.
+ * @param $params Array List of parameters. $.'key' is replaced by $value in all returned data.
+ * @param $wikiTags Array The tags assigned to the wiki.
+ */
function extractAllGlobals( $wiki, $suffix, $params, $wikiTags = array() ) {
foreach ( $this->settings as $varName => $setting ) {
$this->extractGlobal( $varName, $wiki, $suffix, $params, $wikiTags );
return array( $site, $lang );
}
- /** */
+ /** Returns true if the given vhost is handled locally. */
function isLocalVHost( $vhost ) {
return in_array( $vhost, $this->localVHosts );
}