| 15 |
* $Id$ |
* $Id$ |
| 16 |
* |
* |
| 17 |
* $Log$ |
* $Log$ |
| 18 |
|
* Revision 1.16 2003/04/08 17:55:20 joko |
| 19 |
|
* CHANGE: renamed property 'datasource' to 'transport' |
| 20 |
|
* NEW: new case 'method' in 'function datasource_handler_buildoptions' |
| 21 |
|
* minor fixes: updated logging/debugging messages |
| 22 |
|
* |
| 23 |
|
* Revision 1.15 2003/04/06 04:46:33 joko |
| 24 |
|
* renamed linking function |
| 25 |
|
* mozilla fixes |
| 26 |
|
* |
| 27 |
|
* Revision 1.14 2003/04/04 21:19:21 joko |
| 28 |
|
* modified exception handling (enhanced, purged redundant code) |
| 29 |
|
* |
| 30 |
|
* Revision 1.13 2003/04/04 02:37:14 jonen |
| 31 |
|
* _query[action] == write |
| 32 |
|
* |
| 33 |
|
* Revision 1.12 2003/03/29 08:00:48 joko |
| 34 |
|
* modified ErrorBoxing |
| 35 |
|
* |
| 36 |
* Revision 1.11 2003/03/28 06:45:26 joko |
* Revision 1.11 2003/03/28 06:45:26 joko |
| 37 |
* VERBOSE mode |
* VERBOSE mode |
| 38 |
* |
* |
| 288 |
* other presets. |
* other presets. |
| 289 |
* |
* |
| 290 |
* See '_buildLocator' which acts as a dispatcher |
* See '_buildLocator' which acts as a dispatcher |
| 291 |
* depending on $_options[datasource]. |
* depending on $_options[transport]. |
| 292 |
* (main dispatching level) |
* (main dispatching level) |
| 293 |
* |
* |
| 294 |
* The structure of a full blown locator looks like this: |
* The structure of a full blown locator looks like this: |
| 377 |
function DataSource_Generic( &$locator, $query ) { |
function DataSource_Generic( &$locator, $query ) { |
| 378 |
|
|
| 379 |
// copy parameter from query to locator |
// copy parameter from query to locator |
| 380 |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_'); |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_'); |
| 381 |
//$this->_locator->_datasource_type = $query[datasource]; |
//$this->_locator->_datasource_type = $query[transport]; |
| 382 |
//$locator[_datasource_type] = $query[datasource]; |
//$locator[_datasource_type] = $query[transport]; |
| 383 |
|
|
| 384 |
/** |
/** |
| 385 |
* <!-- Autodia --> |
* <!-- Autodia --> |
| 389 |
*/ |
*/ |
| 390 |
|
|
| 391 |
// build master locator |
// build master locator |
| 392 |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) ); |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) ); |
| 393 |
//exit; |
//exit; |
| 394 |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
| 395 |
|
|
| 426 |
// pre-flight: check locator metadata |
// pre-flight: check locator metadata |
| 427 |
//$locator->build(); |
//$locator->build(); |
| 428 |
if (!$this->_locator->check()) { |
if (!$this->_locator->check()) { |
| 429 |
user_error("locator-check failed."); |
user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) ); |
| 430 |
exit; |
//exit; |
| 431 |
//return; |
return; |
| 432 |
} |
} |
| 433 |
|
|
| 434 |
//exit; |
//exit; |
| 500 |
|
|
| 501 |
break; |
break; |
| 502 |
default: |
default: |
| 503 |
user_error("DataSource::GenericDataSource: no Adapter could be selected!"); |
user_error("DataSource::Generic: no Adapter could be selected!"); |
| 504 |
break; |
break; |
| 505 |
} |
} |
| 506 |
|
|
| 696 |
switch ($this->_query[metatype]) { |
switch ($this->_query[metatype]) { |
| 697 |
case 'data': |
case 'data': |
| 698 |
$command = 'queryData'; |
$command = 'queryData'; |
| 699 |
|
|
| 700 |
//$command = 'getObjects'; // FIXME!!! |
//$command = 'getObjects'; // FIXME!!! |
| 701 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
| 702 |
/* |
/* |
| 705 |
case 'objects': |
case 'objects': |
| 706 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
| 707 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 708 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 709 |
} |
} |
| 710 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
| 711 |
break; |
break; |
| 716 |
case 'list': |
case 'list': |
| 717 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
| 718 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 719 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 720 |
} |
} |
| 721 |
//array_push($query_args, $this->_query[classname]); |
//array_push($query_args, $this->_query[classname]); |
| 722 |
$query_args[classname] = $this->_query[classname]; |
$query_args[classname] = $this->_query[classname]; |
| 724 |
case 'item': |
case 'item': |
| 725 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
| 726 |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 727 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 728 |
} |
} |
| 729 |
$query_args[guid] = $this->_query[ident]; |
$query_args[guid] = $this->_query[ident]; |
| 730 |
$query_args[classname] = $this->_query[classname]; |
$query_args[classname] = $this->_query[classname]; |
| 731 |
break; |
break; |
| 732 |
} |
} |
| 733 |
|
if($this->_query[action] == 'write') { |
| 734 |
|
$query_args[action] = $this->_query[action]; |
| 735 |
|
$query_args[data] = $this->_query[data]; |
| 736 |
|
} |
| 737 |
$args = array( |
$args = array( |
| 738 |
'data_type' => $this->_query[abstract_type], |
'data_type' => $this->_query[abstract_type], |
| 739 |
'query_args' => $query_args |
'query_args' => $query_args |
| 744 |
case 'schema': |
case 'schema': |
| 745 |
//print "Testing schema:" . "<br>"; |
//print "Testing schema:" . "<br>"; |
| 746 |
$command = 'querySchema'; |
$command = 'querySchema'; |
| 747 |
|
$args = array( $this->_query[filter] ); |
| 748 |
|
break; |
| 749 |
|
|
| 750 |
|
// remoteMethod |
| 751 |
|
case 'method': |
| 752 |
|
$command = $this->_query[method]; |
| 753 |
|
$args = $this->_query[args]; |
| 754 |
break; |
break; |
| 755 |
|
|
| 756 |
} |
} |
| 757 |
|
|
| 758 |
|
|
| 759 |
|
// FIXME: bad behaviour? |
| 760 |
|
if (!is_array($args)) { $args = array( $args ); } |
| 761 |
|
|
| 762 |
/* |
/* |
| 763 |
$this->_query[rpc_command] = $command; |
$this->_query[rpc_command] = $command; |
| 802 |
// pre-flight checks |
// pre-flight checks |
| 803 |
if (!$call[method]) { |
if (!$call[method]) { |
| 804 |
$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."; |
| 805 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 806 |
return; |
return; |
| 807 |
} |
} |
| 808 |
|
|
| 822 |
|
|
| 823 |
// trace |
// trace |
| 824 |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
| 825 |
if (constants::get('VERBOSE')) { |
if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) { |
| 826 |
//print "_result = " . Dumper($this->_result); |
//print "_result = " . Dumper($this->_result); |
| 827 |
//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>"; |
| 828 |
$this->draw_status_box(); |
$this->draw_status_box(); |
| 838 |
|
|
| 839 |
$boxcount++; |
$boxcount++; |
| 840 |
|
|
| 841 |
// box client code (javascript) |
$box = container(); |
| 842 |
$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; |
|
|
|
|
| 843 |
// box style |
// box style |
| 844 |
$style = container( |
$style = container( |
| 845 |
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
| 846 |
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; }') |
| 847 |
); |
); |
| 848 |
print $style->render(); |
$box->add( $style ); |
| 849 |
|
|
| 850 |
// box content |
// box content |
| 851 |
$statusbox = html_div('box_dsg'); |
$statusbox = html_div('box_dsg'); |
| 853 |
$locatorbox = html_div('box_dsg'); |
$locatorbox = html_div('box_dsg'); |
| 854 |
$locatorbox->set_id("locatorbox_$boxcount"); |
$locatorbox->set_id("locatorbox_$boxcount"); |
| 855 |
$locatorbox->add( Dumper($this->_locator) ); |
$locatorbox->add( Dumper($this->_locator) ); |
|
//$locatorbox->set_style('visibility:false;'); |
|
|
$locatorbox->set_style('display:none;'); |
|
| 856 |
|
|
| 857 |
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), html_a("javascript:toggle_vis('locatorbox_$boxcount');", '[show]'), $locatorbox, html_br() ); |
// FIXME: ie/mozilla? |
| 858 |
|
//$locatorbox->set_style('display:none;'); |
| 859 |
|
//$locatorbox->set_style('visibility:hidden;'); |
| 860 |
|
// already duplicate inside Tracer!!! |
| 861 |
|
$locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;'); |
| 862 |
|
|
| 863 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() ); |
| 864 |
$call = $this->_locator->get_call(); |
$call = $this->_locator->get_call(); |
| 865 |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
| 866 |
if (sizeof($call[args])) { |
if (sizeof($call[args])) { |
| 867 |
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
| 868 |
} |
} |
| 869 |
$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() ); |
| 870 |
print $statusbox->render(); |
$box->add( $statusbox ); |
| 871 |
|
|
| 872 |
|
//print $box->render(); |
| 873 |
|
trace( $box ); |
| 874 |
|
|
| 875 |
} |
} |
| 876 |
|
|