4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.26 2003/12/14 01:50:30 jonen |
8 |
|
## implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes |
9 |
|
## |
10 |
|
## Revision 1.25 2003/11/22 18:47:49 udo |
11 |
|
## update for expand data item |
12 |
|
## |
13 |
|
## Revision 1.24 2003/07/02 11:39:16 jonen |
14 |
|
## fixed bugs |
15 |
|
## |
16 |
|
## Revision 1.23 2003/06/06 11:57:20 joko |
17 |
|
## minor update: cosmetic changes |
18 |
|
## |
19 |
|
## Revision 1.22 2003/05/13 14:50:27 joko |
20 |
|
## HACKed compatibility for config-type data sources |
21 |
|
## + function get_data_filter |
22 |
|
## |
23 |
## Revision 1.21 2003/05/10 18:23:21 jonen |
## Revision 1.21 2003/05/10 18:23:21 jonen |
24 |
## + added stuff relating to 'create/add new' links/buttons |
## + added stuff relating to 'create/add new' links/buttons |
25 |
## |
## |
170 |
$this->set_e_state(); |
$this->set_e_state(); |
171 |
|
|
172 |
//debug |
//debug |
173 |
//print "State: " . Dumper($this->_state) ."<br>"; |
// print "State: " . Dumper($this->_state) ."<br>"; |
174 |
|
//print "_data_locators: " . Dumper($this->_data_locators) ."<br>"; |
175 |
$div = html_div(); |
$div = html_div(); |
176 |
$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)); |
177 |
$div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;'); |
$div->set_style('background: #adadad; border: 2px black groove; width:640px; padding:10px; margin:40px;'); |
211 |
|
|
212 |
function get_page_state() { |
function get_page_state() { |
213 |
$requestTracker = mkObject("Application::Request::Tracker"); |
$requestTracker = mkObject("Application::Request::Tracker"); |
|
//print Dumper($this->_state); |
|
214 |
$this->_state = $requestTracker->getPointer(); |
$this->_state = $requestTracker->getPointer(); |
215 |
} |
} |
216 |
|
|
220 |
// 2. (was) get page state from request tracker |
// 2. (was) get page state from request tracker |
221 |
if ($state) { |
if ($state) { |
222 |
$this->_e_state = $state; |
$this->_e_state = $state; |
223 |
|
|
224 |
} else { |
} else { |
225 |
$this->get_page_state(); |
$this->get_page_state(); |
226 |
$this->_e_state = $this->_state[options][options]; |
$this->_e_state = $this->_state[options][options]; |
227 |
|
|
228 |
} |
} |
229 |
// print "Setting Explorer state:" . Dumper($this->_e_state); |
// print "Setting Explorer state:" . Dumper($this->_e_state); |
230 |
} |
} |
231 |
|
|
232 |
function set_page_state() { |
function set_page_state() { |
281 |
|
|
282 |
// that's better ... |
// that's better ... |
283 |
$this->_load_ecom($label, $args); |
$this->_load_ecom($label, $args); |
284 |
|
|
285 |
|
//print "getEcom_args: " .Dumper($args). "<br>"; |
286 |
|
|
287 |
return $this->_ecom[$label]; |
return $this->_ecom[$label]; |
288 |
|
|
289 |
} |
} |
362 |
if($ecom_state['ecom_abstract_type'] == "list") { |
if($ecom_state['ecom_abstract_type'] == "list") { |
363 |
$hidden_items = array( |
$hidden_items = array( |
364 |
'ecl' => $label, |
'ecl' => $label, |
365 |
'ecat' => "item", |
'ecat' => "list", |
366 |
'ecmod' => "view", |
'ecmod' => "view", |
367 |
'ecdm' => $ecom_state['ecom_data_ident'], |
'ecdid' => $ecom_state['ecom_data_ident'], |
368 |
); |
); |
369 |
} |
} |
370 |
elseif($ecom_state['ecom_abstract_type'] == "item") { |
elseif($ecom_state['ecom_abstract_type'] == "item") { |
381 |
// are more label specified!! |
// are more label specified!! |
382 |
// OLD: |
// OLD: |
383 |
//if($ecom_state['ecom_abstract_type'] == "list") { |
//if($ecom_state['ecom_abstract_type'] == "list") { |
384 |
|
|
385 |
|
// decide whether to link to items or to a list |
386 |
|
$abstract_type = 'list'; |
387 |
|
// FIXME: HACK |
388 |
|
if ($this->_e_state[main][ecom_data_source_key] == 'config') { |
389 |
|
$abstract_type = 'item'; |
390 |
|
} |
391 |
|
|
392 |
// NEW: |
// NEW: |
393 |
if($label == "nav") { |
if ($label == "nav") { |
394 |
$hidden_items = array( |
$hidden_items = array( |
395 |
'ecl' => "content", |
'ecl' => "content", |
396 |
'ecat' => "list", |
'ecat' => $abstract_type, |
397 |
'ecmod' => "view", |
'ecmod' => "view", |
398 |
'ect' => "data", |
'ect' => "data", |
399 |
'ecdlk' => "rpc", |
'ecdlk' => "rpc", |
400 |
); |
); |
401 |
|
|
402 |
} |
} |
403 |
elseif($label == "chooser") { |
elseif ($label == "chooser") { |
404 |
$hidden_items = array( |
$hidden_items = array( |
405 |
'ecl' => "phase_startup", |
'ecl' => "phase_startup", |
406 |
'ecdlk' => "rpc", |
'ecdlk' => "rpc", |
409 |
} |
} |
410 |
} |
} |
411 |
// add page idents |
// add page idents |
412 |
|
|
413 |
|
//print "-e-state-idents: " .Dumper($this->_e_state[idents]). "<br>"; |
414 |
|
|
415 |
foreach($this->_e_state[idents] as $label => $value) { |
foreach($this->_e_state[idents] as $label => $value) { |
416 |
$hidden_items[$label] = $value; |
$hidden_items[$label] = $value; |
417 |
} |
} |
422 |
|
|
423 |
function _prepare_component_args($label, $args = array()) { |
function _prepare_component_args($label, $args = array()) { |
424 |
$val = $this->_e_state['ecoms'][$label]; |
$val = $this->_e_state['ecoms'][$label]; |
425 |
|
//print "val: " .Dumper($val). "<br>"; |
426 |
// pre-flight checks |
// pre-flight checks |
427 |
if (!$val['ecom_data_locator_key']) { |
if (!$val['ecom_data_locator_key']) { |
428 |
user_error("_prepare_component_args: Key 'ecom_data_locator_key' was empty, should be one of 'rpc'."); |
user_error("_prepare_component_args: Key 'ecom_data_locator_key' was empty, should be one of 'rpc'."); |
440 |
|
|
441 |
// trace |
// trace |
442 |
//print "YAI1<br/>"; |
//print "YAI1<br/>"; |
443 |
//print Dumper($val); |
|
444 |
|
|
445 |
$this->set_data_locator($val['ecom_data_locator_key']); |
$this->set_data_locator($val['ecom_data_locator_key']); |
446 |
|
|
458 |
if($val['ecom_type'] == "data") { |
if($val['ecom_type'] == "data") { |
459 |
// switch abstract type |
// switch abstract type |
460 |
if($val['ecom_abstract_type'] == "list") { |
if($val['ecom_abstract_type'] == "list") { |
461 |
|
// debugging |
462 |
|
//print "Mode: $val[ecom_mode], type: list<br>"; |
463 |
|
//print "val: " .Dumper($val). "<br>"; |
464 |
|
|
465 |
if($val['ecom_data_locator_key'] == "rpc") { |
if($val['ecom_data_locator_key'] == "rpc") { |
466 |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
467 |
$data_locator_meta = array( transport => 'rpc', metatype => 'data', abstract_type => 'list', nodename => $val['ecom_data_ident'], list_meta => $val['ecom_data_meta']); |
|
468 |
|
$data_locator_meta = array( |
469 |
|
transport => 'rpc', |
470 |
|
metatype => 'data', |
471 |
|
abstract_type => 'list', |
472 |
|
nodename => $val['ecom_data_ident'], |
473 |
|
list_meta => $val['ecom_data_meta'] |
474 |
|
); |
475 |
} else { |
} else { |
476 |
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] !"); |
477 |
} |
} |
478 |
|
|
479 |
|
if($val['ecom_mode'] == 'select') { |
480 |
|
$actionbar = array( |
481 |
|
'buttons' => array( |
482 |
|
array( |
483 |
|
'name' => "ecdfsel", |
484 |
|
'value' => "Select" |
485 |
|
), |
486 |
|
), |
487 |
|
); |
488 |
|
} else { |
489 |
|
$actionbar = array( |
490 |
|
'name' => "ecdfa", |
491 |
|
'list' => array( |
492 |
|
"View" => 'view', |
493 |
|
"Edit" => 'edit', |
494 |
|
"Delete" => 'delete', |
495 |
|
"Expand" => 'expand', |
496 |
|
"Expandedit" => 'expandedit', |
497 |
|
), |
498 |
|
'selected' => 'view', |
499 |
|
'buttons' => array( |
500 |
|
array( |
501 |
|
'name' => "ecdfcr", |
502 |
|
'value' => "Add new" |
503 |
|
), |
504 |
|
), |
505 |
|
); |
506 |
|
} |
507 |
|
|
508 |
$args = array( |
$args = array( |
509 |
'caption' => $val['ecom_data_ident'], |
'caption' => $val['ecom_data_ident'], |
510 |
'orderby' => "Guid", |
'orderby' => "Guid", |
515 |
'seperator' => "_", |
'seperator' => "_", |
516 |
//'form' => 1, |
//'form' => 1, |
517 |
), |
), |
518 |
'actionbar' => array( |
'actionbar' => $actionbar, |
|
'name' => "ecdfa", |
|
|
'list' => array( |
|
|
"View" => 'view', |
|
|
"Edit" => 'edit', |
|
|
"Delete" => 'delete', |
|
|
), |
|
|
'selected' => 'view', |
|
|
'create' => array( |
|
|
'name' => "ecdfcr", |
|
|
'value' => "Add new" |
|
|
), |
|
|
), |
|
519 |
'parent' => array( |
'parent' => array( |
520 |
'class' => $val['ecom_data_ident'], |
'class' => $val['ecom_data_ident'], |
521 |
), |
), |
522 |
), |
), |
523 |
); |
); |
524 |
|
if($val['ecom_data_meta_x']) { |
525 |
|
//unset($args['options']['data_locator_meta']['nodename']); |
526 |
|
$args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta']; |
527 |
|
$args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x']; |
528 |
|
} |
529 |
|
|
530 |
// switch abstract type |
// switch abstract type |
531 |
} elseif ($val['ecom_abstract_type'] == "item") { |
} elseif ($val['ecom_abstract_type'] == "item") { |
533 |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
534 |
|
|
535 |
// NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes |
// NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes |
536 |
// this propagates the full identifier to reach through all parent nodes |
$filter = $this->get_data_filter($val); |
537 |
$filter = array( |
|
|
dotted => $val['ecom_data_filter'], |
|
|
ident => $val['ecom_data_ident'], |
|
|
//xpq => '*/*[@name="cli"]', |
|
|
//xpq => '*/*', |
|
|
); |
|
|
// lift filter from dotted format to xpq format |
|
|
$lift = mkObject('Data::Lift', $filter, array( metatype => 'filter' ) ); |
|
|
$filter = $lift->to('XPath'); |
|
|
|
|
538 |
$data_locator_meta = array( |
$data_locator_meta = array( |
539 |
transport => 'rpc', metatype => 'data', abstract_type => 'item', |
transport => 'rpc', metatype => 'data', abstract_type => 'item', |
540 |
ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], filter => $filter, |
ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], filter => $filter, |
550 |
// debugging |
// debugging |
551 |
print "Mode: $val[ecom_mode]<br>"; |
print "Mode: $val[ecom_mode]<br>"; |
552 |
|
|
553 |
|
//print Dumper($val); |
554 |
|
// NEW [2003-04-22]: append some more meta information to the caption |
555 |
|
//$caption_addendum = ' {' . $val['ecom_data_meta'] . '}'; |
556 |
|
$caption_addendum = ' {' . $val['ecom_data_meta'] . ':' . $val['ecom_data_filter'] . '}'; |
557 |
|
|
558 |
// prepare some arguments... |
// prepare some arguments... |
559 |
$args = array( |
$args = array( |
560 |
'caption' => $val['ecom_data_meta'], |
'caption' => $val['ecom_data_ident'] . $caption_addendum, |
561 |
'mode' => $val['ecom_mode'], |
'mode' => $val['ecom_mode'], |
562 |
'options' => array( |
'options' => array( |
563 |
'data_locator_meta' => $data_locator_meta, |
'data_locator_meta' => $data_locator_meta, |
583 |
$args['adapter'] = 'FormProcessor'; |
$args['adapter'] = 'FormProcessor'; |
584 |
$args['options']['caption'] = $val['ecom_data_ident']; |
$args['options']['caption'] = $val['ecom_data_ident']; |
585 |
$args['options']['data_locator_meta']['action'] = 'create'; |
$args['options']['data_locator_meta']['action'] = 'create'; |
586 |
print "debug 'create': " . Dumper($val); |
//print "debug 'create': " . Dumper($val); |
587 |
if($val['ecom_data_meta_x']) { |
if($val['ecom_data_meta_x']) { |
588 |
unset($args['options']['data_locator_meta']['nodename']); |
unset($args['options']['data_locator_meta']['nodename']); |
589 |
$args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta']; |
$args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta']; |
590 |
$args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x']; |
$args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x']; |
591 |
} |
} |
592 |
} |
} |
593 |
|
if ($val['ecom_mode'] == "select") { |
594 |
|
$args['adapter'] = 'FormProcessor'; |
595 |
|
$args['caption'] = $val['ecom_data_meta_xe'] . " {". $val['ecom_data_meta_x'] . ":}"; |
596 |
|
$args['options']['data_locator_meta']['action'] = 'select'; |
597 |
|
//print "debug 'select': " . Dumper($val); |
598 |
|
if($val['ecom_data_meta_x']) { |
599 |
|
$args['options']['data_locator_meta']['parent'][guid] = $val['ecom_data_meta_xe']; |
600 |
|
$args['options']['data_locator_meta']['parent'][nodename] = $val['ecom_data_meta_x']; |
601 |
|
} |
602 |
|
} |
603 |
|
|
604 |
|
//print "debug 'args' : " . Dumper($args); |
605 |
|
|
606 |
// switch abstract type |
// switch abstract type |
607 |
} elseif ($val['ecom_abstract_type'] == "tree") { |
} elseif ($val['ecom_abstract_type'] == "tree") { |
608 |
//print "TREE!<br/>"; |
|
609 |
|
// NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes |
610 |
|
$filter = $this->get_data_filter($val); |
611 |
|
|
612 |
// FIXME: shouldn't this (dispatching by transport-key) be done very *outside* of this scope? |
// FIXME: shouldn't this (dispatching by transport-key) be done very *outside* of this scope? |
613 |
// or: do it outside per default, let a possibility to modify it inside the lower levels of the dispatcher (here) |
// or: do it outside per default, let a possibility to modify it inside the lower levels of the dispatcher (here) |
614 |
if ($val['ecom_data_locator_key'] == "rpc") { |
if ($val['ecom_data_locator_key'] == "rpc") { |
615 |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
//$data_locator_meta = array( transport => 'rpc', metatype => 'data', vartype => 'objects', nodename => $val['ecom_data_ident']); |
616 |
$args[options][data_locator_meta] = array( transport => 'rpc', metatype => 'data', abstract_type => 'tree', ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta']); |
$args[options][data_locator_meta] = array( |
617 |
|
transport => 'rpc', metatype => 'data', abstract_type => 'tree', |
618 |
|
ident => $val['ecom_data_ident'], nodename => $val['ecom_data_meta'], |
619 |
|
// NEW [2003-04-22]: Full tree node filtering established. |
620 |
|
filter => $filter |
621 |
|
); |
622 |
} |
} |
623 |
|
|
624 |
|
// NEW [2003-09-26]: transparent content - argument pass-through mode |
625 |
|
} elseif ($val['ecom_abstract_type'] == "transparent") { |
626 |
|
|
627 |
|
// You are responsible for all arguments passed through. |
628 |
|
// Where are these arguments from? |
629 |
|
// They are propagated transparently to this place from a new optional |
630 |
|
// parameter ($args) introduced for the methods 'get_com', 'load_com' |
631 |
|
// and '_prepare_component_args' (this one). |
632 |
|
// This means full control over ecoms from outside. |
633 |
|
|
634 |
|
// TODO: maybe add some additional pre-flight checks here!? |
635 |
|
|
636 |
|
// croak |
637 |
} else { |
} else { |
638 |
user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'."); |
user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'."); |
639 |
|
|
685 |
|
|
686 |
// NEW [2003-04-18]: transparent nav - argument pass-through mode |
// NEW [2003-04-18]: transparent nav - argument pass-through mode |
687 |
} elseif ($val['ecom_abstract_type'] == "transparent") { |
} elseif ($val['ecom_abstract_type'] == "transparent") { |
|
|
|
688 |
// You are responsible for all arguments passed through. |
// You are responsible for all arguments passed through. |
689 |
// Where are these arguments from? |
// Where are these arguments from? |
690 |
// They are propagated transparently to this place from a new optional |
// They are propagated transparently to this place from a new optional |
693 |
// This means full control over ecoms from outside. |
// This means full control over ecoms from outside. |
694 |
|
|
695 |
// TODO: maybe add some additional pre-flight checks here!? |
// TODO: maybe add some additional pre-flight checks here!? |
|
|
|
696 |
// croak |
// croak |
697 |
} else { |
} else { |
698 |
user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'."); |
user_error("_prepare_component_args: Could not dispatch ecom_abstract_type='$val[ecom_abstract_type]'."); |
728 |
|
|
729 |
// NEW[2003-04-18]: add hidden items to args |
// NEW[2003-04-18]: add hidden items to args |
730 |
$args['hidden_elements'] = $this->_get_hidden_items($label); |
$args['hidden_elements'] = $this->_get_hidden_items($label); |
731 |
|
//print "args_hidden: " .Dumper($args['hidden_elements']). "<br>"; |
732 |
return $args; |
return $args; |
733 |
} |
} |
734 |
|
|
747 |
user_error("AbstractExplorer::render - please implement me...."); |
user_error("AbstractExplorer::render - please implement me...."); |
748 |
} |
} |
749 |
|
|
750 |
|
|
751 |
|
function get_data_filter($state = array()) { |
752 |
|
|
753 |
|
// NEW: 'filter' - 2003-04-14 - required for filtering xml-nodes |
754 |
|
// V1: this was inside ecom_abstract_type == item && ecom_data_locator_key == rpc, but ... |
755 |
|
// V2: ... it should be considered / work independent of these both criterias |
756 |
|
// since it is required for showing xml nodes in items (editing) *and* trees again (browsing). |
757 |
|
|
758 |
|
if ($filter_expression = $state[ecom_data_filter]) { |
759 |
|
|
760 |
|
// new of 2003-05-13: Apply "Node navigation" in tree mode only. |
761 |
|
// Lock context when switching to item mode. |
762 |
|
//print Dumper($state); |
763 |
|
if ($state[ecom_abstract_type] == "tree") { |
764 |
|
if ($parent_xpq = $state[ecom_data_meta]) { |
765 |
|
$filter_expression = $parent_xpq . $filter_expression; |
766 |
|
} |
767 |
|
} |
768 |
|
|
769 |
|
// This propagates a XPath filter expression which fully identifies |
770 |
|
// a single node in a document. It reaches through all parent nodes. |
771 |
|
$filter = array( |
772 |
|
//dotted => $val['ecom_data_filter'], |
773 |
|
//ident => $val['ecom_data_ident'], |
774 |
|
//xpq => '*/*[@name="cli"]', |
775 |
|
//xpq => '*/*', |
776 |
|
// NEW [2003-04-21]: An xpq is already ready now inside |
777 |
|
// 'ecdf' since it already has been built by the revamped tree lift. |
778 |
|
xpq => '*' . $filter_expression |
779 |
|
); |
780 |
|
|
781 |
|
} else { |
782 |
|
$filter = ''; |
783 |
|
|
784 |
|
} |
785 |
|
|
786 |
|
// lift filter from dotted format to xpq format |
787 |
|
// NEW [2003-04-21]: not required any more (see above) |
788 |
|
//$lift = mkObject('Data::Lift', $filter, array( metatype => 'filter' ) ); |
789 |
|
//$filter = $lift->to('XPath'); |
790 |
|
|
791 |
|
return $filter; |
792 |
|
|
793 |
|
} |
794 |
|
|
795 |
} |
} |
796 |
|
|
797 |
|
|
|
?> |
|
798 |
|
?> |