first commit
This commit is contained in:
81
_rejestracja/core/class/Config.class.php
Normal file
81
_rejestracja/core/class/Config.class.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* $Id: Config.class.php 395 2008-05-28 19:41:06Z pawy $
|
||||
* Singleton dostepu do danych konfiguracyjnych serwisu
|
||||
*
|
||||
*/
|
||||
class Config {
|
||||
|
||||
static private $dbConfig;
|
||||
static private $internalConfig;
|
||||
static private $iniConfig;
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
*/
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Zapobiegacz klonowania
|
||||
*
|
||||
*/
|
||||
private function __clone() {}
|
||||
|
||||
/**
|
||||
* Ustawia konfiga z bazy
|
||||
*
|
||||
*/
|
||||
public static function SetDbConfig($dbConfig) {
|
||||
self::$dbConfig = $dbConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca wartosc lub wyjatek
|
||||
*
|
||||
*/
|
||||
public static function Get($value) {
|
||||
if(isset(self::$dbConfig[$value])) {
|
||||
$return = self::$dbConfig[$value];
|
||||
} else if(isset(self::$internalConfig[$value])) {
|
||||
$return = self::$internalConfig[$value];
|
||||
} else if(isset(self::$iniConfig[$value])) {
|
||||
$return = self::$iniConfig[$value];
|
||||
} else if(defined($value)) {
|
||||
$return = constant($value);
|
||||
} else {
|
||||
$return = false;
|
||||
throw new UserException("Niezdefiniowany parametr konfiguracji: '$value'",$value);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function Exists($value) {
|
||||
if(isset(self::$dbConfig[$value]) || isset(self::$internalConfig[$value]) || defined($value)) {
|
||||
return true;
|
||||
} else {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function Set($variable, $value) {
|
||||
self::$internalConfig[$variable] = $value;
|
||||
}
|
||||
|
||||
public static function LoadIniConfig($file, $sections = true) {
|
||||
if (!is_array(self::$iniConfig)) {
|
||||
self::$iniConfig = array();
|
||||
}
|
||||
|
||||
self::$iniConfig = array_merge(self::$iniConfig, parse_ini_file($file, $sections));
|
||||
}
|
||||
|
||||
public static function GetIniConfig() {
|
||||
return self::$iniConfig;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user