4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.13 2003/04/09 00:03:11 jonen |
8 |
|
## disabled form rendering for inheritanced items at 'list' |
9 |
|
## |
10 |
|
## Revision 1.12 2003/04/08 17:52:12 joko |
11 |
|
## CHANGE: renamed property 'datasource' to 'transport' |
12 |
|
## NEW: Module 'RemoteAction' |
13 |
|
## |
14 |
|
## Revision 1.11 2003/04/07 22:31:51 jonen |
15 |
|
## + added switch of ecom label (e.g. nav, chooser) at ecom type switch 'nav' |
16 |
|
## - removed recent added ecom type chooser |
17 |
|
## |
18 |
|
## Revision 1.10 2003/04/05 20:32:04 joko |
19 |
|
## added Chooser |
20 |
|
## |
21 |
|
## Revision 1.9 2003/04/04 02:22:37 joko |
22 |
|
## minor fix: querySchema now issues argument |
23 |
|
## |
24 |
|
## Revision 1.8 2003/04/04 01:16:03 jonen |
25 |
|
## + integrated different mode's for 'DataItem' |
26 |
|
## |
27 |
## Revision 1.7 2003/03/29 07:49:55 joko |
## Revision 1.7 2003/03/29 07:49:55 joko |
28 |
## show boxes in DEBUG-mode only! |
## show boxes in DEBUG-mode only! |
29 |
## |
## |
104 |
|
|
105 |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
function WebExplorer_AbstractExplorer($data_locators=array()) { |
106 |
$this->_data_locators = $data_locators; |
$this->_data_locators = $data_locators; |
107 |
$this->init_default_gui_modules(); |
$this->init_default_gui_modules(); |
|
|
|
108 |
$this->set_e_state(); |
$this->set_e_state(); |
109 |
|
|
110 |
|
//debug |
111 |
//print "State: " . Dumper($this->_state) ."<br>"; |
//print "State: " . Dumper($this->_state) ."<br>"; |
112 |
$div = html_div(); |
$div = html_div(); |
113 |
$div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state)); |
$div->add( html_b(get_class($this)), html_hr(), "Explorer_State: " . Dumper($this->_e_state)); |
115 |
if (constants::get('DEBUG')) { |
if (constants::get('DEBUG')) { |
116 |
print $div->render(); |
print $div->render(); |
117 |
} |
} |
|
//$this->init_state(); |
|
118 |
} |
} |
119 |
|
|
120 |
|
|
157 |
|
|
158 |
|
|
159 |
function init_default_gui_modules() { |
function init_default_gui_modules() { |
160 |
|
|
161 |
|
// format of parameters: label, ecom_type, abstract_type, module_name |
162 |
|
|
163 |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
//$this->register_gui_module("n_tree", "nav", array( 'name' => "NavigationTree", 'type' => "tree") ); |
164 |
$this->register_gui_module("list", "nav", array( 'name' => "WebExplorer::Module::NavigationList", 'type' => "list") ); |
$this->register_gui_module("nav", "nav", "list", "WebExplorer::Module::NavigationList" ); |
165 |
$this->register_gui_module("list", "data", array( 'name' => "WebExplorer::Module::DataList", 'type' => "list") ); |
$this->register_gui_module("content", "data", "list", "WebExplorer::Module::DataList" ); |
166 |
$this->register_gui_module("item", "data", array( 'name' => "WebExplorer::Module::DataItem", 'type' => "item") ); |
$this->register_gui_module("content", "data", "item", "WebExplorer::Module::DataItem" ); |
167 |
|
// 2003-04-05 - Chooser |
168 |
|
$this->register_gui_module("chooser", "nav", "list", "WebExplorer::Module::Chooser"); |
169 |
|
// 2003-04-07 - RemoteAction |
170 |
|
$this->register_gui_module("phase_startup", "call", "auto", "WebExplorer::Module::RemoteAction"); |
171 |
} |
} |
172 |
|
|
173 |
function register_source_module($label, $args) { |
function register_source_module($label, $args) { |
174 |
$this->_module['source'][$label] = $args; |
$this->_module['source'][$label] = $args; |
175 |
} |
} |
176 |
|
|
177 |
function register_gui_module($abstract_type, $ecom_type, $args) { |
function register_gui_module($label, $ecom_type, $abstract_type, $module_name) { |
178 |
$this->_module['gui'][$ecom_type][$abstract_type] = $args; |
$this->_module['gui'][$label][$ecom_type][$abstract_type] = $module_name; |
179 |
} |
} |
180 |
|
|
181 |
|
|
182 |
function &get_ecom($label) { |
function &get_ecom($label) { |
183 |
//return "Hello World"; |
//return "Hello World"; |
184 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
185 |
return $this->_ecom[$label]; |
return $this->_ecom[$label]; |
186 |
} |
} |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
function _load_ecoms() { |
function _load_ecoms() { |
191 |
|
//trace("_load_ecoms: " . Dumper($this->_e_state[ecoms]) . "<br/>"); |
192 |
foreach($this->_e_state[ecoms] as $label => $val) { |
foreach($this->_e_state[ecoms] as $label => $val) { |
193 |
$this->_load_ecom($label); |
$this->_load_ecom($label); |
194 |
} |
} |
195 |
} |
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
function _load_ecom($label) { |
function _load_ecom($label) { |
200 |
|
// fetch values from state |
201 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
202 |
// find right gui module |
debug::info("_load_ecom($label): " . Dumper($val) . "<br/>"); |
203 |
$com_type = $val['ecom_type']; |
|
204 |
|
// find right ecom gui module |
205 |
|
$ecom_type = $val['ecom_type']; |
206 |
$abstract_type = $val['ecom_abstract_type']; |
$abstract_type = $val['ecom_abstract_type']; |
207 |
$gui_module = $this->_module['gui'][$com_type][$abstract_type]['name']; |
$gui_module = $this->_module['gui'][$label][$ecom_type][$abstract_type]; |
208 |
|
//print Dumper($gui_module); |
209 |
if(!$gui_module) { |
if(!$gui_module) { |
210 |
user_error("AbstractExplorer::_load_component - No GUI module found for abstract type $val[ecom_abstract_type] ecom type $val[ecom_type] !"); |
user_error("AbstractExplorer::_load_component - No GUI module found. [label='$label', abstract type='$val[ecom_abstract_type]', ecom type='$val[ecom_type]']"); |
211 |
return; |
return; |
212 |
} |
} |
213 |
// get arguments needed for gui module |
|
214 |
|
// get arguments needed for ecom gui module |
215 |
$args = $this->_prepare_component_args($label); |
$args = $this->_prepare_component_args($label); |
216 |
//print Dumper($args); |
//print Dumper($args); |
217 |
|
|
218 |
// get GUI module |
// get ecom GUI module |
219 |
$ecom = php::mkComponent($gui_module, $args); |
if (!$ecom = php::mkComponent($gui_module, $args)) { |
220 |
|
return; |
221 |
|
} |
222 |
//print Dumper($ecom); |
//print Dumper($ecom); |
223 |
|
|
224 |
// get phphtmllib GUI object |
// load phphtmllib GUI object |
225 |
$gui_ecom = &$ecom->get(); |
$gui_ecom = &$ecom->get(); |
226 |
|
|
227 |
// add hidden vars, needed for explorer control |
// add hidden vars, needed for explorer control |
228 |
$hidden_items = $this->_get_hidden_items($label); |
$hidden_items = $this->_get_hidden_items($label); |
229 |
if(is_array($hidden_items) ) { $ecom->add_hidden_items($hidden_items); } |
if(is_array($hidden_items) ) { |
230 |
//print "Hidden: " . Dumper($gui_ecom->_hidden_items); |
$ecom->add_hidden_items($hidden_items); |
231 |
|
//print "Hidden: " . Dumper($hidden_items); |
232 |
|
} |
233 |
|
|
234 |
|
// attempt: |
235 |
|
//$gui_ecom->make_transparent(); |
236 |
|
|
237 |
|
// store phphtmllib GUI object |
238 |
$this->_ecom[$label] = &$gui_ecom; |
$this->_ecom[$label] = &$gui_ecom; |
239 |
} |
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
function _get_hidden_items($label) { |
function _get_hidden_items($label) { |
244 |
$ecom_state = $this->_e_state['ecoms'][$label]; |
$ecom_state = $this->_e_state['ecoms'][$label]; |
245 |
if($ecom_state['ecom_type'] == "data") { |
if($ecom_state['ecom_type'] == "data") { |
246 |
if($ecom_state['ecom_abstract_type'] == "list") { |
if($ecom_state['ecom_abstract_type'] == "list") { |
247 |
$hidden_items = array( |
$hidden_items = array( |
248 |
'ecl' => $label, |
'ecl' => $label, |
249 |
|
'ecat' => "item", |
250 |
|
'ecmod' => "view", |
251 |
|
); |
252 |
|
} |
253 |
|
elseif($ecom_state['ecom_abstract_type'] == "item") { |
254 |
|
$hidden_items = array( |
255 |
|
'ecl' => $label, |
256 |
|
'ecat' => "item", |
257 |
|
'ecmod' => "view", |
258 |
); |
); |
259 |
|
/* |
260 |
|
if($ecom_state['ecom_mode'] == "view") { |
261 |
|
$hidden_items['ecmod'] = "edit"; |
262 |
|
} |
263 |
|
elseif($ecom_state['ecom_mode'] == "edit") { |
264 |
|
$hidden_items['ecmod'] = "edit"; |
265 |
|
} |
266 |
|
*/ |
267 |
} |
} |
|
// set default hidden item for whole explorer |
|
268 |
$hidden_items['ap'] = "explorer"; |
$hidden_items['ap'] = "explorer"; |
269 |
} |
} |
270 |
return $hidden_items; |
return $hidden_items; |
271 |
} |
} |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
function _prepare_component_args($label) { |
function _prepare_component_args($label) { |
276 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
277 |
$this->set_data_locator($val['ecom_data_locator_key']); |
$this->set_data_locator($val['ecom_data_locator_key']); |
278 |
|
|
279 |
|
// detect and execute 'selectSource' action |
280 |
|
// FIXME: this is a HACK!!! move to a module 'BackendAction' or s.th.l.th. |
281 |
|
//print Dumper($this->_e_state['sources']); |
282 |
|
if ($source = $this->_e_state['main']['ecom_data_source_key']) { |
283 |
|
//print "selectSource: $source<br/>"; |
284 |
|
//global $app; |
285 |
|
//print Dumper($backend); |
286 |
|
//$app->backend->do(); |
287 |
|
} |
288 |
|
|
289 |
// switch component type |
// switch component type |
290 |
if($val['ecom_type'] == "data") { |
if($val['ecom_type'] == "data") { |
291 |
// switch abstract type |
// switch abstract type |
292 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
293 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
294 |
//$data_locator_meta = array( datasource => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']); |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']); |
295 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']); |
$data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'list', classname => $val['ecom_data_ident']); |
296 |
} else { |
} else { |
297 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
298 |
} |
} |
299 |
$args = array( |
$args = array( |
300 |
'caption' => "Liste", |
'caption' => $val['ecom_data_ident'], |
301 |
'orderby' => "Guid", |
'orderby' => "Guid", |
302 |
'options' => array( |
'options' => array( |
303 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
304 |
'decode' => 1, |
'decode' => 1, |
305 |
'decode_args' => array( |
'decode_args' => array( |
306 |
'seperator' => "_", |
'seperator' => "_", |
307 |
'form' => 1, |
//'form' => 1, |
308 |
), |
), |
309 |
), |
), |
310 |
); |
); |
311 |
// switch abstract type |
// switch abstract type |
312 |
} elseif ($val['ecom_abstract_type'] == "item") { |
} elseif ($val['ecom_abstract_type'] == "item") { |
|
$args = array(); |
|
|
} |
|
|
// switch component type |
|
|
} elseif ($val['ecom_type'] == "nav") { |
|
|
// switch abstract type |
|
|
if($val['ecom_abstract_type'] == "list") { |
|
313 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
314 |
$data_locator_meta = array( datasource => 'rpc', metatype => 'schema' ); |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', classname => $val['ecom_data_ident']); |
315 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'item', ident => $val['ecom_data_ident'], classname => $val['ecom_data_meta']); |
316 |
} else { |
} else { |
317 |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
user_error("AbstractExplorer::_prepare_component_args - Cannot build query for data_locator_key $val[ecom_data_locator_key] !"); |
318 |
} |
} |
319 |
|
if(!$val['ecom_mode']) { $val['ecom_mode'] = "view"; } |
320 |
|
print "Mode: $val[ecom_mode]<br>"; |
321 |
$args = array( |
$args = array( |
322 |
'caption' => "Objekt Typen", |
'caption' => $val['ecom_data_meta'], |
323 |
|
'mode' => $val['ecom_mode'], |
324 |
'options' => array( |
'options' => array( |
325 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
326 |
|
'decode' => 1, |
327 |
|
'decode_args' => array( |
328 |
|
'seperator' => "_", |
329 |
|
), |
330 |
), |
), |
331 |
); |
); |
332 |
|
if($val['ecom_mode'] == "edit") { $args['adapter'] = 'FormProcessor'; } |
333 |
|
} |
334 |
|
|
335 |
|
// switch component type |
336 |
|
} elseif ($val['ecom_type'] == "nav") { |
337 |
|
// switch abstract type |
338 |
|
if($val['ecom_abstract_type'] == "list") { |
339 |
|
$args = array(); |
340 |
|
if($val['ecom_data_locator_key'] == "rpc") { |
341 |
|
// switch component label |
342 |
|
if($label == "nav") { |
343 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'nodes.root:concrete' ); |
344 |
|
$args['caption'] = "Objekt Typen"; |
345 |
|
} |
346 |
|
// NEW [2003-04-05]: DataSource.Chooser |
347 |
|
elseif ($label == "chooser") { |
348 |
|
$data_locator_meta = array( transport => 'rpc', metatype => 'schema', filter => 'sources.all' ); |
349 |
|
$args['caption'] = "Datenquellen"; |
350 |
|
} |
351 |
|
$args['options']['data_locator_meta'] = $data_locator_meta; |
352 |
|
} else { |
353 |
|
user_error("AbstractExplorer::_prepare_component_args - Cannot build schema query for data_locator_key $val[ecom_data_locator_key] !"); |
354 |
|
} |
355 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
} elseif ($val['ecom_abstract_type'] == "tree") { |
356 |
$args = array(); |
$args = array(); |
357 |
} |
} |
358 |
|
|
359 |
|
// NEW [2003-04-08]: RemoteAction (e.g.: result of a selection inside a Chooser) |
360 |
|
// switch component type |
361 |
|
} elseif ($val['ecom_type'] == "call") { |
362 |
|
|
363 |
|
// responses of RemoteActions are not predictable! |
364 |
|
if ($val['ecom_abstract_type'] == "auto") { |
365 |
|
|
366 |
|
// Dispatching by $label is not done here. RemoteAction-ecoms can appear anywhere! |
367 |
|
|
368 |
|
// Just define the RemoteQuery using a declaration to use DataSource::Generic most transparently. |
369 |
|
// Really - just a remote call is issued, no data-/schema-structures or similar are expected. |
370 |
|
|
371 |
|
// The RemoteMethod 'method' is called directly with arguments in 'args'! |
372 |
|
// As response (important for widget assignement!) you may expect an arbitrary payload. |
373 |
|
$args['options']['data_locator_meta'] = array( |
374 |
|
transport => 'rpc', |
375 |
|
metatype => 'method', |
376 |
|
method => $val['ecom_call_method'], |
377 |
|
args => $val['ecom_call_args'] |
378 |
|
); |
379 |
|
|
380 |
|
} else { |
381 |
|
// FIXME: implement automatic re-dispatching to available ecoms here! |
382 |
|
user_error("WebExplorer::AbstractExplorer: results of RemoteActions can only be handled automatically. Who knows what comes back?"); |
383 |
|
} |
384 |
|
|
385 |
} |
} |
386 |
return $args; |
return $args; |
387 |
} |
} |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
function get_msg($label) { |
function get_msg($label) { |
392 |
if($label == "welcome") { |
if($label == "welcome") { |
393 |
$msg = "Welcome to the Explorer."; |
$msg = "Welcome to the Explorer."; |
394 |
} |
} |
395 |
return $msg; |
return $msg; |
396 |
} |
} |
397 |
|
|
398 |
|
|
399 |
|
|
400 |
function render() { |
function render() { |
401 |
user_error("AbstractExplorer::render - please implement me...."); |
user_error("AbstractExplorer::render - please implement me...."); |