1 |
<? |
<? |
2 |
// ------------------------------------------------------------------------- |
/** |
3 |
// $Id$ |
* This file contains the Data::Lift component. |
4 |
// ------------------------------------------------------------------------- |
* |
5 |
// $Log$ |
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
// Revision 1.3 2003/03/03 21:28:11 joko |
* @package org.netfrag.glib |
7 |
// updated comments |
* @name Data::Lift |
8 |
// |
* |
9 |
// Revision 1.2 2003/02/27 16:30:17 joko |
*/ |
10 |
// + enhanced '_autodetect' |
|
11 |
// + added '_check' |
/** |
12 |
// + now throughout returning lifted values by reference |
* Cvs-Log: |
13 |
// |
* |
14 |
// Revision 1.1 2003/02/22 16:20:04 joko |
* $Id$ |
15 |
// + initial commit |
* |
16 |
// |
* $Log$ |
17 |
// ------------------------------------------------------------------------- |
* Revision 1.9 2003/05/13 15:15:20 joko |
18 |
|
* option propagation generic again |
19 |
|
* |
20 |
// Data::Lift - Pass data around between various "actors". |
* Revision 1.8 2003/04/19 16:13:52 jonen |
21 |
// |
* + added class var '$_hidden_elements' which are passed to 'ExplorerTree' if exists |
22 |
// These "actors" are kinda plugin-modules |
* |
23 |
// lying at "locations" and actually mungle the data. |
* Revision 1.7 2003/04/18 15:48:00 joko |
24 |
// |
* better error handling: a) croak messages, b) just perform lift module if instance could be created |
25 |
// "Locations" are by now: |
* |
26 |
// x local filesystem |
* Revision 1.6 2003/03/09 15:49:20 joko |
27 |
// o remote anything |
* fix towards optimizing autodocumentation: |
28 |
// |
* enriched with metadata to tell autodia how to build object-relationships by discarding the fancy namespacing stuff there |
29 |
// The "actors" require (by now) to be native php classes |
* |
30 |
// having a method "perform". Please have a look at others |
* Revision 1.5 2003/03/08 20:04:59 root |
31 |
// lying in the Data::Lift namespace at org.netfrag.glib to |
* + optimized comments for Autodia |
32 |
// get a picture of how to implement own "actors". |
* |
33 |
// |
* Revision 1.4 2003/03/08 18:22:23 joko |
34 |
// @url: http://cvs.netfrag.org/php/libs/org.netfrag.glib |
* updated comments: now in phpDocumentor style |
35 |
// |
* |
36 |
// TODO: |
* Revision 1.3 2003/03/03 21:28:11 joko |
37 |
// o refactor Data::Deep to a plugin module |
* updated comments |
38 |
// o refactor Data::Encode to a plugin module |
* |
39 |
// o combine Data::Lift and Data::Container somehow |
* Revision 1.2 2003/02/27 16:30:17 joko |
40 |
// o integrate with Data::Driver somehow -- proposal: |
* + enhanced '_autodetect' |
41 |
// $lift = new Data::Lift($locator); |
* + added '_check' |
42 |
// $lift->perform(); // talks to a Data::Driver |
* + now throughout returning lifted values by reference |
43 |
// |
* |
44 |
|
* Revision 1.1 2003/02/22 16:20:04 joko |
45 |
|
* + initial commit |
46 |
|
* |
47 |
|
*/ |
48 |
|
|
49 |
|
/** |
50 |
|
* Data::Lift |
51 |
|
* |
52 |
|
* <pre> |
53 |
|
* Data::Lift - Pass data around between various "actors". |
54 |
|
* |
55 |
|
* These "actors" are kinda plugin-modules |
56 |
|
* lying at "locations" and actually mungle the data. |
57 |
|
* |
58 |
|
* "Locations" are by now: |
59 |
|
* x local filesystem |
60 |
|
* o remote anything |
61 |
|
* |
62 |
|
* The "actors" require (by now) to be native php classes |
63 |
|
* having a method "perform". Please have a look at others |
64 |
|
* lying in the Data::Lift namespace at org.netfrag.glib to |
65 |
|
* get a picture of how to implement own "actors". |
66 |
|
* </pre> |
67 |
|
* |
68 |
|
* |
69 |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
70 |
|
* @copyright (c) 2003 - All Rights reserved. |
71 |
|
* @license GNU LGPL (GNU Lesser General Public License) |
72 |
|
* |
73 |
|
* @link http://www.netfrag.org/~joko/ |
74 |
|
* @link http://www.gnu.org/licenses/lgpl.txt |
75 |
|
* |
76 |
|
* @package org.netfrag.glib |
77 |
|
* @subpackage DataLift |
78 |
|
* @name Data::Lift |
79 |
|
* |
80 |
|
* @link http://cvs.netfrag.org/php/libs/org.netfrag.glib |
81 |
|
* |
82 |
|
* |
83 |
|
* @todo refactor Data::Deep to a plugin module |
84 |
|
* @todo refactor Data::Encode to a plugin module |
85 |
|
* @todo combine Data::Lift and Data::Container somehow |
86 |
|
* @todo integrate with Data::Driver somehow -- proposal: |
87 |
|
* // $lift = ne w Data::Lift($locator); |
88 |
|
* // $lift->perform(); // talks to a Data::Driver |
89 |
|
* |
90 |
|
* |
91 |
|
*/ |
92 |
|
class Data_Lift { |
93 |
|
|
94 |
|
/** |
95 |
|
* this is to trick Autodia let understanding "namespaces" in php |
96 |
|
* unless the pattern can be tweaked by mode (namespace=0|1) |
97 |
|
* // $this = ne w Data::Lift(&$payload, $options = array()); |
98 |
|
*/ |
99 |
|
|
|
class Data_Lift { |
|
|
|
|
100 |
var $dblocations; |
var $dblocations; |
101 |
var $actor; |
var $actor; |
102 |
|
var $actor_instance; |
103 |
|
|
104 |
var $payload; |
var $payload; |
105 |
var $vartype; |
var $vartype; |
106 |
var $metatype; |
var $metatype; |
107 |
|
var $_link_args = NULL; |
108 |
|
|
109 |
function Data_Lift(&$payload, $options = array()) { |
function Data_Lift(&$payload, $options = array()) { |
110 |
$this->_init_locations(); |
$this->_init_locations(); |
111 |
//print Dumper($options); |
//print Dumper($options); |
112 |
//exit; |
//exit; |
113 |
|
$this->options = $options; |
114 |
if ($options[metatype]) { $this->metatype = $options[metatype]; } |
if ($options[metatype]) { $this->metatype = $options[metatype]; } |
115 |
|
if ($options[link_args]) { $this->_link_args = $options[link_args]; } |
116 |
$this->set(&$payload); |
$this->set(&$payload); |
117 |
} |
} |
118 |
|
|
157 |
//print "metatype: " . $this->metatype . "<br>"; |
//print "metatype: " . $this->metatype . "<br>"; |
158 |
|
|
159 |
if (!$good) { |
if (!$good) { |
160 |
print "Data::Lift cannot handle this payload: "; |
$msg = "Data::Lift cannot handle this payload: "; |
161 |
print "(vartype=" . $this->vartype . ", metatype=" . $this->metatype . ")<br/>"; |
$msg .= "[vartype=" . $this->vartype . ", metatype=" . $this->metatype . "]<br/>"; |
162 |
print Dumper($this->payload); |
$msg .= "payload: '" . Dumper($this->payload) . "'"; |
163 |
|
user_error($msg); |
164 |
} |
} |
165 |
|
|
166 |
} |
} |
193 |
function &_perform_actor() { |
function &_perform_actor() { |
194 |
//$actor_file = join('/', $this->actor) . '.php'; |
//$actor_file = join('/', $this->actor) . '.php'; |
195 |
//include($actor_file); |
//include($actor_file); |
196 |
|
|
197 |
|
/** |
198 |
|
* <!-- Autodia --> |
199 |
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
200 |
|
* $this->_actor_instance = new Data_Lift_hash_job_html() |
201 |
|
* $this->_actor_instance = new Data_Lift_hash_tree_PEAR_Tree() |
202 |
|
* $this->_actor_instance = new Data_Lift_object_tree_common_PEAR_HTML_TreeMenu() |
203 |
|
* $this->_actor_instance = new Data_Lift_object_tree_common_PEAR_HTML_TreeMenu_DHTML() |
204 |
|
* $this->_actor_instance = new Data_Lift_object_tree_common_PEAR_HTML_TreeMenu_Listbox() |
205 |
|
* |
206 |
|
*/ |
207 |
|
|
208 |
$actor_name = 'Data/Lift/' . join('/', $this->actor); |
$actor_name = 'Data/Lift/' . join('/', $this->actor); |
209 |
$actor_object = mkObject($actor_name); |
//$actor_name = 'Data::Lift::' . join('::', $this->actor); |
210 |
return $actor_object->perform($this->payload); |
|
211 |
|
//$actor_object = mkObject($actor_name); |
212 |
|
//return $actor_object->perform($this->payload); |
213 |
|
|
214 |
|
// fix [2003-04-13]: just perform if instance good |
215 |
|
//if ($actor_object = php::mkComponent($actor_name)) { |
216 |
|
// enhanced [2003-04-20]: pass Lift's options to actor's constructor |
217 |
|
$actor_object = mkObject($actor_name, $this->options); |
218 |
|
if (is_object($actor_object) && method_exists($actor_object, 'perform')) { |
219 |
|
// enhanced [2003-04-20]: *inject* Lift's options to actor's instance - prefix attribute by '_' to prevent collisions |
220 |
|
$actor_object->_options = $this->options; |
221 |
|
return $actor_object->perform($this->payload); |
222 |
|
if ($actor_name == "Data/Lift/hash/topic/ExplorerTree") { |
223 |
|
return $actor_object->perform($this->payload, $this->_link_args); |
224 |
|
} else { |
225 |
|
return $actor_object->perform($this->payload); |
226 |
|
} |
227 |
|
} else { |
228 |
|
user_error("Data::Lift could not call method 'perform' on actor object. [actor_name='$actor_name']"); |
229 |
|
//return array(); |
230 |
|
} |
231 |
|
|
232 |
} |
} |
233 |
|
|
234 |
function get() { |
function get() { |
241 |
|
|
242 |
} |
} |
243 |
|
|
|
?> |
|
244 |
|
?> |