Minor bugfixes
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Thu, 4 Feb 2010 20:38:43 +0000 (21:38 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Thu, 4 Feb 2010 20:38:43 +0000 (21:38 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/plfilter.php
classes/plset.php

index ed0e039..15bcaf5 100644 (file)
@@ -32,7 +32,7 @@ class PlLimit
 
     public function getSql()
     {
-        if (!is_null($this->count)) {
+        if (!is_null($this->count) && $this->count != 0) {
             if (!is_null($this->from) && $this->from != 0) {
                 return XDB::format('LIMIT {?}, {?}', (int)$this->from, (int)$this->count);
             } else {
@@ -56,7 +56,7 @@ class PlSqlJoin
     public function __construct($mode, $table, $condition)
     {
         if ($mode != self::MODE_LEFT && $mode != self::MODE_RIGHT && $mode != self::MODE_INNER) {
-            Platal::page()->kill("Join mode error : unknown mode $mode");
+            Platal::page()->kill("Join mode error: unknown mode $mode");
             return;
         }
         $this->mode = $mode;
@@ -98,7 +98,7 @@ class PlSqlJoin
     {
         $str = '';
         foreach ($joins as $key => $join) {
-            if (! ($join instanceof PlSqlJoin)) {
+            if (!($join instanceof PlSqlJoin)) {
                 Platal::page()->kill("Error: not a join: $join");
             }
             $mode  = $join->mode();
@@ -145,7 +145,7 @@ abstract class PlFilterOrder
         return $sel;
     }
 
-//    abstract protected function getSortTokens(&$pf);
+    abstract protected function getSortTokens(&$pf);
 }
 
 // {{{ interface PlFilterCondition
index 93afc3f..5b0ecb6 100644 (file)
@@ -24,6 +24,8 @@
  */
 abstract class PlSet
 {
+    const DEFAULT_MAX_RES = 20;
+
     private $conds   = null;
     private $orders  = null;
     private $limit   = null;
@@ -44,7 +46,7 @@ abstract class PlSet
         }
 
         if ($orders instanceof PlFilterOrder) {
-            $this->orders = array($order);
+            $this->orders[] = $order;
         } else {
             foreach ($orders as $order) {
                 $this->orders[] = $order;
@@ -89,7 +91,7 @@ abstract class PlSet
         $pf = $this->buildFilter($this->conds, $this->orders);
 
         if (is_null($limit)) {
-            $limit = new PlLimit(20, 0);
+            $limit = new PlLimit(self::DEFAULT_MAX_RES, 0);
         }
         $it          = $pf->get($limit);
         $this->count = $pf->getTotalCount();
@@ -192,13 +194,13 @@ class PlViewOrder
      */
     public function __construct($name, PlFilterOrder &$pfo, $displaytext = null)
     {
-        $this->name         = $name;
+        $this->name = $name;
         if (is_null($displaytext)) {
             $this->displaytext = ucfirst($name);
         } else {
-            $this->displaytext  = $displaytext;
+            $this->displaytext = $displaytext;
         }
-        $this->pfo        = $pfo;
+        $this->pfo = $pfo;
     }
 }