Refactor bib management functions for improved dynamic text handling and AJAX context. Updated text retrieval methods to enhance user experience and ensure consistency across components. Adjusted JavaScript selectors for better element targeting in the UI.
This commit is contained in:
@ -1,9 +1,19 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// MSIN-4379 — Contexte traduction = compte.php (pas ajax_bib_range.php) ; pas d'auto-création info en AJAX.
|
||||
define('MS1_BIB_AJAX', true);
|
||||
$_SERVER['PHP_SELF'] = '/compte.php';
|
||||
|
||||
require_once('php/inc_fonctions.php');
|
||||
require_once('php/inc_fx_promoteur.php');
|
||||
global $objDatabase;
|
||||
global $objDatabase, $vPage, $strLangue, $vtexte_page;
|
||||
|
||||
if (empty($strLangue)) {
|
||||
$strLangue = $_SESSION['lang'] ?? 'fr';
|
||||
}
|
||||
$vPage = 'compte.php';
|
||||
$vtexte_page = obtenirTextepage($vPage, $strLangue, 2);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
|
||||
@ -1968,7 +1968,10 @@ if ($strLangue == 'fr') {
|
||||
|
||||
function getBibContainer(row) {
|
||||
if (!row) return null;
|
||||
return row.querySelector('.epr-block-assign .bib-container') || row.querySelector('.bib-container');
|
||||
return row.querySelector('.epr-block-assign .epr-table.bib-container')
|
||||
|| row.querySelector('.epr-table.bib-container')
|
||||
|| row.querySelector('.epr-block-assign .bib-container')
|
||||
|| row.querySelector('.bib-container');
|
||||
}
|
||||
|
||||
function initModuleBibTippy(root) {
|
||||
@ -1995,8 +1998,16 @@ if ($strLangue == 'fr') {
|
||||
function setBibContainerHtml(row, html) {
|
||||
let container = getBibContainer(row);
|
||||
if (!container) return null;
|
||||
container.innerHTML = html;
|
||||
initModuleBibTippy(row);
|
||||
// renderBibRanges renvoie un bloc .epr-table.bib-container complet.
|
||||
if (html.indexOf('bib-container') !== -1) {
|
||||
container.outerHTML = html;
|
||||
container = getBibContainer(row);
|
||||
} else {
|
||||
container.innerHTML = html;
|
||||
}
|
||||
if (container) {
|
||||
initModuleBibTippy(row);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
@ -2588,7 +2588,7 @@ function renderBatchConfig($tabBibAssignments, $strLangue = 'fr', $isTeamEpreuve
|
||||
|
||||
<!-- ANALYSE -->
|
||||
<div class="batch-info text-muted small">
|
||||
<span class="batch-info-text"><?php afficheTexte('bib_v4_batch_info'); ?></span>
|
||||
<span class="batch-info-text"><?php fxBibTexte('bib_v4_batch_info', 1); ?></span>
|
||||
<?php echo fxBibAideButton('bib_v4_batch_info'); ?>
|
||||
</div>
|
||||
|
||||
@ -2631,9 +2631,84 @@ function fxBibEsc($str) {
|
||||
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
/** Page info pour le module bib v4 — toujours compte.php, jamais le script AJAX. */
|
||||
function fxBibInfoPage() {
|
||||
return 'compte.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Lit info_texte / info_aide depuis $vtexte_page ou la BD (compte.php / global uniquement).
|
||||
* N'écrit jamais dans info — évite les doublons info_prg=ajax_bib_range.php en AJAX.
|
||||
*/
|
||||
function fxBibGetInfoRow($clef) {
|
||||
global $vtexte_page, $objDatabase, $strLangue;
|
||||
|
||||
if (!empty($vtexte_page[$clef])) {
|
||||
return $vtexte_page[$clef];
|
||||
}
|
||||
|
||||
static $bibInfoCache = array();
|
||||
if (array_key_exists($clef, $bibInfoCache)) {
|
||||
return $bibInfoCache[$clef];
|
||||
}
|
||||
|
||||
if (!isset($objDatabase)) {
|
||||
$bibInfoCache[$clef] = array();
|
||||
return $bibInfoCache[$clef];
|
||||
}
|
||||
|
||||
$strLang = !empty($strLangue) ? $strLangue : 'fr';
|
||||
$strPage = fxBibInfoPage();
|
||||
$sql = "SELECT info_texte, info_aide FROM info
|
||||
WHERE info_actif = 1
|
||||
AND info_clef = '" . $objDatabase->fxEscape($clef) . "'
|
||||
AND info_langue = '" . $objDatabase->fxEscape($strLang) . "'
|
||||
AND info_prg IN ('" . $strPage . "', 'global')
|
||||
ORDER BY FIELD(info_prg, '" . $strPage . "', 'global')
|
||||
LIMIT 1";
|
||||
$row = $objDatabase->fxGetRow($sql);
|
||||
$bibInfoCache[$clef] = is_array($row) ? $row : array();
|
||||
return $bibInfoCache[$clef];
|
||||
}
|
||||
|
||||
/** Libellé bib v4 — sur compte.php auto-crée si absent ; en AJAX, lecture seule + repli. */
|
||||
function fxBibTexte($clef, $mem_echo = 0, $strFallback = '') {
|
||||
$row = fxBibGetInfoRow($clef);
|
||||
$str = trim($row['info_texte'] ?? '');
|
||||
|
||||
if ($str === '' || $str === $clef || $str === '*' . $clef . '*') {
|
||||
if (!defined('MS1_BIB_AJAX') || !MS1_BIB_AJAX) {
|
||||
$str = trim(afficheTexte($clef, 0));
|
||||
}
|
||||
if ($str === '' || $str === $clef || $str === '*' . $clef . '*') {
|
||||
$str = $strFallback !== '' ? $strFallback : $clef;
|
||||
}
|
||||
}
|
||||
|
||||
if ($mem_echo) {
|
||||
echo fxBibEsc($str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/** Texte d'aide long bib v4 — même règle que fxBibTexte pour l'auto-création. */
|
||||
function fxBibAide($clef, $mem_echo = 0) {
|
||||
$row = fxBibGetInfoRow($clef);
|
||||
$str = trim($row['info_aide'] ?? '');
|
||||
|
||||
if ($str === '' && (!defined('MS1_BIB_AJAX') || !MS1_BIB_AJAX)) {
|
||||
$str = trim(afficheAide($clef, 0));
|
||||
}
|
||||
|
||||
if ($mem_echo) {
|
||||
echo fxBibEsc($str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/** Attribut data-tippy-content — texte court depuis info_texte (clé bib_v4_tip_*). */
|
||||
function fxBibTippyAttr($clef) {
|
||||
$strTip = trim(afficheTexte($clef, 0));
|
||||
$strTip = trim(fxBibTexte($clef, 0));
|
||||
if ($strTip === '' || $strTip === '*' . $clef . '*') {
|
||||
return '';
|
||||
}
|
||||
@ -2642,7 +2717,7 @@ function fxBibTippyAttr($clef) {
|
||||
|
||||
/** Bouton (?) — pop-up long depuis info_aide ; absent si info_aide vide. */
|
||||
function fxBibAideButton($clef) {
|
||||
$strAide = trim(afficheAide($clef, 0));
|
||||
$strAide = trim(fxBibAide($clef, 0));
|
||||
if ($strAide === '') {
|
||||
return '';
|
||||
}
|
||||
@ -2652,10 +2727,7 @@ function fxBibAideButton($clef) {
|
||||
|
||||
/** Libellé info_texte + bouton (?) si info_aide renseigné. */
|
||||
function fxBibTexteAide($clef, $mem_echo = 1, $strFallback = '') {
|
||||
$str = trim(afficheTexte($clef, 0));
|
||||
if ($str === '' || $str === '*' . $clef . '*') {
|
||||
$str = $strFallback !== '' ? $strFallback : $clef;
|
||||
}
|
||||
$str = fxBibTexte($clef, 0, $strFallback);
|
||||
$html = fxBibEsc($str) . fxBibAideButton($clef);
|
||||
if ($mem_echo) {
|
||||
echo $html;
|
||||
@ -2665,20 +2737,12 @@ function fxBibTexteAide($clef, $mem_echo = 1, $strFallback = '') {
|
||||
|
||||
/** Titre d'en-tête de bloc (assignation, gestion…) + aide. */
|
||||
function fxBibBlockHeader($clef, $strFallback = '') {
|
||||
$str = trim(afficheTexte($clef, 0));
|
||||
if ($str === '' || $str === '*' . $clef . '*') {
|
||||
$str = $strFallback !== '' ? $strFallback : $clef;
|
||||
}
|
||||
return '<span class="epr-header-label">' . fxBibEsc($str) . fxBibAideButton($clef) . '</span>';
|
||||
return '<span class="epr-header-label">' . fxBibEsc(fxBibTexte($clef, 0, $strFallback)) . fxBibAideButton($clef) . '</span>';
|
||||
}
|
||||
|
||||
/** Cellule d'en-tête de colonne séquence + aide optionnelle. */
|
||||
function fxBibColHeader($clef, $strFallback) {
|
||||
$str = trim(afficheTexte($clef, 0));
|
||||
if ($str === '' || $str === '*' . $clef . '*') {
|
||||
$str = $strFallback;
|
||||
}
|
||||
return fxBibEsc($str) . fxBibAideButton($clef);
|
||||
return fxBibEsc(fxBibTexte($clef, 0, $strFallback)) . fxBibAideButton($clef);
|
||||
}
|
||||
|
||||
/** Bouton « ajouter séquence » — libellé BD (bib_v4_add) + tip court + aide longue. */
|
||||
@ -2689,7 +2753,7 @@ function renderBibAddRangeButton($epr_id, $extraStyle = '') {
|
||||
<button type="button"
|
||||
class="btn btn-success btn-sm btn-add-range"
|
||||
data-epr-id="<?php echo (int)$epr_id; ?>"<?php echo fxBibTippyAttr('bib_v4_tip_add'); ?>>
|
||||
<?php afficheTexte('bib_v4_add'); ?>
|
||||
<?php fxBibTexte('bib_v4_add', 1); ?>
|
||||
</button>
|
||||
<?php echo fxBibAideButton('bib_v4_add'); ?>
|
||||
</div>
|
||||
@ -2723,7 +2787,7 @@ function renderBibAssignActions($tabBibAssignments, $strLangue, $infoBib, $blnAu
|
||||
<div class="epr-action-row epr-action-row-main">
|
||||
<span class="epr-action-group">
|
||||
<button type="button" class="btn btn-sm btn-secondary btn-assign-batch"<?php echo fxBibTippyAttr('bib_v4_tip_assign_seq'); ?>>
|
||||
<?php afficheTexte('bib_v4_assign_seq'); ?>
|
||||
<?php fxBibTexte('bib_v4_assign_seq', 1); ?>
|
||||
</button>
|
||||
<?php echo fxBibAideButton('bib_v4_assign_seq'); ?>
|
||||
</span>
|
||||
@ -2731,41 +2795,41 @@ function renderBibAssignActions($tabBibAssignments, $strLangue, $infoBib, $blnAu
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-danger btn-reset"
|
||||
style="<?php echo ((int)$infoBib['avec_bib'] > 0 ? '' : 'display:none;'); ?>"<?php echo fxBibTippyAttr('bib_v4_tip_reset'); ?>>
|
||||
<?php afficheTexte('bib_v4_reset'); ?>
|
||||
<?php fxBibTexte('bib_v4_reset', 1); ?>
|
||||
</button>
|
||||
<?php echo fxBibAideButton('bib_v4_reset'); ?>
|
||||
</span>
|
||||
<span class="epr-action-group">
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-auto <?php echo $blnAutoActive ? 'btn-success' : 'btn-secondary'; ?>"<?php echo fxBibTippyAttr('bib_v4_tip_auto'); ?>>
|
||||
<?php echo fxBibEsc($blnAutoActive ? afficheTexte('bib_v4_auto_config', 0) : afficheTexte('bib_v4_auto', 0)); ?>
|
||||
<?php echo fxBibEsc($blnAutoActive ? fxBibTexte('bib_v4_auto_config', 0) : fxBibTexte('bib_v4_auto', 0)); ?>
|
||||
</button>
|
||||
<?php echo fxBibAideButton('bib_v4_auto'); ?>
|
||||
<span class="bib-auto-badge badge badge-success ml-1"
|
||||
style="<?php echo $blnAutoActive ? '' : 'display:none;'; ?>"><?php afficheTexte('bib_v4_auto_badge'); ?></span>
|
||||
style="<?php echo $blnAutoActive ? '' : 'display:none;'; ?>"><?php fxBibTexte('bib_v4_auto_badge', 1); ?></span>
|
||||
<?php echo fxBibAideButton('bib_v4_auto_badge'); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="auto-config-container" style="display:none;">
|
||||
<div class="auto-info text-muted small mb-2">
|
||||
<span class="auto-info-text"><?php afficheTexte('bib_v4_auto_select_hint'); ?></span>
|
||||
<span class="auto-info-text"><?php fxBibTexte('bib_v4_auto_select_hint', 1); ?></span>
|
||||
<?php echo fxBibAideButton('bib_v4_auto_select_hint'); ?>
|
||||
</div>
|
||||
<div class="epr-action-row">
|
||||
<span class="epr-action-group">
|
||||
<button type="button" class="btn btn-sm btn-success btn-accepter-auto"><?php afficheTexte('bib_v4_auto_accept'); ?></button>
|
||||
<button type="button" class="btn btn-sm btn-success btn-accepter-auto"><?php fxBibTexte('bib_v4_auto_accept', 1); ?></button>
|
||||
<?php echo fxBibAideButton('bib_v4_auto_accept'); ?>
|
||||
</span>
|
||||
<span class="epr-action-group">
|
||||
<button type="button" class="btn btn-sm btn-secondary btn-annuler-auto"><?php afficheTexte('bib_v4_auto_cancel'); ?></button>
|
||||
<button type="button" class="btn btn-sm btn-secondary btn-annuler-auto"><?php fxBibTexte('bib_v4_auto_cancel', 1); ?></button>
|
||||
<?php echo fxBibAideButton('bib_v4_auto_cancel'); ?>
|
||||
</span>
|
||||
<span class="epr-action-group">
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-danger btn-desactiver-auto"
|
||||
style="<?php echo $blnAutoActive ? '' : 'display:none;'; ?>">
|
||||
<?php afficheTexte('bib_v4_auto_disable'); ?>
|
||||
<?php fxBibTexte('bib_v4_auto_disable', 1); ?>
|
||||
</button>
|
||||
<?php echo fxBibAideButton('bib_v4_auto_disable'); ?>
|
||||
</span>
|
||||
@ -2777,13 +2841,13 @@ function renderBibAssignActions($tabBibAssignments, $strLangue, $infoBib, $blnAu
|
||||
<div class="epr-action-row">
|
||||
<span class="epr-action-group">
|
||||
<button type="button" class="btn btn-sm btn-secondary btn-simuler-batch" style="display:none;">
|
||||
<?php afficheTexte('bib_v4_batch_simulate'); ?>
|
||||
<?php fxBibTexte('bib_v4_batch_simulate', 1); ?>
|
||||
</button>
|
||||
<?php echo fxBibAideButton('bib_v4_batch_simulate'); ?>
|
||||
</span>
|
||||
<span class="epr-action-group">
|
||||
<button type="button" class="btn btn-sm btn-success btn-go-batch" style="display:none;">
|
||||
<?php afficheTexte('bib_v4_batch_go'); ?>
|
||||
<?php fxBibTexte('bib_v4_batch_go', 1); ?>
|
||||
</button>
|
||||
<?php echo fxBibAideButton('bib_v4_batch_go'); ?>
|
||||
</span>
|
||||
@ -2842,10 +2906,10 @@ function fxShowBibTool4($str_code, $int_eve_id, $strLangue){
|
||||
<div class="epr-row <?php echo $strClass ?><?php echo $blnAutoActive ? ' auto-enabled' : ''; ?>"
|
||||
data-epr-id="<?php echo (int)$tabEpreuves[$i]['epr_id']; ?>"
|
||||
data-auto-active="<?php echo $blnAutoActive ? '1' : '0'; ?>"
|
||||
data-auto-label="<?php echo fxBibEsc(afficheTexte('bib_v4_auto', 0)); ?>"
|
||||
data-auto-label-config="<?php echo fxBibEsc(afficheTexte('bib_v4_auto_config', 0)); ?>"
|
||||
data-batch-label="<?php echo fxBibEsc(afficheTexte('bib_v4_assign_seq', 0)); ?>"
|
||||
data-batch-label-cancel="<?php echo fxBibEsc(afficheTexte('bib_v4_assign_seq_cancel', 0)); ?>">
|
||||
data-auto-label="<?php echo fxBibEsc(fxBibTexte('bib_v4_auto', 0)); ?>"
|
||||
data-auto-label-config="<?php echo fxBibEsc(fxBibTexte('bib_v4_auto_config', 0)); ?>"
|
||||
data-batch-label="<?php echo fxBibEsc(fxBibTexte('bib_v4_assign_seq', 0)); ?>"
|
||||
data-batch-label-cancel="<?php echo fxBibEsc(fxBibTexte('bib_v4_assign_seq_cancel', 0)); ?>">
|
||||
<!-- GAUCHE -->
|
||||
<div class="epr-block">
|
||||
<div class="epr-header">Épreuve</div>
|
||||
@ -2942,9 +3006,9 @@ if ($teamMode <= 0) {
|
||||
<div class="epr-col-right">
|
||||
<?php /* MSIN-4379 — Gestion de l'épreuve : coquille phase 2, masquée pour l'instant. */ ?>
|
||||
<div class="epr-block epr-block-gestion" style="display:none;">
|
||||
<div class="epr-header"><?php afficheTexte('bib_v4_gestion_title'); ?></div>
|
||||
<div class="epr-header"><?php fxBibTexte('bib_v4_gestion_title', 1); ?></div>
|
||||
<div class="epr-content epr-gestion-placeholder text-muted small">
|
||||
<?php afficheTexte('bib_v4_gestion_placeholder'); ?>
|
||||
<?php fxBibTexte('bib_v4_gestion_placeholder', 1); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -2955,9 +3019,7 @@ if ($teamMode <= 0) {
|
||||
|
||||
<?php if (count($tabBibStats) == 0) { ?>
|
||||
|
||||
<div class="bib-container">
|
||||
<?php echo renderBibAddRangeButton($tabEpreuves[$i]['epr_id']); ?>
|
||||
</div>
|
||||
<?php echo renderBibRanges([], $tabEpreuves[$i]['epr_id']); ?>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user