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