From 52f25fe231bb3c14b8a79dbc6d01aef1e9e94adc Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 12 Apr 2023 15:02:35 +0200 Subject: [PATCH] =?UTF-8?q?12308=20D=C3=A9placement=20test=20404=20langue?= =?UTF-8?q?=20non=20s=C3=A9lectionn=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/class/router.class.php | 18 ++++++++++++++++++ core/core.php | 19 +------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/core/class/router.class.php b/core/class/router.class.php index c65b8a12..738b7746 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -513,6 +513,24 @@ class core extends common header('Location:' . helper::baseUrl() . 'maintenance'); exit(); } + + // Pour éviter une 404 sur une langue étrangère, bascule dans la langue correcte. + if (is_null($this->getData(['page', $this->getUrl(0)]))) { + foreach (self::$languages as $key => $value) { + if (is_dir(self::DATA_DIR . $key) && + file_exists(self::DATA_DIR . $key . '/page.json')) { + $pagesId = json_decode(file_get_contents(self::DATA_DIR . $key . '/page.json'), true); + if (array_key_exists($this->getUrl(0), $pagesId['page'])) { + setcookie('ZWII_CONTENT', $key, time() + 3600, helper::baseUrl(false, false), '', true, helper::isHttps()); + self::$i18nContent = $key; + \setlocale(LC_ALL, self::$i18nContent . '.UTF8'); + header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl(0)); + exit(); + } + } + } + } + // Check l'accès à la page $access = null; if ($this->getData(['page', $this->getUrl(0)]) !== null) { diff --git a/core/core.php b/core/core.php index 37663a02..3e145338 100644 --- a/core/core.php +++ b/core/core.php @@ -53,7 +53,7 @@ class common const ACCESS_TIMER = 1800; // Numéro de version et branche pour l'auto-update - const ZWII_VERSION = '12.3.07'; + const ZWII_VERSION = '12.3.08'; const ZWII_DATAVERSION = 12301; @@ -383,23 +383,6 @@ class common $this->url = $this->getData(['locale', 'homePageId']); } } - - // Pour éviter une 404 sur une langue étrangère, bascule dans la langue correcte. - if (is_null($this->getData(['page', $this->getUrl(0)]))) { - foreach (self::$languages as $key => $value) { - if (is_dir(self::DATA_DIR . $key) && - file_exists(self::DATA_DIR . $key . '/page.json')) { - $pagesId = json_decode(file_get_contents(self::DATA_DIR . $key . '/page.json'), true); - if (array_key_exists($this->getUrl(0), $pagesId['page'])) { - setcookie('ZWII_CONTENT', $key, time() + 3600, helper::baseUrl(false, false), '', true, helper::isHttps()); - self::$i18nContent = $key; - \setlocale(LC_ALL, self::$i18nContent . '.UTF8'); - header('Refresh:0; url=' . helper::baseUrl() . $this->getUrl(0)); - exit(); - } - } - } - } // Chargement des dialogues if (!file_exists(self::I18N_DIR . self::$i18nUI . '.json')) {