/[cvs]/nfo/php/libs/org.netfrag.elib/_unused/Kopie von lib_tracking.php.inc
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.elib/_unused/Kopie von lib_tracking.php.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Wed Jan 23 17:40:38 2002 UTC (22 years, 5 months ago) by cvsjoko
Branch: nfo, MAIN
CVS Tags: v003, HEAD
Changes since 1.1: +0 -0 lines
initial

1 cvsjoko 1.1 <?
2    
3     // ===============================================================
4     class Tracking {
5    
6     // our TrackingState
7     var $state;
8    
9     // a reference to HttpLib
10     var $httplib;
11    
12     // instantiated datastore, some pages might need it
13     var $ds;
14    
15    
16     // some information-clusters (ics) for keeping meta-information
17     var $ic_virtualpages;
18     var $ic_pagetemplates;
19     var $ic_menustructure;
20     var $ic_navigationtargets;
21    
22     // an object-reference to an ic which holds metadata for the current virtual-page being rendered by "$tracking->genArea()"
23     var $ic_virtualpage_current;
24    
25     // misc
26     var $pageargs;
27    
28    
29     // ------------------------------------------------------------------------------------------------
30     function Tracking() {
31    
32     // we need some information from "Site"
33     global $site;
34    
35     // create objects
36     $this->httplib = new HttpLib();
37    
38     // initialize information clusters
39     ($this->ic_virtualpages = $site->getInformationCluster('virtualpages')) || trigger_error("could not load InformationCluster", E_USER_ERROR);
40     ($this->ic_pagetemplates = $site->getInformationCluster('pagetemplates')) || trigger_error("could not load InformationCluster", E_USER_ERROR);
41     ($this->ic_menustructure = $site->getInformationCluster('menu_structure')) || trigger_error("could not load InformationCluster", E_USER_ERROR);
42     ($this->ic_navigationtargets = $site->getInformationCluster('navigation_targets')) || trigger_error("could not load InformationCluster", E_USER_ERROR);
43    
44     // initialize some class-variables
45     $this->modules_loaded = array();
46    
47     }
48    
49    
50     // ------------------------------------------------------------------------------------------------
51     function initState($metadata_tracking_vars, $metadata_tracking_callbacks) {
52     // initialize state
53     $this->state = new TrackingState($metadata_tracking_vars, $metadata_tracking_callbacks);
54     $this->state->collectInputArguments();
55     //$this->_processState();
56     }
57    
58     // ------------------------------------------------------------------------------------------------
59     function setStatusAttribute($name, $value) {
60     $this->state->set($name, $value);
61     }
62     function unsetStatusAttribute($name) {
63     $this->state->unsetVar($name);
64     }
65     function getStatusAttribute($name) {
66     return $this->state->get($name);
67     }
68     function clearStatusAttributes() {
69     $this->state->clear();
70     }
71     function dumpState() {
72     $this->state->dump();
73     }
74     function dumpState_get() {
75     return $this->state->dump_get();
76     }
77    
78    
79     // ------------------------------------------------------------------------------------
80     function getLink_ByArgs($link_args) {
81    
82     // data, which is displayed between "<a >"-"</a>-tags (parameters/args, which have a special meaning for building a html-link)
83     // either converted via "htmlentities" (if "caption" is supplied) or directly set (if "innerHTML" is given)
84     if (isset($link_args['caption'])) { $innerHTML = htmlentities($link_args['caption']); }
85     if (isset($link_args['innerHTML'])) { $innerHTML = $link_args['innerHTML']; }
86    
87     // some html-attributes
88     if ( isset($link_args['html_class']) ) { $html_attribs['class'] = $link_args['html_class']; }
89     if ( isset($link_args['title']) ) { $html_attribs['title'] = ' ' . $link_args['title'] . ' '; }
90     if ( isset($link_args['target']) ) {
91     // get MetaItem where target-information (e.g. name of target frameset, wrapperpage, ...) is stored
92     if ( $mi = $this->ic_navigationtargets->getMetaItem($link_args['target']) ) {
93     // get name of targetframe from MetaItem
94     if ($targetframe = $mi->getAttribute('targetframe')) { $html_attribs['target'] = $targetframe; }
95     }
96     }
97    
98     // "href"
99     if (isset($link_args['href'])) {
100     $html_attribs['href'] = $link_args['href'];
101     } else {
102    
103     // filter "$link_args" through valid keys of output-args and return valid hash of output-args
104     $outputargs = $this->state->getOutputArguments($link_args);
105    
106     // get complete url-parameters from outputargs
107     $querystring = $this->httplib->getRequestString($outputargs);
108     $html_attribs['href'] = '?' . $querystring;
109     }
110    
111     // build html-link
112     $html_attribstring = getAttribStringFromHash($html_attribs, ' ', '=', '"');
113     // TODO: use "get_HtmlTag()"
114     $link = "<a $html_attribstring>$innerHTML</a>";
115    
116     // return built link
117     return $link;
118    
119     }
120    
121    
122     // ------------------------------------------------------------------------------------
123     function getLink_ByName($name) {
124     // ($mi = $this->ic_menustructure->getMetaItem($name)) || trigger_error("could not get link \"$name\"", E_USER_ERROR);
125     if ( $mi = $this->ic_menustructure->getMetaItem($name) ) {
126     return $this->getLink_ByArgs($mi->getAttributes());
127     }
128     }
129    
130    
131    
132     // --------------------------------------------------------------------------------------------------------------------------------
133     // generates output
134     // --------------------------------------------------------------------------------------------------------------------------------
135    
136     // ------------------------------------------------------------------------------------
137     function genArea_ErrorPage( $args ) {
138    
139     global $site;
140    
141     if ($mi_template_effective = $this->ic_pagetemplates->getMetaItem('error_404')) {
142     $attribs = $mi_template_effective->getAttributes();
143     $file_error404 = $site->getAttribute('path_pages') . $attribs['file'];
144     if (file_exists($file_error404)) {
145     // TODO: pass "$args['reason']" to show on error-page
146     $this->genArea( array('pseudopage' => 'error_404') );
147     } else {
148     $die_dump_tracking = $this->dumpState_get();
149     $die_message = "
150     {$args['reason']} <br>
151     <br>
152     While trying to open a proper page for bringing this error to you (\"error-404-template\"), another error occoured. <br>
153     At most times this means that no physical file representing the \"error-404-template\" exists. <br>
154     For your information: \"file_exists('$file_error404')\" returned \"false\". <br>
155     <br>
156     We also supply a variable-dump here, feel free sending a copy of it to us at <a href=\"mailto:x4@ilo.de\">x4@ilo.de</a>. <br>
157     ------------------------------------------------------------------------------------ <br>
158     dump of arguments to \"\$tracking->genArea_ErrorPage()\": <br>
159     (virtualpage=\"{$args['virtualpage']}\", pseudopage=\"{$args['pseudopage']}\") <br>
160     ------------------------------------------------------------------------------------ <br>
161     dump of tracking: <br>
162     $die_dump_tracking <br>
163     ------------------------------------------------------------------------------------ <br>
164     ";
165     die($die_message);
166     }
167     }
168    
169     }
170    
171    
172     // ------------------------------------------------------------------------------------
173     function genArea($args) {
174    
175     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
176     // declaration/initialization/globalization of variables
177    
178     // important globals (these two objects are used *everywhere* to do (almost) *anything*)
179     global $site;
180     global $tracking;
181    
182     // some other variables which should be global but are not as important
183     // for benchmarking
184     global $benchmark_all;
185     global $glbl_bool_benchmarking;
186    
187     // some variables used in page
188     global $pageargs;
189     global $areaargs;
190    
191     // some local ones
192    
193     // should the result of "genArea()" be returned instead of printed out?
194     $bool_return = 0;
195    
196    
197     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
198     // configuration ...
199    
200     // ... dependent on arguments to this function
201     if (isset($args['returnContent'])) { $bool_return = 1; }
202    
203     $pageargs = array();
204     $areaargs = array();
205    
206    
207     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
208     // determination of proper virtualpage / pseudopage
209    
210     // init
211     $virtualpage_name = '';
212     $pseudopage_name = '';
213     $genpage_name = '';
214     $pagetemplate_name = '';
215    
216     // get name of virtual-page from tracking-state by default
217     $virtualpage_name = $this->getStatusAttribute('virtualpage');
218    
219     // modify virtual-page and set pseudo-page, if given
220     isset($args['virtualpage']) && ($virtualpage_name = $args['virtualpage']);
221     isset($args['pseudopage']) && ($pseudopage_name = $args['pseudopage']);
222    
223     // get virtual-page
224     if ( $mi_VirtualPage = $this->ic_virtualpages->getMetaItem($virtualpage_name) ) {
225     // remember reference to current virtual-page in "$tracking->ic_virtualpage_current"
226     $this->ic_virtualpage_current = $mi_VirtualPage;
227     $vpname = $mi_VirtualPage->getAttribute('name');
228     print "process-object for vp \"$vpname\".<br>";
229    
230     $tracking->loadModule('main/common.library');
231     $pObj =& new ObjectHandler_User();
232     $pObj->call('_list');
233     }
234    
235     // is a pseudo-page given?
236     if ($pseudopage_name) {
237     $genpage_name = $pseudopage_name;
238     } else {
239     $genpage_name = $virtualpage_name;
240     }
241    
242    
243    
244     $tmp_bool_ok = 0;
245     // get virtual-page-MetaItem of gen-page
246     if ( $mi_VirtualPage = $this->ic_virtualpages->getMetaItem($genpage_name) ) {
247    
248     // virtual-page-redirection
249     // current: one level
250     // TODO: n-levels
251     if ($redir = $mi_VirtualPage->getAttribute('redirect')) {
252     $genpage_name = $redir;
253     $mi_VirtualPage = $this->ic_virtualpages->getMetaItem($genpage_name);
254     }
255    
256     // determine page-template
257     $pagetemplate_name = $mi_VirtualPage->getAttribute('pagetemplate');
258     if ($mi_PageTemplate = $this->ic_pagetemplates->getMetaItem($pagetemplate_name)) {
259     $tmp_bool_ok = 1;
260     }
261    
262     }
263    
264    
265    
266     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
267     // detect errors
268    
269     // if something's wrong with determining the virtual-page or the current page-template,
270     // we deliver an error-page (current: 404 - file not found) via loading the "error_404" page-template.
271     // we have to handle a special case here and test the physical file for existance before
272     // calling "$this->genArea", because else we would get a recursive loop here and
273     // soon (immediately) end up with a php-error: "PHP has encountered a Stack overflow"
274     if (!$tmp_bool_ok) {
275     $err_reason = "Something went wrong when determining template for effective page \"$genpage_name\" in \"\$tracking->genArea()\".";
276     $this->genArea_ErrorPage( array('reason' => $err_reason, 'virtualpage' => $virtualpage_name, 'pseudopage' => $pseudopage_name) );
277    
278     //die("could not find requested virtual page *and* could not find entry for generating an error-page in \"ic_pagetemplates\"");
279     exit;
280     }
281    
282    
283     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
284     // startup rendering
285    
286     if ($bool_return) { ob_start(); }
287    
288    
289    
290    
291     // get all attributes of current page-template
292     $attribs = $mi_PageTemplate->getAttributes();
293    
294     // physical file to be included
295     $includefile = $site->getAttribute('path_pages') . $attribs['file'];
296    
297     // test physical file for existance
298     // was:
299     // if ( !file_exists($includefile) ) { trigger_error("could not include file \"$includefile\", quitting...", E_USER_ERROR); }
300     // is:
301     if ( !file_exists($includefile) ) {
302     // was:
303     // $this->genArea( array('pseudopage' => 'error_404') );
304     // exit;
305     // is:
306     $err_reason = "Could not find physical file \"$includefile\" when trying to open template \"$pagetemplate_name\" for effective page \"$genpage_name\" in \"\$tracking->genArea()\".";
307     $this->genArea_ErrorPage( array('reason' => $err_reason, 'virtualpage' => $virtualpage_name, 'pseudopage' => $pseudopage_name) );
308     exit;
309     }
310    
311    
312     // ------------------------
313     // render page
314    
315     // shall we render a body and stuff?
316     if ( isset($attribs['bool_HTMLBody']) && ($attribs['bool_HTMLBody']) ) {
317    
318     // if we shall render a body, then here comes the "body-begin"
319     $this->genArea( array('pseudopage' => 'static.content.begin') );
320    
321     if ( isset($attribs['form']) ) { print "<form name=\"mf\">\n"; }
322    
323     }
324    
325     // get page-arguments
326     if ($mi_VirtualPage) {
327     $pageargs = $mi_VirtualPage->getAttribute('pageargs');
328     $pageargs['virtualpage_effective'] = $mi_VirtualPage->getAttribute('name');
329     }
330    
331     if ( isset($attribs['bool_PageHeader']) && isset($pageargs['pageheader']) ) { print $pageargs['pageheader'] . "\n"; }
332    
333     if (isset($args['areaargs'])) {
334     $areaargs = $args['areaargs'];
335     }
336    
337     // here comes the include
338     $include_retval = include($includefile);
339    
340     // shall we render a body and stuff?
341     if ( isset($attribs['bool_HTMLBody']) && ($attribs['bool_HTMLBody']) ) {
342    
343     if ( isset($attribs['form']) ) { print "<input type=\"image\" width=\"0\" height=\"0\"></form>\n"; }
344    
345     // if we shall render a body, then here comes the "body-end"
346     $this->genArea( array('pseudopage' => 'static.content.end') );
347    
348     // dump our state
349     //$this->dumpState();
350    
351     }
352    
353     if ($bool_return) {
354     $retval = ob_get_contents();
355     ob_end_clean();
356     return $retval;
357     }
358    
359     }
360    
361    
362    
363    
364     function authenticate($user, $pass) {
365     $dq = new DataQuery();
366     $dq->setQuery("SELECT * FROM users WHERE nachname='$user' AND passwd='$pass';");
367     $dq->query();
368     if ($dq->getRowCount()) {
369     $dq->next();
370     $entry = $dq->getResult();
371     $this->setStatusAttribute('login::userid', $entry['user_id']);
372     return 1;
373     }
374     }
375    
376     function loadLibrary($libname) {
377     global $site;
378     $site->loadLibrary($libname);
379     }
380    
381     function loadModule($modulename) {
382     global $site;
383     $site->loadModule($modulename);
384     }
385    
386     function redirect($args) {
387     $this->httplib->redirect($args);
388     }
389    
390     }
391     ?>

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