/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.app/WebExplorer/AbstractExplorer.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations)
Tue Apr 8 17:52:12 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.11: +44 -8 lines
CHANGE: renamed property 'datasource' to 'transport'
NEW: Module 'RemoteAction'

1 <?
2 /*
3 ## -----------------------------------------------------------------------------
4 ## $Id: AbstractExplorer.php,v 1.11 2003/04/07 22:31:51 jonen Exp $
5 ## -----------------------------------------------------------------------------
6 ## $Log: AbstractExplorer.php,v $
7 ## Revision 1.11 2003/04/07 22:31:51 jonen
8 ## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav'
9 ## - removed recent added ecom type chooser
10 ##
11 ## Revision 1.10 2003/04/05 20:32:04 joko
12 ## added Chooser
13 ##
14 ## Revision 1.9 2003/04/04 02:22:37 joko
15 ## minor fix: querySchema now issues argument
16 ##
17 ## Revision 1.8 2003/04/04 01:16:03 jonen
18 ## + integrated different mode's for 'DataItem'
19 ##
20 ## Revision 1.7 2003/03/29 07:49:55 joko
21 ## show boxes in DEBUG-mode only!
22 ##
23 ## Revision 1.6 2003/03/28 06:42:37 joko
24 ## fix: propagating rpc-debugging-options to constants here
25 ##
26 ## Revision 1.5 2003/03/27 01:24:29 jonen
27 ## + enabled navigation ecom (only list yet)
28 ##
29 ## Revision 1.4 2003/03/20 08:02:11 jonen
30 ## + purged code
31 ##
32 ## Revision 1.3 2003/03/20 07:54:52 jonen
33 ## + added docu
34 ##
35 ## Revision 1.2 2003/03/20 07:44:31 jonen
36 ## + removed dumper
37 ##
38 ## Revision 1.1 2003/03/20 03:48:46 jonen
39 ## + initial commit
40 ##
41 ## Revision 1.1 2003/03/08 02:36:17 cvsmax
42 ## + moved from *.inc
43 ## + mungled namespace with WebExplorer
44 ##
45 ## Revision 1.3 2003/03/03 22:25:21 joko
46 ## fixed minor typos
47 ## namespace mungling
48 ##
49 ## Revision 1.2 2003/03/02 00:48:49 cvsmax
50 ## + set up gui module registry
51 ## - purged old/sample code
52 ##
53 ## Revision 1.1 2003/03/01 22:57:32 cvsmax
54 ## + inital commit
55 ##
56 ##
57 ## -----------------------------------------------------------------------------
58 */
59
60 /**
61 * WebExplorer::AbstractExplorer - this can be simple compared to a container,
62 * which modular GUI classes can be register, manipulated and rendered...
63 *
64 * @author Sebastian Utz <seut@tunemedia.de>
65 * @package org.netfrag.app
66 * @name WebExplorer::AbstractExplorer
67 */
68
69
70 class WebExplorer_AbstractExplorer {
71
72 /**
73 * container holds meta information of data locators
74 */
75 var $_data_locators = array();
76
77 /**
78 * container for registered modules
79 */
80 var $_module = array();
81
82 /**
83 * container holds references to each ecom
84 */
85 var $_ecom = array();
86
87 /**
88 * holds the whole page state
89 */
90 var $_state = array();
91
92 /**
93 * holds state variables only needed for explorer
94 */
95 var $_e_state = array();
96
97
98 function WebExplorer_AbstractExplorer($data_locators=array()) {
99 $this->_data_locators = $data_locators;
100 $this->init_default_gui_modules();
101 $this->set_e_state();
102
103 //debug
104 //print "State: " . Dumper($this->_state) ."<br>";
105 $div = html_div();
106 $div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state));
107 $div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;');
108 if (constants::get('DEBUG')) {
109 print $div->render();
110 }
111 }
112
113
114 function add_data_locator($label, $args) {
115 $this->_data_locators[$label] = $args;
116 }
117
118 function set_data_locator($label, $new_args=array() ) {
119 global $app;
120 //print Dumper($app) . "<br>";
121 if($label == "rpc") {
122 $rpcinfo = $app->getConfig("rpcinfo");
123 define('RPC_HOSTNAME', $rpcinfo[Host]);
124 define('RPC_PORT', $rpcinfo[Port]);
125 define('RPC_DEBUG', $rpcinfo[DEBUG]);
126 define('RPC_TRACE', $rpcinfo[TRACE]);
127 define('RPC_DISCONNECT_ON_ERROR', $rpcinfo[DISCONNECT_ON_ERROR]);
128 } else {
129 user_error("AbstractExplorer::set_data_locator - data_locator_key label $label not found!");
130 }
131 }
132
133 function get_data_locator($label) {
134 }
135
136 function get_page_state() {
137 $requestTracker = mkObject("Application::Request::Tracker");
138 $this->_state = $requestTracker->getPointer();
139 }
140
141 function set_e_state() {
142 $this->get_page_state();
143 $this->_e_state = $this->_state[options][options];
144 }
145
146
147 function set_page_state() {
148 user_error("AbstractExplorer::set_page_state - please implement me....");
149 }
150
151
152 function init_default_gui_modules() {
153
154 // format of parameters: label, ecom_type, abstract_type, module_name
155
156 //$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") );
157 $this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" );
158 $this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" );
159 $this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" );
160 // 2003-04-05 - Chooser
161 $this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser");
162 // 2003-04-07 - RemoteAction
163 $this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction");
164 }
165
166 function register_source_module($label, $args) {
167 $this->_module['source'][$label] = $args;
168 }
169
170 function register_gui_module($label, $ecom_type, $abstract_type, $module_name) {
171 $this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name;
172 }
173
174
175 function &get_ecom($label) {
176 //return "Hello World";
177 $this->_load_ecom($label);
178 return $this->_ecom[$label];
179 }
180
181
182
183 function _load_ecoms() {
184 //trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>");
185 foreach($this->_e_state[ecoms] as $label => $val) {
186 $this->_load_ecom($label);
187 }
188 }
189
190
191
192 function _load_ecom($label) {
193 // fetch values from state
194 $val = $this->_e_state['ecoms'][$label];
195 debug::info("_load_ecom($label): " . Dumper($val) . "<br/>");
196
197 // find right ecom gui module
198 $ecom_type = $val['ecom_type'];
199 $abstract_type = $val['ecom_abstract_type'];
200 $gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type];
201 //print Dumper($gui_module);
202 if(!$gui_module) {
203 user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']");
204 return;
205 }
206
207 // get arguments needed for ecom gui module
208 $args = $this->_prepare_component_args($label);
209 //print Dumper($args);
210
211 // get ecom GUI module
212 if (!$ecom = php::mkComponent($gui_module, $args)) {
213 return;
214 }
215 //print Dumper($ecom);
216
217 // load phphtmllib GUI object
218 $gui_ecom = &$ecom->get();
219
220 // add hidden vars, needed for explorer control
221 $hidden_items = $this->_get_hidden_items($label);
222 if(is_array($hidden_items) ) {
223 $ecom->add_hidden_items($hidden_items);
224 //print "Hidden: " . Dumper($hidden_items);
225 }
226
227 // attempt:
228 //$gui_ecom->make_transparent();
229
230 // store phphtmllib GUI object
231 $this->_ecom[$label] = &$gui_ecom;
232 }
233
234
235
236 function _get_hidden_items($label) {
237 $ecom_state = $this->_e_state['ecoms'][$label];
238 if($ecom_state['ecom_type'] == "data") {
239 if($ecom_state['ecom_abstract_type'] == "list") {
240 $hidden_items = array(
241 'ecl' => $label,
242 'ecat' => "item",
243 'ecmod' => "view",
244 );
245 }
246 elseif($ecom_state['ecom_abstract_type'] == "item") {
247 $hidden_items = array(
248 'ecl' => $label,
249 'ecat' => "item",
250 'ecmod' => "view",
251 );
252 /*
253 if($ecom_state['ecom_mode'] == "view") {
254 $hidden_items['ecmod'] = "edit";
255 }
256 elseif($ecom_state['ecom_mode'] == "edit") {
257 $hidden_items['ecmod'] = "edit";
258 }
259 */
260 }
261 $hidden_items['ap'] = "explorer";
262 }
263 return $hidden_items;
264 }
265
266
267
268 function _prepare_component_args($label) {
269 $val = $this->_e_state['ecoms'][$label];
270 $this->set_data_locator($val['ecom_data_locator_key']);
271
272 // detect and execute 'selectSource' action
273 // FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th.
274 //print Dumper($this->_e_state['sources']);
275 if ($source = $this->_e_state['main']['ecom_data_source_key']) {
276 //print "selectSource: $source<br/>";
277 //global $app;
278 //print Dumper($backend);
279 //$app->backend->do();
280 }
281
282 // switch component type
283 if($val['ecom_type'] == "data") {
284 // switch abstract type
285 if($val['ecom_abstract_type'] == "list") {
286 if($val['ecom_data_locator_key'] == "rpc") {
287 //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
288 $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']);
289 } else {
290 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
291 }
292 $args = array(
293 'caption' => $val['ecom_data_ident'],
294 'orderby' => "Guid",
295 'options' => array(
296 'data_locator_meta' => $data_locator_meta,
297 'decode' => 1,
298 'decode_args' => array(
299 'seperator' => "_",
300 'form' => 1,
301 ),
302 ),
303 );
304 // switch abstract type
305 } elseif ($val['ecom_abstract_type'] == "item") {
306 if($val['ecom_data_locator_key'] == "rpc") {
307 //$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']);
308 $data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']);
309 } else {
310 user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !");
311 }
312 if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; }
313 print "Mode: $val[ecom_mode]<br>";
314 $args = array(
315 'caption' => $val['ecom_data_meta'],
316 'mode' => $val['ecom_mode'],
317 'options' => array(
318 'data_locator_meta' => $data_locator_meta,
319 'decode' => 1,
320 'decode_args' => array(
321 'seperator' => "_",
322 ),
323 ),
324 );
325 if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; }
326 }
327
328 // switch component type
329 } elseif ($val['ecom_type'] == "nav") {
330 // switch abstract type
331 if($val['ecom_abstract_type'] == "list") {
332 $args = array();
333 if($val['ecom_data_locator_key'] == "rpc") {
334 // switch component label
335 if($label == "nav") {
336 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' );
337 $args['caption'] = "Objekt Typen";
338 }
339 // NEW [2003-04-05]: DataSource.Chooser
340 elseif ($label == "chooser") {
341 $data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' );
342 $args['caption'] = "Datenquellen";
343 }
344 $args['options']['data_locator_meta'] = $data_locator_meta;
345 } else {
346 user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !");
347 }
348 } elseif ($val['ecom_abstract_type'] == "tree") {
349 $args = array();
350 }
351
352 // NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser)
353 // switch component type
354 } elseif ($val['ecom_type'] == "call") {
355
356 // responses of RemoteActions are not predictable!
357 if ($val['ecom_abstract_type'] == "auto") {
358
359 // Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere!
360
361 // Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently.
362 // Really - just a remote call is issued, no data-/schema-structures or similar are expected.
363
364 // The RemoteMethod 'method' is called directly with arguments in 'args'!
365 // As response (important for widget assignement!) you may expect an arbitrary payload.
366 $args['options']['data_locator_meta'] = array(
367 transport => 'rpc',
368 metatype => 'method',
369 method => $val['ecom_call_method'],
370 args => $val['ecom_call_args']
371 );
372
373 } else {
374 // FIXME: implement automatic re-dispatching to available ecoms here!
375 user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?");
376 }
377
378 }
379 return $args;
380 }
381
382
383
384 function get_msg($label) {
385 if($label == "welcome") {
386 $msg = "Welcome to the Explorer.";
387 }
388 return $msg;
389 }
390
391
392
393 function render() {
394 user_error("AbstractExplorer::render - please implement me....");
395 }
396
397 }
398
399
400 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed