/[cvs]/nfo/php/libs/org.netfrag.glib/Application/AbstractBase.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/Application/AbstractBase.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Mon Mar 3 21:11:01 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.1: +11 -4 lines
mungled the namespaces

1 joko 1.1 <?
2     // ---------------------------------------------------------------------------
3 joko 1.2 // $Id: AbstractBase.php,v 1.1 2003/02/09 17:05:57 joko Exp $
4 joko 1.1 // ---------------------------------------------------------------------------
5 joko 1.2 // $Log: AbstractBase.php,v $
6     // Revision 1.1 2003/02/09 17:05:57 joko
7     // + initial commit
8     //
9 joko 1.1 // ---------------------------------------------------------------------------
10    
11    
12 joko 1.2 require_once('php_extensions.php');
13     php::export_symbols( 'is_hash', 'array_join_merge', 'session_register_safe', 'array_init' );
14    
15     loadModule('Class::Inner');
16     class Application_AbstractBase extends Class_Inner {
17 joko 1.1
18     var $children = array();
19    
20     function constructor() {
21     parent::constructor();
22     $this->log( get_class($this) . "->new", PEAR_LOG_DEBUG );
23    
24     //print "BASE<br>";
25    
26     $build = array();
27     $defaults = array(
28     parent_name => get_class($this),
29     run => 'start',
30     );
31    
32     foreach ($this->children as $dummykey => $block) {
33    
34     $class_names = array();
35     $ref_names = array();
36    
37     // build declaration (classnames, objectnames)
38     if (is_hash($block)) {
39     foreach ($block as $key => $val) {
40     //array_push($class_names, $key);
41     $args_t = array_join_merge($defaults, array( class_names => array($key) ) );
42     $args = array_join_merge($args_t, $val);
43     //print Dumper($args);
44     array_push($build, $args);
45     }
46    
47     } else {
48     foreach ($block as $idx => $entry) {
49     array_push($class_names, $entry);
50     }
51     $args = array( class_names => $class_names );
52     array_push($build, array_join_merge($defaults, $args ));
53    
54     }
55    
56    
57     }
58    
59     //print Dumper($build);
60     //exit;
61    
62     // create child objects
63     //$args = array( parent_name => get_class($this), run => 'start', class_names => $class_names, ref_names => $ref_names );
64     foreach ($build as $declaration) {
65     //$args = array_join_merge($defaults, $declaration);
66     //print Dumper($declaration);
67 joko 1.2 $this->perform( $declaration );
68 joko 1.1 }
69    
70     }
71    
72     function _init_database() {
73     // Database
74     //print "database<br>";
75     $this->log( get_class($this) . "->_init_database: connecting...", PEAR_LOG_DEBUG);
76     //print "dsn: " . $site->config[dbinfo][dsn] . "<br>";
77     $this->db = DB::connect($this->config[dbinfo][dsn], true);
78     if (DB::isError($this->db)) {
79     // TODO
80     // (notifyBox!!! (will we get there?)) else:
81     // do a redirect to a completely static "out-of-order-page" ("maintenance.html")
82     // or do a die here?
83     $error_log = $this->db->getMessage();
84     $this->log( "init_site: database ERROR (dsn=" . $this->config[dbinfo][dsn] . "): \"$error_log\"", PEAR_LOG_EMERG);
85     // TODO: include email-address, too (from config, if available there)
86     gen_badDbError();
87     exit;
88     } else {
89     $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
90     $this->log( get_class($this) . "->_init_database: ok", PEAR_LOG_DEBUG);
91     }
92     }
93    
94     }
95    
96     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed