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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Sun Feb 9 17:40:10 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +4 -1 lines
FILE REMOVED
- moved to org.netfrag.glib/Application/AbstractRequest.php

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

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