| 15 |
* $Id$ |
* $Id$ |
| 16 |
* |
* |
| 17 |
* $Log$ |
* $Log$ |
| 18 |
|
* Revision 1.18 2003/04/11 00:55:49 joko |
| 19 |
|
* updated 'datasource_handler_buildoptions': action dispatcher now aware of 'delete' |
| 20 |
|
* |
| 21 |
|
* Revision 1.17 2003/04/09 02:07:33 joko |
| 22 |
|
* CHANGE: renamed key 'classname' through 'nodename' |
| 23 |
|
* |
| 24 |
|
* Revision 1.16 2003/04/08 17:55:20 joko |
| 25 |
|
* CHANGE: renamed property 'datasource' to 'transport' |
| 26 |
|
* NEW: new case 'method' in 'function datasource_handler_buildoptions' |
| 27 |
|
* minor fixes: updated logging/debugging messages |
| 28 |
|
* |
| 29 |
|
* Revision 1.15 2003/04/06 04:46:33 joko |
| 30 |
|
* renamed linking function |
| 31 |
|
* mozilla fixes |
| 32 |
|
* |
| 33 |
|
* Revision 1.14 2003/04/04 21:19:21 joko |
| 34 |
|
* modified exception handling (enhanced, purged redundant code) |
| 35 |
|
* |
| 36 |
|
* Revision 1.13 2003/04/04 02:37:14 jonen |
| 37 |
|
* _query[action] == write |
| 38 |
|
* |
| 39 |
|
* Revision 1.12 2003/03/29 08:00:48 joko |
| 40 |
|
* modified ErrorBoxing |
| 41 |
|
* |
| 42 |
* Revision 1.11 2003/03/28 06:45:26 joko |
* Revision 1.11 2003/03/28 06:45:26 joko |
| 43 |
* VERBOSE mode |
* VERBOSE mode |
| 44 |
* |
* |
| 294 |
* other presets. |
* other presets. |
| 295 |
* |
* |
| 296 |
* See '_buildLocator' which acts as a dispatcher |
* See '_buildLocator' which acts as a dispatcher |
| 297 |
* depending on $_options[datasource]. |
* depending on $_options[transport]. |
| 298 |
* (main dispatching level) |
* (main dispatching level) |
| 299 |
* |
* |
| 300 |
* The structure of a full blown locator looks like this: |
* The structure of a full blown locator looks like this: |
| 383 |
function DataSource_Generic( &$locator, $query ) { |
function DataSource_Generic( &$locator, $query ) { |
| 384 |
|
|
| 385 |
// copy parameter from query to locator |
// copy parameter from query to locator |
| 386 |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_'); |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_'); |
| 387 |
//$this->_locator->_datasource_type = $query[datasource]; |
//$this->_locator->_datasource_type = $query[transport]; |
| 388 |
//$locator[_datasource_type] = $query[datasource]; |
//$locator[_datasource_type] = $query[transport]; |
| 389 |
|
|
| 390 |
/** |
/** |
| 391 |
* <!-- Autodia --> |
* <!-- Autodia --> |
| 395 |
*/ |
*/ |
| 396 |
|
|
| 397 |
// build master locator |
// build master locator |
| 398 |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) ); |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) ); |
| 399 |
//exit; |
//exit; |
| 400 |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
| 401 |
|
|
| 432 |
// pre-flight: check locator metadata |
// pre-flight: check locator metadata |
| 433 |
//$locator->build(); |
//$locator->build(); |
| 434 |
if (!$this->_locator->check()) { |
if (!$this->_locator->check()) { |
| 435 |
user_error("locator-check failed."); |
user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) ); |
| 436 |
exit; |
//exit; |
| 437 |
//return; |
return; |
| 438 |
} |
} |
| 439 |
|
|
| 440 |
//exit; |
//exit; |
| 506 |
|
|
| 507 |
break; |
break; |
| 508 |
default: |
default: |
| 509 |
user_error("DataSource::GenericDataSource: no Adapter could be selected!"); |
user_error("DataSource::Generic: no Adapter could be selected!"); |
| 510 |
break; |
break; |
| 511 |
} |
} |
| 512 |
|
|
| 702 |
switch ($this->_query[metatype]) { |
switch ($this->_query[metatype]) { |
| 703 |
case 'data': |
case 'data': |
| 704 |
$command = 'queryData'; |
$command = 'queryData'; |
| 705 |
|
|
| 706 |
//$command = 'getObjects'; // FIXME!!! |
//$command = 'getObjects'; // FIXME!!! |
| 707 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
| 708 |
/* |
/* |
| 711 |
case 'objects': |
case 'objects': |
| 712 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
| 713 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 714 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 715 |
} |
} |
| 716 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
| 717 |
break; |
break; |
| 720 |
$query_args = array(); |
$query_args = array(); |
| 721 |
switch ($this->_query[abstract_type]) { |
switch ($this->_query[abstract_type]) { |
| 722 |
case 'list': |
case 'list': |
| 723 |
if (!$this->_query[classname]) { |
if (!$this->_query[nodename]) { |
| 724 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
| 725 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 726 |
} |
} |
| 727 |
//array_push($query_args, $this->_query[classname]); |
//array_push($query_args, $this->_query[nodename]); |
| 728 |
$query_args[classname] = $this->_query[classname]; |
$query_args[nodename] = $this->_query[nodename]; |
| 729 |
break; |
break; |
| 730 |
case 'item': |
case 'item': |
| 731 |
if (!$this->_query[classname]) { |
if (!$this->_query[nodename]) { |
| 732 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
| 733 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 734 |
} |
} |
| 735 |
$query_args[guid] = $this->_query[ident]; |
$query_args[guid] = $this->_query[ident]; |
| 736 |
$query_args[classname] = $this->_query[classname]; |
$query_args[nodename] = $this->_query[nodename]; |
| 737 |
break; |
break; |
| 738 |
} |
} |
| 739 |
|
|
| 740 |
|
// dispatch action |
| 741 |
|
if ($this->_query[action] == 'write') { |
| 742 |
|
$query_args[action] = $this->_query[action]; |
| 743 |
|
$query_args[data] = $this->_query[data]; |
| 744 |
|
} elseif ($this->_query[action] == 'delete') { |
| 745 |
|
$query_args[action] = $this->_query[action]; |
| 746 |
|
} |
| 747 |
$args = array( |
$args = array( |
| 748 |
'data_type' => $this->_query[abstract_type], |
'data_type' => $this->_query[abstract_type], |
| 749 |
'query_args' => $query_args |
'query_args' => $query_args |
| 754 |
case 'schema': |
case 'schema': |
| 755 |
//print "Testing schema:" . "<br>"; |
//print "Testing schema:" . "<br>"; |
| 756 |
$command = 'querySchema'; |
$command = 'querySchema'; |
| 757 |
|
$args = array( $this->_query[filter] ); |
| 758 |
|
break; |
| 759 |
|
|
| 760 |
|
// remoteMethod |
| 761 |
|
case 'method': |
| 762 |
|
$command = $this->_query[method]; |
| 763 |
|
$args = $this->_query[args]; |
| 764 |
break; |
break; |
| 765 |
|
|
| 766 |
} |
} |
| 767 |
|
|
| 768 |
|
|
| 769 |
|
// FIXME: bad behaviour? |
| 770 |
|
if (!is_array($args)) { $args = array( $args ); } |
| 771 |
|
|
| 772 |
/* |
/* |
| 773 |
$this->_query[rpc_command] = $command; |
$this->_query[rpc_command] = $command; |
| 812 |
// pre-flight checks |
// pre-flight checks |
| 813 |
if (!$call[method]) { |
if (!$call[method]) { |
| 814 |
$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."; |
| 815 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 816 |
return; |
return; |
| 817 |
} |
} |
| 818 |
|
|
| 832 |
|
|
| 833 |
// trace |
// trace |
| 834 |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
| 835 |
if (constants::get('VERBOSE')) { |
if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) { |
| 836 |
//print "_result = " . Dumper($this->_result); |
//print "_result = " . Dumper($this->_result); |
| 837 |
//print "<div><b><font color=\"darkgreen\">Debug:</font></b> DataSource::Generic->_result_count = <b>" . $this->_result_count . "</b></div>"; |
//print "<div><b><font color=\"darkgreen\">Debug:</font></b> DataSource::Generic->_result_count = <b>" . $this->_result_count . "</b></div>"; |
| 838 |
$this->draw_status_box(); |
$this->draw_status_box(); |
| 848 |
|
|
| 849 |
$boxcount++; |
$boxcount++; |
| 850 |
|
|
| 851 |
// box client code (javascript) |
$box = container(); |
| 852 |
$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(); |
|
|
print $code_js; |
|
|
|
|
| 853 |
// box style |
// box style |
| 854 |
$style = container( |
$style = container( |
| 855 |
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
| 856 |
html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }') |
html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }') |
| 857 |
); |
); |
| 858 |
print $style->render(); |
$box->add( $style ); |
| 859 |
|
|
| 860 |
// box content |
// box content |
| 861 |
$statusbox = html_div('box_dsg'); |
$statusbox = html_div('box_dsg'); |
| 863 |
$locatorbox = html_div('box_dsg'); |
$locatorbox = html_div('box_dsg'); |
| 864 |
$locatorbox->set_id("locatorbox_$boxcount"); |
$locatorbox->set_id("locatorbox_$boxcount"); |
| 865 |
$locatorbox->add( Dumper($this->_locator) ); |
$locatorbox->add( Dumper($this->_locator) ); |
|
//$locatorbox->set_style('visibility:false;'); |
|
|
$locatorbox->set_style('display:none;'); |
|
| 866 |
|
|
| 867 |
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), html_a("javascript:toggle_vis('locatorbox_$boxcount');", '[show]'), $locatorbox, html_br() ); |
// FIXME: ie/mozilla? |
| 868 |
|
//$locatorbox->set_style('display:none;'); |
| 869 |
|
//$locatorbox->set_style('visibility:hidden;'); |
| 870 |
|
// already duplicate inside Tracer!!! |
| 871 |
|
$locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;'); |
| 872 |
|
|
| 873 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() ); |
| 874 |
$call = $this->_locator->get_call(); |
$call = $this->_locator->get_call(); |
| 875 |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
| 876 |
if (sizeof($call[args])) { |
if (sizeof($call[args])) { |
| 877 |
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
| 878 |
} |
} |
| 879 |
$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() ); |
| 880 |
print $statusbox->render(); |
$box->add( $statusbox ); |
| 881 |
|
|
| 882 |
|
//print $box->render(); |
| 883 |
|
trace( $box ); |
| 884 |
|
|
| 885 |
} |
} |
| 886 |
|
|