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