15 |
* $Id$ |
* $Id$ |
16 |
* |
* |
17 |
* $Log$ |
* $Log$ |
18 |
|
* Revision 1.13 2003/04/04 02:37:14 jonen |
19 |
|
* _query[action] == write |
20 |
|
* |
21 |
|
* Revision 1.12 2003/03/29 08:00:48 joko |
22 |
|
* modified ErrorBoxing |
23 |
|
* |
24 |
|
* Revision 1.11 2003/03/28 06:45:26 joko |
25 |
|
* VERBOSE mode |
26 |
|
* |
27 |
* Revision 1.10 2003/03/28 03:01:02 joko |
* Revision 1.10 2003/03/28 03:01:02 joko |
28 |
* more fancy debugging-output |
* more fancy debugging-output |
29 |
* |
* |
684 |
switch ($this->_query[metatype]) { |
switch ($this->_query[metatype]) { |
685 |
case 'data': |
case 'data': |
686 |
$command = 'queryData'; |
$command = 'queryData'; |
687 |
|
|
688 |
//$command = 'getObjects'; // FIXME!!! |
//$command = 'getObjects'; // FIXME!!! |
689 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
690 |
/* |
/* |
718 |
$query_args[classname] = $this->_query[classname]; |
$query_args[classname] = $this->_query[classname]; |
719 |
break; |
break; |
720 |
} |
} |
721 |
|
if($this->_query[action] == 'write') { |
722 |
|
$query_args[action] = $this->_query[action]; |
723 |
|
$query_args[data] = $this->_query[data]; |
724 |
|
} |
725 |
$args = array( |
$args = array( |
726 |
'data_type' => $this->_query[abstract_type], |
'data_type' => $this->_query[abstract_type], |
727 |
'query_args' => $query_args |
'query_args' => $query_args |
767 |
|
|
768 |
} |
} |
769 |
|
|
770 |
|
|
771 |
|
|
772 |
function &fetch_result() { |
function &fetch_result() { |
773 |
|
|
774 |
$this->datasource_handler_buildoptions(); |
$this->datasource_handler_buildoptions(); |
775 |
|
|
776 |
$method = $this->_locator->_call[_method]; |
$call = $this->_locator->get_call(); |
777 |
$args = $this->_locator->_call[_arguments]; |
//print Dumper($call); |
778 |
|
|
779 |
// pre-flight checks |
// pre-flight checks |
780 |
if (!$method) { |
if (!$call[method]) { |
781 |
$msg = "Remote command could not be resolved, please pass in or check configuration."; |
$msg = "Remote method is empty, please pass in proper metadata or check configuration."; |
782 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
783 |
return; |
return; |
784 |
} |
} |
787 |
|
|
788 |
// do remote call here and get result |
// do remote call here and get result |
789 |
// FIXME: handle synchronous/asynchronous mode here!!! |
// FIXME: handle synchronous/asynchronous mode here!!! |
790 |
$this->datasource_handler_call($method, $args); |
$this->datasource_handler_call($call[method], $call[args]); |
791 |
|
|
792 |
|
|
793 |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
798 |
$this->_result_count = sizeof($this->_result); |
$this->_result_count = sizeof($this->_result); |
799 |
|
|
800 |
// trace |
// trace |
801 |
if ($this->_debug[notice]) { |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
802 |
|
if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) { |
803 |
//print "_result = " . Dumper($this->_result); |
//print "_result = " . Dumper($this->_result); |
804 |
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>"; |
805 |
|
$this->draw_status_box(); |
806 |
} |
} |
807 |
|
|
808 |
return $this->_result; |
return $this->_result; |
809 |
|
|
810 |
} |
} |
811 |
|
|
812 |
|
function draw_status_box() { |
813 |
|
|
814 |
|
static $boxcount; |
815 |
|
|
816 |
|
$boxcount++; |
817 |
|
|
818 |
|
$box = container(); |
819 |
|
|
820 |
|
// box client code (javascript) |
821 |
|
$code_js = " |
822 |
|
<script language=\"javascript\"> |
823 |
|
function toggle_vis(id) { |
824 |
|
elem = eval('document.all.' + id); |
825 |
|
status = elem.style.getAttribute('display'); |
826 |
|
if (status == 'none') { |
827 |
|
elem.style.setAttribute('display', 'block'); |
828 |
|
} else { |
829 |
|
elem.style.setAttribute('display', 'none'); |
830 |
|
} |
831 |
|
} |
832 |
|
</script> |
833 |
|
"; |
834 |
|
//$script = html_script($code_js); |
835 |
|
//print $script->render(); |
836 |
|
$box->add( $code_js ); |
837 |
|
|
838 |
|
// box style |
839 |
|
$style = container( |
840 |
|
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
841 |
|
html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }') |
842 |
|
); |
843 |
|
$box->add( $style ); |
844 |
|
|
845 |
|
// box content |
846 |
|
$statusbox = html_div('box_dsg'); |
847 |
|
$statusbox->add( html_b("DataSource::Generic"), html_br() ); |
848 |
|
$locatorbox = html_div('box_dsg'); |
849 |
|
$locatorbox->set_id("locatorbox_$boxcount"); |
850 |
|
$locatorbox->add( Dumper($this->_locator) ); |
851 |
|
//$locatorbox->set_style('visibility:false;'); |
852 |
|
$locatorbox->set_style('display:none;'); |
853 |
|
|
854 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), html_a("javascript:toggle_vis('locatorbox_$boxcount');", '[show]'), $locatorbox, html_br() ); |
855 |
|
$call = $this->_locator->get_call(); |
856 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
857 |
|
if (sizeof($call[args])) { |
858 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
859 |
|
} |
860 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() ); |
861 |
|
$box->add( $statusbox ); |
862 |
|
|
863 |
|
print $box->render(); |
864 |
|
|
865 |
|
} |
866 |
|
|
867 |
|
|
868 |
function &query_data() { |
function &query_data() { |
869 |
//print "query!<br/>"; |
//print "query!<br/>"; |
879 |
function &get_result() { |
function &get_result() { |
880 |
return $this->_result; |
return $this->_result; |
881 |
} |
} |
882 |
|
|
883 |
|
function get_result_count() { |
884 |
|
return $this->_result_count; |
885 |
|
} |
886 |
|
|
887 |
} |
} |
888 |
|
|