Code

Added experimental sorting for rendered cells. Preparing for cached entries.
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 24 Aug 2009 07:28:26 +0000 (07:28 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 24 Aug 2009 07:28:26 +0000 (07:28 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14111 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_listing.inc

index e0ca916ef09189fa7e64a337fc6435643e90a057..e2bdb9a44a2d7e608db8d888dbf9cc66f59bea41 100644 (file)
@@ -293,23 +293,35 @@ class listing {
     }
 
     // Fill with contents, sort as configured
-    $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], $this->sortAttribute, $this->sortType);
-    foreach ($entryIterator as $row => $entry){
-      $result.="<tr class='rowxp".($alt&1)."'>";
+    foreach ($this->entry as $row => $entry) {
+      $trow ="<tr class='rowxp".($alt&1)."'>";
 
       // Render multi select if needed
       if ($this->multiSelect) {
-        $result.="<td style='text-align:center;width:20px;' class='list0'><input type='checkbox' id='listing_selected_$row' name='listing_selected_$row'></td>";
+        $trow.="<td style='text-align:center;width:20px;' class='list0'><input type='checkbox' id='listing_selected_$row' name='listing_selected_$row'></td>";
       }
 
       foreach ($this->xmlData['table']['column'] as $index => $config) {
-        $result.="<td ".$this->colprops[$index]." class='list0'>".$this->renderCell($config['value'], $entry, $row)."</td>";
+        $renderedCell= $this->renderCell($config['value'], $entry, $row);
+        $trow.="<td ".$this->colprops[$index]." class='list0'>".$renderedCell."</td>";
+
+        // Save rendered column
+        $this->entry[$row]["_sort$index"]= $renderedCell;
       }
-      $result.="</tr>";
+      $trow.="</tr>";
+
+      // Save rendered entry
+      $this->entry[$row]['_rendered']= $trow;
 
       $alt++;
     }
 
+    // Complete list by sorting entries for _sort$index and appending them to the output
+    $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
+    foreach ($entryIterator as $row => $entry){
+      $result.= $entry['_rendered'];
+    }
+
     // Need to fill the list if it's not full (nobody knows why this is 22 ;-))
     $emptyListStyle= (count($this->entries) + $deps == 0)?"border:0;":"";
     if ((count($this->entries) + $deps) < 22) {