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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Tue Feb 4 08:24:37 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
+ initial commit
+ refactored from flib/Site/Request.php and flib/Site/Handler.php

1 joko 1.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 Application_AbstractRequest {
28    
29     // parent's instance
30     var $parent;
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     $parent = $this->parent;
43     $this->$parent->log( get_class($this) . "->getRequest()", LOG_DEBUG );
44     $this->_init();
45     return $this->request;
46     }
47    
48     function _init() {
49     if (!$this->meta[read]) {
50     $this->_read();
51     }
52     if (!$this->meta[parse]) {
53     $this->_parse();
54     }
55     }
56    
57    
58     function _read() {
59    
60     $parent = $this->parent;
61    
62     // shift external arguments from url
63     $identifier = $_GET[x];
64     $externalpage = $_GET[p];
65     // fallback to post
66     if (!$identifier) { $identifier = $_POST[x]; }
67    
68     $this->$parent->log( get_class($this) . "->_read( identifier $identifier )", LOG_DEBUG );
69    
70     // remember raw arguments in object
71     $this->raw[identifier] = $identifier;
72     $this->raw[externalpage] = $externalpage;
73     // TODO: url
74    
75     $this->meta[read] = 1;
76    
77     }
78    
79    
80     function _parse() {
81    
82     $parent = $this->parent;
83    
84     // generic identifier
85     $ident = $this->$parent->decodeIdentifier($this->raw[identifier]);
86    
87     // get handler for identifier
88     $this->$parent->log( get_class($this) . "->_parse: getHandler( identifier $ident )", LOG_DEBUG );
89     //$handler = $this->getHandler($ident);
90     $handler = $this->$parent->getHandler($ident);
91    
92     // trace
93     //print "handler:<br>" . Dumper($handler) . "<br>";
94    
95     // modify handlername
96     $handler[name] = $ident;
97    
98     // parse action from identifier
99     if ($ident && substr($ident, -1) != '/') {
100     $action = substr($ident, strrpos($ident, '/') + 1);
101     }
102    
103     // this is the internal (metadata-)structure of the request-object
104     $result = array(
105     'raw' => $this->raw,
106     'ident' => $ident,
107     'handler' => $handler,
108     'action' => $action,
109     );
110    
111     $this->request = $result;
112    
113     $this->meta[parse] = 1;
114    
115     }
116    
117     function getCached() {
118     $parent = $this->parent;
119     return $this->$parent->session->get('cachedRequest');
120     }
121    
122     function cacheRequest($request = array()) {
123     $parent = $this->parent;
124     if (!count($request)) {
125     $request = $this->getRequest();
126     }
127     //print Dumper($request);
128     $this->$parent->session->set('cachedRequest', $request);
129     }
130    
131     function overrideRequestIdentifier($ident) {
132     $this->overrideIdentifier($ident);
133     }
134    
135     function overrideIdentifier($ident) {
136     $parent = $this->parent;
137     $ident_encoded = $this->$parent->encodeIdentifier($ident);
138     $this->raw[identifier] = $ident_encoded;
139     $this->meta[parse] = 0;
140     }
141    
142     function getIdentifier() {
143     $this->_init();
144     return $this->request[ident];
145     }
146    
147     function isPage() {
148     $this->_init();
149     return $this->request[handler][isPage];
150     }
151    
152     }
153    
154     ?>

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