| 3 |
// $Id$ |
// $Id$ |
| 4 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
| 5 |
// $Log$ |
// $Log$ |
| 6 |
|
// 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 |
|
// 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 |
|
// 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 |
// Revision 1.1 2002/11/12 05:42:31 joko |
// Revision 1.1 2002/11/12 05:42:31 joko |
| 19 |
// + initial checkin |
// + initial checkin |
| 20 |
// |
// |
| 23 |
|
|
| 24 |
class Site_Request { |
class Site_Request { |
| 25 |
|
|
| 26 |
|
// site's instance |
| 27 |
var $site; |
var $site; |
| 28 |
|
|
| 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 |
|
var $request; |
| 37 |
|
|
| 38 |
function getRequest() { |
function getRequest() { |
| 39 |
|
$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 |
|
// remember arguments in object |
| 67 |
|
$this->raw[identifier] = $identifier; |
| 68 |
|
$this->raw[externalpage] = $externalpage; |
| 69 |
|
|
| 70 |
|
$this->meta[read] = 1; |
| 71 |
|
|
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
// shift external arguments |
function _parse() { |
| 76 |
$arg = $_GET[x]; |
|
| 77 |
if (!$arg) { $arg = $_POST[x]; } |
//print "_parse<br>"; |
|
$externalpage = $_GET[p]; |
|
|
|
|
|
$this->site->log( get_class($this) . "->getRequest( arg $arg )", LOG_DEBUG ); |
|
| 78 |
|
|
| 79 |
// generic identifier |
// generic identifier |
| 80 |
//$ident = $this->_decodeIdentifier($arg); |
$ident = $this->site->decodeIdentifier($this->raw[identifier]); |
| 81 |
$ident = $this->site->decodeIdentifier($arg); |
|
| 82 |
|
//print "ident: $ident<br>"; |
| 83 |
|
|
| 84 |
// get handler for identifier |
// get handler for identifier |
| 85 |
//$handler = $this->getHandler($ident); |
//$handler = $this->getHandler($ident); |
| 86 |
$this->site->log( get_class($this) . "->getRequest: getHandler( ident $ident )", LOG_DEBUG ); |
$this->site->log( get_class($this) . "->_parse: getHandler( identifier $ident )", LOG_DEBUG ); |
| 87 |
$handler = $this->site->getHandler($ident); |
$handler = $this->site->getHandler($ident); |
| 88 |
//print "handler: " . dumpvar($handler) . "<br>"; |
//print "handler: " . dumpvar($handler) . "<br>"; |
| 89 |
$handler[name] = $ident; |
$handler[name] = $ident; |
| 94 |
} |
} |
| 95 |
|
|
| 96 |
$result = array( |
$result = array( |
| 97 |
'url_arg' => $arg, |
'raw' => $this->raw, |
| 98 |
'ident' => $ident, |
'ident' => $ident, |
| 99 |
'handler' => $handler, |
'handler' => $handler, |
|
'externalpage' => $externalpage, |
|
| 100 |
'action' => $action, |
'action' => $action, |
| 101 |
); |
); |
| 102 |
|
|
| 103 |
|
$this->request = $result; |
| 104 |
|
|
| 105 |
return $result; |
$this->meta[parse] = 1; |
| 106 |
|
|
| 107 |
} |
} |
| 108 |
|
|
| 109 |
function getCachedRequest () { |
function getCached() { |
| 110 |
global $site_state; |
return $this->site->session->get('cachedRequest'); |
|
return $site_state[cachedRequest]; |
|
| 111 |
} |
} |
| 112 |
|
|
| 113 |
function cacheThisRequest($request) { |
function cacheRequest($request = array()) { |
| 114 |
global $site_state; |
if (!count($request)) { |
| 115 |
$site_state[cachedRequest] = $request; |
$request = $this->getRequest(); |
| 116 |
|
} |
| 117 |
|
//print Dumper($request); |
| 118 |
|
$this->site->session->set('cachedRequest', $request); |
| 119 |
} |
} |
| 120 |
|
|
| 121 |
function overrideRequestIdentifier($ident) { |
function overrideRequestIdentifier($ident) { |
| 122 |
$pident = $this->site->encodeIdentifier($ident); |
$this->overrideIdentifier($ident); |
| 123 |
// PATCH!!!! clean up!!! |
} |
| 124 |
$_GET[x] = $pident; |
|
| 125 |
|
function overrideIdentifier($ident) { |
| 126 |
|
$ident_encoded = $this->site->encodeIdentifier($ident); |
| 127 |
|
$this->raw[identifier] = $ident_encoded; |
| 128 |
|
$this->meta[parse] = 0; |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
function getIdentifier() { |
| 132 |
|
$this->_init(); |
| 133 |
|
return $this->request[ident]; |
| 134 |
} |
} |
| 135 |
|
|
| 136 |
|
function isPage() { |
| 137 |
|
$this->_init(); |
| 138 |
|
return $this->request[handler][isPage]; |
| 139 |
|
} |
| 140 |
|
|
| 141 |
} |
} |
| 142 |
|
|
| 143 |
?> |
?> |