1 |
<? |
2 |
// ------------------------------------------------------------------------------- |
3 |
// $Id: Site.class.php,v 1.3 2002/10/25 15:14:50 cvsjoko Exp $ |
4 |
// ------------------------------------------------------------------------------- |
5 |
// $Log: Site.class.php,v $ |
6 |
// Revision 1.3 2002/10/25 15:14:50 cvsjoko |
7 |
// + generic logging mechanism via PEAR::Log |
8 |
// |
9 |
// Revision 1.2 2002/10/20 21:52:00 cvsmax |
10 |
// + add new |
11 |
// + function cacheThisRequest($request) # save current request in session |
12 |
// + function getCachedRequest() # get cached request from session |
13 |
// |
14 |
// Revision 1.1 2002/10/09 00:42:50 cvsjoko |
15 |
// + much code from "lib/menu/libnav.php.inc" |
16 |
// ------------------------------------------------------------------------------- |
17 |
|
18 |
|
19 |
require_once 'Site/Boot.php'; |
20 |
|
21 |
class Site extends Site_Boot { |
22 |
//class Site extends PEAR_Autoloader { |
23 |
|
24 |
// this collects all/some stuff (object variables and methods) |
25 |
// from other (helper)-objects and acts as a dispatcher to them... |
26 |
// ...is this a bridge then? |
27 |
|
28 |
// TODO: |
29 |
// - "Request" depends on "Handler" for now ;( |
30 |
// - application should croak if preboot doesn't exist inside config |
31 |
// - implement autoloading mechanism via php's overload |
32 |
|
33 |
// essentials (more or less) |
34 |
var $config; // config ...is very essential (especially preboot stuff) |
35 |
var $logger; // logging? yea |
36 |
var $db; // the database handle (actually a PEAR::DB) |
37 |
var $smarty; // a reference to a new smarty object, do templating stuff with that |
38 |
|
39 |
// some helper objects |
40 |
var $handler; // keeps track of handlers and identifiers |
41 |
var $request; // takes care about the requests |
42 |
var $loader; // loads various components (lib, page, file, etc.) |
43 |
var $misc; // not needed yet, just wastes space |
44 |
|
45 |
// some application objects |
46 |
var $session; |
47 |
var $user; |
48 |
|
49 |
function Site(&$config) { |
50 |
// this will not work, logger is initialized two lines below |
51 |
$this->log( get_class($this) . "->Site( config $config )", LOG_DEBUG ); |
52 |
$this->config = $config; |
53 |
$this->_init_logger(); |
54 |
$this->_init_helpers(); |
55 |
$this->_init_application(); |
56 |
//$this->_init_database(); |
57 |
} |
58 |
|
59 |
// Dispatchers for all subobjects |
60 |
// TODO: |
61 |
// - make this much more generic |
62 |
// - maybe use "aggregate" if it becomes available |
63 |
// - there is some function to get given args to a function from inside it, use this perhaps |
64 |
// - patch php to support multiple inheritance ;) |
65 |
|
66 |
// dispatchers for Handler |
67 |
function &encodeIdentifier($a) { |
68 |
return $this->handler->encodeIdentifier($a); |
69 |
} |
70 |
function &decodeIdentifier($a) { |
71 |
return $this->handler->decodeIdentifier($a); |
72 |
} |
73 |
function &getPageIdentifier() { |
74 |
return $this->handler->getPageIdentifier(); |
75 |
} |
76 |
function &setHandler($a, $b) { |
77 |
return $this->handler->setHandler($a, $b); |
78 |
} |
79 |
function getHandler($a) { |
80 |
return $this->handler->getHandler($a); |
81 |
} |
82 |
|
83 |
// dispatchers for Request |
84 |
function getRequest() { |
85 |
return $this->request->getRequest(); |
86 |
} |
87 |
|
88 |
// dispatchers for Loader |
89 |
function &loadHandler($a) { |
90 |
return $this->loader->loadHandler($a); |
91 |
} |
92 |
function &loadPage($a) { |
93 |
return $this->loader->loadPage($a); |
94 |
} |
95 |
|
96 |
// dispatchers for Http |
97 |
function &redirect($a) { |
98 |
return $this->http->redirect($a); |
99 |
} |
100 |
|
101 |
|
102 |
|
103 |
// TODO: throw these out! |
104 |
|
105 |
function getLink($key, $attribs = array()) { |
106 |
//dprint("getlink: " . dumpvar($attribs)); |
107 |
$ident = $this->encodeIdentifier($key); |
108 |
// base url with ident |
109 |
$url = $_SERVER[PHP_SELF] . '?' . 'x=' . $ident; |
110 |
// additional arguments? |
111 |
foreach ($attribs as $key => $value) { |
112 |
$url .= '&' . $key . '=' . $value; |
113 |
} |
114 |
return $url; |
115 |
} |
116 |
|
117 |
function isAuthenticated() { |
118 |
//global $uservars_db; |
119 |
//return isset($uservars_db[status]); |
120 |
global $site; |
121 |
return $site->user->isLoggedOn(); |
122 |
} |
123 |
|
124 |
function log($msg, $level) { |
125 |
if ($this->logger) { |
126 |
$this->logger->log($msg, $level); |
127 |
} else { |
128 |
// TODO: how are these type of errors handled? |
129 |
//print "error-message: $msg<br>"; |
130 |
} |
131 |
} |
132 |
|
133 |
} |
134 |
|
135 |
?> |