123 lines
5.2 KiB
PHP
123 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* MSIN-4435 — Assets JS modules v2 (hors inc_footer_scripts.php legacy).
|
|
* Bib v4, gestion inscriptions v2 : chargés uniquement sur leurs pages.
|
|
*/
|
|
|
|
if (!function_exists('fxV2RegisterScript')) {
|
|
|
|
/** @param string $strName bib-assignments | inscr-gestion | promoteur-hub */
|
|
function fxV2RegisterScript($strName) {
|
|
global $MS1_V2_SCRIPTS;
|
|
if (!isset($MS1_V2_SCRIPTS) || !is_array($MS1_V2_SCRIPTS)) {
|
|
$MS1_V2_SCRIPTS = [];
|
|
}
|
|
if (!in_array($strName, $MS1_V2_SCRIPTS, true)) {
|
|
$MS1_V2_SCRIPTS[] = $strName;
|
|
}
|
|
}
|
|
|
|
/** Config injectée dans window.MS1_V2_PROMOTEUR_HUB avant promoteur-hub.js */
|
|
function fxV2PromoteurHubConfig($strLangue) {
|
|
global $vDomaine;
|
|
|
|
$strLangue = ($strLangue === 'en') ? 'en' : 'fr';
|
|
$strWait = afficheTexte('preloader_wait', 0, 0, 1);
|
|
if (trim((string)$strWait) === '' || $strWait === 'preloader_wait' || $strWait === '*preloader_wait*') {
|
|
$strWait = function_exists('fxPromoteurHubTexte')
|
|
? fxPromoteurHubTexte('promoteur_hub_load_dashboard', 0)
|
|
: '';
|
|
}
|
|
|
|
// MSIN-4401 — libellés Info injectés (pas de FR/EN en dur dans promoteur-hub.js).
|
|
$strAjaxError = function_exists('fxPromoteurHubTexte')
|
|
? fxPromoteurHubTexte('promoteur_hub_ajax_error', 0)
|
|
: afficheTexte('promoteur_hub_ajax_error', 0, 0, 1);
|
|
|
|
return [
|
|
'ajaxUrl' => $vDomaine . '/ajax_promoteur_hub.php',
|
|
'preloaderWait' => $strWait,
|
|
'i18n' => [
|
|
'ajaxError' => $strAjaxError,
|
|
],
|
|
];
|
|
}
|
|
|
|
/** Config injectée dans window.MS1_V2_INSCR_GESTION avant inscr-gestion.js */
|
|
function fxV2InscrGestionConfig($strLangue) {
|
|
global $vDomaine;
|
|
|
|
$strLangue = ($strLangue === 'en') ? 'en' : 'fr';
|
|
|
|
return [
|
|
'domain' => $vDomaine,
|
|
'lang' => $strLangue,
|
|
// MSIN-4401 — true = OCR dossard via serveur (Vision), pas Tesseract local.
|
|
'bibOcrCloud' => function_exists('fxInscrGestionBibOcrCloudEnabled')
|
|
? (bool)fxInscrGestionBibOcrCloudEnabled()
|
|
: false,
|
|
'preloaderWait' => afficheTexte('preloader_wait', 0, 0, 1),
|
|
'refundCancelHint' => function_exists('fxInscrGestionT')
|
|
? fxInscrGestionT('inscr_gestion_refund_cancel_hint')
|
|
: '',
|
|
'loginMessages' => [
|
|
'txt_login' => function_exists('fxInscrGestionT')
|
|
? fxInscrGestionT('inscr_gestion_login_err_user')
|
|
: '',
|
|
'txt_password' => function_exists('fxInscrGestionT')
|
|
? fxInscrGestionT('inscr_gestion_login_err_pass')
|
|
: '',
|
|
],
|
|
// MSIN-4401 — libellés Info injectés (pas de FR/EN en dur dans le JS).
|
|
'i18n' => function_exists('fxInscrGestionT') ? [
|
|
'errLoad' => fxInscrGestionT('inscr_gestion_err_load'),
|
|
'errNetwork' => fxInscrGestionT('inscr_gestion_err_network'),
|
|
'errRefund' => fxInscrGestionT('inscr_gestion_err_refund'),
|
|
'refundOk' => fxInscrGestionT('inscr_gestion_refund_ok'),
|
|
'bibOcrNotConfigured' => fxInscrGestionT('inscr_gestion_bib_ocr_not_configured'),
|
|
'bibOcrVisionPrefix' => fxInscrGestionT('inscr_gestion_bib_ocr_vision_prefix'),
|
|
'bibOcrImageInvalid' => fxInscrGestionT('inscr_gestion_bib_ocr_image_invalid'),
|
|
'bibOcrNetwork' => fxInscrGestionT('inscr_gestion_bib_ocr_network'),
|
|
'bibOcrUnreadable' => fxInscrGestionT('inscr_gestion_bib_scan_invalid'),
|
|
] : [],
|
|
];
|
|
}
|
|
|
|
/** À appeler dans inc_footer.php après inc_footer_scripts.php */
|
|
function fxV2RenderFooterScripts() {
|
|
global $MS1_V2_SCRIPTS, $vDomaine, $strLangue;
|
|
|
|
if (empty($MS1_V2_SCRIPTS) || !is_array($MS1_V2_SCRIPTS)) {
|
|
return;
|
|
}
|
|
|
|
$mapFiles = [
|
|
'bib-assignments' => '/js/v2/bib-assignments.js',
|
|
'inscr-gestion' => '/js/v2/inscr-gestion.js',
|
|
'promoteur-hub' => '/js/v2/promoteur-hub.js',
|
|
];
|
|
|
|
if (in_array('promoteur-hub', $MS1_V2_SCRIPTS, true)) {
|
|
$cfg = fxV2PromoteurHubConfig($strLangue ?? 'fr');
|
|
echo '<script>window.MS1_V2_PROMOTEUR_HUB='
|
|
. json_encode($cfg, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP)
|
|
. ';</script>' . "\n";
|
|
}
|
|
|
|
if (in_array('inscr-gestion', $MS1_V2_SCRIPTS, true)) {
|
|
$cfg = fxV2InscrGestionConfig($strLangue ?? 'fr');
|
|
echo '<script>window.MS1_V2_INSCR_GESTION='
|
|
. json_encode($cfg, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP)
|
|
. ';</script>' . "\n";
|
|
}
|
|
|
|
foreach ($MS1_V2_SCRIPTS as $strName) {
|
|
if (!isset($mapFiles[$strName])) {
|
|
continue;
|
|
}
|
|
$strSrc = htmlspecialchars($vDomaine . $mapFiles[$strName], ENT_QUOTES, 'UTF-8');
|
|
echo '<script src="' . $strSrc . '?v=' . htmlspecialchars(_VERSION_CODE, ENT_QUOTES, 'UTF-8') . '"></script>' . "\n";
|
|
}
|
|
}
|
|
}
|