Author: rande
Date: 2010-02-11 12:03:44 +0100 (Thu, 11 Feb 2010)
New Revision: 27884

Modified:
   plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDatagrid.class.php
   
plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDoctrineDatagrid.class.php
   plugins/swToolboxPlugin/sf1.2/trunk/lib/datagrid/swDoctrineDatagrid.class.php
Log:
[swToolboxPlugin] apply change to branch 1.3 and fix typoo

Modified: 
plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDatagrid.class.php
===================================================================
--- plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDatagrid.class.php    
2010-02-11 10:55:20 UTC (rev 27883)
+++ plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDatagrid.class.php    
2010-02-11 11:03:44 UTC (rev 27884)
@@ -48,14 +48,14 @@
   public function __construct($params = array(), $options = array(), 
$CSRFSecret = null)
   {
     // validator options
-    $options['allow_extra_fields'] = isset($options['allow_extra_fields']) ? 
$options['allow_extra_fields'] : true;
+    $options['allow_extra_fields']  = isset($options['allow_extra_fields']) ? 
$options['allow_extra_fields'] : true;
     $options['filter_extra_fields'] = isset($options['filter_extra_fields']) ? 
$options['filter_extra_fields'] : false;
-    $options['disabled_init'] = isset($options['disabled_init']) ? 
$options['disabled_init'] : false;
+    $options['disabled_init']       = isset($options['disabled_init']) ? 
$options['disabled_init'] : false;
     
     parent::__construct(array(), $options, $CSRFSecret);
 
     // init sort features
-    $params['sort_by'] = isset($params['sort_by']) ? $params['sort_by'] : null;
+    $params['sort_by']    = isset($params['sort_by']) ? $params['sort_by'] : 
null;
     $params['sort_order'] = isset($params['sort_order']) ? 
$params['sort_order'] : null;
    
     // init values
@@ -436,7 +436,9 @@
   {
     if($this->cached_results == false)
     {
-      $this->cached_results =  $this->pager->getResults();
+      $args = func_get_args();
+      
+      $this->cached_results = call_user_func_array(array($this->pager, 
'getResults'), $args);
     }
     
     return $this->cached_results;

Modified: 
plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDoctrineDatagrid.class.php
===================================================================
--- 
plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDoctrineDatagrid.class.php
    2010-02-11 10:55:20 UTC (rev 27883)
+++ 
plugins/swToolboxPlugin/branches/sf1.3/lib/datagrid/swDoctrineDatagrid.class.php
    2010-02-11 11:03:44 UTC (rev 27884)
@@ -64,12 +64,22 @@
   }
   
   
+  /**
+   * return the base query
+   *
+   * @return Doctrine_Query
+   */
   public function getBaseQuery()
   {
     
     return Doctrine::getTable($this->getModelName())->createQuery();
   }
   
+  /**
+   * return the final query used by the pager
+   *
+   * @return Doctrine_Query
+   */
   public function getQuery()
   {
 
@@ -81,17 +91,36 @@
     return clone $this->query;
   }
   
+  /**
+   * prepare the pager once everything is setup
+   */
   public function preparePager()
   {
-    $page  = $this->getOption('page');
-    $query = $this->getQuery();
+    $page     = $this->getOption('page');
     $per_page = $this->getOption('per_page', 25);
+    $query    = $this->getQuery();
+    $class    = $this->getOption('pager_class', 'sfDoctrinePager'); // allow 
to pass custom class
 
-    $this->pager = new sfDoctrinePager($this->getModelName());
+    // define the hydration mode
+    $query->setHydrationMode($this->getOption('hydration_mode', 
Doctrine::HYDRATE_RECORD));
+    
+    $this->pager = new $class($this->getModelName());
     $this->pager->setPage($page);
     $this->pager->setQuery($query);
     $this->pager->setMaxPerPage($per_page);
     $this->pager->init();
   }
 
+  // PAGER PROXY METHODS
+  public function getResults()
+  {
+    if($this->cached_results == false)
+    {
+      $args = func_num_args() == 0 ? array($this->getOption('hydration_mode', 
Doctrine::HYDRATE_RECORD)) : func_get_args();
+      
+      $this->cached_results = call_user_func_array(array($this->pager, 
'getResults'), $args);
+    }
+    
+    return $this->cached_results;
+  }
 }
\ No newline at end of file

Modified: 
plugins/swToolboxPlugin/sf1.2/trunk/lib/datagrid/swDoctrineDatagrid.class.php
===================================================================
--- 
plugins/swToolboxPlugin/sf1.2/trunk/lib/datagrid/swDoctrineDatagrid.class.php   
    2010-02-11 10:55:20 UTC (rev 27883)
+++ 
plugins/swToolboxPlugin/sf1.2/trunk/lib/datagrid/swDoctrineDatagrid.class.php   
    2010-02-11 11:03:44 UTC (rev 27884)
@@ -112,7 +112,7 @@
   }
 
   // PAGER PROXY METHODS
-  public function gestResults()
+  public function getResults()
   {
     if($this->cached_results == false)
     {

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" 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/symfony-svn?hl=en.

Reply via email to