/[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.2 - (show annotations)
Fri Dec 13 09:17:41 2002 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.1: +13 -2 lines
+ function getLastRequest
+ function cacheRequest

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

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