9 |
*/ |
*/ |
10 |
|
|
11 |
/** |
/** |
12 |
* <b>Cvs-Log:</b> |
* Cvs-Log: |
13 |
* |
* |
|
* <pre> |
|
14 |
* $Id$ |
* $Id$ |
15 |
* |
* |
16 |
* $Log$ |
* $Log$ |
17 |
|
* Revision 1.26 2003/12/14 01:53:42 jonen |
18 |
|
* implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes |
19 |
|
* |
20 |
|
* Revision 1.25 2003/11/17 18:01:03 jonen |
21 |
|
* bugfix: php cannot use perl-syntax!! ;-) |
22 |
|
* |
23 |
|
* Revision 1.23 2003/07/14 10:02:32 jonen |
24 |
|
* removed debug dumper |
25 |
|
* |
26 |
|
* Revision 1.22 2003/06/06 04:25:45 joko |
27 |
|
* fix: query args get encapsulated once more |
28 |
|
* |
29 |
|
* Revision 1.21 2003/05/10 18:14:50 jonen |
30 |
|
* + implements 'create' of item (query mapping part) |
31 |
|
* |
32 |
|
* Revision 1.20 2003/04/19 16:07:15 jonen |
33 |
|
* + added '_query[list_meta]' at 'queryData' needed for meta query args |
34 |
|
* (e.g. at UserManagment) |
35 |
|
* |
36 |
|
* Revision 1.19 2003/04/18 15:40:51 joko |
37 |
|
* NEW: tree data handling |
38 |
|
* introduced new adapter: DataSource::Adapter::Free |
39 |
|
* enhanced datasource_handler_buildoptions: now handles a) case 'tree' b) _query[filter] |
40 |
|
* |
41 |
|
* Revision 1.18 2003/04/11 00:55:49 joko |
42 |
|
* updated 'datasource_handler_buildoptions': action dispatcher now aware of 'delete' |
43 |
|
* |
44 |
|
* Revision 1.17 2003/04/09 02:07:33 joko |
45 |
|
* CHANGE: renamed key 'classname' through 'nodename' |
46 |
|
* |
47 |
|
* Revision 1.16 2003/04/08 17:55:20 joko |
48 |
|
* CHANGE: renamed property 'datasource' to 'transport' |
49 |
|
* NEW: new case 'method' in 'function datasource_handler_buildoptions' |
50 |
|
* minor fixes: updated logging/debugging messages |
51 |
|
* |
52 |
|
* Revision 1.15 2003/04/06 04:46:33 joko |
53 |
|
* renamed linking function |
54 |
|
* mozilla fixes |
55 |
|
* |
56 |
|
* Revision 1.14 2003/04/04 21:19:21 joko |
57 |
|
* modified exception handling (enhanced, purged redundant code) |
58 |
|
* |
59 |
* Revision 1.13 2003/04/04 02:37:14 jonen |
* Revision 1.13 2003/04/04 02:37:14 jonen |
60 |
* _query[action] == write |
* _query[action] == write |
61 |
* |
* |
120 |
* |
* |
121 |
* Revision 1.1 2003/03/01 03:10:40 joko |
* Revision 1.1 2003/03/01 03:10:40 joko |
122 |
* + initial commit |
* + initial commit |
|
* </pre> |
|
123 |
* |
* |
124 |
*/ |
*/ |
125 |
|
|
316 |
* other presets. |
* other presets. |
317 |
* |
* |
318 |
* See '_buildLocator' which acts as a dispatcher |
* See '_buildLocator' which acts as a dispatcher |
319 |
* depending on $_options[datasource]. |
* depending on $_options[transport]. |
320 |
* (main dispatching level) |
* (main dispatching level) |
321 |
* |
* |
322 |
* The structure of a full blown locator looks like this: |
* The structure of a full blown locator looks like this: |
405 |
function DataSource_Generic( &$locator, $query ) { |
function DataSource_Generic( &$locator, $query ) { |
406 |
|
|
407 |
// copy parameter from query to locator |
// copy parameter from query to locator |
408 |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_'); |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_'); |
409 |
//$this->_locator->_datasource_type = $query[datasource]; |
//$this->_locator->_datasource_type = $query[transport]; |
410 |
//$locator[_datasource_type] = $query[datasource]; |
//$locator[_datasource_type] = $query[transport]; |
411 |
|
|
412 |
/** |
/** |
413 |
* <!-- Autodia --> |
* <!-- Autodia --> |
417 |
*/ |
*/ |
418 |
|
|
419 |
// build master locator |
// build master locator |
420 |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) ); |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) ); |
421 |
//exit; |
//exit; |
422 |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
423 |
|
|
454 |
// pre-flight: check locator metadata |
// pre-flight: check locator metadata |
455 |
//$locator->build(); |
//$locator->build(); |
456 |
if (!$this->_locator->check()) { |
if (!$this->_locator->check()) { |
457 |
user_error("locator-check failed."); |
user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) ); |
458 |
exit; |
//exit; |
459 |
//return; |
return; |
460 |
} |
} |
461 |
|
|
462 |
//exit; |
//exit; |
515 |
// ... resolves this._modules.adapter._id to this._modules.adapter._module |
// ... resolves this._modules.adapter._id to this._modules.adapter._module |
516 |
|
|
517 |
switch ($locator->_adapter_type) { |
switch ($locator->_adapter_type) { |
518 |
|
|
519 |
case 'phpHtmlLib': |
case 'phpHtmlLib': |
520 |
//$adapter_arguments = $args[title]; |
//$adapter_arguments = $args[title]; |
|
|
|
521 |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
522 |
|
|
523 |
// in order to let the Adapter communicate with the Proxy, |
// in order to let the Adapter communicate with the Proxy, |
524 |
// instantiate a wrapper method in a third namespace via |
// instantiate a wrapper method in a third namespace via |
525 |
// Exporter::export_symbol(from, to) |
// Exporter::export_symbol(from, to) |
526 |
$this->set_adapter_options($this); |
$this->set_adapter_options($this); |
527 |
|
break; |
528 |
|
|
529 |
|
// NEW [2003-04-17]: Freedom for the adapter! |
530 |
|
// phpHtmlLib didn't have a tree widget, but PEAR does. |
531 |
|
// So: Free us from the phpHtmlLib-adapter in this case. |
532 |
|
case 'free': |
533 |
|
$this->set_adapter_module('DataSource::Adapter::Free'); |
534 |
|
$this->set_adapter_options($this); |
535 |
break; |
break; |
536 |
|
|
537 |
default: |
default: |
538 |
user_error("DataSource::GenericDataSource: no Adapter could be selected!"); |
user_error("DataSource::Generic: no Adapter could be selected: \$locator->_adapter_type='$locator->_adapter_type'"); |
539 |
break; |
break; |
540 |
} |
} |
541 |
|
|
740 |
case 'objects': |
case 'objects': |
741 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
742 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
743 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
744 |
} |
} |
745 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
746 |
break; |
break; |
747 |
} |
} |
748 |
*/ |
*/ |
749 |
$query_args = array(); |
$query_args = array(); |
750 |
|
|
751 |
|
$msg_prefix = "DataSource::Generic::datasource_handler_buildoptions failed: "; |
752 |
switch ($this->_query[abstract_type]) { |
switch ($this->_query[abstract_type]) { |
753 |
|
case 'item': |
754 |
|
if (!$this->_query[nodename] && $this->_query[action] != 'create') { |
755 |
|
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
756 |
|
user_error($msg_prefix . $msg); |
757 |
|
} elseif($this->_query[action] == 'create' && $this->_query[parent]) { |
758 |
|
if($this->_query[nodename]) { $query_args[node_class] = $this->_query[nodename]; } |
759 |
|
if($this->_query['hash_key']) { $query_args['hash_key'] = $this->_query['hash_key']; } |
760 |
|
$query_args[nodename] = $this->_query[ident]; |
761 |
|
$query_args[parent][guid] = $this->_query[parent][guid]; |
762 |
|
$query_args[parent][nodename] = $this->_query[parent][nodename]; |
763 |
|
} elseif($this->_query[parent]) { |
764 |
|
$query_args[guid] = $this->_query[ident]; |
765 |
|
$query_args[nodename] = $this->_query[nodename]; |
766 |
|
$query_args[parent][guid] = $this->_query[parent][guid]; |
767 |
|
$query_args[parent][nodename] = $this->_query[parent][nodename]; |
768 |
|
} else { |
769 |
|
$query_args[guid] = $this->_query[ident]; |
770 |
|
$query_args[nodename] = $this->_query[nodename]; |
771 |
|
// 2003-11-17 NEW: use expand flag for real obj expand at backend |
772 |
|
if ($this->_query[expand]) {$query_args[expand] = 1; } |
773 |
|
} |
774 |
|
//print "generic_source->debug: args " . Dumper($query_args) . "<br>"; |
775 |
|
break; |
776 |
case 'list': |
case 'list': |
777 |
if (!$this->_query[classname]) { |
if (!$this->_query[nodename]) { |
778 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
779 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error($msg_prefix . $msg); |
780 |
|
} elseif($this->_query[parent]) { |
781 |
|
//if($this->_query[nodename]) { $query_args[node_class] = $this->_query[nodename]; } |
782 |
|
//if($this->_query['hash_key']) { $query_args['hash_key'] = $this->_query['hash_key']; } |
783 |
|
//$query_args[nodename] = $this->_query[ident]; |
784 |
|
$query_args[parent][guid] = $this->_query[parent][guid]; |
785 |
|
$query_args[parent][nodename] = $this->_query[parent][nodename]; |
786 |
} |
} |
787 |
//array_push($query_args, $this->_query[classname]); |
//array_push($query_args, $this->_query[nodename]); |
788 |
$query_args[classname] = $this->_query[classname]; |
$query_args[nodename] = $this->_query[nodename]; |
789 |
|
if($this->_query[list_meta]) { $query_args[list_meta] = $this->_query[list_meta]; } |
790 |
break; |
break; |
791 |
case 'item': |
case 'tree': |
792 |
if (!$this->_query[classname]) { |
/* |
793 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
if (!$this->_query[nodename]) { |
794 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
795 |
|
user_error($msg_prefix . $msg); |
796 |
} |
} |
797 |
|
*/ |
798 |
$query_args[guid] = $this->_query[ident]; |
$query_args[guid] = $this->_query[ident]; |
799 |
$query_args[classname] = $this->_query[classname]; |
//$query_args[nodename] = $this->_query[nodename]; |
800 |
break; |
break; |
801 |
|
default: |
802 |
|
$msg = "\$this->_query[abstract_type] could not be dispatched as 'item', 'list' or 'tree'."; |
803 |
|
user_error($msg_prefix . $msg); |
804 |
|
break; |
805 |
|
} |
806 |
|
|
807 |
|
// filter??? |
808 |
|
//print "Filter: " . Dumper($this->_query[filter]) . "<br>"; |
809 |
|
if ($this->_query[filter]) { |
810 |
|
$query_args[filter] = $this->_query[filter]; |
811 |
} |
} |
812 |
if($this->_query[action] == 'write') { |
|
813 |
|
// dispatch action |
814 |
|
//print "Action: " . $this->_query[action] . "<br>"; |
815 |
|
if ($this->_query[action] == 'write') { |
816 |
$query_args[action] = $this->_query[action]; |
$query_args[action] = $this->_query[action]; |
817 |
$query_args[data] = $this->_query[data]; |
$query_args[data] = $this->_query[data]; |
818 |
|
} elseif ($this->_query[action] == 'delete') { |
819 |
|
$query_args[action] = $this->_query[action]; |
820 |
|
} elseif ($this->_query[action] == 'create') { |
821 |
|
$query_args[action] = $this->_query[action]; |
822 |
|
} elseif ($this->_query[action] == 'select') { |
823 |
|
$query_args[action] = $this->_query[action]; |
824 |
} |
} |
825 |
|
|
826 |
$args = array( |
$args = array( |
827 |
'data_type' => $this->_query[abstract_type], |
'data_type' => $this->_query[abstract_type], |
828 |
'query_args' => $query_args |
'query_args' => $query_args |
833 |
case 'schema': |
case 'schema': |
834 |
//print "Testing schema:" . "<br>"; |
//print "Testing schema:" . "<br>"; |
835 |
$command = 'querySchema'; |
$command = 'querySchema'; |
836 |
|
$args = array( $this->_query[filter] ); |
837 |
break; |
break; |
838 |
|
|
839 |
|
// remoteMethod |
840 |
|
case 'method': |
841 |
|
$command = $this->_query[method]; |
842 |
|
//$args = $this->_query[args]; |
843 |
|
// FIX |
844 |
|
$args = array( $this->_query[args] ); |
845 |
|
break; |
846 |
|
|
847 |
} |
} |
848 |
|
|
849 |
|
|
850 |
|
// FIXME: bad behaviour? |
851 |
|
if (!is_array($args)) { $args = array( $args ); } |
852 |
|
|
853 |
|
//print Dumper($args); |
854 |
|
|
855 |
/* |
/* |
856 |
$this->_query[rpc_command] = $command; |
$this->_query[rpc_command] = $command; |
886 |
|
|
887 |
|
|
888 |
function &fetch_result() { |
function &fetch_result() { |
889 |
|
|
890 |
|
//print Dumper($this); |
891 |
|
|
892 |
$this->datasource_handler_buildoptions(); |
$this->datasource_handler_buildoptions(); |
893 |
|
|
894 |
$call = $this->_locator->get_call(); |
$call = $this->_locator->get_call(); |
895 |
|
|
896 |
//print Dumper($call); |
//print Dumper($call); |
897 |
|
//return; |
898 |
|
|
899 |
// pre-flight checks |
// pre-flight checks |
900 |
if (!$call[method]) { |
if (!$call[method]) { |
901 |
$msg = "Remote method is empty, please pass in proper metadata or check configuration."; |
$msg = "Remote method is empty, please pass in proper metadata or check configuration."; |
902 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
903 |
return; |
return; |
904 |
} |
} |
905 |
|
|
937 |
|
|
938 |
$box = container(); |
$box = container(); |
939 |
|
|
|
// box client code (javascript) |
|
|
$code_js = " |
|
|
<script language=\"javascript\"> |
|
|
function toggle_vis(id) { |
|
|
elem = eval('document.all.' + id); |
|
|
status = elem.style.getAttribute('display'); |
|
|
if (status == 'none') { |
|
|
elem.style.setAttribute('display', 'block'); |
|
|
} else { |
|
|
elem.style.setAttribute('display', 'none'); |
|
|
} |
|
|
} |
|
|
</script> |
|
|
"; |
|
|
//$script = html_script($code_js); |
|
|
//print $script->render(); |
|
|
$box->add( $code_js ); |
|
|
|
|
940 |
// box style |
// box style |
941 |
$style = container( |
$style = container( |
942 |
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
950 |
$locatorbox = html_div('box_dsg'); |
$locatorbox = html_div('box_dsg'); |
951 |
$locatorbox->set_id("locatorbox_$boxcount"); |
$locatorbox->set_id("locatorbox_$boxcount"); |
952 |
$locatorbox->add( Dumper($this->_locator) ); |
$locatorbox->add( Dumper($this->_locator) ); |
|
//$locatorbox->set_style('visibility:false;'); |
|
|
$locatorbox->set_style('display:none;'); |
|
953 |
|
|
954 |
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), html_a("javascript:toggle_vis('locatorbox_$boxcount');", '[show]'), $locatorbox, html_br() ); |
// FIXME: ie/mozilla? |
955 |
|
//$locatorbox->set_style('display:none;'); |
956 |
|
//$locatorbox->set_style('visibility:hidden;'); |
957 |
|
// already duplicate inside Tracer!!! |
958 |
|
$locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;'); |
959 |
|
|
960 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() ); |
961 |
$call = $this->_locator->get_call(); |
$call = $this->_locator->get_call(); |
962 |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
963 |
if (sizeof($call[args])) { |
if (sizeof($call[args])) { |
966 |
$statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() ); |
967 |
$box->add( $statusbox ); |
$box->add( $statusbox ); |
968 |
|
|
969 |
print $box->render(); |
//print $box->render(); |
970 |
|
trace( $box ); |
971 |
|
|
972 |
} |
} |
973 |
|
|