Author: francois
Date: 2010-03-22 10:29:12 +0100 (Mon, 22 Mar 2010)
New Revision: 28663

Modified:
   
plugins/sfPropel15Plugin/trunk/data/generator/sfPropelModule/admin15/parts/sortingAction.php
Log:
[sfPropel15Plugin] Added ability to provide a custom sort method in the admin 
generator list

Modified: 
plugins/sfPropel15Plugin/trunk/data/generator/sfPropelModule/admin15/parts/sortingAction.php
===================================================================
--- 
plugins/sfPropel15Plugin/trunk/data/generator/sfPropelModule/admin15/parts/sortingAction.php
        2010-03-22 08:21:49 UTC (rev 28662)
+++ 
plugins/sfPropel15Plugin/trunk/data/generator/sfPropelModule/admin15/parts/sortingAction.php
        2010-03-22 09:29:12 UTC (rev 28663)
@@ -1,3 +1,14 @@
+<?php
+$customSorts = array(); 
+foreach ($this->configuration->getValue('list.display') as $name => $field)
+{
+  if ($customSort = $field->getConfig('sort_method', false, false))
+  {
+    $customSorts[$name] = $customSort;
+  }
+}
+?>
+
   protected function processSort($query)
   {
     $sort = $this->getSort();
@@ -5,7 +16,17 @@
     {
       return;
     }
-    
+
+<?php if ($customSorts): ?>
+    $customSorts = $this->getCustomSorts();
+    if (isset($customSorts[$sort[0]]))
+    {
+      $method = $customSorts[$sort[0]];
+      $query->$method('asc' == $sort[1] ? 'asc' : 'desc');
+      return;
+    }
+
+<?php endif ?>    
     try
     {
       $column = <?php echo constant($this->getModelClass().'::PEER') 
?>::translateFieldName($sort[0], BasePeer::TYPE_FIELDNAME, 
BasePeer::TYPE_PHPNAME);
@@ -51,3 +72,10 @@
 
     $this->getUser()->setAttribute('<?php echo $this->getModuleName() 
?>.sort', $sort, 'admin_module');
   }
+
+<?php if ($customSorts): ?>
+  protected function getCustomSorts()
+  {
+    return <?php echo $this->asPhp($customSorts) ?>;
+  }
+<?php endif ?>

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