This commit is contained in:
Fred Tempez 2024-08-14 09:09:26 +02:00
parent f84bcbb878
commit ad15e8b827
2 changed files with 25 additions and 17 deletions

View File

@ -8,7 +8,7 @@ class helper
/** Filtres personnalisés */ /** Filtres personnalisés */
const FILTER_BOOLEAN = 1; const FILTER_BOOLEAN = 1;
const FILTER_DATETIME = 2; const FILTER_DATETIME = 2; // filtre pour le champ de formulaire A conserver pour la compatibilité
const FILTER_FLOAT = 3; const FILTER_FLOAT = 3;
const FILTER_ID = 4; const FILTER_ID = 4;
const FILTER_INT = 5; const FILTER_INT = 5;
@ -16,10 +16,13 @@ class helper
const FILTER_PASSWORD = 7; const FILTER_PASSWORD = 7;
const FILTER_STRING_LONG = 8; const FILTER_STRING_LONG = 8;
const FILTER_STRING_SHORT = 9; const FILTER_STRING_SHORT = 9;
const FILTER_TIMESTAMP = 10; const FILTER_TIMESTAMP = 10; // Saisie d'une date en locatime
const FILTER_URL = 11; const FILTER_URL = 11;
const FILTER_DATE = 12; const FILTER_DATE = 12; // filtre pour le champ de formulaire
const FILTER_TIME = 13; const FILTER_TIME = 13; // filtre pour le champ de formulair
const FILTER_MONTH = 14; // filtre pour le champ de formulair
const FILTER_YEAR = 16; // filtre pour le champ de formulair
@ -32,12 +35,12 @@ class helper
// La traduction existe déjà dans le core // La traduction existe déjà dans le core
/* /*
if (array_key_exists($text, core::$dialog) === false && !empty($text)) { if (array_key_exists($text, core::$dialog) === false && !empty($text)) {
$dialogues = json_decode(file_get_contents('core/module/install/ressource/i18n/fr_FR.json' ), true); $dialogues = json_decode(file_get_contents('core/module/install/ressource/i18n/fr_FR.json' ), true);
$data = array_merge($dialogues,[$text => '']); $data = array_merge($dialogues,[$text => '']);
file_put_contents ('core/module/install/ressource/i18n/fr_FR.json', json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOCK_EX); file_put_contents ('core/module/install/ressource/i18n/fr_FR.json', json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOCK_EX);
} }
*/ */
return (array_key_exists($text, core::$dialog) && !empty(core::$dialog[$text]) ? core::$dialog[$text] : $text); return (array_key_exists($text, core::$dialog) && !empty(core::$dialog[$text]) ? core::$dialog[$text] : $text);
} }
@ -392,10 +395,10 @@ class helper
'text' => self::relativeLuminanceW3C($rgba) > .22 ? "#222" : "#DDD", 'text' => self::relativeLuminanceW3C($rgba) > .22 ? "#222" : "#DDD",
'rgb' => 'rgb(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ')', 'rgb' => 'rgb(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ')',
'invert' => 'rgba (' . 'invert' => 'rgba (' .
($rgba[0] < 128 ? 255 : 0) . ',' . ($rgba[0] < 128 ? 255 : 0) . ',' .
($rgba[1] < 128 ? 255 : 0) . ',' . ($rgba[1] < 128 ? 255 : 0) . ',' .
($rgba[1] < 128 ? 255 : 0) . ',' . ($rgba[1] < 128 ? 255 : 0) . ',' .
($rgba[0] < 128 ? 255 : 0) . ')' ($rgba[0] < 128 ? 255 : 0) . ')'
]; ];
} }
@ -480,8 +483,13 @@ class helper
$text = date('Y-m-d', $text); $text = date('Y-m-d', $text);
break; break;
case self::FILTER_TIME: case self::FILTER_TIME:
$text = date('H:i:s', $text); $text = date('H:i', $text);
break; break;
case self::FILTER_MONTH:
$text = date('m', $text);
break;
case self::FILTER_YEAR:
$text = date('Y', $text);
} }
return $text; return $text;
} }

View File

@ -253,7 +253,7 @@ class template
// Filtre selon le type // Filtre selon le type
switch ($attributes['type']) { switch ($attributes['type']) {
case 'datetime-local': case 'datetime-local':
$filter = helper::FILTER_TIMESTAMP; $filter = helper::FILTER_DATETIME;
break; break;
case 'date': case 'date':
$filter = helper::FILTER_DATE; $filter = helper::FILTER_DATE;