/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/flibRPCDataListSource.inc
ViewVC logotype

Diff of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/flibRPCDataListSource.inc

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

revision 1.1 by jonen, Thu Jan 30 03:29:46 2003 UTC revision 1.2 by jonen, Fri Jan 31 08:44:53 2003 UTC
# Line 32  class flibRPCDataListSource extends Data Line 32  class flibRPCDataListSource extends Data
32           * this holds the headers read           * this holds the headers read
33           * from the top of the csv file           * from the top of the csv file
34           */           */
35          var $_object_type_keys = array();          var $_object_keys = array();
36                    
37    
38          /**          /**
# Line 42  class flibRPCDataListSource extends Data Line 42  class flibRPCDataListSource extends Data
42           *           *
43           */           */
44          function flibRPCDataListSource( $object_list ) {          function flibRPCDataListSource( $object_list ) {
45          $this->_object_list = $object_list;
46                  if (!file_exists($filename)) {        //print_r($object_list);
                         user_error("CSVFILEDataListSource:: (".$filename.") ".  
                                            "can't be found.");  
                 } else {  
                         $this->_filename = $filename;  
                         $this->_fp = fopen( $filename, 'r');  
                         if (!$this->_fp) {  
                                 user_error("CSVFILEDataListSource:: (".$filename.") ".  
                                                    "cannot be opened");  
                         }  
                 }  
                 $this->_maxlinelength = $maxline;  
47          }          }
48    
49    
# Line 72  class flibRPCDataListSource extends Data Line 61  class flibRPCDataListSource extends Data
61           * and search/sort           * and search/sort
62           */           */
63          function do_query() {          function do_query() {
64                  while ($line = fgets($this->_fp, $this->_maxlinelength)) {                  foreach ($this->_object_list as $value) {
65                          if ($this->add_data_row( $this->_construct_row(trim($line)))) {                          if ($this->add_data_row( $value)) {
66                                  $count++;                                  $count++;
67                          }                          }
68                  }                  }
69    
                 //close the file  
                 fclose($this->_fp);  
70                  $this->set_total_rows( $count );                  $this->set_total_rows( $count );
71                  $this->sort();                  $this->sort();
72          }          }
# Line 112  class flibRPCDataListSource extends Data Line 99  class flibRPCDataListSource extends Data
99          }          }
100    
101    
102    
103    
104          /**          /**
105           * This file trys to get the CSV header.           * This file trys to get the Object Hash Keys.
106           *           *
107           */           */
108          function _get_header() {          function _get_header() {
109                  $done = FALSE;                    foreach($this->_object_list[0] as $key => $value) {
110                  while (!$done) {                                  array_push($this->_object_keys, $key);
                         $line = trim(fgets($this->_fp,$this->_maxlinelength));  
                         if (strncmp('#', $line, 1) != 0 &&  
                                 strncmp('//', $line, 2) != 0 && !empty($line)) {  
                                 $this->_csv_headers = explode(',', $line);  
                                 $done = TRUE;  
111                          }                                      }            
                 }  
112          }          }
113    
           
         /**  
          * this is used to build a row  
          * from a csv line  
          *  
          * @param string - the original csv line from the file  
          * @return array  
          */  
         function _construct_row( $line ) {  
                 $row = NULL;  
                 if (strncmp('#', $line, 1) != 0 &&  
                         strncmp('//', $line, 2) != 0 && !empty($line)) {  
                         $tmp = explode(",", $line);  
                         //xmp_var_dump( $row );  
                         $row = array();  
                         foreach( $this->_csv_headers as $index => $name ) {  
                                 $row[$name] = $tmp[$index];  
                         }  
                 }  
114    
115                  //xmp_var_dump( $row );    function get_header() {
116                  return $row;      $this->_get_header();
117          }      return $this->_object_keys;
118              }            
119    
120    
121      function get_data_source() {
122        
123      }
124    
125    
126          /**          /**

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

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