/[cvs]/nfo/php/libs/org.netfrag.glib/DataSource/Generic.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/DataSource/Generic.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Wed Mar 5 12:04:00 2003 UTC revision 1.19 by joko, Fri Apr 18 15:40:51 2003 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /**  /**
3   * This file contains the GenericDataSource child class   * This file contains the GenericDataSource child class
  * that may use arbitrary code modules as database handlers.  
  * It's aims are to get together:  
  *   o phpHtmlLibs "source-handlers"  
  *   o PEAR's database handlers  
  *   o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)  
4   *   *
5   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
6   * @package phpHtmlLib   * @package org.netfrag.glib
7   * @module GenericDataSource   * @name DataSource::Generic
8   *   *
9   */   */
10    
11  /**  /**
12     * Cvs-Log:
13     *
14   * $Id$   * $Id$
15   *   *
16   * $Log$   * $Log$
17     * Revision 1.19  2003/04/18 15:40:51  joko
18     * NEW: tree data handling
19     *   introduced new adapter: DataSource::Adapter::Free
20     *   enhanced datasource_handler_buildoptions: now handles a) case 'tree'  b) _query[filter]
21     *
22     * Revision 1.18  2003/04/11 00:55:49  joko
23     * updated 'datasource_handler_buildoptions': action dispatcher now aware of 'delete'
24     *
25     * Revision 1.17  2003/04/09 02:07:33  joko
26     * CHANGE: renamed key 'classname' through 'nodename'
27     *
28     * Revision 1.16  2003/04/08 17:55:20  joko
29     * CHANGE: renamed property 'datasource' to 'transport'
30     * NEW: new case 'method' in 'function datasource_handler_buildoptions'
31     * minor fixes: updated logging/debugging messages
32     *
33     * Revision 1.15  2003/04/06 04:46:33  joko
34     * renamed linking function
35     * mozilla fixes
36     *
37     * Revision 1.14  2003/04/04 21:19:21  joko
38     * modified exception handling (enhanced, purged redundant code)
39     *
40     * Revision 1.13  2003/04/04 02:37:14  jonen
41     * _query[action] == write
42     *
43     * Revision 1.12  2003/03/29 08:00:48  joko
44     * modified ErrorBoxing
45     *
46     * Revision 1.11  2003/03/28 06:45:26  joko
47     * VERBOSE mode
48     *
49     * Revision 1.10  2003/03/28 03:01:02  joko
50     * more fancy debugging-output
51     *
52     * Revision 1.9  2003/03/27 16:24:26  jonen
53     * + mugled namespace
54     * + added enhanced 'queryData'
55     *
56     * Revision 1.8  2003/03/20 07:22:14  jonen
57     * + modified case 'object' to 'objects'
58     *   (cause its loads all *objects* of a given classname)
59     *
60     * Revision 1.7  2003/03/11 01:43:00  joko
61     * + fixed metadata for phpDocumentor
62     *
63     * Revision 1.6  2003/03/11 01:22:25  joko
64     * + fixed metadata for phpDocumentor
65     *
66     * Revision 1.5  2003/03/11 00:12:49  joko
67     * + fixed metadata for phpDocumentor
68     *
69     * Revision 1.4  2003/03/10 23:25:03  joko
70     * + fixed metadata for phpDocumentor
71     *
72     * Revision 1.3  2003/03/09 15:50:36  joko
73     * + additional metadata for Autodia
74     *
75     * Revision 1.2  2003/03/05 17:28:43  joko
76     * updated docu (phpDocumentor testing....)
77     *
78   * Revision 1.1  2003/03/05 12:04:00  joko   * Revision 1.1  2003/03/05 12:04:00  joko
79   * + initial commit, from GenericDataSource   * + initial commit, from GenericDataSource
80   *   *
# Line 44  Line 102 
102   * Revision 1.1  2003/03/01 03:10:40  joko   * Revision 1.1  2003/03/01 03:10:40  joko
103   * + initial commit   * + initial commit
104   *   *
  *  
105   */   */
106    
107  /**  /**
# Line 71  Line 128 
128    // require_once("PEAR.php");   // FIXME: what about PEAR::XML::RPC?    // require_once("PEAR.php");   // FIXME: what about PEAR::XML::RPC?
129    // require_once("DB.php");    // require_once("DB.php");
130    
131    
132    loadModule('DesignPattern::Proxy');
133    loadModule('DesignPattern::TransparentProxy');
134    loadModule('DesignPattern::RemoteProxy');
135    
136    //class GenericDataSource extends MemoryDataSource {
137    //class GenericDataSource extends DesignPattern_Proxy {
138    //class GenericDataSource extends DesignPattern_RemoteProxy {
139    //class GenericDataSource extends DesignPattern_TransparentProxy {
140    
141    //class GenericDataSource extends MemoryDataSource {
142    //loadModule("DataSource::Proxy::Memory");
143    //class GenericDataSource extends DataSource_Proxy_Memory {
144    //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
145    //class DataSource_GenericDataSource extends DesignPattern_Proxy {
146    //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
147    
148    // now independent!!! new class-inheritance-tree possible now!
149    // solved by having an Adapter *and* a Proxy here!
150    //class GenericDataSource {
151    
152    loadModule('DesignPattern::AdapterProxy');
153    
154    
155    
156  /**  /**
157   * This GenericDataSource child class is *completely* independent   * This GenericDataSource child class is *completely* independent
158   * of a specific storage implementation and intended to be a wrapper   * of a specific storage implementation and intended to be a wrapper
159   * class on the way from phpHtmlLib to Xyz.   * class on the way from phpHtmlLib to Xyz. <br>
160   *    ("Yyz" gets represented by Data::Storage by now.....)   *    ("Yyz" gets represented by Data::Storage by now.....)
161   *   *
162   * GenericDataSource interacts with an intermediate "proxy" object   * GenericDataSource interacts with an intermediate "proxy" object
163   * (e.g. Data::Driver::Proxy) when doing queries.   * (e.g. Data::Driver::Proxy) when doing queries. <br>
164     * <pre>
165   *    Don't mix this up with a persistent database handle which gets   *    Don't mix this up with a persistent database handle which gets
166   *    reused each and every time for different queries.   *    reused each and every time for different queries.
167   *    Here *is* a new instance of Data::Driver::Proxy for *each* query.   *    Here *is* a new instance of Data::Driver::Proxy for *each* query.
168     * </pre>
169   *   *
170   * But the point is: Caching! The actual *data* isn't read redundant!   * But the point is: Caching! The actual *data* isn't read redundant!
171   *   *
172     * <pre>
173     * --- snipped into here from above ---
174     * that may use arbitrary code modules as database handlers.
175     * It's aims are to get together:
176     *   o phpHtmlLibs "source-handlers"
177     *   o PEAR's database handlers
178     *   o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)
179     * --- snipped into here from above ---
180     * </pre>
181   *   *
182     * <p>
183   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------
184   *   *
185   * Data::Driver::Proxy instantiates "handlers" below itself   * Data::Driver::Proxy instantiates "handlers" below itself
# Line 95  Line 189 
189   * One worker already implemented is Data::Driver::RPC::Remote, which   * One worker already implemented is Data::Driver::RPC::Remote, which
190   * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.   * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.
191   *   *
192     * <pre>
193   * ---  refactored here, but: redundant somehow  ---   * ---  refactored here, but: redundant somehow  ---
194   * Data::Driver::Proxy uses a PEAR XML::RPC object to actually   * Data::Driver::Proxy uses a PEAR XML::RPC object to actually
195   * talk HTTP and serialize data chunks to and from XML,   * talk HTTP and serialize data chunks to and from XML,
# Line 102  Line 197 
197   * It "proxies" arbitrary data chunks a) inside a native php4 session,   * It "proxies" arbitrary data chunks a) inside a native php4 session,
198   * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.   * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.
199   * ---  refactored here, but: redundant somehow  ---   * ---  refactored here, but: redundant somehow  ---
200     * </pre>
201   *   *
202   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------
203     * </p>
204   *   *
205   *   *
206   * How to use?   * <p>
207     * <b>How to use?</b>
208   *   *
209   * Pass an array holding "locator metadata" to the constructor.   * Pass an array holding "locator metadata" to the constructor.
210   * GenericDataSource takes care of the rest.   * GenericDataSource takes care of the rest.
211   *   *
212     * <pre>
213   * Pass an array to the constructor: (e.g.)   * Pass an array to the constructor: (e.g.)
214   *   *
215   *  1. doing rpc-calls....   *  1. doing rpc-calls....
216     *    <code>
217   *    $locator = array(   *    $locator = array(
218   *      type => 'rpc',   *      type => 'rpc',
219   *      metadata => array( Host => 'localhost', Port => '8765' ),   *      metadata => array( Host => 'localhost', Port => '8765' ),
220   *    );   *    );
221   *    $source = new GenericDataSource($locator);   *    $source = ne w GenericDataSource($locator);
222   *    $this->set_data_source( &$source );   *    $this->set_data_source( &$source );
223     *    </code>
224   *   *
225   *  2. [proposal] common datahandles....   *  2. [proposal] common datahandles....
226     *    <code>
227   *    $locator = array(   *    $locator = array(
228   *      type => 'mysql',   *      type => 'mysql',
229   *      dsn => 'known dsn markup',   *      dsn => 'known dsn markup',
230   *    );   *    );
231   *    $source = new GenericDataSource($locator);   *    $source = ne w GenericDataSource($locator);
232   *    $this->set_data_source( &$source );   *    $this->set_data_source( &$source );
233     *    </code>
234     * </pre>
235     * </p>
236     *
237   *   *
238     * @link http://www.netfrag.org/~joko/
239   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
240     *
241     * @link http://www.netfrag.org/~jonen/
242   * @author Sebastian Utz <seut@tunemedia.de>   * @author Sebastian Utz <seut@tunemedia.de>
243     *
244   * @copyright (c) 2003 - All Rights reserved.   * @copyright (c) 2003 - All Rights reserved.
245     *
246     * @link http://www.gnu.org/licenses/lgpl.txt
247   * @license GNU LGPL (GNU Lesser General Public License)   * @license GNU LGPL (GNU Lesser General Public License)
248   *   *
  * @author-url http://www.netfrag.org/~joko/  
  * @author-url http://www.netfrag.org/~jonen/  
  * @license-url http://www.gnu.org/licenses/lgpl.txt  
249   *   *
250   * @package phpHtmlLib   * @package org.netfrag.glib
251   * @module GenericDataSource   * @subpackage DataSource
252     * @name DataSource::Generic
253     *
254     * @todo this:
255     * o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles
256     * o implement another Data::Driver::Proxy container
257     *
258     * <pre>
259     *              !!!!!!!!          THIS IS THE PROBLEM          !!!!!!!!
260     *    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!
261     *
262     *    THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy
263     *    inheritance trees at the same time, which is *not* possible at
264     *    declare-time. We *do* need some runtime-infrastructure to solve this!
265     *
266     *    TODO: move build- and check-locator stuff from ObjectList to this place!!!
267     *
268     *    ABOUT:
269     *      1. otherwhere: WebApp - scope:
270     *          x handles page vs. block vs. widget; dispatches MVC-View
271     *      2. here: DataSource - scope:
272     *          x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.))
273     *          o clean implementation using a DesignPattern::AdapterProxy
274     * </pre>
275   *   *
  */  
   
 /**  
  * Todo:  
  *  
  *  o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles  
  *  o implement another Data::Driver::Proxy container  
276   *   *
277   */   */
   
   
 //              !!!!!!!!          THIS IS THE PROBLEM          !!!!!!!!  
 //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!  
 //  
 //    THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy  
 //    inheritance trees at the same time, which is *not* possible at  
 //    declare-time. We *do* need some runtime-infrastructure to solve this!  
 //  
 //    TODO: move build- and check-locator stuff from ObjectList to this place!!!  
 //  
 //    ABOUT:  
 //      1. otherwhere: WebApp - scope:  
 //          x handles page vs. block vs. widget; dispatches MVC-View  
 //      2. here: DataSource - scope:  
 //          x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.))  
 //          o clean implementation using a DesignPattern::AdapterProxy  
 //  
   
 loadModule('DesignPattern::Proxy');  
 loadModule('DesignPattern::TransparentProxy');  
 loadModule('DesignPattern::RemoteProxy');  
   
 //class GenericDataSource extends MemoryDataSource {  
 //class GenericDataSource extends DesignPattern_Proxy {  
 //class GenericDataSource extends DesignPattern_RemoteProxy {  
 //class GenericDataSource extends DesignPattern_TransparentProxy {  
   
 //class GenericDataSource extends MemoryDataSource {  
 //loadModule("DataSource::Proxy::Memory");  
 //class GenericDataSource extends DataSource_Proxy_Memory {  
 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {  
 //class DataSource_GenericDataSource extends DesignPattern_Proxy {  
 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {  
   
 // now independent!!! new class-inheritance-tree possible now!  
 // solved by having an Adapter *and* a Proxy here!  
 //class GenericDataSource {  
   
 loadModule('DesignPattern::AdapterProxy');  
278  class DataSource_Generic extends DesignPattern_AdapterProxy {  class DataSource_Generic extends DesignPattern_AdapterProxy {
279    
280  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!
# Line 212  class DataSource_Generic extends DesignP Line 297  class DataSource_Generic extends DesignP
297      * other presets.      * other presets.
298      *      *
299      * See '_buildLocator' which acts as a dispatcher      * See '_buildLocator' which acts as a dispatcher
300      * depending on $_options[datasource].      * depending on $_options[transport].
301      * (main dispatching level)      * (main dispatching level)
302      *      *
303      * The structure of a full blown locator looks like this:      * The structure of a full blown locator looks like this:
# Line 301  class DataSource_Generic extends DesignP Line 386  class DataSource_Generic extends DesignP
386          function DataSource_Generic( &$locator, $query ) {          function DataSource_Generic( &$locator, $query ) {
387    
388                  // copy parameter from query to locator                  // copy parameter from query to locator
389                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_');                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_');
390                  //$this->_locator->_datasource_type = $query[datasource];                  //$this->_locator->_datasource_type = $query[transport];
391                  //$locator[_datasource_type] = $query[datasource];                  //$locator[_datasource_type] = $query[transport];
392                                    
393          /**
394           * <!-- Autodia -->
395           * can do: (this is metadata supplied for Autodia, don't delete!)
396           *  $this->_locator = new DataSource_Locator()
397           *
398           */
399    
400                  // build master locator                  // build master locator
401                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) );
402                  //exit;                  //exit;
403                  //$this->_locator = php::mkComponent('DataSource::Locator');                  //$this->_locator = php::mkComponent('DataSource::Locator');
404                                    
# Line 343  class DataSource_Generic extends DesignP Line 435  class DataSource_Generic extends DesignP
435      // pre-flight: check locator metadata      // pre-flight: check locator metadata
436        //$locator->build();        //$locator->build();
437        if (!$this->_locator->check()) {        if (!$this->_locator->check()) {
438          user_error("locator-check failed.");          user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) );
439          exit;          //exit;
440           //return;           return;
441        }        }
442    
443  //exit;  //exit;
444    
445    
446        /**
447         * <!-- Autodia -->
448         * can do: (this is metadata supplied for Autodia, don't delete!)
449         *  $proxy = new DesignPattern_RemoteProxy()
450         *
451         */
452    
453    
454      // --- Proxy selector/dispatcher ...      // --- Proxy selector/dispatcher ...
455            
456      switch ($this->_locator->_datasource_type) {      switch ($this->_locator->_datasource_type) {
# Line 396  class DataSource_Generic extends DesignP Line 496  class DataSource_Generic extends DesignP
496          // ... resolves this._modules.adapter._id to this._modules.adapter._module          // ... resolves this._modules.adapter._id to this._modules.adapter._module
497                    
498          switch ($locator->_adapter_type) {          switch ($locator->_adapter_type) {
499    
500            case 'phpHtmlLib':            case 'phpHtmlLib':
501              //$adapter_arguments = $args[title];              //$adapter_arguments = $args[title];
502                $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource');
             $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource');  
503                            
504              // in order to let the Adapter communicate with the Proxy,              // in order to let the Adapter communicate with the Proxy,
505              // instantiate a wrapper method in a third namespace via              // instantiate a wrapper method in a third namespace via
506              // Exporter::export_symbol(from, to)              // Exporter::export_symbol(from, to)
507              $this->set_adapter_options($this);              $this->set_adapter_options($this);
508                break;
509    
510              // NEW [2003-04-17]: Freedom for the adapter!
511              // phpHtmlLib didn't have a tree widget, but PEAR does.
512              // So: Free us from the phpHtmlLib-adapter in this case.
513              case 'free':
514                $this->set_adapter_module('DataSource::Adapter::Free');
515                $this->set_adapter_options($this);
516              break;              break;
517    
518            default:            default:
519              user_error("DataSource::GenericDataSource: no Adapter could be selected!");              user_error("DataSource::Generic: no Adapter could be selected: \$locator->_adapter_type='$locator->_adapter_type'");
520              break;              break;
521          }          }
522    
# Line 446  class DataSource_Generic extends DesignP Line 553  class DataSource_Generic extends DesignP
553        // $this->create_handler();        // $this->create_handler();
554    
555    
556          /**
557           * <!-- Autodia -->
558           * can do: (this is metadata supplied for Autodia, don't delete!)
559           *  $adapter = new DataSource_Adapter_phpHtmlLib_DataListSource()
560           *
561           */
562    
563        // V1:        // V1:
564        //$this->create_adapter($adapter_module, $this->function, $this->arguments);        //$this->create_adapter($adapter_module, $this->function, $this->arguments);
565    
# Line 597  class DataSource_Generic extends DesignP Line 711  class DataSource_Generic extends DesignP
711        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)
712          switch ($this->_query[metatype]) {          switch ($this->_query[metatype]) {
713            case 'data':            case 'data':
714              //$command = 'queryData';              $command = 'queryData';
715              $command = 'getObjects';   // FIXME!!!              
716                //$command = 'getObjects';   // FIXME!!!
717              //$this->_locator->set_option('metadata.command', $command);              //$this->_locator->set_option('metadata.command', $command);
718    /*
719              $args = array();              $args = array();
720              switch ($this->_query[vartype]) {              switch ($this->_query[vartype]) {
721                case 'object':                case 'objects':
722                  if (!$this->_query[classname]) {                  if (!$this->_query[classname]) {
723                    $msg = "_query[vartype] == 'object' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[classname]";
724                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error("DataSource::Generic: query_data() - failed: " . $msg);
725                  }                  }
726                  array_push($args, $this->_query[classname]);                  array_push($args, $this->_query[classname]);
727                  break;                  break;
728              }              }
729              break;   */
730                $query_args = array();
731                
732                 $msg_prefix = "DataSource::Generic::datasource_handler_buildoptions failed: ";
733                 switch ($this->_query[abstract_type]) {
734                  case 'item':
735                    if (!$this->_query[nodename]) {
736                      $msg = "_query[vartype] == 'objects' requires _query[nodename]";
737                      user_error($msg_prefix . $msg);
738                    }
739                    $query_args[guid] = $this->_query[ident];
740                    $query_args[nodename] = $this->_query[nodename];
741                    break;
742                  case 'list':
743                    if (!$this->_query[nodename]) {
744                      $msg = "_query[vartype] == 'objects' requires _query[nodename]";
745                      user_error($msg_prefix . $msg);
746                    }
747                    //array_push($query_args, $this->_query[nodename]);
748                    $query_args[nodename] = $this->_query[nodename];
749                    break;
750                  case 'tree':
751                    /*
752                    if (!$this->_query[nodename]) {
753                      $msg = "_query[vartype] == 'objects' requires _query[nodename]";
754                      user_error($msg_prefix . $msg);
755                    }
756                    */
757                    $query_args[guid] = $this->_query[ident];
758                    //$query_args[nodename] = $this->_query[nodename];
759                    break;
760                  default:
761                    $msg = "\$this->_query[abstract_type] could not be dispatched as 'item', 'list' or 'tree'.";
762                    user_error($msg_prefix . $msg);
763                    break;
764                }
765                
766                // filter???
767                if ($this->_query[filter]) {
768                  $query_args[filter] = $this->_query[filter];
769                }
770                
771                // dispatch action
772                if ($this->_query[action] == 'write') {
773                 $query_args[action] = $this->_query[action];
774                 $query_args[data] = $this->_query[data];
775                } elseif ($this->_query[action] == 'delete') {
776                 $query_args[action] = $this->_query[action];
777                }
778                
779                $args = array(
780                              'data_type' => $this->_query[abstract_type],
781                              'query_args' => $query_args
782                              );
783               break;
784    
785              // querySchema
786            case 'schema':            case 'schema':
787                //print "Testing schema:" . "<br>";
788              $command = 'querySchema';              $command = 'querySchema';
789                $args = array( $this->_query[filter] );
790                break;
791                
792              // remoteMethod
793              case 'method':
794                $command = $this->_query[method];
795                $args = $this->_query[args];
796              break;              break;
797    
798          }          }
799                
800          
801            // FIXME: bad behaviour?
802            if (!is_array($args)) { $args = array( $args ); }
803                    
804          /*          /*
805          $this->_query[rpc_command] = $command;          $this->_query[rpc_command] = $command;
# Line 648  class DataSource_Generic extends DesignP Line 832  class DataSource_Generic extends DesignP
832                
833    }    }
834    
835    
836    
837          function &fetch_result() {          function &fetch_result() {
838    
839          //print Dumper($this);
840                
841        $this->datasource_handler_buildoptions();        $this->datasource_handler_buildoptions();
842    
843        $method = $this->_locator->_call[_method];        $call = $this->_locator->get_call();
844        $args = $this->_locator->_call[_arguments];  
845                //print Dumper($call);
846          //return;
847    
848        // pre-flight checks        // pre-flight checks
849          if (!$method) {          if (!$call[method]) {
850            $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.";
851                          user_error("GenericDataSource::query_data() - failed: " . $msg);                          user_error("DataSource::Generic: query_data() - failed: " . $msg);
852            return;            return;
853          }          }
854    
# Line 666  class DataSource_Generic extends DesignP Line 856  class DataSource_Generic extends DesignP
856    
857        // do remote call here and get result        // do remote call here and get result
858        // FIXME: handle synchronous/asynchronous mode here!!!        // FIXME: handle synchronous/asynchronous mode here!!!
859          $this->datasource_handler_call($method, $args);          $this->datasource_handler_call($call[method], $call[args]);
860                    
861                    
862          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result
# Line 677  class DataSource_Generic extends DesignP Line 867  class DataSource_Generic extends DesignP
867          $this->_result_count = sizeof($this->_result);          $this->_result_count = sizeof($this->_result);
868    
869        // trace        // trace
870          if ($this->_debug[notice]) {          //if (constants::get('VERBOSE') && $this->_debug[notice]) {
871            if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) {
872            //print "_result = " . Dumper($this->_result);            //print "_result = " . Dumper($this->_result);
873            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>";
874              $this->draw_status_box();
875          }          }
876            
877          return $this->_result;          return $this->_result;
878    
879          }          }
880    
881      function draw_status_box() {
882    
883        static $boxcount;
884        
885        $boxcount++;
886    
887        $box = container();
888    
889        // box style
890        $style = container(
891          html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'),
892          html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }')
893        );
894        $box->add( $style );
895        
896        // box content
897        $statusbox = html_div('box_dsg');
898        $statusbox->add( html_b("DataSource::Generic"), html_br() );
899        $locatorbox = html_div('box_dsg');
900        $locatorbox->set_id("locatorbox_$boxcount");
901        $locatorbox->add( Dumper($this->_locator) );
902        
903        // FIXME: ie/mozilla?
904        //$locatorbox->set_style('display:none;');
905        //$locatorbox->set_style('visibility:hidden;');
906        // already duplicate inside Tracer!!!
907        $locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;');
908        
909        $statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() );
910        $call = $this->_locator->get_call();
911        $statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() );
912        if (sizeof($call[args])) {
913          $statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() );
914        }
915        $statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() );
916        $box->add( $statusbox );
917    
918        //print $box->render();
919        trace( $box );
920    
921      }
922    
923    
924    function &query_data() {    function &query_data() {
925      //print "query!<br/>";      //print "query!<br/>";
# Line 701  class DataSource_Generic extends DesignP Line 935  class DataSource_Generic extends DesignP
935    function &get_result() {    function &get_result() {
936      return $this->_result;      return $this->_result;
937    }    }
938      
939      function get_result_count() {
940        return $this->_result_count;
941      }
942                    
943  }  }
944    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.19

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed