/[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.6 - (hide 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 joko 1.1 <?
2     // -------------------------------------------------------------------------
3 joko 1.6 // $Id: Request.php,v 1.5 2002/12/19 16:24:52 joko Exp $
4 joko 1.1 // -------------------------------------------------------------------------
5 joko 1.2 // $Log: Request.php,v $
6 joko 1.6 // Revision 1.5 2002/12/19 16:24:52 joko
7     // + debugging
8     //
9 joko 1.5 // 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 joko 1.4 // 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 jonen 1.3 // 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 joko 1.2 // Revision 1.1 2002/11/12 05:42:31 joko
22     // + initial checkin
23     //
24 joko 1.1 // -------------------------------------------------------------------------
25    
26    
27     class Site_Request {
28    
29 joko 1.4 // site's instance
30 joko 1.1 var $site;
31 joko 1.4
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 jonen 1.3 var $request;
40 joko 1.1
41     function getRequest() {
42 joko 1.4 $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 joko 1.5 // remember raw arguments in object
70 joko 1.4 $this->raw[identifier] = $identifier;
71     $this->raw[externalpage] = $externalpage;
72 joko 1.5 // TODO: url
73    
74 joko 1.4 $this->meta[read] = 1;
75    
76     }
77    
78 joko 1.1
79 joko 1.4 function _parse() {
80    
81     //print "_parse<br>";
82 joko 1.1
83     // generic identifier
84 joko 1.4 $ident = $this->site->decodeIdentifier($this->raw[identifier]);
85    
86     //print "ident: $ident<br>";
87 joko 1.1
88     // get handler for identifier
89     //$handler = $this->getHandler($ident);
90 joko 1.4 $this->site->log( get_class($this) . "->_parse: getHandler( identifier $ident )", LOG_DEBUG );
91 joko 1.1 $handler = $this->site->getHandler($ident);
92 joko 1.5 //print "handler:<br>" . Dumper($handler) . "<br>";
93 joko 1.1 $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 joko 1.5 // this is the internal (metadata-)structure of the request-object
101 joko 1.1 $result = array(
102 joko 1.4 'raw' => $this->raw,
103 joko 1.1 'ident' => $ident,
104     'handler' => $handler,
105     'action' => $action,
106     );
107 jonen 1.3
108     $this->request = $result;
109 joko 1.1
110 joko 1.4 $this->meta[parse] = 1;
111    
112 joko 1.1 }
113    
114 joko 1.4 function getCached() {
115 jonen 1.3 return $this->site->session->get('cachedRequest');
116 joko 1.1 }
117    
118 joko 1.4 function cacheRequest($request = array()) {
119 joko 1.2 if (!count($request)) {
120     $request = $this->getRequest();
121     }
122 joko 1.4 //print Dumper($request);
123 jonen 1.3 $this->site->session->set('cachedRequest', $request);
124 joko 1.1 }
125    
126     function overrideRequestIdentifier($ident) {
127 joko 1.4 $this->overrideIdentifier($ident);
128 jonen 1.3 }
129 joko 1.4
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 jonen 1.3 function getIdentifier() {
137 joko 1.4 $this->_init();
138 jonen 1.3 return $this->request[ident];
139 joko 1.1 }
140    
141 joko 1.4 function isPage() {
142     $this->_init();
143     return $this->request[handler][isPage];
144     }
145 joko 1.1
146     }
147 joko 1.4
148 joko 1.1 ?>

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