From: hickert Date: Mon, 3 May 2010 13:51:58 +0000 (+0000) Subject: Added a first Idea of the config registry X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fccaf95b90012b6946d1c60dc7de21270921ddfc;p=gosa.git Added a first Idea of the config registry - Not even nearly finished... git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18027 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_config.inc b/gosa-core/include/class_config.inc index 07e915256..741207e2e 100644 --- a/gosa-core/include/class_config.inc +++ b/gosa-core/include/class_config.inc @@ -64,6 +64,8 @@ class config { var $filename = ""; var $last_modified = 0; + public $configRegistry = NULL; + /*! \brief Class constructor of the config class * * \param string 'filename' path to the configuration file @@ -82,6 +84,9 @@ class config { if ($filename != ""){ $this->parse($filename); } + + // Load configuration registry + $this->configRegistry = new configRegistry(); } @@ -1070,7 +1075,13 @@ class config { * * */ - function get_cfg_value($name, $default= "") { + function get_cfg_value($name, $default= "") + { + if($this->configRegistry->propertyExists($name)){ + return($this->configRegistry->getPropertyValue($name)); + } + + $name= strtoupper($name); /* Check if we have a current value for $name */ diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc new file mode 100644 index 000000000..70a3fc664 --- /dev/null +++ b/gosa-core/include/class_configRegistry.inc @@ -0,0 +1,95 @@ +reload(); + } + + function reload() + { + global $class_mapping; + foreach ($class_mapping as $cname => $path){ + $cmethods = get_class_methods($cname); + if (is_array($cmethods) && in_array_ics('plInfo',$cmethods)){ + $def = call_user_func(array($cname, 'plInfo'));; + if(isset($def['plProperties'])){ + foreach($def['plProperties'] as $property){ + $this->register( + $property['name'], + $property['type'], + $property['default'], + $property['description'], + $property['check'], + $property['migrate'], + $property['mandatory']); + } + } + } + } + } + + function register($name,$type,$default,$description,$check,$migrate,$mandatory) + { + $this->properties[$name] = new gosaProperty($name,$type,$default,$description,$check,$migrate,$mandatory); + } + + function propertyExists($name) + { + return(isset($this->properties[$name])); + } + + function getProperty($name) + { + if($this->propertyExists($name)){ + return($this->properties[$name]); + } + return(NULL); + } + + function getPropertyValue($name) + { + if($this->propertyExists($name)){ + return($this->properties[$name]->getValue()); + } + return(""); + } +} + + +class gosaProperty +{ + protected $name = ""; + protected $type = "string"; + protected $default = ""; + protected $description = ""; + protected $check = ""; + protected $migrate = ""; + protected $mandatory = FALSE; + + function __construct($name,$type,$default,$description,$check,$migrate,$mandatory) + { + $this->name = $name; + $this->type = $type; + $this->default = $default; + $this->description = $description; + $this->check = $check; + $this->migrate = $migrate; + $this->mandatory = $mandatory; + } + + function getValue() { return($this->default); } + function getName() { return($this->name); } + function getType() { return($this->type); } + function getDescription() { return($this->description); } + function getDefault() { return($this->default); } + + function isValid() + { + return(TRUE); + } +} + +?>