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