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

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.11

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