From 32051cd9e27a306bacc8cb937d0545f5c4518dd9 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 5 Sep 2023 21:20:40 +0200 Subject: [PATCH] Session ZWII_CLASS --- core/class/layout.class.php | 4 ++-- core/class/router.class.php | 2 +- core/class/template.class.php | 4 ++-- core/core.js.php | 2 +- core/core.php | 14 ++------------ core/module/install/install.php | 20 ++++++++++---------- core/module/language/language.php | 2 +- 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/core/class/layout.class.php b/core/class/layout.class.php index 41d8f19..531e180 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -1231,8 +1231,8 @@ class layout extends common public function showi18n($lang) { if ( - (isset($_SESSION['ZWII_CONTENT']) - and $_SESSION['ZWII_CONTENT'] === $lang + (isset($_SESSION['ZWII_CLASS']) + and $_SESSION['ZWII_CLASS'] === $lang ) ) { $select = ' class="i18nFlagSelected" '; diff --git a/core/class/router.class.php b/core/class/router.class.php index 63bbc34..a8010a3 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -513,7 +513,7 @@ class core extends common is_array($pagesId['page']) && array_key_exists($this->getUrl(0), $pagesId['page']) ) { - $_SESSION['ZWII_CONTENT'] = $key; + $_SESSION['ZWII_CLASS'] = $key; header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl(0)); exit(); } diff --git a/core/class/template.class.php b/core/class/template.class.php index 1651cb6..d6565b2 100644 --- a/core/class/template.class.php +++ b/core/class/template.class.php @@ -494,8 +494,8 @@ class template $lang = $langId; break; case 'selected': - if (isset($_SESSION['ZWII_CONTENT'])) { - $lang = $_SESSION['ZWII_CONTENT']; + if (isset($_SESSION['ZWII_CLASS'])) { + $lang = $_SESSION['ZWII_CLASS']; } else { $lang = 'fr_FR'; } diff --git a/core/core.js.php b/core/core.js.php index 4f17873..bf0ec96 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -532,7 +532,7 @@ $(document).ready(function () { var langSelected = $(this).val(); var langSelected = langSelected.split("/"); // Lit le cookie de langue - var langSession = ""; + var langSession = ""; // Découpe l'URL pour exclure le changement de page avec le thème var url = window.location; var currentUrl = url.href.split("/"); diff --git a/core/core.php b/core/core.php index 9556192..bbbc64a 100644 --- a/core/core.php +++ b/core/core.php @@ -303,20 +303,10 @@ class common // $this->input['_SESSION'] = $_SESSION; // Déterminer la langue du contenu du site - if (isset($_SESSION['ZWII_CONTENT'])) { + if (isset($_SESSION['ZWII_CLASS'])) { // Déterminé par la session présente - self::$classesContent = $_SESSION['ZWII_CONTENT']; - } else { - // Détermine la langue par défaut - foreach (self::$languages as $key => $value) { - if (file_exists(self::DATA_DIR . $key . '/.default')) { - self::$classesContent = $key; - $_SESSION['ZWII_CONTENT'] = $key; - break; - } - } + self::$classesContent = $_SESSION['ZWII_CLASS']; } - \setlocale(LC_ALL, self::$classesContent . '.UTF8'); // Instanciation de la classe des entrées / sorties $this->jsonDB(self::$classesContent); diff --git a/core/module/install/install.php b/core/module/install/install.php index 26a9588..a6ec8ba 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -120,24 +120,24 @@ class install extends common self::$i18nUI = $_SESSION['ZWII_UI']; self::$i18nUI = array_key_exists(self::$i18nUI, self::$languages) ? self::$i18nUI : 'fr_FR'; // par défaut le contenu est la langue d'installation - $_SESSION['ZWII_CONTENT'] = self::$i18nUI; + $_SESSION['ZWII_CLASS'] = self::$i18nUI; // Création du dossier de langue avec le marqueur de langue par défaut - if (!is_dir(self::DATA_DIR . $_SESSION['ZWII_CONTENT'])) { - mkdir(self::DATA_DIR . $_SESSION['ZWII_CONTENT']); - touch(self::DATA_DIR . $_SESSION['ZWII_CONTENT'] . '/.default'); + if (!is_dir(self::DATA_DIR . $_SESSION['ZWII_CLASS'])) { + mkdir(self::DATA_DIR . $_SESSION['ZWII_CLASS']); + touch(self::DATA_DIR . $_SESSION['ZWII_CLASS'] . '/.default'); } // Installation du site de test if ( $this->getInput('installDefaultData', helper::FILTER_BOOLEAN) === false - && $_SESSION['ZWII_CONTENT'] === 'fr_FR' + && $_SESSION['ZWII_CLASS'] === 'fr_FR' ) { $sample = true; } - $this->initData('page', $_SESSION['ZWII_CONTENT'], $sample); - $this->initData('module', $_SESSION['ZWII_CONTENT'], $sample); - $this->initData('config', $_SESSION['ZWII_CONTENT'], $sample); + $this->initData('page', $_SESSION['ZWII_CLASS'], $sample); + $this->initData('module', $_SESSION['ZWII_CLASS'], $sample); + $this->initData('config', $_SESSION['ZWII_CLASS'], $sample); // Création de l'utilisateur si les données sont complétées. // success retour de l'enregistrement des données @@ -153,7 +153,7 @@ class install extends common 'signature' => 1, 'mail' => $userMail, 'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true), - 'language' => $_SESSION['ZWII_CONTENT'] + 'language' => $_SESSION['ZWII_CLASS'] ] ]); @@ -172,7 +172,7 @@ class install extends common // Nettoyage fr par défaut if ( - $_SESSION['ZWII_CONTENT'] !== 'fr_FR' + $_SESSION['ZWII_CLASS'] !== 'fr_FR' ) { if (is_dir(self::DATA_DIR . 'fr_FR')) $this->deleteDir(self::DATA_DIR . 'fr_FR'); diff --git a/core/module/language/language.php b/core/module/language/language.php index 8611b40..19932c8 100644 --- a/core/module/language/language.php +++ b/core/module/language/language.php @@ -532,7 +532,7 @@ class language extends common ) { // Stocker la sélection - $_SESSION['ZWII_CONTENT'] = $lang; + $_SESSION['ZWII_CLASS'] = $lang; } // Valeurs en sortie