From 717f11e3d5f44672ddbf7ddaae326ff9a54c8b9e Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 19 Jun 2026 11:32:09 -0400 Subject: [PATCH] Refactor fxBibTexte function to include fallback for missing keys and add new fxBibStaticFallback function for bilingual support This commit modifies the `fxBibTexte` function to utilize a new fallback mechanism via `fxBibStaticFallback`, which provides default translations for missing or incorrectly entered keys in both French and English. Additionally, the error handling in the bib view is updated to ensure proper display of messages for unassigned and duplicate bibs. These changes enhance the robustness and user experience of the bib management system. --- php/inc_fx_promoteur.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/php/inc_fx_promoteur.php b/php/inc_fx_promoteur.php index bcd0058..fa0b329 100644 --- a/php/inc_fx_promoteur.php +++ b/php/inc_fx_promoteur.php @@ -2813,7 +2813,10 @@ function fxBibTexte($clef, $mem_echo = 0, $blnAllowEmptyLabel = false) { } } if ($str === '' || $str === $clef || $str === '*' . $clef . '*') { - $str = $blnAllowEmptyLabel ? '' : $clef; + $str = fxBibStaticFallback($clef); + if ($str === '') { + $str = $blnAllowEmptyLabel ? '' : $clef; + } } } @@ -2823,6 +2826,20 @@ function fxBibTexte($clef, $mem_echo = 0, $blnAllowEmptyLabel = false) { return $str; } +/** Repli FR/EN si clé bib_v4 absente ou mal saisie en BD. */ +function fxBibStaticFallback($clef) { + global $strLangue; + + $lng = ($strLangue === 'en') ? 'en' : 'fr'; + $tab = [ + 'bib_v4_view_cancelled' => ['fr' => 'Annulé', 'en' => 'Cancelled'], + 'bib_v4_err_gaps' => ['fr' => 'Dossards non assignés :', 'en' => 'Unassigned bibs:'], + 'bib_v4_err_dupes' => ['fr' => 'Dossards en double :', 'en' => 'Duplicate bibs:'], + ]; + + return $tab[$clef][$lng] ?? ''; +} + /** Libellé « Annulé » dans la vue dossards — repli si clé BD absente ou mal saisie. */ function fxBibViewCancelledLabel($strLangue = 'fr') { $str = fxBibTexte('bib_v4_view_cancelled', 0); @@ -4825,11 +4842,11 @@ if (!$blnRangeLocked && (
-
+
-
+