/[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.13 - (show annotations)
Wed Apr 9 00:03:11 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.12: +6 -2 lines
disabled form rendering for inheritanced items at 'list'

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

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