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 |
// Revision 1.3 2003/02/03 14:41:21 joko |
28 |
// + get- and set-methods to access configuration variables |
// + get- and set-methods to access configuration variables |
29 |
// + recursive merging mechanism |
// + recursive merging mechanism |
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; |
75 |
|
|
76 |
function merge() { |
function merge() { |
77 |
//$this->_store[run] = array_merge($this->_store['default'], $this->_store['init']); |
//$this->_store[run] = array_merge($this->_store['default'], $this->_store['init']); |
78 |
|
//print Dumper($this); |
79 |
foreach ($this->_store[_init][configkeys] as $configKey) { |
foreach ($this->_store[_init][configkeys] as $configKey) { |
80 |
//$this->_store[runtime] = array_merge($this->_store[runtime], $this->_store[$configKey]); |
//$this->_store[runtime] = array_merge($this->_store[runtime], $this->_store[$configKey]); |
81 |
//$this->_store[runtime] = array_merge_recursive($this->_store[runtime], $this->_store[$configKey]); |
//$this->_store[runtime] = array_merge_recursive($this->_store[runtime], $this->_store[$configKey]); |
82 |
$this->_store[runtime] = array_join_merge($this->_store[runtime], $this->_store[$configKey]); |
$this->_store[runtime] = php::array_join_merge($this->_store[runtime], $this->_store[$configKey]); |
83 |
} |
} |
84 |
//print Dumper($this); |
//print Dumper($this); |
85 |
} |
} |
86 |
|
|
87 |
function getPart($var = null) { |
function get($var = null) { |
88 |
//$this->merge(); |
//$this->merge(); |
89 |
if ($var) { |
if ($var) { |
90 |
return $this->getVar("runtime.$var"); |
return $this->get_absolute("runtime.$var"); |
91 |
} else { |
} else { |
92 |
return $this->getVar("runtime"); |
return $this->get_absolute("runtime"); |
93 |
} |
} |
94 |
} |
} |
95 |
|
|
96 |
function setVar($var, $val) { |
function set_absolute($var, $val) { |
97 |
//$this->_store[runtime][$var] = $val; |
//$this->_store[runtime][$var] = $val; |
98 |
//$deep = new Data_Deep($this->_store[runtime]); |
//$deep = new Data_Deep($this->_store[runtime]); |
99 |
$deep = new Data_Deep($this->_store); |
$deep = new Data_Deep($this->_store); |
100 |
$deep->set($var, $val); |
$deep->set($var, $val); |
101 |
} |
} |
102 |
|
|
103 |
function getVar($var) { |
function get_absolute($var) { |
104 |
//$this->_store[runtime][$var] = $val; |
//$this->_store[runtime][$var] = $val; |
105 |
//$deep = new Data_Deep($this->_store[runtime]); |
//$deep = new Data_Deep($this->_store[runtime]); |
106 |
$deep = new Data_Deep($this->_store); |
$deep = new Data_Deep($this->_store); |