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