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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations)
Thu Dec 19 16:24:52 2002 UTC (21 years, 8 months ago) by joko
Branch: MAIN
Changes since 1.4: +11 -4 lines
+ debugging

1 joko 1.1 <?
2     // -------------------------------------------------------------------------
3 joko 1.5 // $Id: Request.php,v 1.4 2002/12/13 09:18:48 joko Exp $
4 joko 1.1 // -------------------------------------------------------------------------
5 joko 1.2 // $Log: Request.php,v $
6 joko 1.5 // Revision 1.4 2002/12/13 09:18:48 joko
7     // + new mechanisms for handling the request: split up into _read and _parse
8     // + introduced caching-mechanism
9     // + fixed overriding-mechanism
10     //
11 joko 1.4 // Revision 1.3 2002/12/13 00:22:27 jonen
12     // - removed $site_state vars at cachedRequest
13     // changes related to new Session class
14     //
15 jonen 1.3 // Revision 1.2 2002/12/12 21:39:24 joko
16     // + fix to 'cacheThisRequest' - now uses the current one to cache if none is passed
17     //
18 joko 1.2 // Revision 1.1 2002/11/12 05:42:31 joko
19     // + initial checkin
20     //
21 joko 1.1 // -------------------------------------------------------------------------
22    
23    
24     class Site_Request {
25    
26 joko 1.4 // site's instance
27 joko 1.1 var $site;
28 joko 1.4
29     // to keep some status-information for reading/parsing
30     var $meta;
31    
32     // to keep some lowlevel-information about the request
33     var $raw;
34    
35     // the read and parsed request - ready for further processing with the Request - object
36 jonen 1.3 var $request;
37 joko 1.1
38     function getRequest() {
39 joko 1.4 $this->site->log( get_class($this) . "->getRequest()", LOG_DEBUG );
40     $this->_init();
41     return $this->request;
42     }
43    
44     function _init() {
45     if (!$this->meta[read]) {
46     $this->_read();
47     }
48     if (!$this->meta[parse]) {
49     $this->_parse();
50     }
51     }
52    
53    
54     function _read() {
55    
56     //print "_read<br>";
57    
58     // shift external arguments from url
59     $identifier = $_GET[x];
60     $externalpage = $_GET[p];
61     // fallback to post
62     if (!$identifier) { $identifier = $_POST[x]; }
63    
64     $this->site->log( get_class($this) . "->_read( identifier $identifier )", LOG_DEBUG );
65    
66 joko 1.5 // remember raw arguments in object
67 joko 1.4 $this->raw[identifier] = $identifier;
68     $this->raw[externalpage] = $externalpage;
69 joko 1.5 // TODO: url
70    
71 joko 1.4 $this->meta[read] = 1;
72    
73     }
74    
75 joko 1.1
76 joko 1.4 function _parse() {
77    
78     //print "_parse<br>";
79 joko 1.1
80     // generic identifier
81 joko 1.4 $ident = $this->site->decodeIdentifier($this->raw[identifier]);
82    
83     //print "ident: $ident<br>";
84 joko 1.1
85     // get handler for identifier
86     //$handler = $this->getHandler($ident);
87 joko 1.4 $this->site->log( get_class($this) . "->_parse: getHandler( identifier $ident )", LOG_DEBUG );
88 joko 1.1 $handler = $this->site->getHandler($ident);
89 joko 1.5 //print "handler:<br>" . Dumper($handler) . "<br>";
90 joko 1.1 $handler[name] = $ident;
91    
92     // parse action from identifier
93     if ($ident && substr($ident, -1) != '/') {
94     $action = substr($ident, strrpos($ident, '/') + 1);
95     }
96    
97 joko 1.5 // this is the internal (metadata-)structure of the request-object
98 joko 1.1 $result = array(
99 joko 1.4 'raw' => $this->raw,
100 joko 1.1 'ident' => $ident,
101     'handler' => $handler,
102     'action' => $action,
103     );
104 jonen 1.3
105     $this->request = $result;
106 joko 1.1
107 joko 1.4 $this->meta[parse] = 1;
108    
109 joko 1.1 }
110    
111 joko 1.4 function getCached() {
112 jonen 1.3 return $this->site->session->get('cachedRequest');
113 joko 1.1 }
114    
115 joko 1.4 function cacheRequest($request = array()) {
116 joko 1.2 if (!count($request)) {
117     $request = $this->getRequest();
118     }
119 joko 1.4 //print Dumper($request);
120 jonen 1.3 $this->site->session->set('cachedRequest', $request);
121 joko 1.1 }
122    
123     function overrideRequestIdentifier($ident) {
124 joko 1.4 $this->overrideIdentifier($ident);
125 jonen 1.3 }
126 joko 1.4
127     function overrideIdentifier($ident) {
128     $ident_encoded = $this->site->encodeIdentifier($ident);
129     $this->raw[identifier] = $ident_encoded;
130     $this->meta[parse] = 0;
131     }
132    
133 jonen 1.3 function getIdentifier() {
134 joko 1.4 $this->_init();
135 jonen 1.3 return $this->request[ident];
136 joko 1.1 }
137    
138 joko 1.4 function isPage() {
139     $this->_init();
140     return $this->request[handler][isPage];
141     }
142 joko 1.1
143     }
144 joko 1.4
145 joko 1.1 ?>

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