Author: jablko
Date: Tue Oct 26 15:10:01 2010
New Revision: 8515

Log:
Add select criteria to count criteria, fixes issue 1839

Modified:
   trunk/apps/qubit/modules/repository/actions/browseAction.class.php
   trunk/lib/QubitPager.class.php
   trunk/lib/task/migrate/QubitMigrate109.class.php

Modified: trunk/apps/qubit/modules/repository/actions/browseAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/repository/actions/browseAction.class.php  Tue Oct 
26 15:07:57 2010        (r8514)
+++ trunk/apps/qubit/modules/repository/actions/browseAction.class.php  Tue Oct 
26 15:10:01 2010        (r8515)
@@ -34,6 +34,9 @@
 
     $criteria = new Criteria;
 
+    // Do source culture fallback
+    $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 
'QubitActor');
+
     switch ($request->sort)
     {
       case 'nameDown':
@@ -58,9 +61,6 @@
         break;
     }
 
-    // Do source culture fallback
-    $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 
'QubitRepository');
-
     // Page results
     $this->pager = new QubitPager('QubitRepository');
     $this->pager->setCriteria($criteria);

Modified: trunk/lib/QubitPager.class.php
==============================================================================
--- trunk/lib/QubitPager.class.php      Tue Oct 26 15:07:57 2010        (r8514)
+++ trunk/lib/QubitPager.class.php      Tue Oct 26 15:10:01 2010        (r8515)
@@ -27,47 +27,31 @@
 class QubitPager extends sfPropelPager
 {
   protected
-    $nbResults = null, /* Override sfPager::$nbResults = 0 */
-    $peer_method_name = 'get';
+
+    // Override sfPager::$nbResults = 0
+    $nbResults = null;
 
   /**
    * BasePeer::doCount() returns PDOStatement
    */
   public function doCount(Criteria $criteria)
   {
-    // Set primary table name incase there are no WHERE columns, in which case
-    // BasePeer::createSelectSql() can't determine which tables go in the FROM
-    // clause
-    $criteria->setPrimaryTableName($this->tableName);
+    call_user_func(array($this->class, 'addSelectColumns'), $criteria);
 
     return BasePeer::doCount($criteria)->fetchColumn(0);
   }
 
-  /**
-   * Override ::init() to call BasePeer::doCount()
-   *
-   * @see sfPropelPager
-   */
-  public function init()
+  public function doSelect(Criteria $criteria)
   {
-    $class = $this->class;
-    $this->class = $this;
-
-    parent::init();
-
-    $this->class = $class;
+    return call_user_func(array($this->class, 'get'), $criteria);
   }
 
   /**
-   * Override ::getResults() to call ->init() first
-   *
-   * @see sfPager
+   * @see sfPropelPager
    */
-  public function getResults()
+  public function getClassPeer()
   {
-    $this->init();
-
-    return parent::getResults();
+    return $this;
   }
 
   /**
@@ -86,12 +70,14 @@
   }
 
   /**
-   * For Qubit we only have the BasePeer peer class
+   * Override ::getResults() to call ->init() first
    *
-   * @see sfPropelPager
+   * @see sfPager
    */
-  public function getClassPeer()
+  public function getResults()
   {
-    return $this->class;
+    $this->init();
+
+    return parent::getResults();
   }
 }

Modified: trunk/lib/task/migrate/QubitMigrate109.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate109.class.php    Tue Oct 26 15:07:57 
2010        (r8514)
+++ trunk/lib/task/migrate/QubitMigrate109.class.php    Tue Oct 26 15:10:01 
2010        (r8515)
@@ -123,7 +123,7 @@
         {
           if (isset($value['path']))
           {
-            $this->data['QubitMenu'][$key]['path'] = 
str_replace(array('create',, 'duplicate'), array('add', 'copy'), 
$value['path']);
+            $this->data['QubitMenu'][$key]['path'] = 
str_replace(array('create', 'duplicate'), array('add', 'copy'), $value['path']);
           }
         }
     }

-- 
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