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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Thu Dec 19 06:17:32 2002 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.2: +11 -2 lines
+ database, smarty, and langtext (lt) now gets initialized here (on Site startup)

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

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