/[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.15 - (show annotations)
Wed Apr 9 02:08:20 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.14: +8 -5 lines
CHANGE: renamed key 'classname' through 'nodename'

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

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