1 |
joko |
1.1 |
<? |
2 |
joko |
1.3 |
/** |
3 |
|
|
* This file contains the Application::AbstractBase class. |
4 |
|
|
* |
5 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
|
|
* @package org.netfrag.glib |
7 |
|
|
* @name Application::AbstractBase |
8 |
|
|
* |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
|
12 |
joko |
1.8 |
/** |
13 |
|
|
* <b>Cvs-Log:</b> |
14 |
|
|
* |
15 |
|
|
* <pre> |
16 |
|
|
* --------------------------------------------------------------------------- |
17 |
|
|
* $Id: AbstractBase.php,v 1.7 2003/03/11 01:09:59 joko Exp $ |
18 |
|
|
* --------------------------------------------------------------------------- |
19 |
|
|
* $Log: AbstractBase.php,v $ |
20 |
|
|
* Revision 1.7 2003/03/11 01:09:59 joko |
21 |
|
|
* + fixed metadata for phpDocumentor |
22 |
|
|
* |
23 |
|
|
* Revision 1.6 2003/03/11 00:12:45 joko |
24 |
|
|
* + fixed metadata for phpDocumentor |
25 |
|
|
* |
26 |
|
|
* Revision 1.5 2003/03/10 23:45:29 joko |
27 |
|
|
* + fixed metadata for phpDocumentor |
28 |
|
|
* |
29 |
|
|
* Revision 1.4 2003/03/10 22:58:48 joko |
30 |
|
|
* + fixed metadata for phpDocumentor |
31 |
|
|
* |
32 |
|
|
* Revision 1.3 2003/03/05 23:16:47 joko |
33 |
|
|
* updated docu - phpDocumentor is very strict about its 'blocks'... |
34 |
|
|
* |
35 |
|
|
* Revision 1.2 2003/03/03 21:11:01 joko |
36 |
|
|
* mungled the namespaces |
37 |
|
|
* |
38 |
|
|
* Revision 1.1 2003/02/09 17:05:57 joko |
39 |
|
|
* + initial commit |
40 |
|
|
* |
41 |
|
|
* --------------------------------------------------------------------------- |
42 |
|
|
* </pre> |
43 |
|
|
* |
44 |
|
|
*/ |
45 |
joko |
1.1 |
|
46 |
|
|
|
47 |
joko |
1.2 |
require_once('php_extensions.php'); |
48 |
|
|
php::export_symbols( 'is_hash', 'array_join_merge', 'session_register_safe', 'array_init' ); |
49 |
|
|
|
50 |
|
|
loadModule('Class::Inner'); |
51 |
joko |
1.8 |
|
52 |
joko |
1.3 |
|
53 |
|
|
/** |
54 |
joko |
1.6 |
* --- Application::AbstractBase |
55 |
joko |
1.3 |
* |
56 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
57 |
joko |
1.7 |
* |
58 |
joko |
1.6 |
* @package org.netfrag.glib |
59 |
joko |
1.3 |
* @subpackage Application |
60 |
|
|
* @name Application::AbstractBase |
61 |
|
|
* |
62 |
|
|
*/ |
63 |
joko |
1.2 |
class Application_AbstractBase extends Class_Inner { |
64 |
joko |
1.1 |
|
65 |
|
|
var $children = array(); |
66 |
|
|
|
67 |
|
|
function constructor() { |
68 |
|
|
parent::constructor(); |
69 |
|
|
$this->log( get_class($this) . "->new", PEAR_LOG_DEBUG ); |
70 |
|
|
|
71 |
|
|
//print "BASE<br>"; |
72 |
|
|
|
73 |
|
|
$build = array(); |
74 |
|
|
$defaults = array( |
75 |
|
|
parent_name => get_class($this), |
76 |
|
|
run => 'start', |
77 |
|
|
); |
78 |
|
|
|
79 |
|
|
foreach ($this->children as $dummykey => $block) { |
80 |
|
|
|
81 |
|
|
$class_names = array(); |
82 |
|
|
$ref_names = array(); |
83 |
|
|
|
84 |
|
|
// build declaration (classnames, objectnames) |
85 |
|
|
if (is_hash($block)) { |
86 |
|
|
foreach ($block as $key => $val) { |
87 |
|
|
//array_push($class_names, $key); |
88 |
|
|
$args_t = array_join_merge($defaults, array( class_names => array($key) ) ); |
89 |
|
|
$args = array_join_merge($args_t, $val); |
90 |
|
|
//print Dumper($args); |
91 |
|
|
array_push($build, $args); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
} else { |
95 |
|
|
foreach ($block as $idx => $entry) { |
96 |
|
|
array_push($class_names, $entry); |
97 |
|
|
} |
98 |
|
|
$args = array( class_names => $class_names ); |
99 |
|
|
array_push($build, array_join_merge($defaults, $args )); |
100 |
|
|
|
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
|
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
//print Dumper($build); |
107 |
|
|
//exit; |
108 |
|
|
|
109 |
|
|
// create child objects |
110 |
|
|
//$args = array( parent_name => get_class($this), run => 'start', class_names => $class_names, ref_names => $ref_names ); |
111 |
|
|
foreach ($build as $declaration) { |
112 |
|
|
//$args = array_join_merge($defaults, $declaration); |
113 |
|
|
//print Dumper($declaration); |
114 |
joko |
1.2 |
$this->perform( $declaration ); |
115 |
joko |
1.1 |
} |
116 |
|
|
|
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
function _init_database() { |
120 |
|
|
// Database |
121 |
|
|
//print "database<br>"; |
122 |
|
|
$this->log( get_class($this) . "->_init_database: connecting...", PEAR_LOG_DEBUG); |
123 |
|
|
//print "dsn: " . $site->config[dbinfo][dsn] . "<br>"; |
124 |
|
|
$this->db = DB::connect($this->config[dbinfo][dsn], true); |
125 |
|
|
if (DB::isError($this->db)) { |
126 |
|
|
// TODO |
127 |
|
|
// (notifyBox!!! (will we get there?)) else: |
128 |
|
|
// do a redirect to a completely static "out-of-order-page" ("maintenance.html") |
129 |
|
|
// or do a die here? |
130 |
|
|
$error_log = $this->db->getMessage(); |
131 |
|
|
$this->log( "init_site: database ERROR (dsn=" . $this->config[dbinfo][dsn] . "): \"$error_log\"", PEAR_LOG_EMERG); |
132 |
|
|
// TODO: include email-address, too (from config, if available there) |
133 |
|
|
gen_badDbError(); |
134 |
|
|
exit; |
135 |
|
|
} else { |
136 |
|
|
$this->db->setFetchMode(DB_FETCHMODE_ASSOC); |
137 |
|
|
$this->log( get_class($this) . "->_init_database: ok", PEAR_LOG_DEBUG); |
138 |
|
|
} |
139 |
|
|
} |
140 |
|
|
|
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
?> |