| 9 |
*/ |
*/ |
| 10 |
|
|
| 11 |
/** |
/** |
| 12 |
|
* <b>Cvs-Log:</b> |
| 13 |
|
* |
| 14 |
|
* <pre> |
| 15 |
* $Id$ |
* $Id$ |
| 16 |
* |
* |
| 17 |
* $Log$ |
* $Log$ |
| 18 |
|
* Revision 1.8 2003/03/20 07:22:14 jonen |
| 19 |
|
* + modified case 'object' to 'objects' |
| 20 |
|
* (cause its loads all *objects* of a given classname) |
| 21 |
|
* |
| 22 |
|
* Revision 1.7 2003/03/11 01:43:00 joko |
| 23 |
|
* + fixed metadata for phpDocumentor |
| 24 |
|
* |
| 25 |
|
* Revision 1.6 2003/03/11 01:22:25 joko |
| 26 |
|
* + fixed metadata for phpDocumentor |
| 27 |
|
* |
| 28 |
|
* Revision 1.5 2003/03/11 00:12:49 joko |
| 29 |
|
* + fixed metadata for phpDocumentor |
| 30 |
|
* |
| 31 |
|
* Revision 1.4 2003/03/10 23:25:03 joko |
| 32 |
|
* + fixed metadata for phpDocumentor |
| 33 |
|
* |
| 34 |
|
* Revision 1.3 2003/03/09 15:50:36 joko |
| 35 |
|
* + additional metadata for Autodia |
| 36 |
|
* |
| 37 |
* Revision 1.2 2003/03/05 17:28:43 joko |
* Revision 1.2 2003/03/05 17:28:43 joko |
| 38 |
* updated docu (phpDocumentor testing....) |
* updated docu (phpDocumentor testing....) |
| 39 |
* |
* |
| 63 |
* |
* |
| 64 |
* Revision 1.1 2003/03/01 03:10:40 joko |
* Revision 1.1 2003/03/01 03:10:40 joko |
| 65 |
* + initial commit |
* + initial commit |
| 66 |
* |
* </pre> |
| 67 |
* |
* |
| 68 |
*/ |
*/ |
| 69 |
|
|
| 142 |
* --- snipped into here from above --- |
* --- snipped into here from above --- |
| 143 |
* </pre> |
* </pre> |
| 144 |
* |
* |
| 145 |
* |
* <p> |
| 146 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
| 147 |
* |
* |
| 148 |
* Data::Driver::Proxy instantiates "handlers" below itself |
* Data::Driver::Proxy instantiates "handlers" below itself |
| 163 |
* </pre> |
* </pre> |
| 164 |
* |
* |
| 165 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
| 166 |
|
* </p> |
| 167 |
* |
* |
| 168 |
* |
* |
| 169 |
|
* <p> |
| 170 |
* <b>How to use?</b> |
* <b>How to use?</b> |
| 171 |
* |
* |
| 172 |
* Pass an array holding "locator metadata" to the constructor. |
* Pass an array holding "locator metadata" to the constructor. |
| 173 |
* GenericDataSource takes care of the rest. |
* GenericDataSource takes care of the rest. |
| 174 |
* |
* |
| 175 |
|
* <pre> |
| 176 |
* Pass an array to the constructor: (e.g.) |
* Pass an array to the constructor: (e.g.) |
| 177 |
* |
* |
| 178 |
* 1. doing rpc-calls.... |
* 1. doing rpc-calls.... |
| 181 |
* type => 'rpc', |
* type => 'rpc', |
| 182 |
* metadata => array( Host => 'localhost', Port => '8765' ), |
* metadata => array( Host => 'localhost', Port => '8765' ), |
| 183 |
* ); |
* ); |
| 184 |
* $source = new GenericDataSource($locator); |
* $source = ne w GenericDataSource($locator); |
| 185 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
| 186 |
* </code> |
* </code> |
| 187 |
* |
* |
| 191 |
* type => 'mysql', |
* type => 'mysql', |
| 192 |
* dsn => 'known dsn markup', |
* dsn => 'known dsn markup', |
| 193 |
* ); |
* ); |
| 194 |
* $source = new GenericDataSource($locator); |
* $source = ne w GenericDataSource($locator); |
| 195 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
| 196 |
* </code> |
* </code> |
| 197 |
|
* </pre> |
| 198 |
|
* </p> |
| 199 |
|
* |
| 200 |
* |
* |
| 201 |
* @link http://www.netfrag.org/~joko/ |
* @link http://www.netfrag.org/~joko/ |
| 202 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
| 214 |
* @subpackage DataSource |
* @subpackage DataSource |
| 215 |
* @name DataSource::Generic |
* @name DataSource::Generic |
| 216 |
* |
* |
| 217 |
* @todo |
* @todo this: |
| 218 |
* <ul> |
* o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles |
| 219 |
* 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> |
|
| 220 |
* |
* |
| 221 |
|
* <pre> |
| 222 |
// !!!!!!!! THIS IS THE PROBLEM !!!!!!!! |
* !!!!!!!! THIS IS THE PROBLEM !!!!!!!! |
| 223 |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
* !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
| 224 |
// |
* |
| 225 |
// THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy |
* THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy |
| 226 |
// inheritance trees at the same time, which is *not* possible at |
* inheritance trees at the same time, which is *not* possible at |
| 227 |
// declare-time. We *do* need some runtime-infrastructure to solve this! |
* declare-time. We *do* need some runtime-infrastructure to solve this! |
| 228 |
// |
* |
| 229 |
// TODO: move build- and check-locator stuff from ObjectList to this place!!! |
* TODO: move build- and check-locator stuff from ObjectList to this place!!! |
| 230 |
// |
* |
| 231 |
// ABOUT: |
* ABOUT: |
| 232 |
// 1. otherwhere: WebApp - scope: |
* 1. otherwhere: WebApp - scope: |
| 233 |
// x handles page vs. block vs. widget; dispatches MVC-View |
* x handles page vs. block vs. widget; dispatches MVC-View |
| 234 |
// 2. here: DataSource - scope: |
* 2. here: DataSource - scope: |
| 235 |
// 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.)) |
| 236 |
// o clean implementation using a DesignPattern::AdapterProxy |
* o clean implementation using a DesignPattern::AdapterProxy |
| 237 |
// |
* </pre> |
| 238 |
|
* |
| 239 |
*/ |
* |
| 240 |
|
*/ |
| 241 |
class DataSource_Generic extends DesignPattern_AdapterProxy { |
class DataSource_Generic extends DesignPattern_AdapterProxy { |
| 242 |
|
|
| 243 |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
| 353 |
//$this->_locator->_datasource_type = $query[datasource]; |
//$this->_locator->_datasource_type = $query[datasource]; |
| 354 |
//$locator[_datasource_type] = $query[datasource]; |
//$locator[_datasource_type] = $query[datasource]; |
| 355 |
|
|
| 356 |
|
/** |
| 357 |
|
* <!-- Autodia --> |
| 358 |
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
| 359 |
|
* $this->_locator = new DataSource_Locator() |
| 360 |
|
* |
| 361 |
|
*/ |
| 362 |
|
|
| 363 |
// build master locator |
// build master locator |
| 364 |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) ); |
$this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) ); |
| 365 |
//exit; |
//exit; |
| 406 |
//exit; |
//exit; |
| 407 |
|
|
| 408 |
|
|
| 409 |
|
/** |
| 410 |
|
* <!-- Autodia --> |
| 411 |
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
| 412 |
|
* $proxy = new DesignPattern_RemoteProxy() |
| 413 |
|
* |
| 414 |
|
*/ |
| 415 |
|
|
| 416 |
|
|
| 417 |
// --- Proxy selector/dispatcher ... |
// --- Proxy selector/dispatcher ... |
| 418 |
|
|
| 419 |
switch ($this->_locator->_datasource_type) { |
switch ($this->_locator->_datasource_type) { |
| 509 |
// $this->create_handler(); |
// $this->create_handler(); |
| 510 |
|
|
| 511 |
|
|
| 512 |
|
/** |
| 513 |
|
* <!-- Autodia --> |
| 514 |
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
| 515 |
|
* $adapter = new DataSource_Adapter_phpHtmlLib_DataListSource() |
| 516 |
|
* |
| 517 |
|
*/ |
| 518 |
|
|
| 519 |
// V1: |
// V1: |
| 520 |
//$this->create_adapter($adapter_module, $this->function, $this->arguments); |
//$this->create_adapter($adapter_module, $this->function, $this->arguments); |
| 521 |
|
|
| 672 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
| 673 |
$args = array(); |
$args = array(); |
| 674 |
switch ($this->_query[vartype]) { |
switch ($this->_query[vartype]) { |
| 675 |
case 'object': |
case 'objects': |
| 676 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
| 677 |
$msg = "_query[vartype] == 'object' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 678 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
| 679 |
} |
} |
| 680 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |