1 |
joko |
1.1 |
<? |
2 |
|
|
/* |
3 |
|
|
## ----------------------------------------------------------------------------- |
4 |
|
|
## $Id: RequestTracker.php,v 1.2 2003/03/01 15:17:26 jonen Exp $ |
5 |
|
|
## ----------------------------------------------------------------------------- |
6 |
|
|
## $Log: RequestTracker.php,v $ |
7 |
|
|
## Revision 1.2 2003/03/01 15:17:26 jonen |
8 |
|
|
## + explorer pointers |
9 |
|
|
## + new proposal for internal data structure |
10 |
|
|
## |
11 |
|
|
## Revision 1.1 2003/02/28 04:14:48 joko |
12 |
|
|
## + initial commit |
13 |
|
|
## |
14 |
|
|
## ----------------------------------------------------------------------------- |
15 |
|
|
*/ |
16 |
|
|
|
17 |
|
|
|
18 |
|
|
class Application_Request_Tracker { |
19 |
|
|
|
20 |
|
|
// raw - $_GET and $_POST (merged) |
21 |
|
|
var $request; |
22 |
|
|
|
23 |
|
|
// variables to hold some stacks and pointers - two features / specs |
24 |
|
|
// 1. are kept persistent (session!) under the hood (automagically) |
25 |
|
|
// 2. plugin-namespace - this applies: |
26 |
|
|
// $this->pointers[$name][...][...] = |
27 |
|
|
// $this->stacks[$name][...][...] = |
28 |
|
|
//var $pointers; |
29 |
|
|
//var $stacks; |
30 |
|
|
var $data; |
31 |
|
|
|
32 |
|
|
function Application_Request_Tracker() { |
33 |
|
|
session_register_safe('Application_Request_Tracker_data'); |
34 |
|
|
$this->load(); |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
function load() { |
38 |
|
|
global $Application_Request_Tracker_data; |
39 |
|
|
$this->data = $Application_Request_Tracker_data; |
40 |
|
|
if (!is_array($this->data)) { |
41 |
|
|
$this->data = array(); |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
function save() { |
46 |
|
|
global $Application_Request_Tracker_data; |
47 |
|
|
$Application_Request_Tracker_data = $this->data; |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
function setMark($data) { |
51 |
|
|
$this->data[history][] = $data; |
52 |
|
|
$this->setPointer(); |
53 |
|
|
$this->save(); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
function getHistory() { |
57 |
|
|
return $this->data[history]; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
function setPointer($explicit = null) { |
61 |
|
|
if (!$explicit) { |
62 |
|
|
$this->data['pointer'] = $this->data[history][sizeof($this->data[history]) - 1]; |
63 |
|
|
} |
64 |
|
|
//print "pointer: " . Dumper($this->data[pointer]) . "<br/>"; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
function _resetPointer() { |
68 |
|
|
unset($this->data[pointer]); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
function getPointer() { |
72 |
|
|
return $this->data[pointer]; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
function getPointerAsString($pointer = null) { |
76 |
|
|
if (!$pointer) { |
77 |
|
|
$pointer = $this->data[pointer]; |
78 |
|
|
} |
79 |
|
|
if (is_array($pointer[component])) { |
80 |
|
|
$s_component = "<b>component:</b> " . join(', ', $pointer[component]); |
81 |
|
|
} |
82 |
|
|
if (is_array($pointer[request])) { |
83 |
|
|
$s_request = "<b>request:</b> " . join(', ', $pointer[request]); |
84 |
|
|
} |
85 |
|
|
unset($pointer[component]); |
86 |
|
|
unset($pointer[request]); |
87 |
|
|
$buf = array(); |
88 |
|
|
foreach ($pointer as $key => $val) { |
89 |
|
|
array_push($buf, "$key=$val"); |
90 |
|
|
} |
91 |
|
|
$s_keys = "<b>keys:</b> " . join(', ', $buf); |
92 |
|
|
$pser = join( '<br/>', array( $s_keys, $s_component, $s_request ) ); |
93 |
|
|
return $pser; |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
function addExplorer($data) { |
97 |
|
|
$this->data['explorer'][] = $data; |
98 |
|
|
$this->setExplorerPointer(); |
99 |
|
|
$this->save(); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
function setExplorerPointer($explicit = null) { |
103 |
|
|
if (!$explicit) { |
104 |
|
|
$this->data['explorer_pointer'] = $this->data['explorer'][sizeof($this->data['explorer']) - 1]; |
105 |
|
|
} |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
function getExplorerPointer($pointer = null) { |
109 |
|
|
if(!$pointer) { |
110 |
|
|
return $this->data['explorer_pointer']; |
111 |
|
|
} |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
function resetExplorer() { |
115 |
|
|
unset($this->data['explorer']); |
116 |
|
|
unset($this->data['explorer_pointer']); |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
/* |
122 |
|
|
function register_plugin($name) { |
123 |
|
|
// reserve slot for plugin |
124 |
|
|
$this->pointers[$name][...][...] = |
125 |
|
|
$this->stacks[$name][...][...] = |
126 |
|
|
} |
127 |
|
|
*/ |
128 |
|
|
|
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
?> |