15 |
* $Id$ |
* $Id$ |
16 |
* |
* |
17 |
* $Log$ |
* $Log$ |
18 |
|
* Revision 1.12 2003/03/29 08:00:48 joko |
19 |
|
* modified ErrorBoxing |
20 |
|
* |
21 |
|
* Revision 1.11 2003/03/28 06:45:26 joko |
22 |
|
* VERBOSE mode |
23 |
|
* |
24 |
|
* Revision 1.10 2003/03/28 03:01:02 joko |
25 |
|
* more fancy debugging-output |
26 |
|
* |
27 |
|
* Revision 1.9 2003/03/27 16:24:26 jonen |
28 |
|
* + mugled namespace |
29 |
|
* + added enhanced 'queryData' |
30 |
|
* |
31 |
* Revision 1.8 2003/03/20 07:22:14 jonen |
* Revision 1.8 2003/03/20 07:22:14 jonen |
32 |
* + modified case 'object' to 'objects' |
* + modified case 'object' to 'objects' |
33 |
* (cause its loads all *objects* of a given classname) |
* (cause its loads all *objects* of a given classname) |
475 |
case 'phpHtmlLib': |
case 'phpHtmlLib': |
476 |
//$adapter_arguments = $args[title]; |
//$adapter_arguments = $args[title]; |
477 |
|
|
478 |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource'); |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
479 |
|
|
480 |
// in order to let the Adapter communicate with the Proxy, |
// in order to let the Adapter communicate with the Proxy, |
481 |
// instantiate a wrapper method in a third namespace via |
// instantiate a wrapper method in a third namespace via |
680 |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
681 |
switch ($this->_query[metatype]) { |
switch ($this->_query[metatype]) { |
682 |
case 'data': |
case 'data': |
683 |
//$command = 'queryData'; |
$command = 'queryData'; |
684 |
$command = 'getObjects'; // FIXME!!! |
//$command = 'getObjects'; // FIXME!!! |
685 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
686 |
|
/* |
687 |
$args = array(); |
$args = array(); |
688 |
switch ($this->_query[vartype]) { |
switch ($this->_query[vartype]) { |
689 |
case 'objects': |
case 'objects': |
694 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
695 |
break; |
break; |
696 |
} |
} |
697 |
break; |
*/ |
698 |
|
$query_args = array(); |
699 |
|
switch ($this->_query[abstract_type]) { |
700 |
|
case 'list': |
701 |
|
if (!$this->_query[classname]) { |
702 |
|
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
703 |
|
user_error("GenericDataSource::query_data() - failed: " . $msg); |
704 |
|
} |
705 |
|
//array_push($query_args, $this->_query[classname]); |
706 |
|
$query_args[classname] = $this->_query[classname]; |
707 |
|
break; |
708 |
|
case 'item': |
709 |
|
if (!$this->_query[classname]) { |
710 |
|
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
711 |
|
user_error("GenericDataSource::query_data() - failed: " . $msg); |
712 |
|
} |
713 |
|
$query_args[guid] = $this->_query[ident]; |
714 |
|
$query_args[classname] = $this->_query[classname]; |
715 |
|
break; |
716 |
|
} |
717 |
|
$args = array( |
718 |
|
'data_type' => $this->_query[abstract_type], |
719 |
|
'query_args' => $query_args |
720 |
|
); |
721 |
|
break; |
722 |
|
|
723 |
|
// querySchema |
724 |
case 'schema': |
case 'schema': |
725 |
|
//print "Testing schema:" . "<br>"; |
726 |
$command = 'querySchema'; |
$command = 'querySchema'; |
727 |
break; |
break; |
728 |
} |
} |
759 |
|
|
760 |
} |
} |
761 |
|
|
762 |
|
|
763 |
|
|
764 |
function &fetch_result() { |
function &fetch_result() { |
765 |
|
|
766 |
$this->datasource_handler_buildoptions(); |
$this->datasource_handler_buildoptions(); |
767 |
|
|
768 |
$method = $this->_locator->_call[_method]; |
$call = $this->_locator->get_call(); |
769 |
$args = $this->_locator->_call[_arguments]; |
//print Dumper($call); |
770 |
|
|
771 |
// pre-flight checks |
// pre-flight checks |
772 |
if (!$method) { |
if (!$call[method]) { |
773 |
$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."; |
774 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
775 |
return; |
return; |
776 |
} |
} |
779 |
|
|
780 |
// do remote call here and get result |
// do remote call here and get result |
781 |
// FIXME: handle synchronous/asynchronous mode here!!! |
// FIXME: handle synchronous/asynchronous mode here!!! |
782 |
$this->datasource_handler_call($method, $args); |
$this->datasource_handler_call($call[method], $call[args]); |
783 |
|
|
784 |
|
|
785 |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
790 |
$this->_result_count = sizeof($this->_result); |
$this->_result_count = sizeof($this->_result); |
791 |
|
|
792 |
// trace |
// trace |
793 |
if ($this->_debug[notice]) { |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
794 |
|
if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) { |
795 |
//print "_result = " . Dumper($this->_result); |
//print "_result = " . Dumper($this->_result); |
796 |
print "DataSource::Generic->_result_count = " . $this->_result_count . "<br/>"; |
//print "<div><b><font color=\"darkgreen\">Debug:</font></b> DataSource::Generic->_result_count = <b>" . $this->_result_count . "</b></div>"; |
797 |
|
$this->draw_status_box(); |
798 |
} |
} |
799 |
|
|
800 |
return $this->_result; |
return $this->_result; |
801 |
|
|
802 |
} |
} |
803 |
|
|
804 |
|
function draw_status_box() { |
805 |
|
|
806 |
|
static $boxcount; |
807 |
|
|
808 |
|
$boxcount++; |
809 |
|
|
810 |
|
$box = container(); |
811 |
|
|
812 |
|
// box client code (javascript) |
813 |
|
$code_js = " |
814 |
|
<script language=\"javascript\"> |
815 |
|
function toggle_vis(id) { |
816 |
|
elem = eval('document.all.' + id); |
817 |
|
status = elem.style.getAttribute('display'); |
818 |
|
if (status == 'none') { |
819 |
|
elem.style.setAttribute('display', 'block'); |
820 |
|
} else { |
821 |
|
elem.style.setAttribute('display', 'none'); |
822 |
|
} |
823 |
|
} |
824 |
|
</script> |
825 |
|
"; |
826 |
|
//$script = html_script($code_js); |
827 |
|
//print $script->render(); |
828 |
|
$box->add( $code_js ); |
829 |
|
|
830 |
|
// box style |
831 |
|
$style = container( |
832 |
|
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
833 |
|
html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }') |
834 |
|
); |
835 |
|
$box->add( $style ); |
836 |
|
|
837 |
|
// box content |
838 |
|
$statusbox = html_div('box_dsg'); |
839 |
|
$statusbox->add( html_b("DataSource::Generic"), html_br() ); |
840 |
|
$locatorbox = html_div('box_dsg'); |
841 |
|
$locatorbox->set_id("locatorbox_$boxcount"); |
842 |
|
$locatorbox->add( Dumper($this->_locator) ); |
843 |
|
//$locatorbox->set_style('visibility:false;'); |
844 |
|
$locatorbox->set_style('display:none;'); |
845 |
|
|
846 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), html_a("javascript:toggle_vis('locatorbox_$boxcount');", '[show]'), $locatorbox, html_br() ); |
847 |
|
$call = $this->_locator->get_call(); |
848 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
849 |
|
if (sizeof($call[args])) { |
850 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
851 |
|
} |
852 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() ); |
853 |
|
$box->add( $statusbox ); |
854 |
|
|
855 |
|
print $box->render(); |
856 |
|
|
857 |
|
} |
858 |
|
|
859 |
|
|
860 |
function &query_data() { |
function &query_data() { |
861 |
//print "query!<br/>"; |
//print "query!<br/>"; |
871 |
function &get_result() { |
function &get_result() { |
872 |
return $this->_result; |
return $this->_result; |
873 |
} |
} |
874 |
|
|
875 |
|
function get_result_count() { |
876 |
|
return $this->_result_count; |
877 |
|
} |
878 |
|
|
879 |
} |
} |
880 |
|
|