3 |
// $Id$ |
// $Id$ |
4 |
// --------------------------------------------------------------------------- |
// --------------------------------------------------------------------------- |
5 |
// $Log$ |
// $Log$ |
6 |
|
// Revision 1.4 2003/03/03 21:11:01 joko |
7 |
|
// mungled the namespaces |
8 |
|
// |
9 |
|
// Revision 1.3 2003/02/09 17:05:15 joko |
10 |
|
// + minor update related to new log level constants |
11 |
|
// + restructured get-/setter methods |
12 |
|
// |
13 |
|
// Revision 1.2 2003/02/03 14:42:28 joko |
14 |
|
// + added logging |
15 |
|
// + methods for accessing configuration variables |
16 |
|
// |
17 |
// Revision 1.1 2003/02/03 05:00:01 joko |
// Revision 1.1 2003/02/03 05:00:01 joko |
18 |
// + initial commit |
// + initial commit |
19 |
// |
// |
54 |
|
|
55 |
*/ |
*/ |
56 |
|
|
57 |
|
loadModule('Class::Logger'); |
58 |
|
|
59 |
class Application_Core { |
class Application_Core extends Class_Logger { |
60 |
|
|
61 |
var $_config; |
var $_config; |
62 |
|
|
66 |
|
|
67 |
function run() { |
function run() { |
68 |
//print Dumper($this->_config); |
//print Dumper($this->_config); |
69 |
foreach ($this->_config->_store[run] as $key => $container) { |
|
70 |
|
parent::constructor(); |
71 |
|
|
72 |
|
$this->log("-----------------------------------------------------------------", PEAR_LOG_INFO); |
73 |
|
$this->log(get_class($this) . "->run: begin", PEAR_LOG_INFO); |
74 |
|
|
75 |
|
$cfg = $this->getConfig(); |
76 |
|
|
77 |
|
//print Dumper($cfg); exit; |
78 |
|
|
79 |
|
if (!is_array($cfg[run])) { return; } |
80 |
|
|
81 |
|
foreach ($cfg[run] as $key => $container) { |
82 |
|
|
83 |
|
//print "key: $key<br>"; |
84 |
|
|
85 |
// include files |
// include files |
86 |
foreach ($container[scripts] as $script) { |
if (is_array($container[scripts])) { |
87 |
require_once($script); |
foreach ($container[scripts] as $script) { |
88 |
|
$this->_require_once_isolated($script); |
89 |
|
$this->_config->merge(); |
90 |
|
} |
91 |
} |
} |
92 |
|
|
93 |
// run procedural functions |
// run procedural functions |
94 |
foreach ($container[methods] as $method) { |
if (is_array($container[methods])) { |
95 |
call_user_func($method); |
foreach ($container[methods] as $method) { |
96 |
|
$this->log(get_class($this) . "->run: calling function in global namespace: '$method'", PEAR_LOG_DEBUG); |
97 |
|
call_user_func($method); |
98 |
|
} |
99 |
} |
} |
100 |
|
|
101 |
|
} |
102 |
|
|
103 |
|
$this->log(get_class($this) . "->run: end", PEAR_LOG_INFO); |
104 |
|
|
105 |
|
} |
106 |
|
|
107 |
|
function getConfig($var = null) { |
108 |
|
return $this->_config->get($var); |
109 |
|
} |
110 |
|
|
111 |
|
function _require_once_isolated($file) { |
112 |
|
$this->log(get_class($this) . "->_require_once_isolated: $file", PEAR_LOG_DEBUG); |
113 |
|
if (require_once($file)) { |
114 |
|
return 1; |
115 |
} |
} |
116 |
} |
} |
117 |
|
|
118 |
|
function setConfigVar($var, $val) { |
119 |
|
//print "$var=$val<br>"; |
120 |
|
$this->_config->set_absolute($var, $val); |
121 |
|
} |
122 |
|
|
123 |
|
function getConfigVar($var) { |
124 |
|
return $this->_config->get_absolute($var); |
125 |
|
} |
126 |
|
|
127 |
} |
} |
128 |
|
|
129 |
?> |
?> |