1 |
<? |
<? |
2 |
|
/** |
3 |
|
* This file contains the Application::Config class. |
4 |
|
* |
5 |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
|
* @name Application::Config |
7 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
|
11 |
// --------------------------------------------------------------------------- |
// --------------------------------------------------------------------------- |
12 |
// $Id$ |
// $Id$ |
13 |
// --------------------------------------------------------------------------- |
// --------------------------------------------------------------------------- |
14 |
// $Log$ |
// $Log$ |
15 |
|
// Revision 1.7 2003/03/11 00:12:45 joko |
16 |
|
// + fixed metadata for phpDocumentor |
17 |
|
// |
18 |
|
// Revision 1.6 2003/03/10 23:45:29 joko |
19 |
|
// + fixed metadata for phpDocumentor |
20 |
|
// |
21 |
|
// Revision 1.5 2003/03/03 21:11:01 joko |
22 |
|
// mungled the namespaces |
23 |
|
// |
24 |
|
// Revision 1.4 2003/02/09 17:03:35 joko |
25 |
|
// + additional get-/setter methods |
26 |
|
// |
27 |
|
// Revision 1.3 2003/02/03 14:41:21 joko |
28 |
|
// + get- and set-methods to access configuration variables |
29 |
|
// + recursive merging mechanism |
30 |
|
// |
31 |
// Revision 1.2 2003/02/03 04:59:29 joko |
// Revision 1.2 2003/02/03 04:59:29 joko |
32 |
// + fixed: constructor can now get passed variable of *any type* |
// + fixed: constructor can now get passed variable of *any type* |
33 |
// |
// |
53 |
|
|
54 |
*/ |
*/ |
55 |
|
|
56 |
|
|
57 |
|
/** |
58 |
|
* --- Application_Config |
59 |
|
* |
60 |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
61 |
|
* @package org.netfrag.glib |
62 |
|
* @subpackage Application |
63 |
|
* @name Application::Config |
64 |
|
* |
65 |
|
*/ |
66 |
class Application_Config { |
class Application_Config { |
67 |
|
|
68 |
var $_store; |
var $_store; |
72 |
//print "initCfg:<br/>" . Dumper($initCfg) . "<hr/>"; |
//print "initCfg:<br/>" . Dumper($initCfg) . "<hr/>"; |
73 |
$this->_store = $initCfg; |
$this->_store = $initCfg; |
74 |
} |
} |
75 |
|
|
76 |
|
function merge() { |
77 |
|
//$this->_store[run] = array_merge($this->_store['default'], $this->_store['init']); |
78 |
|
//print Dumper($this); |
79 |
|
foreach ($this->_store[_init][configkeys] as $configKey) { |
80 |
|
//$this->_store[runtime] = array_merge($this->_store[runtime], $this->_store[$configKey]); |
81 |
|
//$this->_store[runtime] = array_merge_recursive($this->_store[runtime], $this->_store[$configKey]); |
82 |
|
$this->_store[runtime] = php::array_join_merge($this->_store[runtime], $this->_store[$configKey]); |
83 |
|
} |
84 |
|
//print Dumper($this); |
85 |
|
} |
86 |
|
|
87 |
|
function get($var = null) { |
88 |
|
//$this->merge(); |
89 |
|
if ($var) { |
90 |
|
return $this->get_absolute("runtime.$var"); |
91 |
|
} else { |
92 |
|
return $this->get_absolute("runtime"); |
93 |
|
} |
94 |
|
} |
95 |
|
|
96 |
|
function set_absolute($var, $val) { |
97 |
|
//$this->_store[runtime][$var] = $val; |
98 |
|
//$deep = new Data_Deep($this->_store[runtime]); |
99 |
|
$deep = new Data_Deep($this->_store); |
100 |
|
$deep->set($var, $val); |
101 |
|
} |
102 |
|
|
103 |
|
function get_absolute($var) { |
104 |
|
//$this->_store[runtime][$var] = $val; |
105 |
|
//$deep = new Data_Deep($this->_store[runtime]); |
106 |
|
$deep = new Data_Deep($this->_store); |
107 |
|
return $deep->get($var); |
108 |
|
} |
109 |
|
|
110 |
} |
} |
111 |
|
|
112 |
?> |
?> |