X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fpltableeditor.php;h=955ac30d3162292728a7ec2b83ba336524aaa184;hb=7743e0e58199e7d59177ab8a6bac8a6310456c86;hp=a2ea5333934c677ca1afcae28e7b8937fa269569;hpb=de61dbcf4475d1182220ae6ac1759d6a5bf7acbd;p=platal.git diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php index a2ea533..955ac30 100644 --- a/classes/pltableeditor.php +++ b/classes/pltableeditor.php @@ -38,6 +38,7 @@ class PLTableEditor { var $nbfields; // the field for sorting entries var $sortfield; + var $sortdesc = false; // action to do to delete row: // null => delete effectively, false => no deletion, SQL var $delete_action; @@ -60,7 +61,7 @@ class PLTableEditor { // desc will be the title of the column $a['desc'] = $a['Field']; $a['display'] = true; - + if (substr($a['Type'],0,8) == 'varchar(') { // limit editing box size $a['Size'] = $a['Maxlength'] = substr($a['Type'], 8, strlen($a['Type']) - 9); @@ -101,7 +102,7 @@ class PLTableEditor { if ($descr['Type'] == 'timestamp') { // set readable timestamp $date =& $entry[$field]; - $date = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', '\3/\2/\1 \4:\5:\6', $date); + $date = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', '\3/\2/\1 \4:\5:\6', $date); } if ($descr['Type'] == 'date') { $date =& $entry[$field]; @@ -115,7 +116,7 @@ class PLTableEditor { $this->vars[$name]['desc'] = $desc; $this->vars[$name]['display'] = $display; } - // add a join table, when deleting a row corresponding entries will be deleted in these tables + // add a join table, when deleting a row corresponding entries will be deleted in these tables function add_join_table($name,$joinid,$joindel,$joinextra="") { if ($joindel) $this->jtables[$name] = array("joinid" => $joinid,"joinextra" => $joinextra?(" AND ".$joinextra):""); @@ -185,9 +186,9 @@ class PLTableEditor { } $val = "'".addslashes($val)."'"; } elseif (Post::has($field)) { - $val = Post::v($field); + $val = Post::v($field); if ($descr['Type'] == 'timestamp') { - $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/', '\3\2\1\4\5\6', $val); + $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/', '\3\2\1\4\5\6', $val); } elseif ($descr['Type'] == 'date') { $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', $val); @@ -195,7 +196,7 @@ class PLTableEditor { $val = "'".addslashes($val)."'"; } else { $cancel = true; - $page->trig("Il manque le champ ".$field); + $page->trig("Il manque le champ ".$field); } $values .= $val; } @@ -221,6 +222,10 @@ class PLTableEditor { if (isset($this->sortfield)) { // add this sort order after the others (chosen by dev) $this->add_sort_field($this->sortfield); + if (substr($this->sortfield,-5) == ' DESC') { + $this->sortfield = substr($this->sortfield,0,-5); + $this->sortdesc = true; + } } if (count($this->sort) > 0) { $sort = 'ORDER BY ' . join($this->sort, ',');