/[cvs]/nfo/php/libs/org.netfrag.patches/phphtmllib/drivers/MemoryDataSource.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.patches/phphtmllib/drivers/MemoryDataSource.php

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

revision 1.2 by joko, Fri Mar 28 02:59:07 2003 UTC revision 1.7 by jonen, Thu Oct 7 14:16:39 2004 UTC
# Line 21  Line 21 
21   * $Id$   * $Id$
22   *   *
23   * $Log$   * $Log$
24     * Revision 1.7  2004/10/07 14:16:39  jonen
25     * + updates related to  HACK at DataSource/Generic (page-control!)
26     *
27     * Revision 1.6  2004/05/06 17:11:55  jonen
28     *  bugfix related to new phphtmllib-v2.4.1 of Apr 01, 2004
29     *
30     * Revision 1.5  2003/07/14 10:07:07  jonen
31     * clean up
32     *
33     * Revision 1.4  2003/04/18 17:26:14  joko
34     * minor fix: updated log api
35     *
36     * Revision 1.3  2003/04/18 13:48:27  joko
37     * minor updates to comments
38     *
39   * Revision 1.2  2003/03/28 02:59:07  joko   * Revision 1.2  2003/03/28 02:59:07  joko
40   * minor fix: prevent php-error if result is empty   * minor fix: prevent php-error if result is empty
41   *   *
# Line 98  Line 113 
113  class MemoryDataSource extends DataListSource {  class MemoryDataSource extends DataListSource {
114    
115  // it's free now!  // it's free now!
116  //class DataSource_Proxy_Memory {  //class MemoryDataSource {
117    
118    // not yet!  ;-)
119    
120    
121          /**          /**
# Line 151  class MemoryDataSource extends DataListS Line 168  class MemoryDataSource extends DataListS
168          $this->trace_payload('MemoryDataSource', $payload);          $this->trace_payload('MemoryDataSource', $payload);
169    
170        // transfer data to "memory"        // transfer data to "memory"
171          $this->_memory = &$payload;        $this->_memory = &$payload;
172    
173          }          }
174    
175    function read_labels_from_result() {    function read_labels_from_result() {
176      $this->set_labels($this->_result[0]);      // NEW 2004-10-07: read last entries labes instead of first,
177        //                because of a HACK at DataSource/Generic, first could be an empty one
178        $count = count($this->_result);
179        $this->set_labels($this->_result[$count-1]);
180      $this->propagate_schema();      $this->propagate_schema();
181    }    }
182    
# Line 187  class MemoryDataSource extends DataListS Line 207  class MemoryDataSource extends DataListS
207          function O_do_prequery() {          function O_do_prequery() {
208                  $this->_read_schema();                  $this->_read_schema();
209          }          }
         function O_do_prequery() {  
    }  
210        
211          /**          /**
212           * This function does the query           * This function does the query
# Line 202  class MemoryDataSource extends DataListS Line 220  class MemoryDataSource extends DataListS
220    
221          function handle_result() {          function handle_result() {
222            $this->debug("handle_result", "HANDLE RESULT!<br>");            $this->debug("handle_result", "HANDLE RESULT!<br>");
223         $this->propagate_result();         return $this->propagate_result();
224      }      }
225    
226      function propagate_result() {      function propagate_result() {
# Line 217  class MemoryDataSource extends DataListS Line 235  class MemoryDataSource extends DataListS
235            }            }
236          }          }
237        }        }
238                   if ($count > 0) {
239        $this->set_total_rows( $count );              $this->set_total_rows($count);
240        $this->sort();              $this->sort();
241                      return true;
242            } else {
243                return false;
244            }
245      }      }
246    
247          /**          /**
# Line 237  class MemoryDataSource extends DataListS Line 258  class MemoryDataSource extends DataListS
258                  $index = $this->get_data_index();                  $index = $this->get_data_index();
259                  $limit = $this->get_limit();                  $limit = $this->get_limit();
260                  $offset = $this->get_offset();                  $offset = $this->get_offset();
261                    
262                  if ($limit == -1) {                  if ($limit == -1) {
263                          //don't limit the data                          //don't limit the data
264                          if ($index > $this->get_total_rows()) {                          if ($index > $this->get_total_rows()) {
# Line 247  class MemoryDataSource extends DataListS Line 268  class MemoryDataSource extends DataListS
268                          }                          }
269                  } else {                  } else {
270                          $left_to_show = $limit - ($index - $offset);                          $left_to_show = $limit - ($index - $offset);
271                          if ($left_to_show > 0) {                          if ($left_to_show > 0 ) {
272                                  return $this->_data[$index];                                  return $this->_data[$index];
273                          } else {                          } else {
274                                  return NULL;                                  return NULL;
# Line 276  class MemoryDataSource extends DataListS Line 297  class MemoryDataSource extends DataListS
297  */  */
298    
299      if (!is_array($this->_schema[labels] )) {      if (!is_array($this->_schema[labels] )) {
300        logp(get_class($this) . "->propagate_schema: No schema data could be read from result.", PEAR_LOG_WARNING);        php::log(get_class($this) . "->propagate_schema: No schema data could be read from result.", PEAR_LOG_WARNING);
301        return;        return;
302      }      }
303    
# Line 323  class MemoryDataSource extends DataListS Line 344  class MemoryDataSource extends DataListS
344                        
345            //print "add_row!<br/>";            //print "add_row!<br/>";
346                        
347                  if ($row != NULL) {      // NEW 2004-10-07: ignore empty entries,
348        //                because of a HACK at DataSource/Generic, there could be empty one's
349                    //if ($row != NULL) {
350                          if ($this->get_searchby_value()) {                          if ($this->get_searchby_value()) {
351                                  //user wants to search the data                                  //user wants to search the data
352                                  if ($this->_find_data($row) ) {                                  if ($this->_find_data($row) ) {
# Line 336  class MemoryDataSource extends DataListS Line 359  class MemoryDataSource extends DataListS
359                                  $this->_data[] = $row;                                  $this->_data[] = $row;
360                                  return TRUE;                                  return TRUE;
361                          }                          }
362                  } else {                  //} else {
363                          return FALSE;                  //      return FALSE;
364                  }                  //}
365          }          }
366    
367          function sort() {          function sort() {

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

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