1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-16 03:24:01 +02:00

Date localization

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@917 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2009-07-27 16:32:56 +00:00
parent f93c84e4d8
commit a0def4790e
17 changed files with 50 additions and 25 deletions

View File

@@ -118,6 +118,13 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
return ($link ? "<a href=\"$link\">$return</a>" : $return);
}
function editVal($val, $field) {
if (ereg('date|timestamp', $field["type"])) {
return preg_replace('~^([0-9]{2}([0-9]+))-(0?([0-9]+))-(0?([0-9]+))~', lang('$1-$3-$5'), $val);
}
return $val;
}
function selectColumnsPrint($select, $columns) {
//! allow grouping functions by indexes
}
@@ -177,11 +184,11 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
}
function selectSearchProcess($indexes, $fields) {
global $dbh;
$return = array();
foreach ((array) $_GET["where"] as $val) {
if (strlen("$val[col]$val[val]")) {
$cond = " = " . $dbh->quote($val["val"]);
$value = $this->processInput($fields[$val["col"]], $val["val"]);
$cond = ($value == "NULL" ? " IS $value" : " = $value");
if (strlen($val["col"])) {
$return[] = idf_escape($val["col"]) . $cond;
} else {
@@ -285,16 +292,9 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
return $return;
}
/** Process sent input
* @param string field name
* @param array single field from fields()
* @return string expression to use in a query
*/
function processInput($name, $field) {
function processInput($field, $value, $function = "") {
global $dbh;
$idf = bracket_escape($name);
$value = $_POST["fields"][$idf];
$return = $dbh->quote($value);
$return = $dbh->quote(ereg('date|timestamp', $field["type"]) ? preg_replace_callback('(' . preg_replace('~(\\\\\\$([0-9]))~', '(?P<p\\2>[0-9]+)', preg_quote(lang('$1-$3-$5'))) . ')', 'conversion_date', $value) : $value);
if (!ereg('varchar|text', $field["type"]) && !strlen($value)) {
$return = "NULL";
} elseif (ereg('date|time', $field["type"]) && $value == "CURRENT_TIMESTAMP") {

View File

@@ -1 +1,4 @@
<?php
function conversion_date($match) {
return ($match["p1"] ? $match["p1"] : ($match["p2"] < 70 ? 20 : 19) . $match["p2"]) . "-$match[p3]$match[p4]-$match[p5]$match[p6]";
}