Pass the user as an argument to 'isValidPassword' hook callbacks; see docs/hooks...
[lhc/web/wiklou.git] / includes / SiteConfiguration.php
index 1abe48d..353f5b3 100644 (file)
@@ -1,39 +1,39 @@
 <?php
-/**
- *This file is used to configure the live Wikimedia wikis. The file that
- * includes it contains passwords and other sensitive data, and there's
- * currently no public equivalent.
- *
- * @package MediaWiki
- */
-
-/**
- *
- * @package MediaWiki
- */
 
 /**
- * The include paths change after this file is included from commandLine.inc, 
+ * The include paths change after this file is included from commandLine.inc,
  * meaning that require_once() fails to detect that it is including the same
  * file again. We use DIY C-style protection as a workaround.
  */
 if (!defined('SITE_CONFIGURATION')) {
 define('SITE_CONFIGURATION', 1);
 
+/**
+ * This is a class used to hold configuration settings, particularly for multi-wiki sites.
+ *
+ */
 class SiteConfiguration {
-       var $suffixes, $wikis, $settings;
-       var $localDatabases;
-       
+       var $suffixes = array();
+       var $wikis = array();
+       var $settings = array();
+       var $localVHosts = array();
+
+       /** */
        function get( $setting, $wiki, $suffix, $params = array() ) {
-               if ( array_key_exists( $wiki, $this->settings[$setting] ) ) {
-                       $retval = $this->settings[$setting][$wiki];
-               } elseif ( array_key_exists( $suffix, $this->settings[$setting] ) ) {
-                       $retval = $this->settings[$setting][$suffix];
-               } elseif ( array_key_exists( 'default', $this->settings[$setting] ) ) {
-                       $retval = $this->settings[$setting]['default'];
+               if ( array_key_exists( $setting, $this->settings ) ) {
+                       if ( array_key_exists( $wiki, $this->settings[$setting] ) ) {
+                               $retval = $this->settings[$setting][$wiki];
+                       } elseif ( array_key_exists( $suffix, $this->settings[$setting] ) ) {
+                               $retval = $this->settings[$setting][$suffix];
+                       } elseif ( array_key_exists( 'default', $this->settings[$setting] ) ) {
+                               $retval = $this->settings[$setting]['default'];
+                       } else {
+                               $retval = NULL;
+                       }
                } else {
                        $retval = NULL;
                }
+
                if ( !is_null( $retval ) && count( $params ) ) {
                        foreach ( $params as $key => $value ) {
                                $retval = str_replace( '$' . $key, $value, $retval );
@@ -42,27 +42,41 @@ class SiteConfiguration {
                return $retval;
        }
 
+       /** */
+       function getAll( $wiki, $suffix, $params ) {
+               $localSettings = array();
+               foreach ( $this->settings as $varname => $stuff ) {
+                       $value = $this->get( $varname, $wiki, $suffix, $params );
+                       if ( !is_null( $value ) ) {
+                               $localSettings[$varname] = $value;
+                       }
+               }
+               return $localSettings;
+       }
+
+       /** */
        function getBool( $setting, $wiki, $suffix ) {
                return (bool)($this->get( $setting, $wiki, $suffix ));
        }
 
+       /** */
        function &getLocalDatabases() {
-               return $this->localDatabases;
+               return $this->wikis;
        }
-       
+
+       /** */
        function initialise() {
-               foreach ( $this->wikis as $db ) {
-                       $this->localDatabases[$db] = $db;
-               }
        }
 
+       /** */
        function extractVar( $setting, $wiki, $suffix, &$var, $params ) {
                $value = $this->get( $setting, $wiki, $suffix, $params );
                if ( !is_null( $value ) ) {
                        $var = $value;
                }
        }
-       
+
+       /** */
        function extractGlobal( $setting, $wiki, $suffix, $params ) {
                $value = $this->get( $setting, $wiki, $suffix, $params );
                if ( !is_null( $value ) ) {
@@ -70,6 +84,7 @@ class SiteConfiguration {
                }
        }
 
+       /** */
        function extractAllGlobals( $wiki, $suffix, $params ) {
                foreach ( $this->settings as $varName => $setting ) {
                        $this->extractGlobal( $varName, $wiki, $suffix, $params );
@@ -90,9 +105,15 @@ class SiteConfiguration {
                                break;
                        }
                }
+               $lang = str_replace( '_', '-', $lang );
                return array( $site, $lang );
        }
+
+       /** */
+       function isLocalVHost( $vhost ) {
+               return in_array( $vhost, $this->localVHosts );
+       }
 }
 }
-       
-?>
+
+