From: x2003bruneau Date: Fri, 11 Aug 2006 23:44:11 +0000 (+0000) Subject: Table editor also recognise date fields X-Git-Tag: xorg/0.9.11~109 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=b9cd8008fe77ee0dc83d9626f558d7202e9aad5b;p=platal.git Table editor also recognise date fields Allow j/m/aaaa as a valid date git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@806 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/classes/PLTableEditor.php b/classes/PLTableEditor.php index 16d1e95..ac41b39 100644 --- a/classes/PLTableEditor.php +++ b/classes/PLTableEditor.php @@ -71,7 +71,7 @@ class PLTableEditor { $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 6, strlen($a['Type']) - 8))); $a['Type'] = 'enum'; } - elseif (substr($a['Type'],0,10) == 'timestamp(') { + elseif (substr($a['Type'],0,10) == 'timestamp(' || $a['Type'] == 'datetime') { $a['Type'] = 'timestamp'; } @@ -94,6 +94,10 @@ class PLTableEditor { $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); } + if ($descr['Type'] == 'date') { + $date =& $entry[$field]; + $date = preg_replace('/([0-9]{4})-?([0-9]{2})-?([0-9]{2})/', '\3/\2/\1', $date); + } } return $entry; } @@ -148,7 +152,10 @@ class PLTableEditor { } elseif (Post::has($field)) { $val = Post::v($field); if ($descr['Type'] == 'timestamp') { - $val = preg_replace('/([0-9]{2})\/([0-9]{2})\/([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{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); } $val = "'".addslashes($val)."'"; } else { diff --git a/templates/table-editor.tpl b/templates/table-editor.tpl index dd6704c..7226fc2 100644 --- a/templates/table-editor.tpl +++ b/templates/table-editor.tpl @@ -112,6 +112,7 @@ {else} {if $myval.Type eq 'timestamp'}jj/mm/aaaa hh:mm:ss{/if} + {if $myval.Type eq 'date'}jj/mm/aaaa{/if} {if $myval.Type eq 'time'}hh:mm:ss{/if} {/if}