/[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.1 by jonen, Thu Mar 27 01:10:57 2003 UTC revision 1.8 by jonen, Wed Oct 26 22:40:54 2005 UTC
# Line 21  Line 21 
21   * $Id$   * $Id$
22   *   *
23   * $Log$   * $Log$
24     * Revision 1.8  2005/10/26 22:40:54  jonen
25     * + fixed page-control is search-value passed, searching/filtering is already done at backend (Memory!)
26     *   FIXME: the method '_find_data_' caused a 0 result if try to search already filtered results, fix this!
27     *
28     * Revision 1.7  2004/10/07 14:16:39  jonen
29     * + updates related to  HACK at DataSource/Generic (page-control!)
30     *
31     * Revision 1.6  2004/05/06 17:11:55  jonen
32     *  bugfix related to new phphtmllib-v2.4.1 of Apr 01, 2004
33     *
34     * Revision 1.5  2003/07/14 10:07:07  jonen
35     * clean up
36     *
37     * Revision 1.4  2003/04/18 17:26:14  joko
38     * minor fix: updated log api
39     *
40     * Revision 1.3  2003/04/18 13:48:27  joko
41     * minor updates to comments
42     *
43     * Revision 1.2  2003/03/28 02:59:07  joko
44     * minor fix: prevent php-error if result is empty
45     *
46   * Revision 1.1  2003/03/27 01:10:57  jonen   * Revision 1.1  2003/03/27 01:10:57  jonen
47   * + moved from com.newsblob.phphtmllib tree(was MemoryDataListSource.inc)   * + moved from com.newsblob.phphtmllib tree(was MemoryDataListSource.inc)
48   *   *
# Line 95  Line 117 
117  class MemoryDataSource extends DataListSource {  class MemoryDataSource extends DataListSource {
118    
119  // it's free now!  // it's free now!
120  //class DataSource_Proxy_Memory {  //class MemoryDataSource {
121    
122    // not yet!  ;-)
123    
124    
125          /**          /**
# Line 135  class MemoryDataSource extends DataListS Line 159  class MemoryDataSource extends DataListS
159          var $_errors = array();          var $_errors = array();
160    
161    
162            /**
163             * This disable searching here.
164             * Because lot of entries breaks memory if data is fetched remotely,
165             * searching/filtering have to be done at backend.
166             * Another search in already searched/filtered data return in 0 data.
167             * This can be handled maybe by fixing the '_find_data' method!
168             *
169             */
170       var $_enable_search = 0;
171    
172    
173          /**          /**
174           * The constructor.           * The constructor.
# Line 148  class MemoryDataSource extends DataListS Line 182  class MemoryDataSource extends DataListS
182          $this->trace_payload('MemoryDataSource', $payload);          $this->trace_payload('MemoryDataSource', $payload);
183    
184        // transfer data to "memory"        // transfer data to "memory"
185          $this->_memory = &$payload;        $this->_memory = &$payload;
186    
187          }          }
188    
189    function read_labels_from_result() {    function read_labels_from_result() {
190      $this->set_labels($this->_result[0]);      // NEW 2004-10-07: read last entries labes instead of first,
191        //                because of a HACK at DataSource/Generic, first could be an empty one
192        $count = count($this->_result);
193        $this->set_labels($this->_result[$count-1]);
194      $this->propagate_schema();      $this->propagate_schema();
195    }    }
196    
# Line 184  class MemoryDataSource extends DataListS Line 221  class MemoryDataSource extends DataListS
221          function O_do_prequery() {          function O_do_prequery() {
222                  $this->_read_schema();                  $this->_read_schema();
223          }          }
         function O_do_prequery() {  
    }  
224        
225          /**          /**
226           * This function does the query           * This function does the query
# Line 199  class MemoryDataSource extends DataListS Line 234  class MemoryDataSource extends DataListS
234    
235          function handle_result() {          function handle_result() {
236            $this->debug("handle_result", "HANDLE RESULT!<br>");            $this->debug("handle_result", "HANDLE RESULT!<br>");
237         $this->propagate_result();         return $this->propagate_result();
238      }      }
239    
240          function propagate_result() {      function propagate_result() {
241            $this->debug('propagate_result', "PROPAGATE RESULT!");        $this->debug('propagate_result', "PROPAGATE RESULT!");
242                  foreach ($this->_result as $value) {        
243          $count = 0;
244          if (is_array($this->_result)) {
245            foreach ($this->_result as $value) {
246            $this->trace_payload("propagate_result", $value);            $this->trace_payload("propagate_result", $value);
247                          if ($this->add_data_row( $value)) {            if ($this->add_data_row($value)) {
248                                  $count++;              $count++;
249                          }            }
250                  }          }
251                  $this->set_total_rows( $count );        }
252                  $this->sort();           if ($count > 0) {
253                $this->set_total_rows($count);
254                $this->sort();
255                return true;
256            } else {
257                return false;
258            }
259      }      }
260    
261          /**          /**
# Line 228  class MemoryDataSource extends DataListS Line 272  class MemoryDataSource extends DataListS
272                  $index = $this->get_data_index();                  $index = $this->get_data_index();
273                  $limit = $this->get_limit();                  $limit = $this->get_limit();
274                  $offset = $this->get_offset();                  $offset = $this->get_offset();
275                    
276                  if ($limit == -1) {                  if ($limit == -1) {
277                          //don't limit the data                          //don't limit the data
278                          if ($index > $this->get_total_rows()) {                          if ($index > $this->get_total_rows()) {
# Line 238  class MemoryDataSource extends DataListS Line 282  class MemoryDataSource extends DataListS
282                          }                          }
283                  } else {                  } else {
284                          $left_to_show = $limit - ($index - $offset);                          $left_to_show = $limit - ($index - $offset);
285                          if ($left_to_show > 0) {                          if ($left_to_show > 0 ) {
286                                  return $this->_data[$index];                                  return $this->_data[$index];
287                          } else {                          } else {
288                                  return NULL;                                  return NULL;
# Line 265  class MemoryDataSource extends DataListS Line 309  class MemoryDataSource extends DataListS
309                          return;                          return;
310                          }                          }
311  */  */
312    
313        if (!is_array($this->_schema[labels] )) {
314          php::log(get_class($this) . "->propagate_schema: No schema data could be read from result.", PEAR_LOG_WARNING);
315          return;
316        }
317    
318                    foreach($this->_schema[labels] as $value) {                    foreach($this->_schema[labels] as $value) {
319                        $this->debug("propagate_schema", "label: $value");                        $this->debug("propagate_schema", "label: $value");
320                                  array_push($this->_data_keys, $value);                                  array_push($this->_data_keys, $value);
# Line 308  class MemoryDataSource extends DataListS Line 358  class MemoryDataSource extends DataListS
358                        
359            //print "add_row!<br/>";            //print "add_row!<br/>";
360                        
361                  if ($row != NULL) {      // NEW 2004-10-07: ignore empty entries,
362                          if ($this->get_searchby_value()) {      //                because of a HACK at DataSource/Generic, there could be empty one's
363                    //if ($row != NULL) {
364                            if ($this->get_searchby_value() && $this->_enable_search) {
365                                  //user wants to search the data                                  //user wants to search the data
366                                  if ($this->_find_data($row) ) {                                  if ($this->_find_data($row) ) {
367                                          $this->_data[] = $row;                                          $this->_data[] = $row;
# Line 321  class MemoryDataSource extends DataListS Line 373  class MemoryDataSource extends DataListS
373                                  $this->_data[] = $row;                                  $this->_data[] = $row;
374                                  return TRUE;                                  return TRUE;
375                          }                          }
376                  } else {                  //} else {
377                          return FALSE;                  //      return FALSE;
378                  }                  //}
379          }          }
380    
381          function sort() {          function sort() {

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

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