1 |
<? |
2 |
// ------------------------------------------------------------------------- |
3 |
// $Id: Request.php,v 1.2 2002/12/12 21:39:24 joko Exp $ |
4 |
// ------------------------------------------------------------------------- |
5 |
// $Log: Request.php,v $ |
6 |
// Revision 1.2 2002/12/12 21:39:24 joko |
7 |
// + fix to 'cacheThisRequest' - now uses the current one to cache if none is passed |
8 |
// |
9 |
// Revision 1.1 2002/11/12 05:42:31 joko |
10 |
// + initial checkin |
11 |
// |
12 |
// ------------------------------------------------------------------------- |
13 |
|
14 |
|
15 |
class Site_Request { |
16 |
|
17 |
var $site; |
18 |
var $request; |
19 |
|
20 |
function getRequest() { |
21 |
|
22 |
// shift external arguments |
23 |
$arg = $_GET[x]; |
24 |
if (!$arg) { $arg = $_POST[x]; } |
25 |
$externalpage = $_GET[p]; |
26 |
|
27 |
$this->site->log( get_class($this) . "->getRequest( arg $arg )", LOG_DEBUG ); |
28 |
|
29 |
// generic identifier |
30 |
//$ident = $this->_decodeIdentifier($arg); |
31 |
$ident = $this->site->decodeIdentifier($arg); |
32 |
|
33 |
// get handler for identifier |
34 |
//$handler = $this->getHandler($ident); |
35 |
$this->site->log( get_class($this) . "->getRequest: getHandler( ident $ident )", LOG_DEBUG ); |
36 |
$handler = $this->site->getHandler($ident); |
37 |
//print "handler: " . dumpvar($handler) . "<br>"; |
38 |
$handler[name] = $ident; |
39 |
|
40 |
// parse action from identifier |
41 |
if ($ident && substr($ident, -1) != '/') { |
42 |
$action = substr($ident, strrpos($ident, '/') + 1); |
43 |
} |
44 |
|
45 |
$result = array( |
46 |
'url_arg' => $arg, |
47 |
'ident' => $ident, |
48 |
'handler' => $handler, |
49 |
'externalpage' => $externalpage, |
50 |
'action' => $action, |
51 |
); |
52 |
|
53 |
$this->request = $result; |
54 |
|
55 |
return $result; |
56 |
} |
57 |
|
58 |
function getCachedRequest () { |
59 |
return $this->site->session->get('cachedRequest'); |
60 |
} |
61 |
|
62 |
function cacheThisRequest($request = array()) { |
63 |
if (!count($request)) { |
64 |
$request = $this->getRequest(); |
65 |
//$request = $this->request; |
66 |
} |
67 |
//print Dumper($request); |
68 |
$this->site->session->set('cachedRequest', $request); |
69 |
} |
70 |
|
71 |
function overrideRequestIdentifier($ident) { |
72 |
$pident = $this->site->encodeIdentifier($ident); |
73 |
// PATCH!!!! clean up!!! |
74 |
$_GET[x] = $pident; |
75 |
} |
76 |
|
77 |
function getIdentifier() { |
78 |
return $this->request[ident]; |
79 |
} |
80 |
|
81 |
|
82 |
} |
83 |
?> |