MediaWiki  REL1_19
SiteConfiguration Class Reference

This is a class used to hold configuration settings, particularly for multi-wiki sites. More...

List of all members.

Public Member Functions

 doReplace ($from, $to, $in)
 Type-safe string replace; won't do replacements on non-strings private?
 extractAllGlobals ($wiki, $suffix=null, $params=array(), $wikiTags=array())
 Retrieves the values of all settings, and places them in their corresponding global variables.
 extractGlobal ($setting, $wiki, $suffix=null, $params=array(), $wikiTags=array())
 Retrieves the value of a given setting, and places it in its corresponding global variable.
 extractGlobalSetting ($setting, $wiki, $params)
 extractVar ($setting, $wiki, $suffix, &$var, $params=array(), $wikiTags=array())
 Retrieves the value of a given setting, and places it in a variable passed by reference.
 get ($settingName, $wiki, $suffix=null, $params=array(), $wikiTags=array())
 Retrieves a configuration setting for a given wiki.
 getAll ($wiki, $suffix=null, $params=array(), $wikiTags=array())
 Gets all settings for a wiki.
 getBool ($setting, $wiki, $suffix=null, $wikiTags=array())
 Retrieves a configuration setting for a given wiki, forced to a boolean.
getLocalDatabases ()
 Retrieves an array of local databases.
 isLocalVHost ($vhost)
 Returns true if the given vhost is handled locally.
 loadFullData ()
 siteFromDB ($db)
 Work out the site and language name from a database name.

Static Public Member Functions

static arrayMerge ($array1)
 Merge multiple arrays together.

Public Attributes

 $fullLoadCallback = null
 Optional callback to load full configuration data.
 $fullLoadDone = false
 Whether or not all data has been loaded.
 $localVHosts = array()
 Array of domains that are local and can be handled by the same server.
 $settings = array()
 The whole array of settings.
 $siteParamsCallback = null
 A callback function that returns an array with the following keys (all optional):
 $suffixes = array()
 Array of suffixes, for self::siteFromDB()
 $wikis = array()
 Array of wikis, should be the same as $wgLocalDatabases.

Protected Member Functions

 getSetting ($settingName, $wiki, $params)
 Really retrieves a configuration setting for a given wiki.
 getWikiParams ($wiki)
 Return specific settings for $wiki See the documentation of self::$siteParamsCallback for more in-depth documentation about this function.
 mergeParams ($wiki, $suffix, $params, $wikiTags)
 Merge params between the ones passed to the function and the ones given by self::$siteParamsCallback for backward compatibility Values returned by self::getWikiParams() have the priority.

Detailed Description

This is a class used to hold configuration settings, particularly for multi-wiki sites.

Definition at line 5 of file SiteConfiguration.php.


Member Function Documentation

static SiteConfiguration::arrayMerge ( array1) [static]

Merge multiple arrays together.

On encountering duplicate keys, merge the two, but ONLY if they're arrays. PHP's array_merge_recursive() merges ANY duplicate values into arrays, which is not fun

Parameters:
$array1array
Returns:
array

Definition at line 385 of file SiteConfiguration.php.

References $out.

Referenced by extractGlobalSetting(), getAll(), and getSetting().

Here is the caller graph for this function:

SiteConfiguration::doReplace ( from,
to,
in 
)

Type-safe string replace; won't do replacements on non-strings private?

Parameters:
$from
$to
$in
Returns:
string

Definition at line 145 of file SiteConfiguration.php.

References $in.

Referenced by getSetting().

Here is the caller graph for this function:

SiteConfiguration::extractAllGlobals ( wiki,
suffix = null,
params = array(),
wikiTags = array() 
)

Retrieves the values of all settings, and places them in their corresponding global variables.

Parameters:
$wikiString Wiki ID of the wiki in question.
$suffixString The suffix of the wiki in question.
$paramsArray List of parameters. $.'key' is replaced by $value in all returned data.
$wikiTagsArray The tags assigned to the wiki.

Definition at line 265 of file SiteConfiguration.php.

References extractGlobalSetting(), and mergeParams().

Here is the call graph for this function:

SiteConfiguration::extractGlobal ( setting,
wiki,
suffix = null,
params = array(),
wikiTags = array() 
)

Retrieves the value of a given setting, and places it in its corresponding global variable.

Parameters:
$settingString ID of the setting name to retrieve
$wikiString Wiki ID of the wiki in question.
$suffixString The suffix of the wiki in question.
$paramsArray List of parameters. $.'key' is replaced by $value in all returned data.
$wikiTagsArray The tags assigned to the wiki.

Definition at line 232 of file SiteConfiguration.php.

References extractGlobalSetting(), and mergeParams().

Here is the call graph for this function:

SiteConfiguration::extractGlobalSetting ( setting,
wiki,
params 
)
Parameters:
$settingstring
$wikistring
$paramsarray

Definition at line 242 of file SiteConfiguration.php.

References arrayMerge(), and getSetting().

Referenced by extractAllGlobals(), and extractGlobal().

Here is the call graph for this function:

Here is the caller graph for this function:

SiteConfiguration::extractVar ( setting,
wiki,
suffix,
&$  var,
params = array(),
wikiTags = array() 
)

