+
+ /**
+ * Array of suffixes, for self::siteFromDB()
+ */
+ public $suffixes = array();
+
+ /**
+ * Array of wikis, should be the same as $wgLocalDatabases
+ */
+ public $wikis = array();
+
+ /**
+ * The whole array of settings
+ */
+ public $settings = array();
+
+ /**
+ * Array of domains that are local and can be handled by the same server
+ */
+ public $localVHosts = array();
+
+ /**
+ * Optional callback to load full configuration data.
+ */
+ public $fullLoadCallback = null;
+
+ /** Whether or not all data has been loaded */
+ public $fullLoadDone = false;
+
+ /**
+ * A callback function that returns an array with the following keys (all
+ * optional):
+ * - suffix: site's suffix
+ * - lang: site's lang
+ * - tags: array of wiki tags
+ * - params: array of parameters to be replaced
+ * The function will receive the SiteConfiguration instance in the first
+ * argument and the wiki in the second one.
+ * if suffix and lang are passed they will be used for the return value of
+ * self::siteFromDB() and self::$suffixes will be ignored
+ */
+ public $siteParamsCallback = null;
+
+ /**
+ * 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.
+ */
+ public function get( $settingName, $wiki, $suffix = null, $params = array(), $wikiTags = array() ) {
+ $params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags );
+ return $this->getSetting( $settingName, $wiki, $params );
+ }
+
+ /**
+ * Really 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 $params Array: array of parameters.
+ * @return Mixed the value of the setting requested.
+ */
+ protected function getSetting( $settingName, $wiki, /*array*/ $params ){
+ $retval = null;
+ 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( $params['tags'] as $tag ) {
+ if( array_key_exists( $tag, $thisSetting ) ) {
+ if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$tag] ) ) {
+ $retval = self::arrayMerge( $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 = self::arrayMerge( $retval, $thisSetting["+$tag"] );
+ }
+ }
+ // Do suffix settings
+ $suffix = $params['suffix'];
+ if( !is_null( $suffix ) ) {
+ if( array_key_exists( $suffix, $thisSetting ) ) {
+ if ( isset($retval) && is_array($retval) && is_array($thisSetting[$suffix]) ) {
+ $retval = self::arrayMerge( $retval, $thisSetting[$suffix] );
+ } else {
+ $retval = $thisSetting[$suffix];
+ }
+ break;
+ } elseif( array_key_exists( "+$suffix", $thisSetting ) && is_array($thisSetting["+$suffix"]) ) {
+ if (!isset($retval))
+ $retval = array();
+ $retval = self::arrayMerge( $retval, $thisSetting["+$suffix"] );
+ }
+ }
+
+ // Fall back to default.
+ if( array_key_exists( 'default', $thisSetting ) ) {
+ if( is_array( $retval ) && is_array( $thisSetting['default'] ) ) {
+ $retval = self::arrayMerge( $retval, $thisSetting['default'] );
+ } else {
+ $retval = $thisSetting['default'];
+ }
+ break;
+ }
+ } while ( false );