/[cvs]/nfo/php/libs/org.netfrag.flib/Site/Boot.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.flib/Site/Boot.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Nov 12 05:42:30 2002 UTC (21 years, 9 months ago) by joko
Branch: MAIN
+ initial checkin

1 <?
2 // -------------------------------------------------------------------------
3 // $Id$
4 // -------------------------------------------------------------------------
5 // $Log$
6 // -------------------------------------------------------------------------
7
8
9 require_once 'DebugBox.php';
10 require_once 'ExtHttp.php';
11 require_once 'Loader.php';
12 require_once 'Handler.php';
13 require_once 'Request.php';
14 require_once 'Misc.php';
15
16 class Site_Boot {
17
18 function _init_logger() {
19 // Log
20 // valid logging-levels are:
21 // LOG_EMERG, LOG_ALERT, LOG_CRIT,
22 // LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG.
23 // The default is LOG_INFO.
24 $logfile = 'log.txt';
25 $logfile = $this->config[path][base] . "core/var/log/logfile.txt";
26
27 // TODO: maybe include userid here?
28 //$log_ident = substr(session_id(), 10, 6);
29 $log_ident = session_id();
30 if ($this->config[mode][LOG]) {
31 $this->logger = &Log::singleton('file', $logfile, $log_ident);
32 //$site->logger = new Log_file($logfile, $log_ident);
33 } else {
34 $this->logger = &Log::singleton('dummy', $logfile, $log_ident);
35 }
36 $this->log( get_class($this) . "->_init_logger: ready\t\t--------------------", LOG_DEBUG );
37 }
38
39
40 function _init_helpers() {
41 $this->log( get_class($this) . "->_init_helpers()", LOG_DEBUG );
42 $helpers = array( 'Site_DebugBox', 'Site_Handler', 'Site_Request', 'Site_Loader', 'Site_Misc', 'Site_Http' );
43 $args = array( class_names => $helpers, parent_name => 'site', run => 'start' );
44 $this->_mkEmbeddedObjects( $args );
45 }
46
47 function _init_application() {
48 $this->log( get_class($this) . "->_init_application()", LOG_DEBUG );
49 /*
50 was:
51 // User
52 // was:
53 //$user = new User;
54 //$this->user = &$user;
55 // is:
56 $this->user = new User;
57 //$site->log( "boot.inc:init_site: user ready", LOG_DEBUG);
58 // Session
59 $this->session = new Session;
60 */
61
62 $helpers = array( 'User', 'Session' );
63 $args = array( class_names => $helpers, parent_name => 'site', run => 'start' );
64 $this->_mkEmbeddedObjects( $args );
65
66 }
67
68 function &_mkInstance($classname) {
69 $this->log( get_class($this) . "->_mkInstance( classname $classname )", LOG_DEBUG );
70 return new $classname;
71 }
72
73 function _mkEmbeddedObjects($args) {
74
75 $this->log( get_class($this) . "->_mkEmbeddedObjects()", LOG_DEBUG );
76
77 foreach ($args[class_names] as $classname) {
78
79 // build objectname from classname
80 // - make lowercase
81 // - strip leading "Xyz_" ('Site_' here)
82 $objectname = $classname;
83 $objectname = str_replace('Site_', '', $objectname);
84 $objectname = strtolower($objectname);
85
86 // create new instance of helper object by classname
87 $this->$objectname = &$this->_mkInstance($classname);
88
89 // helper gets reference to ourselves as a parent
90 $this->$objectname->$args[parent_name] = &$this;
91
92 if ( $method = $args[run] ) {
93 if (method_exists($this->$objectname, $method)) {
94 $this->log( get_class($this) . "->_mkEmbeddedObjects: calling method \$this->" . $objectname . "->$method()", LOG_DEBUG );
95 $this->$objectname->$method();
96 }
97 }
98
99 }
100
101 }
102
103 }
104 ?>

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