| 1 |
<? |
| 2 |
/** |
| 3 |
* This file contains the Application::Request::Tracker class. |
| 4 |
* |
| 5 |
* @author Andreas Motl <andreas.motl@ilo.de> |
| 6 |
* @package org.netfrag.glib |
| 7 |
* @name Application::Request::Tracker |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* <b>Cvs-Log:</b> |
| 13 |
* |
| 14 |
* <pre> |
| 15 |
* ----------------------------------------------------------------------------- |
| 16 |
* $Id: Tracker.php,v 1.3 2003/03/11 01:22:22 joko Exp $ |
| 17 |
* ----------------------------------------------------------------------------- |
| 18 |
* $Log: Tracker.php,v $ |
| 19 |
* Revision 1.3 2003/03/11 01:22:22 joko |
| 20 |
* + fixed metadata for phpDocumentor |
| 21 |
* |
| 22 |
* Revision 1.2 2003/03/03 21:16:41 joko |
| 23 |
* mungled namespaces |
| 24 |
* |
| 25 |
* Revision 1.1 2003/03/01 15:30:38 joko |
| 26 |
* + initial commit, refactored from Application::RequestTracker |
| 27 |
* |
| 28 |
* Revision 1.2 2003/03/01 15:17:26 jonen |
| 29 |
* + explorer pointers |
| 30 |
* + new proposal for internal data structure |
| 31 |
* |
| 32 |
* Revision 1.1 2003/02/28 04:14:48 joko |
| 33 |
* + initial commit |
| 34 |
* |
| 35 |
* ----------------------------------------------------------------------------- |
| 36 |
* </pre> |
| 37 |
* |
| 38 |
*/ |
| 39 |
|
| 40 |
|
| 41 |
/** |
| 42 |
* --- Application::Request::Tracker |
| 43 |
* |
| 44 |
* @author Andreas Motl <andreas.motl@ilo.de> |
| 45 |
* @copyright (c) 2003 - All Rights reserved. |
| 46 |
* @license GNU LGPL (GNU Lesser General Public License) |
| 47 |
* |
| 48 |
* @link http://www.netfrag.org/~joko/ |
| 49 |
* @link http://www.gnu.org/licenses/lgpl.txt |
| 50 |
* |
| 51 |
* @package org.netfrag.glib |
| 52 |
* @subpackage Application |
| 53 |
* @name Application::Request::Tracker |
| 54 |
* |
| 55 |
*/ |
| 56 |
class Application_Request_Tracker { |
| 57 |
|
| 58 |
// raw - $_GET and $_POST (merged) |
| 59 |
var $request; |
| 60 |
|
| 61 |
// variables to hold some stacks and pointers - two features / specs |
| 62 |
// 1. are kept persistent (session!) under the hood (automagically) |
| 63 |
// 2. plugin-namespace - this applies: |
| 64 |
// $this->pointers[$name][...][...] = |
| 65 |
// $this->stacks[$name][...][...] = |
| 66 |
//var $pointers; |
| 67 |
//var $stacks; |
| 68 |
var $data; |
| 69 |
|
| 70 |
function Application_Request_Tracker() { |
| 71 |
php::session_register_safe('Application_Request_Tracker_data'); |
| 72 |
$this->load(); |
| 73 |
} |
| 74 |
|
| 75 |
function load() { |
| 76 |
global $Application_Request_Tracker_data; |
| 77 |
$this->data = $Application_Request_Tracker_data; |
| 78 |
if (!is_array($this->data)) { |
| 79 |
$this->data = array(); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
function save() { |
| 84 |
global $Application_Request_Tracker_data; |
| 85 |
$Application_Request_Tracker_data = $this->data; |
| 86 |
} |
| 87 |
|
| 88 |
function setMark($data) { |
| 89 |
$this->data[history][] = $data; |
| 90 |
$this->setPointer(); |
| 91 |
$this->save(); |
| 92 |
} |
| 93 |
|
| 94 |
function getHistory() { |
| 95 |
return $this->data[history]; |
| 96 |
} |
| 97 |
|
| 98 |
function setPointer($explicit = null) { |
| 99 |
if (!$explicit) { |
| 100 |
$this->data['pointer'] = $this->data[history][sizeof($this->data[history]) - 1]; |
| 101 |
} |
| 102 |
//print "pointer: " . Dumper($this->data[pointer]) . "<br/>"; |
| 103 |
} |
| 104 |
|
| 105 |
function _resetPointer() { |
| 106 |
unset($this->data[pointer]); |
| 107 |
} |
| 108 |
|
| 109 |
function getPointer() { |
| 110 |
return $this->data[pointer]; |
| 111 |
} |
| 112 |
|
| 113 |
function getPointerAsString($pointer = null) { |
| 114 |
if (!$pointer) { |
| 115 |
$pointer = $this->data[pointer]; |
| 116 |
} |
| 117 |
if (is_array($pointer[component])) { |
| 118 |
$s_component = "<b>component:</b> " . join(', ', $pointer[component]); |
| 119 |
} |
| 120 |
if (is_array($pointer[request])) { |
| 121 |
$s_request = "<b>request:</b> " . join(', ', $pointer[request]); |
| 122 |
} |
| 123 |
unset($pointer[component]); |
| 124 |
unset($pointer[request]); |
| 125 |
$buf = array(); |
| 126 |
foreach ($pointer as $key => $val) { |
| 127 |
array_push($buf, "$key=$val"); |
| 128 |
} |
| 129 |
$s_keys = "<b>keys:</b> " . join(', ', $buf); |
| 130 |
$pser = join( '<br/>', array( $s_keys, $s_component, $s_request ) ); |
| 131 |
return $pser; |
| 132 |
} |
| 133 |
|
| 134 |
function addExplorer($data) { |
| 135 |
$this->data['explorer'][] = $data; |
| 136 |
$this->setExplorerPointer(); |
| 137 |
$this->save(); |
| 138 |
} |
| 139 |
|
| 140 |
function setExplorerPointer($explicit = null) { |
| 141 |
if (!$explicit) { |
| 142 |
$this->data['explorer_pointer'] = $this->data['explorer'][sizeof($this->data['explorer']) - 1]; |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
function getExplorerPointer($pointer = null) { |
| 147 |
if(!$pointer) { |
| 148 |
return $this->data['explorer_pointer']; |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
function resetExplorer() { |
| 153 |
unset($this->data['explorer']); |
| 154 |
unset($this->data['explorer_pointer']); |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
/* |
| 160 |
function register_plugin($name) { |
| 161 |
// reserve slot for plugin |
| 162 |
$this->pointers[$name][...][...] = |
| 163 |
$this->stacks[$name][...][...] = |
| 164 |
} |
| 165 |
*/ |
| 166 |
|
| 167 |
} |
| 168 |
|
| 169 |
?> |