Retrieves the value of a given setting, and places it in a variable passed by reference.

Parameters:
$settingString ID of the setting name to retrieve
$wikiString Wiki ID of the wiki in question.
$suffixString The suffix of the wiki in question.
$varReference The variable to insert the value into.
$paramsArray List of parameters. $.'key' is replaced by $value in all returned data.
$wikiTagsArray The tags assigned to the wiki.

Definition at line 217 of file SiteConfiguration.php.

SiteConfiguration::get ( settingName,
wiki,
suffix = null,
params = array(),
wikiTags = array() 
)

Retrieves a configuration setting for a given wiki.

Parameters:
$settingNameString ID of the setting name to retrieve
$wikiString Wiki ID of the wiki in question.
$suffixString The suffix of the wiki in question.
$paramsArray List of parameters. $.'key' is replaced by $value in all returned data.
$wikiTagsArray The tags assigned to the wiki.
Returns:
Mixed the value of the setting requested.

Definition at line 58 of file SiteConfiguration.php.

References getSetting(), and mergeParams().

Here is the call graph for this function:

SiteConfiguration::getAll ( wiki,
suffix = null,
params = array(),
wikiTags = array() 
)

Gets all settings for a wiki.

Parameters:
$wikiString Wiki ID of the wiki in question.
$suffixString The suffix of the wiki in question.
$paramsArray List of parameters. $.'key' is replaced by $value in all returned data.
$wikiTagsArray The tags assigned to the wiki.
Returns:
Array Array of settings requested.

Definition at line 166 of file SiteConfiguration.php.

References arrayMerge(), getSetting(), and mergeParams().

Here is the call graph for this function:

SiteConfiguration::getBool ( setting,
wiki,
suffix = null,
wikiTags = array() 
)

Retrieves a configuration setting for a given wiki, forced to a boolean.

Parameters:
$settingString ID of the setting name to retrieve
$wikiString Wiki ID of the wiki in question.
$suffixString The suffix of the wiki in question.
$wikiTagsArray The tags assigned to the wiki.
Returns:
bool The value of the setting requested.

Definition at line 195 of file SiteConfiguration.php.

Retrieves an array of local databases.

Returns:
array

Definition at line 204 of file SiteConfiguration.php.

SiteConfiguration::getSetting ( settingName,
wiki,
params 
) [protected]

Really retrieves a configuration setting for a given wiki.

Parameters:
$settingNameString ID of the setting name to retrieve.
$wikiString Wiki ID of the wiki in question.
$paramsArray: array of parameters.
Returns:
Mixed the value of the setting requested.

Definition at line 71 of file SiteConfiguration.php.

References arrayMerge(), and doReplace().

Referenced by extractGlobalSetting(), get(), and getAll().

Here is the call graph for this function:

Here is the caller graph for this function:

SiteConfiguration::getWikiParams ( wiki) [protected]

Return specific settings for $wiki See the documentation of self::$siteParamsCallback for more in-depth documentation about this function.

Parameters:
$wikiString
Returns:
array

Definition at line 280 of file SiteConfiguration.php.

Referenced by mergeParams(), and siteFromDB().

Here is the caller graph for this function:

Returns true if the given vhost is handled locally.

Parameters:
$vhostString
Returns:
bool

Definition at line 371 of file SiteConfiguration.php.

SiteConfiguration::mergeParams ( wiki,
suffix,
params,
wikiTags 
) [protected]

Merge params between the ones passed to the function and the ones given by self::$siteParamsCallback for backward compatibility Values returned by self::getWikiParams() have the priority.

Parameters:
$wikiString Wiki ID of the wiki in question.
$suffixString The suffix of the wiki in question.
$paramsArray List of parameters. $.'key' is replaced by $value in all returned data.
$wikiTagsArray The tags assigned to the wiki.
Returns:
array

Definition at line 318 of file SiteConfiguration.php.

References getWikiParams().

Referenced by extractAllGlobals(), extractGlobal(), get(), and getAll().

Here is the call graph for this function:

Here is the caller graph for this function:

Work out the site and language name from a database name.

Parameters:
$db
Returns:
array

Definition at line 343 of file SiteConfiguration.php.

References getWikiParams().

Here is the call graph for this function:


Member Data Documentation

SiteConfiguration::$fullLoadCallback = null

Optional callback to load full configuration data.

Definition at line 30 of file SiteConfiguration.php.

SiteConfiguration::$fullLoadDone = false

Whether or not all data has been loaded.

Definition at line 33 of file SiteConfiguration.php.

SiteConfiguration::$localVHosts = array()

Array of domains that are local and can be handled by the same server.

Definition at line 25 of file SiteConfiguration.php.

SiteConfiguration::$settings = array()

The whole array of settings.

Definition at line 20 of file SiteConfiguration.php.

SiteConfiguration::$siteParamsCallback = null

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

Definition at line 47 of file SiteConfiguration.php.

SiteConfiguration::$suffixes = array()

Array of suffixes, for self::siteFromDB()

Definition at line 10 of file SiteConfiguration.php.

SiteConfiguration::$wikis = array()

Array of wikis, should be the same as $wgLocalDatabases.

Definition at line 15 of file SiteConfiguration.php.


The documentation for this class was generated from the following file: