From 74bb32c126e00ce849c99b09e09a54e114b16457 Mon Sep 17 00:00:00 2001 From: RastaPopoulos <rastapopoulos@spip.org> Date: Tue, 1 Mar 2022 15:06:59 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20#5069=20:=20quitter=20la=20fonction=20qui?= =?UTF-8?q?=20g=C3=A8re=20les=20variantes=20de=20crit=C3=A8res=20de=20date?= =?UTF-8?q?=20parce=20qu'il=20n'y=20aurait=20pas=20de=20d=C3=A9claration?= =?UTF-8?q?=20dans=20l'API=20objet=20ne=20doit=20se=20faire=20QUE=20quand?= =?UTF-8?q?=20il=20n'y=20a=20PAS=20de=20nom=20de=20champ=20directement=20d?= =?UTF-8?q?onn=C3=A9=20dans=20le=20crit=C3=A8re=20lui-m=C3=AAme.=20S'il=20?= =?UTF-8?q?y=20a=20annee=5Fnomprecis,=20mois=5Fnomprecis,=20=C3=A7a=20doit?= =?UTF-8?q?=20marcher=20m=C3=AAme=20sans=20d=C3=A9claration.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/public/criteres.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ecrire/public/criteres.php b/ecrire/public/criteres.php index 6308f0c78f..4d808cb313 100644 --- a/ecrire/public/criteres.php +++ b/ecrire/public/criteres.php @@ -2616,23 +2616,29 @@ function calculer_critere_infixe_date($idb, &$boucles, $col) { return ''; } - if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) { - return ''; - } - $pred = $date_orig = $GLOBALS['table_date'][$table['id_table']] ?? $table['date']; - + // Le type de critère à prendre en compte $col = $regs[1]; + + // Si on trouve un nom de champ date précis, on l'utilise, pas besoin de déclaration dans l'API objet if (isset($regs[3]) and $suite = $regs[3]) { # Recherche de l'existence du champ date_xxxx, # si oui choisir ce champ, sinon choisir xxxx - if (isset($table['field']["date$suite"])) { $date_orig = 'date' . $suite; } else { $date_orig = substr($suite, 1); } + $pred = $date_orig; - } else { + } else { // Sinon il FAUT avoir déclaré le champ date officiel dans l'API objet + // Si aucune déclaration trouvée, on quitte + if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) { + return ''; + } + // Par défaut, on prend le champ date déclaré dans l'API + $pred = $date_orig = $GLOBALS['table_date'][$table['id_table']] ?? $table['date']; + + // Si c'est pour du relatif if (isset($regs[2]) and $rel = $regs[2]) { $pred = 'date'; } -- GitLab