alpha_full/_include/req/03-init.langueActives.php
2026-04-06 22:58:51 +02:00

97 lines
5.1 KiB
PHP
Executable File

<?php
if (!isset($refresh)) $refresh = 'N';
//titi2026
// $refresh = 'Oui';
if (isset($debug[9]) && $debug[9] == '1' || isset($debug[5]) && $debug[5] == '1') { $debugMsg .= monDebug (1, ['refresh' => $refresh], '03-init.langueActives.php');}
if ($refresh == 'Oui' || empty($_SESSION['tableLangueCode'])) {
$i = 0;
$nbLgActives = 0;
if(!isset($lg)) $lg='FRA';
// ---------------------------------------------------
// Requete sur les codes
// ---------------------------------------------------
$tabResult = dynRequete_select('SELECT', 'codeslangues as CL JOIN codeslangueslibelle as CLL ON CL.id = CLL.id ', ['CL.id', 'CL.idLg', 'CL.afficher', 'CL.description', 'CLL.libelle', 'CLL.imgDrapeauWeb', 'CLL.drapeauTitle', 'CLL.drapeauAlt', 'CLL.drapeauLien'], ['CL.afficher' => 1, 'CLL.idLg' => 'FRA'], 'order by CL.id', '03-init.langueActives.php', 0, $debug[2],'tabResult');
if ($tabResult) {
$tableLangueID=array();
$tableLangueCode=array();
$tableLangueAfficher=array();
$tableLangueDesc=array();
$tableLangueMsg=array();
$tableLangueImgPt=array();
$tableLangueAlt=array();
$tableLangueTitle=array();
$tableLangueLien=array();
foreach ($tabResult as $i => $row) {
$tableLangueID[$i] = $row['id'];
$tableLangueCode[$i] = $row['idLg'];
$tableLangueAfficher[$i] = $row['afficher'];
$tableLangueDesc[$i] = $row['description'];
// ---------------------------------------------------
// Recup valeurs depuis libelles
// ---------------------------------------------------
$tableLangueMsg[$i] = $row['libelle'];
$tableLangueImgPt[$i] = $row['imgDrapeauWeb'];
$tableLangueTitle[$i] = $row['drapeauTitle'];
$tableLangueAlt[$i] = $row['drapeauAlt'];
$tableLangueLien[$i] = $row['drapeauLien'];
}
if (!empty($tableLangueID)) { $nbLgActives = count($tableLangueID); }
// En final c'est bien de garder cette variable ici, pourquoi ?
// Car lorsque l'on modifie les langues si on modifie que les actives les inactives ne seront pas modifiées
// Et alors si plus tard on active une langue désactivé, elle ne sera pas a jour
// Donc si on boucle toujours sur nbLg tout sera à jour
// Il faudrait juste que pour l'affichage on ne dise pas que les inactives ont été mises à jour
// Deplus historique nbLg etait utilisé, le fait de le désactiver fait planter par ci et par là, trop chiant de tout analyser
// Actuellemnt des fois nbLg est donc utilisé, et des fois nbLgActives
// Il faudrait dans l'idéal tout reprendre avec nbLg et désactiver les messages autres langues ( donc là boucle sur nbLgActives )
// Non prioritaire, non urgent
$_SESSION['nbLg'] = $nbLgActives;
$_SESSION['nbLgActives'] = $nbLgActives;
$_SESSION['tableLangueCode'] = $tableLangueCode;
$_SESSION['tableLangueAfficher'] = $tableLangueAfficher;
$_SESSION['tableLangueMsg'] = $tableLangueMsg;
$_SESSION['tableLangueDesc'] = $tableLangueDesc;
$_SESSION['tableLangueImgPt'] = $tableLangueImgPt;
$_SESSION['tableLangueAlt'] = $tableLangueAlt;
$_SESSION['tableLangueTitle'] = $tableLangueTitle;
$_SESSION['tableLangueLien'] = $tableLangueLien;
if (isset($debug[5]) && $debug[5] == '1' || isset($debug[9]) && $debug[9] == '1' ) { $debugMsg .= monDebug (5, [ 'session langue re-chargée ! ', 'nbLgActives' => $nbLgActives],'');}
}
else if (isset($debug[5]) && $debug[5] == '1' || isset($debug[9]) && $debug[9] == '1') { $debugMsg .= monDebug(5, ['Impossible de récupérer les données langues' => ''], '');}
}
else {
if (isset($debug[5]) && $debug[5] == '1' || isset($debug[9]) && $debug[9] == '1' ) { $debugMsg .= monDebug(5, ['refresh' => $refresh, 'tableCodesLangues déjà en session ' => 'Oui'], '03-init.langueActives.php');}
$nbLg = $_SESSION['nbLg'];
$nbLgActives = $_SESSION['nbLg'];
// $tableLangueID = $_SESSION['tableLangueID'];
$tableLangueCode = $_SESSION['tableLangueCode'];
$tableLangueAfficher = $_SESSION['tableLangueAfficher'];
$tableLangueMsg = $_SESSION['tableLangueMsg'];
$tableLangueDesc = $_SESSION['tableLangueDesc'];
$tableLangueImgPt = $_SESSION['tableLangueImgPt'];
$tableLangueAlt = $_SESSION['tableLangueAlt'];
$tableLangueTitle = $_SESSION['tableLangueTitle'];
$tableLangueLien = $_SESSION['tableLangueLien'];
}
// mettre en session le lib langue
if (!isset($_SESSION['idLgCourante'])) {
$_SESSION['lgCouranteCode'] = $lg;
for($aa = 0; $aa<count($tableLangueCode); $aa++) {
if ($tableLangueCode[$aa] == $lg) {
$_SESSION['listBoxAffLg'] = $tableLangueMsg[$aa];
$_SESSION['AffichageDrapeau'] = $tableLangueImgPt[$aa];
$_SESSION['lgCouranteCode'] = $tableLangueCode[$aa];
if (isset($debug[5]) && $debug[5] == '1' ) { $debugMsg .= monDebug (1, [ '<br>lg' => $lg, 'tableLangueCode['.$aa.']' => $tableLangueCode[$aa], 'drapeau de la langueActive' => $_SESSION['AffichageDrapeau']],'');}
}
}
}
else {
if (isset($debug[5]) && $debug[5] == '1' ) { $debugMsg .= monDebug (1, [ 'lg' => $lg, '$_SESSION[idLgCourante]' => 'empty !'],'03-init.langueActives.php');}
}
?>