9 |
*/ |
*/ |
10 |
|
|
11 |
/** |
/** |
12 |
* <b>Cvs-Log:</b> |
* Cvs-Log: |
13 |
* |
* |
|
* <pre> |
|
14 |
* $Id$ |
* $Id$ |
15 |
* |
* |
16 |
* $Log$ |
* $Log$ |
17 |
|
* Revision 1.22 2003/06/06 04:25:45 joko |
18 |
|
* fix: query args get encapsulated once more |
19 |
|
* |
20 |
|
* Revision 1.21 2003/05/10 18:14:50 jonen |
21 |
|
* + implements 'create' of item (query mapping part) |
22 |
|
* |
23 |
|
* Revision 1.20 2003/04/19 16:07:15 jonen |
24 |
|
* + added '_query[list_meta]' at 'queryData' needed for meta query args |
25 |
|
* (e.g. at UserManagment) |
26 |
|
* |
27 |
|
* Revision 1.19 2003/04/18 15:40:51 joko |
28 |
|
* NEW: tree data handling |
29 |
|
* introduced new adapter: DataSource::Adapter::Free |
30 |
|
* enhanced datasource_handler_buildoptions: now handles a) case 'tree' b) _query[filter] |
31 |
|
* |
32 |
|
* Revision 1.18 2003/04/11 00:55:49 joko |
33 |
|
* updated 'datasource_handler_buildoptions': action dispatcher now aware of 'delete' |
34 |
|
* |
35 |
|
* Revision 1.17 2003/04/09 02:07:33 joko |
36 |
|
* CHANGE: renamed key 'classname' through 'nodename' |
37 |
|
* |
38 |
|
* Revision 1.16 2003/04/08 17:55:20 joko |
39 |
|
* CHANGE: renamed property 'datasource' to 'transport' |
40 |
|
* NEW: new case 'method' in 'function datasource_handler_buildoptions' |
41 |
|
* minor fixes: updated logging/debugging messages |
42 |
|
* |
43 |
|
* Revision 1.15 2003/04/06 04:46:33 joko |
44 |
|
* renamed linking function |
45 |
|
* mozilla fixes |
46 |
|
* |
47 |
* Revision 1.14 2003/04/04 21:19:21 joko |
* Revision 1.14 2003/04/04 21:19:21 joko |
48 |
* modified exception handling (enhanced, purged redundant code) |
* modified exception handling (enhanced, purged redundant code) |
49 |
* |
* |
111 |
* |
* |
112 |
* Revision 1.1 2003/03/01 03:10:40 joko |
* Revision 1.1 2003/03/01 03:10:40 joko |
113 |
* + initial commit |
* + initial commit |
|
* </pre> |
|
114 |
* |
* |
115 |
*/ |
*/ |
116 |
|
|
307 |
* other presets. |
* other presets. |
308 |
* |
* |
309 |
* See '_buildLocator' which acts as a dispatcher |
* See '_buildLocator' which acts as a dispatcher |
310 |
* depending on $_options[datasource]. |
* depending on $_options[transport]. |
311 |
* (main dispatching level) |
* (main dispatching level) |
312 |
* |
* |
313 |
* The structure of a full blown locator looks like this: |
* The structure of a full blown locator looks like this: |
396 |
function DataSource_Generic( &$locator, $query ) { |
function DataSource_Generic( &$locator, $query ) { |
397 |
|
|
398 |
// copy parameter from query to locator |
// copy parameter from query to locator |
399 |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_'); |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_'); |
400 |
//$this->_locator->_datasource_type = $query[datasource]; |
//$this->_locator->_datasource_type = $query[transport]; |
401 |
//$locator[_datasource_type] = $query[datasource]; |
//$locator[_datasource_type] = $query[transport]; |
402 |
|
|
403 |
/** |
/** |
404 |
* <!-- Autodia --> |
* <!-- Autodia --> |
408 |
*/ |
*/ |
409 |
|
|
410 |
// build master locator |
// build master locator |
411 |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) ); |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) ); |
412 |
//exit; |
//exit; |
413 |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
414 |
|
|
445 |
// pre-flight: check locator metadata |
// pre-flight: check locator metadata |
446 |
//$locator->build(); |
//$locator->build(); |
447 |
if (!$this->_locator->check()) { |
if (!$this->_locator->check()) { |
448 |
user_error("locator-check failed."); |
user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) ); |
449 |
exit; |
//exit; |
450 |
//return; |
return; |
451 |
} |
} |
452 |
|
|
453 |
//exit; |
//exit; |
506 |
// ... resolves this._modules.adapter._id to this._modules.adapter._module |
// ... resolves this._modules.adapter._id to this._modules.adapter._module |
507 |
|
|
508 |
switch ($locator->_adapter_type) { |
switch ($locator->_adapter_type) { |
509 |
|
|
510 |
case 'phpHtmlLib': |
case 'phpHtmlLib': |
511 |
//$adapter_arguments = $args[title]; |
//$adapter_arguments = $args[title]; |
|
|
|
512 |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
513 |
|
|
514 |
// in order to let the Adapter communicate with the Proxy, |
// in order to let the Adapter communicate with the Proxy, |
515 |
// instantiate a wrapper method in a third namespace via |
// instantiate a wrapper method in a third namespace via |
516 |
// Exporter::export_symbol(from, to) |
// Exporter::export_symbol(from, to) |
517 |
$this->set_adapter_options($this); |
$this->set_adapter_options($this); |
518 |
|
break; |
519 |
|
|
520 |
|
// NEW [2003-04-17]: Freedom for the adapter! |
521 |
|
// phpHtmlLib didn't have a tree widget, but PEAR does. |
522 |
|
// So: Free us from the phpHtmlLib-adapter in this case. |
523 |
|
case 'free': |
524 |
|
$this->set_adapter_module('DataSource::Adapter::Free'); |
525 |
|
$this->set_adapter_options($this); |
526 |
break; |
break; |
527 |
|
|
528 |
default: |
default: |
529 |
user_error("DataSource::GenericDataSource: no Adapter could be selected!"); |
user_error("DataSource::Generic: no Adapter could be selected: \$locator->_adapter_type='$locator->_adapter_type'"); |
530 |
break; |
break; |
531 |
} |
} |
532 |
|
|
731 |
case 'objects': |
case 'objects': |
732 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
733 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
734 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
735 |
} |
} |
736 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
737 |
break; |
break; |
738 |
} |
} |
739 |
*/ |
*/ |
740 |
$query_args = array(); |
$query_args = array(); |
741 |
|
|
742 |
|
$msg_prefix = "DataSource::Generic::datasource_handler_buildoptions failed: "; |
743 |
switch ($this->_query[abstract_type]) { |
switch ($this->_query[abstract_type]) { |
744 |
|
case 'item': |
745 |
|
if (!$this->_query[nodename] && $this->_query[action] != 'create') { |
746 |
|
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
747 |
|
user_error($msg_prefix . $msg); |
748 |
|
} elseif($this->_query[action] == 'create' && $this->_query[parent]) { |
749 |
|
if($this->_query[nodename]) { $query_args[node_class] = $this->_query[nodename]; } |
750 |
|
if($this->_query['hash_key']) { $query_args['hash_key'] = $this->_query['hash_key']; } |
751 |
|
$query_args[nodename] = $this->_query[ident]; |
752 |
|
$query_args[parent][guid] = $this->_query[parent][guid]; |
753 |
|
$query_args[parent][nodename] = $this->_query[parent][nodename]; |
754 |
|
} else { |
755 |
|
$query_args[guid] = $this->_query[ident]; |
756 |
|
$query_args[nodename] = $this->_query[nodename]; |
757 |
|
} |
758 |
|
break; |
759 |
case 'list': |
case 'list': |
760 |
if (!$this->_query[classname]) { |
if (!$this->_query[nodename]) { |
761 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
762 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error($msg_prefix . $msg); |
763 |
} |
} |
764 |
//array_push($query_args, $this->_query[classname]); |
//array_push($query_args, $this->_query[nodename]); |
765 |
$query_args[classname] = $this->_query[classname]; |
$query_args[nodename] = $this->_query[nodename]; |
766 |
|
if($this->_query[list_meta]) { $query_args[list_meta] = $this->_query[list_meta]; } |
767 |
break; |
break; |
768 |
case 'item': |
case 'tree': |
769 |
if (!$this->_query[classname]) { |
/* |
770 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
if (!$this->_query[nodename]) { |
771 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
772 |
|
user_error($msg_prefix . $msg); |
773 |
} |
} |
774 |
|
*/ |
775 |
$query_args[guid] = $this->_query[ident]; |
$query_args[guid] = $this->_query[ident]; |
776 |
$query_args[classname] = $this->_query[classname]; |
//$query_args[nodename] = $this->_query[nodename]; |
777 |
break; |
break; |
778 |
|
default: |
779 |
|
$msg = "\$this->_query[abstract_type] could not be dispatched as 'item', 'list' or 'tree'."; |
780 |
|
user_error($msg_prefix . $msg); |
781 |
|
break; |
782 |
} |
} |
783 |
if($this->_query[action] == 'write') { |
|
784 |
|
// filter??? |
785 |
|
print "Filter: " . Dumper($this->_query[filter]) . "<br>"; |
786 |
|
if ($this->_query[filter]) { |
787 |
|
$query_args[filter] = $this->_query[filter]; |
788 |
|
} |
789 |
|
|
790 |
|
// dispatch action |
791 |
|
print "Action: " . $this->_query[action] . "<br>"; |
792 |
|
if ($this->_query[action] == 'write') { |
793 |
$query_args[action] = $this->_query[action]; |
$query_args[action] = $this->_query[action]; |
794 |
$query_args[data] = $this->_query[data]; |
$query_args[data] = $this->_query[data]; |
795 |
|
} elseif ($this->_query[action] == 'delete') { |
796 |
|
$query_args[action] = $this->_query[action]; |
797 |
|
} elseif ($this->_query[action] == 'create') { |
798 |
|
$query_args[action] = $this->_query[action]; |
799 |
} |
} |
800 |
|
|
801 |
$args = array( |
$args = array( |
802 |
'data_type' => $this->_query[abstract_type], |
'data_type' => $this->_query[abstract_type], |
803 |
'query_args' => $query_args |
'query_args' => $query_args |
810 |
$command = 'querySchema'; |
$command = 'querySchema'; |
811 |
$args = array( $this->_query[filter] ); |
$args = array( $this->_query[filter] ); |
812 |
break; |
break; |
813 |
|
|
814 |
|
// remoteMethod |
815 |
|
case 'method': |
816 |
|
$command = $this->_query[method]; |
817 |
|
//$args = $this->_query[args]; |
818 |
|
// FIX |
819 |
|
$args = array( $this->_query[args] ); |
820 |
|
break; |
821 |
|
|
822 |
} |
} |
823 |
|
|
824 |
|
|
825 |
|
// FIXME: bad behaviour? |
826 |
|
if (!is_array($args)) { $args = array( $args ); } |
827 |
|
|
828 |
|
//print Dumper($args); |
829 |
|
|
830 |
/* |
/* |
831 |
$this->_query[rpc_command] = $command; |
$this->_query[rpc_command] = $command; |
861 |
|
|
862 |
|
|
863 |
function &fetch_result() { |
function &fetch_result() { |
864 |
|
|
865 |
|
//print Dumper($this); |
866 |
|
|
867 |
$this->datasource_handler_buildoptions(); |
$this->datasource_handler_buildoptions(); |
868 |
|
|
869 |
$call = $this->_locator->get_call(); |
$call = $this->_locator->get_call(); |
870 |
|
|
871 |
//print Dumper($call); |
//print Dumper($call); |
872 |
|
//return; |
873 |
|
|
874 |
// pre-flight checks |
// pre-flight checks |
875 |
if (!$call[method]) { |
if (!$call[method]) { |
876 |
$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."; |
877 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
878 |
return; |
return; |
879 |
} |
} |
880 |
|
|
927 |
$locatorbox->add( Dumper($this->_locator) ); |
$locatorbox->add( Dumper($this->_locator) ); |
928 |
|
|
929 |
// FIXME: ie/mozilla? |
// FIXME: ie/mozilla? |
930 |
//$locatorbox->set_style('visibility:false;'); |
//$locatorbox->set_style('display:none;'); |
931 |
$locatorbox->set_style('display:none;'); |
//$locatorbox->set_style('visibility:hidden;'); |
932 |
|
// already duplicate inside Tracer!!! |
933 |
|
$locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;'); |
934 |
|
|
935 |
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), jsAnchor( 'toggle_vis', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() ); |
936 |
$call = $this->_locator->get_call(); |
$call = $this->_locator->get_call(); |
937 |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
938 |
if (sizeof($call[args])) { |
if (sizeof($call[args])) { |