/[cvs]/nfo/php/libs/org.netfrag.glib/Application/AbstractRequest.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.glib/Application/AbstractRequest.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Sun Feb 9 17:02:30 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.1: +19 -9 lines
+ minor update related to new log level constants

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

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