Go to the documentation of this file.
179 public function get( $settingName, $wiki, $suffix =
null,
$params =
array(), $wikiTags =
array() ) {
194 if ( array_key_exists( $settingName, $this->
settings ) ) {
195 $thisSetting =& $this->
settings[$settingName];
198 if ( array_key_exists( $wiki, $thisSetting ) ) {
201 } elseif ( array_key_exists(
"+$wiki", $thisSetting ) && is_array( $thisSetting[
"+$wiki"] ) ) {
202 $retval = $thisSetting[
"+$wiki"];
207 if ( array_key_exists( $tag, $thisSetting ) ) {
208 if ( isset(
$retval ) && is_array(
$retval ) && is_array( $thisSetting[$tag] ) ) {
214 } elseif ( array_key_exists(
"+$tag", $thisSetting ) && is_array( $thisSetting[
"+$tag"] ) ) {
223 if ( !is_null( $suffix ) ) {
224 if ( array_key_exists( $suffix, $thisSetting ) ) {
225 if ( isset(
$retval ) && is_array(
$retval ) && is_array( $thisSetting[$suffix] ) ) {
228 $retval = $thisSetting[$suffix];
231 } elseif ( array_key_exists(
"+$suffix", $thisSetting ) && is_array( $thisSetting[
"+$suffix"] ) ) {
240 if ( array_key_exists(
'default', $thisSetting ) ) {
241 if ( is_array(
$retval ) && is_array( $thisSetting[
'default'] ) ) {
244 $retval = $thisSetting[
'default'];
269 if ( is_string(
$in ) ) {
270 return str_replace(
$from, $to,
$in );
271 } elseif ( is_array(
$in ) ) {
272 foreach (
$in as $key => $val ) {
291 $localSettings =
array();
292 foreach ( $this->
settings as $varname => $stuff ) {
295 if ( substr( $varname, 0, 1 ) ==
'+' ) {
297 $var = substr( $varname, 1 );
301 if ( $append && is_array(
$value ) && is_array(
$GLOBALS[$var] ) ) {
304 if ( !is_null(
$value ) ) {
305 $localSettings[$var] =
$value;
308 return $localSettings;
319 public function getBool( $setting, $wiki, $suffix =
null, $wikiTags =
array() ) {
320 return (
bool)$this->
get( $setting, $wiki, $suffix,
array(), $wikiTags );
342 $value = $this->
get( $setting, $wiki, $suffix,
$params, $wikiTags );
343 if ( !is_null(
$value ) ) {
368 if ( !is_null(
$value ) ) {
369 if ( substr( $setting, 0, 1 ) ==
'+' && is_array(
$value ) ) {
370 $setting = substr( $setting, 1 );
371 if ( is_array(
$GLOBALS[$setting] ) ) {
391 foreach ( $this->
settings as $varName => $setting ) {
405 static $default =
array(
412 if ( !is_callable( $this->siteParamsCallback ) ) {
416 $ret = call_user_func_array( $this->siteParamsCallback,
array( $this, $wiki ) );
417 # Validate the returned value
418 if ( !is_array(
$ret ) ) {
422 foreach ( $default
as $name => $def ) {
446 if ( is_null(
$ret[
'suffix'] ) ) {
447 $ret[
'suffix'] = $suffix;
450 $ret[
'tags'] = array_unique( array_merge(
$ret[
'tags'], $wikiTags ) );
455 if ( !isset(
$ret[
'params'][
'lang'] ) && !is_null(
$ret[
'lang'] ) ) {
456 $ret[
'params'][
'lang'] =
$ret[
'lang'];
458 if ( !isset(
$ret[
'params'][
'site'] ) && !is_null(
$ret[
'suffix'] ) ) {
459 $ret[
'params'][
'site'] =
$ret[
'suffix'];
474 if ( !is_null( $def[
'suffix'] ) && !is_null( $def[
'lang'] ) ) {
475 return array( $def[
'suffix'], $def[
'lang'] );
480 foreach ( $this->suffixes
as $altSite => $suffix ) {
481 if ( $suffix ===
'' ) {
485 } elseif ( substr( $db, -strlen( $suffix ) ) == $suffix ) {
486 $site = is_numeric( $altSite ) ? $suffix : $altSite;
487 $lang = substr( $db, 0, strlen( $db ) - strlen( $suffix ) );
491 $lang = str_replace(
'_',
'-', $lang );
492 return array( $site, $lang );
514 if ( !preg_match(
'/^wg[A-Z]/',
$name ) ) {
515 throw new MWException(
"Variable '$name' does start with 'wg'." );
517 throw new MWException(
"Variable '$name' is not set." );
522 if ( isset( $this->cfgCache[$wiki] ) ) {
523 $res = array_intersect_key( $this->cfgCache[$wiki], array_flip(
$settings ) );
527 } elseif ( !in_array( $wiki, $this->wikis ) ) {
530 $this->cfgCache[$wiki] =
array();
534 "$IP/maintenance/getConfiguration.php",
543 if ( $retVal != 0 || !strlen( $data ) ) {
544 throw new MWException(
"Failed to run getConfiguration.php." );
546 $res = unserialize( $data );
547 if ( !is_array(
$res ) ) {
548 throw new MWException(
"Failed to unserialize configuration array." );
550 $this->cfgCache[$wiki] = $this->cfgCache[$wiki] +
$res;
553 return $multi ?
$res : current(
$res );
562 return in_array( $vhost, $this->localVHosts );
577 for ( $i = 1; $i < func_num_args(); $i++ ) {
578 foreach ( func_get_arg( $i )
as $key =>
$value ) {
579 if ( isset(
$out[$key] ) && is_array(
$out[$key] ) && is_array(
$value ) ) {
581 } elseif ( !isset(
$out[$key] ) || !
$out[$key] && !is_numeric( $key ) ) {
584 } elseif ( is_numeric( $key ) ) {
594 if ( $this->fullLoadCallback && !$this->fullLoadDone ) {
595 call_user_func( $this->fullLoadCallback, $this );
596 $this->fullLoadDone =
true;
mergeParams( $wiki, $suffix, $params, $wikiTags)
Merge params between the ones passed to the function and the ones given by self::$siteParamsCallback ...
wfShellExec( $cmd, &$retval=null, $environ=array(), $limits=array(), $options=array())
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
$fullLoadDone
Whether or not all data has been loaded.
This is a class for holding configuration settings, particularly for multi-wiki sites.
getConfig( $wiki, $settings)
Get the resolved (post-setup) configuration of a potentially foreign wiki.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
isLocalVHost( $vhost)
Returns true if the given vhost is handled locally.
doReplace( $from, $to, $in)
Type-safe string replace; won't do replacements on non-strings private?
siteFromDB( $db)
Work out the site and language name from a database name.
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.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
array $cfgCache
Configuration cache for getConfig()
when a variable name is used in a it is silently declared as a new masking the global
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings
$localVHosts
Array of domains that are local and can be handled by the same server.
string array $siteParamsCallback
A callback function that returns an array with the following keys (all optional):
extractGlobal( $setting, $wiki, $suffix=null, $params=array(), $wikiTags=array())
Retrieves the value of a given setting, and places it in its corresponding global variable.
wfShellWikiCmd( $script, array $parameters=array(), array $options=array())
Generate a shell-escaped command line string to run a MediaWiki cli script.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
extractAllGlobals( $wiki, $suffix=null, $params=array(), $wikiTags=array())
Retrieves the values of all settings, and places them in their corresponding global variables.
Allows to change the fields on the form that will be generated $name
static arrayMerge( $array1)
Merge multiple arrays together.
& getLocalDatabases()
Retrieves an array of local databases.
$wikis
Array of wikis, should be the same as $wgLocalDatabases.
string array $fullLoadCallback
Optional callback to load full configuration data.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getBool( $setting, $wiki, $suffix=null, $wikiTags=array())
Retrieves a configuration setting for a given wiki, forced to a boolean.
$settings
The whole array of settings.
getSetting( $settingName, $wiki, $params)
Really retrieves a configuration setting for a given wiki.
extractGlobalSetting( $setting, $wiki, $params)
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
$suffixes
Array of suffixes, for self::siteFromDB()
getAll( $wiki, $suffix=null, $params=array(), $wikiTags=array())
Gets all settings for a wiki.
getWikiParams( $wiki)
Return specific settings for $wiki See the documentation of self::$siteParamsCallback for more in-dep...