From: x2001corpet Date: Tue, 3 Oct 2006 21:36:27 +0000 (+0000) Subject: tri automatique en cliquant sur l'entete de colonne des table editor : bug #484 X-Git-Tag: xorg/0.9.12~226 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=a38287878bf37b4a39120dceb82877b3e1d99303;p=platal.git tri automatique en cliquant sur l'entete de colonne des table editor : bug #484 git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@944 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php index 7d435a5..58894d6 100644 --- a/classes/pltableeditor.php +++ b/classes/pltableeditor.php @@ -36,6 +36,8 @@ class PLTableEditor { var $vars; // number of displayed fields var $nbfields; + // the field for sorting entries + var $sortfield; /* table editor for platal * $plname : the PLname of the page, ex: admin/payments * $table : the table to edit, ex: profile_medals @@ -46,6 +48,7 @@ class PLTableEditor { $this->pl = $plname; $this->table = $table; $this->idfield = $idfield; + $this->sortfield = $idfield; $this->idfield_editable = $editid; $r = XDB::iterator("SHOW COLUMNS FROM $table"); $this->vars = array(); @@ -185,6 +188,19 @@ class PLTableEditor { $page->trig("Impossible de mette à jour."); } if ($list) { + // user can sort by field by clicking the title of the column + if ($action == 'sort' || $action == 'sortdesc') { + if (isset($this->vars[$id])) { + // add this sort order after the others (chosen by dev) + $this->add_sort_field($id, $action == 'sortdesc'); + // set as sortfield to reverse sort when clicking again + if ($action == 'sort') { + $this->sortfield = $id; + } else { + $this->sortfield = ''; + } + } + } if (count($this->sort) > 0) { $sort = 'ORDER BY ' . join($this->sort, ','); } diff --git a/templates/table-editor.tpl b/templates/table-editor.tpl index 7226fc2..cfa08e9 100644 --- a/templates/table-editor.tpl +++ b/templates/table-editor.tpl @@ -27,8 +27,8 @@ - {foreach from=$t->vars item=myval}{if $myval.display} - + {foreach from=$t->vars item=myval key=myvar}{if $myval.display} + {/if}{/foreach} {if !$hideactions}
{$myval.desc}{$myval.desc}action