Author: david
Date: Fri Oct 21 13:13:18 2011
New Revision: 10158

Log:
Don't require calling getResults() to set

Modified:
   trunk/lib/QubitArrayPager.class.php

Modified: trunk/lib/QubitArrayPager.class.php
==============================================================================
--- trunk/lib/QubitArrayPager.class.php Fri Oct 21 12:45:56 2011        (r10157)
+++ trunk/lib/QubitArrayPager.class.php Fri Oct 21 13:13:18 2011        (r10158)
@@ -25,16 +25,43 @@
  */
 class QubitArrayPager extends sfPager
 {
+  protected
+    $hits;
+
   public function __construct()
   {
     parent::__construct(null);
   }
 
-  public function getResults()
+  public function __get($name)
+  {
+    if ('hits' == $name) 
+    {
+      return $this->hits;
+    }
+    else
+    {
+      call_user_func(array($this, 'get'.ucfirst($name)));
+    }
+  }
+
+  public function __set($name, $val)
   {
-    $this->nbResults = count($this->hits);
-    $this->lastPage = ceil($this->nbResults / $this->getMaxPerPage());
+    if ('hits' == $name) 
+    {
+      $this->hits = $val;
 
+      $this->nbResults = count($this->hits);
+      $this->lastPage = ceil($this->nbResults / $this->getMaxPerPage());
+    }
+    else
+    {
+      call_user_func(array($this, 'set'.ucfirst($name)));
+    }
+  }
+
+  public function getResults()
+  {
     return array_slice($this->hits, $this->getFirstIndice() - 1, 
$this->getMaxPerPage());
   }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to