Files
ms1inscription-v5/php/inc_v2_assets.php
stephan 96765aac84 MSIN-4435 Add inc_v2_assets.php integration across multiple files
This commit integrates the `inc_v2_assets.php` file into several PHP scripts, including `compte.php`, `inc_footer.php`, `inc_tableau_gestion_epreuves.php`, `inc_tableau_inscriptions_gestion.php`, and `mobile.php`. Additionally, it registers new scripts for improved functionality in the `inscriptions gestion` context. The version code is incremented to reflect these updates, aiming to enhance asset management and script handling across the application.
2026-07-07 15:27:33 -04:00

73 lines
2.7 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 */
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_INSCR_GESTION avant inscr-gestion.js */
function fxV2InscrGestionConfig($strLangue) {
global $vDomaine;
$strLangue = ($strLangue === 'en') ? 'en' : 'fr';
return [
'domain' => $vDomaine,
'lang' => $strLangue,
'preloaderWait' => afficheTexte('preloader_wait', 0, 0, 1),
'refundCancelHint' => ($strLangue === 'en')
? 'Your transaction has been refunded. If you also want to cancel it in the registration system:'
: "Votre transaction a été remboursée. Si vous voulez aussi l'annuler dans le système d'inscription :",
'loginMessages' => [
'txt_login' => ($strLangue === 'fr')
? "Veuillez entrer votre nom d'usager"
: 'Please enter your username',
'txt_password' => ($strLangue === 'fr')
? 'Veuillez entrer votre mot de passe'
: 'Please enter your password',
],
];
}
/** À 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',
];
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";
}
}
}