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