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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Thu Dec 19 16:25:29 2002 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.3: +26 -1 lines
+ function loadCmsPage($template, $data_merge = array())

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

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