Indicates the bounds of the page's display if possible (Closes #854)
authorStéphane Jacob <jacou@melix.net>
Fri, 11 Jul 2008 22:14:04 +0000 (00:14 +0200)
committerStéphane Jacob <jacou@melix.net>
Fri, 11 Jul 2008 22:14:04 +0000 (00:14 +0200)
ChangeLog
classes/plset.php
templates/include/plview.minifiche.tpl
templates/include/plview.multipage.tpl

index 6068643..49b1284 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,7 @@ Bug/Wish:
         - Fix display of autocompletion menu (use plugin's latest version) -ALK
         - Clicking on the "..." entry no longer replaces search with "..." -ALK
         - #850: Fix autocompletion bug when changing an advanced search    -ALK
+        - #854: Indicates the bounds of the page's display if possible     -JAC
 
     * Xnet:
         - #821: Fix infinite loop when user can't be authenticated         -FRU
index 648d814..231b4d4 100644 (file)
@@ -80,7 +80,8 @@ class PlSet
                           $limit";
 //        echo $query;
 //        print_r($this);
-        $it    = XDB::iterator($query);
+        $it    = XDB::query($query);
+        $it    = $it->fetchAllAssoc();
         $count = XDB::query('SELECT FOUND_ROWS()');
         $this->count = intval($count->fetchOneCell());
         return $it;
@@ -255,17 +256,38 @@ abstract class MultipageView implements PlView
 
     public function apply(PlatalPage &$page)
     {
-        $page->assign('order', Env::v('order', $this->defaultkey));
+        $res = $this->set->get($this->fields(),
+                               $this->joins(),
+                               $this->where(),
+                               $this->groupBy(),
+                               $this->order(),
+                               $this->entriesPerPage,
+                               $this->offset);
+        $order       = Env::v('order', $this->defaultkey);
+        $end         = end($res);
+        $show_bounds = 0;
+        if (($order == "name") || ($order == "-name")) {
+            $first       = $res[0]['nom'];
+            $last        = $end['nom'];
+            $show_bounds = 1;
+        } elseif (($order == "promo") || ($order == "-promo")) {
+            $first       = $end['promo'];
+            $last        = $res[0]['promo'];
+            $show_bounds = 1;
+        }
+        if (($show_bounds) && ($order{0} == '-')) {
+            $aux   = $first;
+            $first = $last;
+            $last  = $aux;
+        }
+
+        $page->assign('first', $first);
+        $page->assign('last', $last);
+        $page->assign('show_bounds', $show_bounds);
+        $page->assign('order', $order);
         $page->assign('orders', $this->sortkeys);
         $page->assign_by_ref('plview', $this);
-        $page->assign_by_ref('set',
-                             $this->set->get($this->fields(),
-                                             $this->joins(),
-                                             $this->where(),
-                                             $this->groupBy(),
-                                             $this->order(),
-                                             $this->entriesPerPage,
-                                             $this->offset));
+        $page->assign_by_ref('set', $res);
         $count = $this->set->count();
         $this->pages = intval(ceil($count / $this->entriesPerPage));
         return 'include/plview.multipage.tpl';
index 2527d2f..4753463 100644 (file)
 {**************************************************************************}
 
 <div class="contact-list" style="clear: both">
-{iterate from=$set item=res}
+{foreach from=$set item=res}
   {if $res.contact}
   {include file="include/minifiche.tpl" c=$res show_action="retirer"}
   {else}
   {include file="include/minifiche.tpl" c=$res show_action="ajouter"}
   {/if}
-{/iterate}
+{/foreach}
 </div>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 348a72d..854c320 100644 (file)
@@ -23,6 +23,7 @@
 {capture name=pages}
 {if $plview->pages > 1}
 <div class="center pages">
+  {if $show_bounds}[{$first} - {$last}]{/if}
   {if $plview->page neq 1}
   <a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page=1">{icon name=resultset_first title="Première page"}</a>{*
   *}<a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$plview->page-1}">{icon name=resultset_previous title="Page précédente"}</a>