| 9 |
*/ |
*/ |
| 10 |
|
|
| 11 |
/** |
/** |
| 12 |
|
* Cvs-Log: |
| 13 |
|
* |
| 14 |
* $Id$ |
* $Id$ |
| 15 |
* |
* |
| 16 |
* $Log$ |
* $Log$ |
| 17 |
|
* Revision 1.29 2005/08/11 14:05:42 jonen |
| 18 |
|
* + added arguments to query |
| 19 |
|
* |
| 20 |
|
* Revision 1.28 2004/10/07 14:11:28 jonen |
| 21 |
|
* + added HACK related to DataList-filters which are mapped to backend now (page-control!) |
| 22 |
|
* |
| 23 |
|
* Revision 1.27 2004/06/15 12:50:48 joko |
| 24 |
|
* disabled caching in "datasource_handler_call" |
| 25 |
|
* |
| 26 |
|
* Revision 1.26 2003/12/14 01:53:42 jonen |
| 27 |
|
* implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes |
| 28 |
|
* |
| 29 |
|
* Revision 1.25 2003/11/17 18:01:03 jonen |
| 30 |
|
* bugfix: php cannot use perl-syntax!! ;-) |
| 31 |
|
* |
| 32 |
|
* Revision 1.23 2003/07/14 10:02:32 jonen |
| 33 |
|
* removed debug dumper |
| 34 |
|
* |
| 35 |
|
* Revision 1.22 2003/06/06 04:25:45 joko |
| 36 |
|
* fix: query args get encapsulated once more |
| 37 |
|
* |
| 38 |
|
* Revision 1.21 2003/05/10 18:14:50 jonen |
| 39 |
|
* + implements 'create' of item (query mapping part) |
| 40 |
|
* |
| 41 |
|
* Revision 1.20 2003/04/19 16:07:15 jonen |
| 42 |
|
* + added '_query[list_meta]' at 'queryData' needed for meta query args |
| 43 |
|
* (e.g. at UserManagment) |
| 44 |
|
* |
| 45 |
|
* Revision 1.19 2003/04/18 15:40:51 joko |
| 46 |
|
* NEW: tree data handling |
| 47 |
|
* introduced new adapter: DataSource::Adapter::Free |
| 48 |
|
* enhanced datasource_handler_buildoptions: now handles a) case 'tree' b) _query[filter] |
| 49 |
|
* |
| 50 |
|
* Revision 1.18 2003/04/11 00:55:49 joko |
| 51 |
|
* updated 'datasource_handler_buildoptions': action dispatcher now aware of 'delete' |
| 52 |
|
* |
| 53 |
|
* Revision 1.17 2003/04/09 02:07:33 joko |
| 54 |
|
* CHANGE: renamed key 'classname' through 'nodename' |
| 55 |
|
* |
| 56 |
|
* Revision 1.16 2003/04/08 17:55:20 joko |
| 57 |
|
* CHANGE: renamed property 'datasource' to 'transport' |
| 58 |
|
* NEW: new case 'method' in 'function datasource_handler_buildoptions' |
| 59 |
|
* minor fixes: updated logging/debugging messages |
| 60 |
|
* |
| 61 |
|
* Revision 1.15 2003/04/06 04:46:33 joko |
| 62 |
|
* renamed linking function |
| 63 |
|
* mozilla fixes |
| 64 |
|
* |
| 65 |
|
* Revision 1.14 2003/04/04 21:19:21 joko |
| 66 |
|
* modified exception handling (enhanced, purged redundant code) |
| 67 |
|
* |
| 68 |
|
* Revision 1.13 2003/04/04 02:37:14 jonen |
| 69 |
|
* _query[action] == write |
| 70 |
|
* |
| 71 |
|
* Revision 1.12 2003/03/29 08:00:48 joko |
| 72 |
|
* modified ErrorBoxing |
| 73 |
|
* |
| 74 |
|
* Revision 1.11 2003/03/28 06:45:26 joko |
| 75 |
|
* VERBOSE mode |
| 76 |
|
* |
| 77 |
|
* Revision 1.10 2003/03/28 03:01:02 joko |
| 78 |
|
* more fancy debugging-output |
| 79 |
|
* |
| 80 |
|
* Revision 1.9 2003/03/27 16:24:26 jonen |
| 81 |
|
* + mugled namespace |
| 82 |
|
* + added enhanced 'queryData' |
| 83 |
|
* |
| 84 |
|
* Revision 1.8 2003/03/20 07:22:14 jonen |
| 85 |
|
* + modified case 'object' to 'objects' |
| 86 |
|
* (cause its loads all *objects* of a given classname) |
| 87 |
|
* |
| 88 |
|
* Revision 1.7 2003/03/11 01:43:00 joko |
| 89 |
|
* + fixed metadata for phpDocumentor |
| 90 |
|
* |
| 91 |
|
* Revision 1.6 2003/03/11 01:22:25 joko |
| 92 |
|
* + fixed metadata for phpDocumentor |
| 93 |
|
* |
| 94 |
|
* Revision 1.5 2003/03/11 00:12:49 joko |
| 95 |
|
* + fixed metadata for phpDocumentor |
| 96 |
|
* |
| 97 |
|
* Revision 1.4 2003/03/10 23:25:03 joko |
| 98 |
|
* + fixed metadata for phpDocumentor |
| 99 |
|
* |
| 100 |
* Revision 1.3 2003/03/09 15:50:36 joko |
* Revision 1.3 2003/03/09 15:50:36 joko |
| 101 |
* + additional metadata for Autodia |
* + additional metadata for Autodia |
| 102 |
* |
* |
| 130 |
* Revision 1.1 2003/03/01 03:10:40 joko |
* Revision 1.1 2003/03/01 03:10:40 joko |
| 131 |
* + initial commit |
* + initial commit |
| 132 |
* |
* |
|
* |
|
| 133 |
*/ |
*/ |
| 134 |
|
|
| 135 |
/** |
/** |
| 207 |
* --- snipped into here from above --- |
* --- snipped into here from above --- |
| 208 |
* </pre> |
* </pre> |
| 209 |
* |
* |
| 210 |
* |
* <p> |
| 211 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
| 212 |
* |
* |
| 213 |
* Data::Driver::Proxy instantiates "handlers" below itself |
* Data::Driver::Proxy instantiates "handlers" below itself |
| 228 |
* </pre> |
* </pre> |
| 229 |
* |
* |
| 230 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
| 231 |
|
* </p> |
| 232 |
* |
* |
| 233 |
* |
* |
| 234 |
|
* <p> |
| 235 |
* <b>How to use?</b> |
* <b>How to use?</b> |
| 236 |
* |
* |
| 237 |
* Pass an array holding "locator metadata" to the constructor. |
* Pass an array holding "locator metadata" to the constructor. |
| 238 |
* GenericDataSource takes care of the rest. |
* GenericDataSource takes care of the rest. |
| 239 |
* |
* |
| 240 |
|
* <pre> |
| 241 |
* Pass an array to the constructor: (e.g.) |
* Pass an array to the constructor: (e.g.) |
| 242 |
* |
* |
| 243 |
* 1. doing rpc-calls.... |
* 1. doing rpc-calls.... |
| 259 |
* $source = ne w GenericDataSource($locator); |
* $source = ne w GenericDataSource($locator); |
| 260 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
| 261 |
* </code> |
* </code> |
| 262 |
|
* </pre> |
| 263 |
|
* </p> |
| 264 |
|
* |
| 265 |
* |
* |
| 266 |
* @link http://www.netfrag.org/~joko/ |
* @link http://www.netfrag.org/~joko/ |
| 267 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
| 279 |
* @subpackage DataSource |
* @subpackage DataSource |
| 280 |
* @name DataSource::Generic |
* @name DataSource::Generic |
| 281 |
* |
* |
| 282 |
* @todo |
* @todo this: |
| 283 |
* <ul> |
* o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles |
| 284 |
* o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles |
* o implement another Data::Driver::Proxy container |
|
* o implement another Data::Driver::Proxy container |
|
|
* </ul> |
|
| 285 |
* |
* |
| 286 |
|
* <pre> |
| 287 |
// !!!!!!!! THIS IS THE PROBLEM !!!!!!!! |
* !!!!!!!! THIS IS THE PROBLEM !!!!!!!! |
| 288 |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
* !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
| 289 |
// |
* |
| 290 |
// THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy |
* THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy |
| 291 |
// inheritance trees at the same time, which is *not* possible at |
* inheritance trees at the same time, which is *not* possible at |
| 292 |
// declare-time. We *do* need some runtime-infrastructure to solve this! |
* declare-time. We *do* need some runtime-infrastructure to solve this! |
| 293 |
// |
* |
| 294 |
// TODO: move build- and check-locator stuff from ObjectList to this place!!! |
* TODO: move build- and check-locator stuff from ObjectList to this place!!! |
| 295 |
// |
* |
| 296 |
// ABOUT: |
* ABOUT: |
| 297 |
// 1. otherwhere: WebApp - scope: |
* 1. otherwhere: WebApp - scope: |
| 298 |
// x handles page vs. block vs. widget; dispatches MVC-View |
* x handles page vs. block vs. widget; dispatches MVC-View |
| 299 |
// 2. here: DataSource - scope: |
* 2. here: DataSource - scope: |
| 300 |
// x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.)) |
* x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.)) |
| 301 |
// o clean implementation using a DesignPattern::AdapterProxy |
* o clean implementation using a DesignPattern::AdapterProxy |
| 302 |
// |
* </pre> |
| 303 |
|
* |
| 304 |
*/ |
* |
| 305 |
|
*/ |
| 306 |
class DataSource_Generic extends DesignPattern_AdapterProxy { |
class DataSource_Generic extends DesignPattern_AdapterProxy { |
| 307 |
|
|
| 308 |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
| 325 |
* other presets. |
* other presets. |
| 326 |
* |
* |
| 327 |
* See '_buildLocator' which acts as a dispatcher |
* See '_buildLocator' which acts as a dispatcher |
| 328 |
* depending on $_options[datasource]. |
* depending on $_options[transport]. |
| 329 |
* (main dispatching level) |
* (main dispatching level) |
| 330 |
* |
* |
| 331 |
* The structure of a full blown locator looks like this: |
* The structure of a full blown locator looks like this: |
| 414 |
function DataSource_Generic( &$locator, $query ) { |
function DataSource_Generic( &$locator, $query ) { |
| 415 |
|
|
| 416 |
// copy parameter from query to locator |
// copy parameter from query to locator |
| 417 |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_'); |
//$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_'); |
| 418 |
//$this->_locator->_datasource_type = $query[datasource]; |
//$this->_locator->_datasource_type = $query[transport]; |
| 419 |
//$locator[_datasource_type] = $query[datasource]; |
//$locator[_datasource_type] = $query[transport]; |
| 420 |
|
|
| 421 |
/** |
/** |
| 422 |
* <!-- Autodia --> |
* <!-- Autodia --> |
| 426 |
*/ |
*/ |
| 427 |
|
|
| 428 |
// build master locator |
// build master locator |
| 429 |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) ); |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) ); |
| 430 |
//exit; |
//exit; |
| 431 |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
//$this->_locator = php::mkComponent('DataSource::Locator'); |
| 432 |
|
|
| 447 |
*/ |
*/ |
| 448 |
|
|
| 449 |
//$this->set_locator( $locator ); |
//$this->set_locator( $locator ); |
| 450 |
|
//print "query: " . Dumper($query) . "<br>"; |
| 451 |
$this->set_query( $query ); |
$this->set_query( $query ); |
| 452 |
|
|
| 453 |
|
|
| 464 |
// pre-flight: check locator metadata |
// pre-flight: check locator metadata |
| 465 |
//$locator->build(); |
//$locator->build(); |
| 466 |
if (!$this->_locator->check()) { |
if (!$this->_locator->check()) { |
| 467 |
user_error("locator-check failed."); |
user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) ); |
| 468 |
exit; |
//exit; |
| 469 |
//return; |
return; |
| 470 |
} |
} |
| 471 |
|
|
| 472 |
//exit; |
//exit; |
| 525 |
// ... resolves this._modules.adapter._id to this._modules.adapter._module |
// ... resolves this._modules.adapter._id to this._modules.adapter._module |
| 526 |
|
|
| 527 |
switch ($locator->_adapter_type) { |
switch ($locator->_adapter_type) { |
| 528 |
|
|
| 529 |
case 'phpHtmlLib': |
case 'phpHtmlLib': |
| 530 |
//$adapter_arguments = $args[title]; |
//$adapter_arguments = $args[title]; |
| 531 |
|
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
|
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource'); |
|
| 532 |
|
|
| 533 |
// in order to let the Adapter communicate with the Proxy, |
// in order to let the Adapter communicate with the Proxy, |
| 534 |
// instantiate a wrapper method in a third namespace via |
// instantiate a wrapper method in a third namespace via |
| 535 |
// Exporter::export_symbol(from, to) |
// Exporter::export_symbol(from, to) |
| 536 |
$this->set_adapter_options($this); |
$this->set_adapter_options($this); |
| 537 |
|
break; |
| 538 |
|
|
| 539 |
|
// NEW [2003-04-17]: Freedom for the adapter! |
| 540 |
|
// phpHtmlLib didn't have a tree widget, but PEAR does. |
| 541 |
|
// So: Free us from the phpHtmlLib-adapter in this case. |
| 542 |
|
case 'free': |
| 543 |
|
$this->set_adapter_module('DataSource::Adapter::Free'); |
| 544 |
|
$this->set_adapter_options($this); |
| 545 |
break; |
break; |
| 546 |
|
|
| 547 |
default: |
default: |
| 548 |
user_error("DataSource::GenericDataSource: no Adapter could be selected!"); |
user_error("DataSource::Generic: no Adapter could be selected: \$locator->_adapter_type='$locator->_adapter_type'"); |
| 549 |
break; |
break; |
| 550 |
} |
} |
| 551 |
|
|
| 708 |
|
|
| 709 |
|
|
| 710 |
//$this->set_component_name( $proxy_name ); |
//$this->set_component_name( $proxy_name ); |
| 711 |
$this->set_component_options( $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) ); |
$this->set_component_options( $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 0 ) ) ); |
| 712 |
//print Dumper($this); |
//print Dumper($this); |
| 713 |
//exit; |
//exit; |
| 714 |
|
|
| 740 |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
| 741 |
switch ($this->_query[metatype]) { |
switch ($this->_query[metatype]) { |
| 742 |
case 'data': |
case 'data': |
| 743 |
//$command = 'queryData'; |
$command = 'queryData'; |
| 744 |
$command = 'getObjects'; // FIXME!!! |
|
| 745 |
|
//$command = 'getObjects'; // FIXME!!! |
| 746 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
| 747 |
|
/* |
| 748 |
$args = array(); |
$args = array(); |
| 749 |
switch ($this->_query[vartype]) { |
switch ($this->_query[vartype]) { |
| 750 |
case 'object': |
case 'objects': |
| 751 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
| 752 |
$msg = "_query[vartype] == 'object' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 753 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 754 |
} |
} |
| 755 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
| 756 |
break; |
break; |
| 757 |
} |
} |
| 758 |
break; |
*/ |
| 759 |
|
$query_args = array(); |
| 760 |
|
|
| 761 |
|
$msg_prefix = "DataSource::Generic::datasource_handler_buildoptions failed: "; |
| 762 |
|
switch ($this->_query[abstract_type]) { |
| 763 |
|
case 'item': |
| 764 |
|
if (!$this->_query[nodename] && $this->_query[action] != 'create') { |
| 765 |
|
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
| 766 |
|
user_error($msg_prefix . $msg); |
| 767 |
|
} elseif($this->_query[action] == 'create' && $this->_query[parent]) { |
| 768 |
|
if($this->_query[nodename]) { $query_args[node_class] = $this->_query[nodename]; } |
| 769 |
|
if($this->_query['hash_key']) { $query_args['hash_key'] = $this->_query['hash_key']; } |
| 770 |
|
$query_args[nodename] = $this->_query[ident]; |
| 771 |
|
$query_args[parent][guid] = $this->_query[parent][guid]; |
| 772 |
|
$query_args[parent][nodename] = $this->_query[parent][nodename]; |
| 773 |
|
} elseif($this->_query[parent]) { |
| 774 |
|
$query_args[guid] = $this->_query[ident]; |
| 775 |
|
$query_args[nodename] = $this->_query[nodename]; |
| 776 |
|
$query_args[parent][guid] = $this->_query[parent][guid]; |
| 777 |
|
$query_args[parent][nodename] = $this->_query[parent][nodename]; |
| 778 |
|
} else { |
| 779 |
|
$query_args[guid] = $this->_query[ident]; |
| 780 |
|
$query_args[nodename] = $this->_query[nodename]; |
| 781 |
|
// 2003-11-17 NEW: use expand flag for real obj expand at backend |
| 782 |
|
if ($this->_query[expand]) {$query_args[expand] = 1; } |
| 783 |
|
} |
| 784 |
|
//print "generic_source->debug: args " . Dumper($query_args) . "<br>"; |
| 785 |
|
break; |
| 786 |
|
case 'list': |
| 787 |
|
if (!$this->_query[nodename]) { |
| 788 |
|
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
| 789 |
|
user_error($msg_prefix . $msg); |
| 790 |
|
} elseif($this->_query[parent]) { |
| 791 |
|
//if($this->_query[nodename]) { $query_args[node_class] = $this->_query[nodename]; } |
| 792 |
|
//if($this->_query['hash_key']) { $query_args['hash_key'] = $this->_query['hash_key']; } |
| 793 |
|
//$query_args[nodename] = $this->_query[ident]; |
| 794 |
|
$query_args[parent][guid] = $this->_query[parent][guid]; |
| 795 |
|
$query_args[parent][nodename] = $this->_query[parent][nodename]; |
| 796 |
|
} |
| 797 |
|
//array_push($query_args, $this->_query[nodename]); |
| 798 |
|
$query_args[nodename] = $this->_query[nodename]; |
| 799 |
|
if($this->_query[list_meta]) { $query_args[list_meta] = $this->_query[list_meta]; } |
| 800 |
|
if(is_array($this->_query[owner])) { $query_args[owner] = $this->_query[owner]; } |
| 801 |
|
break; |
| 802 |
|
case 'tree': |
| 803 |
|
/* |
| 804 |
|
if (!$this->_query[nodename]) { |
| 805 |
|
$msg = "_query[vartype] == 'objects' requires _query[nodename]"; |
| 806 |
|
user_error($msg_prefix . $msg); |
| 807 |
|
} |
| 808 |
|
*/ |
| 809 |
|
$query_args[guid] = $this->_query[ident]; |
| 810 |
|
//$query_args[nodename] = $this->_query[nodename]; |
| 811 |
|
break; |
| 812 |
|
default: |
| 813 |
|
$msg = "\$this->_query[abstract_type] could not be dispatched as 'item', 'list' or 'tree'."; |
| 814 |
|
user_error($msg_prefix . $msg); |
| 815 |
|
break; |
| 816 |
|
} |
| 817 |
|
|
| 818 |
|
// filter??? |
| 819 |
|
//print "Filter: " . Dumper($this->_query[filter]) . "<br>"; |
| 820 |
|
if ($this->_query[filter]) { |
| 821 |
|
$query_args[filter] = $this->_query[filter]; |
| 822 |
|
} |
| 823 |
|
|
| 824 |
|
// dispatch action |
| 825 |
|
//print "Action: " . $this->_query[action] . "<br>"; |
| 826 |
|
if ($this->_query[action] == 'write') { |
| 827 |
|
$query_args[action] = $this->_query[action]; |
| 828 |
|
$query_args[data] = $this->_query[data]; |
| 829 |
|
} elseif ($this->_query[action] == 'delete') { |
| 830 |
|
$query_args[action] = $this->_query[action]; |
| 831 |
|
} elseif ($this->_query[action] == 'create') { |
| 832 |
|
$query_args[action] = $this->_query[action]; |
| 833 |
|
} elseif ($this->_query[action] == 'select') { |
| 834 |
|
$query_args[action] = $this->_query[action]; |
| 835 |
|
} |
| 836 |
|
|
| 837 |
|
$args = array( |
| 838 |
|
'data_type' => $this->_query[abstract_type], |
| 839 |
|
'query_args' => $query_args |
| 840 |
|
); |
| 841 |
|
break; |
| 842 |
|
|
| 843 |
|
// querySchema |
| 844 |
case 'schema': |
case 'schema': |
| 845 |
|
//print "Testing schema:" . "<br>"; |
| 846 |
$command = 'querySchema'; |
$command = 'querySchema'; |
| 847 |
|
$args = array( $this->_query[filter] ); |
| 848 |
|
break; |
| 849 |
|
|
| 850 |
|
// remoteMethod |
| 851 |
|
case 'method': |
| 852 |
|
$command = $this->_query[method]; |
| 853 |
|
//$args = $this->_query[args]; |
| 854 |
|
// FIX |
| 855 |
|
$args = array( $this->_query[args] ); |
| 856 |
break; |
break; |
| 857 |
|
|
| 858 |
} |
} |
| 859 |
|
|
| 860 |
|
|
| 861 |
|
// FIXME: bad behaviour? |
| 862 |
|
if (!is_array($args)) { $args = array( $args ); } |
| 863 |
|
|
| 864 |
|
//print Dumper($args); |
| 865 |
|
|
| 866 |
/* |
/* |
| 867 |
$this->_query[rpc_command] = $command; |
$this->_query[rpc_command] = $command; |
| 894 |
|
|
| 895 |
} |
} |
| 896 |
|
|
| 897 |
|
|
| 898 |
|
|
| 899 |
function &fetch_result() { |
function &fetch_result() { |
| 900 |
|
|
| 901 |
|
//print Dumper($this); |
| 902 |
|
|
| 903 |
$this->datasource_handler_buildoptions(); |
$this->datasource_handler_buildoptions(); |
| 904 |
|
|
| 905 |
$method = $this->_locator->_call[_method]; |
$call = $this->_locator->get_call(); |
| 906 |
$args = $this->_locator->_call[_arguments]; |
|
| 907 |
|
//print Dumper($call); |
| 908 |
|
//return; |
| 909 |
|
|
| 910 |
// pre-flight checks |
// pre-flight checks |
| 911 |
if (!$method) { |
if (!$call[method]) { |
| 912 |
$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."; |
| 913 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("DataSource::Generic: query_data() - failed: " . $msg); |
| 914 |
return; |
return; |
| 915 |
} |
} |
| 916 |
|
|
| 918 |
|
|
| 919 |
// do remote call here and get result |
// do remote call here and get result |
| 920 |
// FIXME: handle synchronous/asynchronous mode here!!! |
// FIXME: handle synchronous/asynchronous mode here!!! |
| 921 |
$this->datasource_handler_call($method, $args); |
$this->datasource_handler_call($call[method], $call[args]); |
| 922 |
|
|
| 923 |
|
|
| 924 |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
| 925 |
$proxy = $this->get_proxy(); |
$proxy = $this->get_proxy(); |
| 926 |
$this->_result = $proxy->getResult(); |
//HACK 2004-10-07: page-filter done by backend now, |
| 927 |
|
// before offset values filled with empty arrays |
| 928 |
|
//$this->_result = $proxy->getResult(); |
| 929 |
|
$result = $proxy->getResult(); |
| 930 |
|
if($result['total_rows']) { |
| 931 |
|
// debug |
| 932 |
|
//print "result: " . Dumper($result); |
| 933 |
|
$this->_result_count = $result['total_rows']; |
| 934 |
|
if($result[offset]) { |
| 935 |
|
$result_new = array(); |
| 936 |
|
for($i=0;$i<$result[offset];$i++) { |
| 937 |
|
array_push($result_new, array()); |
| 938 |
|
} |
| 939 |
|
foreach($result['payload'] as $key => $value) { |
| 940 |
|
array_push($result_new, $value); |
| 941 |
|
} |
| 942 |
|
$this->_result = $result_new; |
| 943 |
|
} else { |
| 944 |
|
$this->_result = $result['payload']; |
| 945 |
|
} |
| 946 |
|
} else { |
| 947 |
|
$this->_result = $result; |
| 948 |
|
$this->_result_count = sizeof($this->_result); |
| 949 |
|
} |
| 950 |
|
//print "result: " . Dumper($this->_result); |
| 951 |
//print "result: " . Dumper($this->_result); exit; |
//print "result: " . Dumper($this->_result); exit; |
| 952 |
|
|
|
$this->_result_count = sizeof($this->_result); |
|
| 953 |
|
|
| 954 |
// trace |
// trace |
| 955 |
if ($this->_debug[notice]) { |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
| 956 |
|
if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) { |
| 957 |
//print "_result = " . Dumper($this->_result); |
//print "_result = " . Dumper($this->_result); |
| 958 |
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>"; |
| 959 |
|
$this->draw_status_box(); |
| 960 |
} |
} |
| 961 |
|
|
| 962 |
return $this->_result; |
return $this->_result; |
| 963 |
|
|
| 964 |
} |
} |
| 965 |
|
|
| 966 |
|
function draw_status_box() { |
| 967 |
|
|
| 968 |
|
static $boxcount; |
| 969 |
|
|
| 970 |
|
$boxcount++; |
| 971 |
|
|
| 972 |
|
$box = container(); |
| 973 |
|
|
| 974 |
|
// box style |
| 975 |
|
$style = container( |
| 976 |
|
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
| 977 |
|
html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }') |
| 978 |
|
); |
| 979 |
|
$box->add( $style ); |
| 980 |
|
|
| 981 |
|
// box content |
| 982 |
|
$statusbox = html_div('box_dsg'); |
| 983 |
|
$statusbox->add( html_b("DataSource::Generic"), html_br() ); |
| 984 |
|
$locatorbox = html_div('box_dsg'); |
| 985 |
|
$locatorbox->set_id("locatorbox_$boxcount"); |
| 986 |
|
$locatorbox->add( Dumper($this->_locator) ); |
| 987 |
|
|
| 988 |
|
// FIXME: ie/mozilla? |
| 989 |
|
//$locatorbox->set_style('display:none;'); |
| 990 |
|
//$locatorbox->set_style('visibility:hidden;'); |
| 991 |
|
// already duplicate inside Tracer!!! |
| 992 |
|
$locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;'); |
| 993 |
|
|
| 994 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() ); |
| 995 |
|
$call = $this->_locator->get_call(); |
| 996 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
| 997 |
|
if (sizeof($call[args])) { |
| 998 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
| 999 |
|
} |
| 1000 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() ); |
| 1001 |
|
$box->add( $statusbox ); |
| 1002 |
|
|
| 1003 |
|
//print $box->render(); |
| 1004 |
|
trace( $box ); |
| 1005 |
|
|
| 1006 |
|
} |
| 1007 |
|
|
| 1008 |
|
|
| 1009 |
function &query_data() { |
function &query_data() { |
| 1010 |
//print "query!<br/>"; |
//print "query!<br/>"; |
| 1020 |
function &get_result() { |
function &get_result() { |
| 1021 |
return $this->_result; |
return $this->_result; |
| 1022 |
} |
} |
| 1023 |
|
|
| 1024 |
|
function get_result_count() { |
| 1025 |
|
return $this->_result_count; |
| 1026 |
|
} |
| 1027 |
|
|
| 1028 |
} |
} |
| 1029 |
|
|