summaryrefslogtreecommitdiff
path: root/includes/SiteConfiguration.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/SiteConfiguration.php')
-rw-r--r--includes/SiteConfiguration.php58
1 files changed, 29 insertions, 29 deletions
diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php
index bbc14a12..fa871fe0 100644
--- a/includes/SiteConfiguration.php
+++ b/includes/SiteConfiguration.php
@@ -191,11 +191,11 @@ class SiteConfiguration {
*/
protected function getSetting( $settingName, $wiki, /*array*/ $params ) {
$retval = null;
- if( array_key_exists( $settingName, $this->settings ) ) {
+ if ( array_key_exists( $settingName, $this->settings ) ) {
$thisSetting =& $this->settings[$settingName];
do {
// Do individual wiki settings
- if( array_key_exists( $wiki, $thisSetting ) ) {
+ if ( array_key_exists( $wiki, $thisSetting ) ) {
$retval = $thisSetting[$wiki];
break;
} elseif ( array_key_exists( "+$wiki", $thisSetting ) && is_array( $thisSetting["+$wiki"] ) ) {
@@ -203,16 +203,16 @@ class SiteConfiguration {
}
// Do tag settings
- foreach( $params['tags'] as $tag ) {
- if( array_key_exists( $tag, $thisSetting ) ) {
+ 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 ) ) {
+ } elseif ( array_key_exists( "+$tag", $thisSetting ) && is_array( $thisSetting["+$tag"] ) ) {
+ if ( !isset( $retval ) ) {
$retval = array();
}
$retval = self::arrayMerge( $retval, $thisSetting["+$tag"] );
@@ -220,15 +220,15 @@ class SiteConfiguration {
}
// Do suffix settings
$suffix = $params['suffix'];
- if( !is_null( $suffix ) ) {
- if( array_key_exists( $suffix, $thisSetting ) ) {
+ 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"]) ) {
+ } elseif ( array_key_exists( "+$suffix", $thisSetting ) && is_array( $thisSetting["+$suffix"] ) ) {
if ( !isset( $retval ) ) {
$retval = array();
}
@@ -237,8 +237,8 @@ class SiteConfiguration {
}
// Fall back to default.
- if( array_key_exists( 'default', $thisSetting ) ) {
- if( is_array( $retval ) && is_array( $thisSetting['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'];
@@ -248,7 +248,7 @@ class SiteConfiguration {
} while ( false );
}
- if( !is_null( $retval ) && count( $params['params'] ) ) {
+ if ( !is_null( $retval ) && count( $params['params'] ) ) {
foreach ( $params['params'] as $key => $value ) {
$retval = $this->doReplace( '$' . $key, $value, $retval );
}
@@ -266,10 +266,10 @@ class SiteConfiguration {
* @return string
*/
function doReplace( $from, $to, $in ) {
- if( is_string( $in ) ) {
+ if ( is_string( $in ) ) {
return str_replace( $from, $to, $in );
- } elseif( is_array( $in ) ) {
- foreach( $in as $key => $val ) {
+ } elseif ( is_array( $in ) ) {
+ foreach ( $in as $key => $val ) {
$in[$key] = $this->doReplace( $from, $to, $val );
}
return $in;
@@ -289,7 +289,7 @@ class SiteConfiguration {
public function getAll( $wiki, $suffix = null, $params = array(), $wikiTags = array() ) {
$params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags );
$localSettings = array();
- foreach( $this->settings as $varname => $stuff ) {
+ foreach ( $this->settings as $varname => $stuff ) {
$append = false;
$var = $varname;
if ( substr( $varname, 0, 1 ) == '+' ) {
@@ -317,7 +317,7 @@ class SiteConfiguration {
* @return bool The value of the setting requested.
*/
public function getBool( $setting, $wiki, $suffix = null, $wikiTags = array() ) {
- return (bool)($this->get( $setting, $wiki, $suffix, array(), $wikiTags ) );
+ return (bool)$this->get( $setting, $wiki, $suffix, array(), $wikiTags );
}
/**
@@ -409,18 +409,18 @@ class SiteConfiguration {
'params' => array(),
);
- if( !is_callable( $this->siteParamsCallback ) ) {
+ if ( !is_callable( $this->siteParamsCallback ) ) {
return $default;
}
$ret = call_user_func_array( $this->siteParamsCallback, array( $this, $wiki ) );
# Validate the returned value
- if( !is_array( $ret ) ) {
+ if ( !is_array( $ret ) ) {
return $default;
}
- foreach( $default as $name => $def ) {
- if( !isset( $ret[$name] ) || ( is_array( $default[$name] ) && !is_array( $ret[$name] ) ) ) {
+ foreach ( $default as $name => $def ) {
+ if ( !isset( $ret[$name] ) || ( is_array( $default[$name] ) && !is_array( $ret[$name] ) ) ) {
$ret[$name] = $default[$name];
}
}
@@ -443,7 +443,7 @@ class SiteConfiguration {
protected function mergeParams( $wiki, $suffix, /*array*/ $params, /*array*/ $wikiTags ) {
$ret = $this->getWikiParams( $wiki );
- if( is_null( $ret['suffix'] ) ) {
+ if ( is_null( $ret['suffix'] ) ) {
$ret['suffix'] = $suffix;
}
@@ -452,10 +452,10 @@ class SiteConfiguration {
$ret['params'] += $params;
// Automatically fill that ones if needed
- if( !isset( $ret['params']['lang'] ) && !is_null( $ret['lang'] ) ) {
+ if ( !isset( $ret['params']['lang'] ) && !is_null( $ret['lang'] ) ) {
$ret['params']['lang'] = $ret['lang'];
}
- if( !isset( $ret['params']['site'] ) && !is_null( $ret['suffix'] ) ) {
+ if ( !isset( $ret['params']['site'] ) && !is_null( $ret['suffix'] ) ) {
$ret['params']['site'] = $ret['suffix'];
}
@@ -471,19 +471,19 @@ class SiteConfiguration {
public function siteFromDB( $db ) {
// Allow override
$def = $this->getWikiParams( $db );
- if( !is_null( $def['suffix'] ) && !is_null( $def['lang'] ) ) {
+ if ( !is_null( $def['suffix'] ) && !is_null( $def['lang'] ) ) {
return array( $def['suffix'], $def['lang'] );
}
$site = null;
$lang = null;
- foreach ( $this->suffixes as $suffix ) {
+ foreach ( $this->suffixes as $altSite => $suffix ) {
if ( $suffix === '' ) {
$site = '';
$lang = $db;
break;
} elseif ( substr( $db, -strlen( $suffix ) ) == $suffix ) {
- $site = $suffix == 'wiki' ? 'wikipedia' : $suffix;
+ $site = is_numeric( $altSite ) ? $suffix : $altSite;
$lang = substr( $db, 0, strlen( $db ) - strlen( $suffix ) );
break;
}
@@ -574,8 +574,8 @@ class SiteConfiguration {
*/
static function arrayMerge( $array1/* ... */ ) {
$out = $array1;
- for( $i = 1; $i < func_num_args(); $i++ ) {
- foreach( func_get_arg( $i ) as $key => $value ) {
+ for ( $i = 1; $i < func_num_args(); $i++ ) {
+ foreach ( func_get_arg( $i ) as $key => $value ) {
if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) {
$out[$key] = self::arrayMerge( $out[$key], $value );
} elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) {