From f235a65fe722bd2ec64a5bfde754881400bb65b0 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 24 Apr 2023 22:28:53 +0200 Subject: [PATCH] Nettoyage des anciennes installations --- core/core.php | 2 +- core/module/install/install.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/core.php b/core/core.php index 55295588..63b9b7ed 100644 --- a/core/core.php +++ b/core/core.php @@ -167,7 +167,7 @@ class common // Langue de l'interface sélectionnée public static $i18nUI = 'fr_FR'; // Langues de contenu - public static $i18nContent = ''; + public static $i18nContent = 'fr_FR'; public static $languages = [ 'az_AZ' => 'Azərbaycan dili', 'bg_BG' => 'български език', diff --git a/core/module/install/install.php b/core/module/install/install.php index 66ca625f..9c4601db 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -51,10 +51,9 @@ class install extends common ]); } - - // Soumission du formulaire if ($this->isPost()) { + $lang = $this->getInput('installLanguage'); // Pour la suite de l'installation // setcookie('ZWII_UI', $lang, time() + 3600, helper::baseUrl(false, false), '', false, false); @@ -70,7 +69,6 @@ class install extends common if (is_dir(self::I18N_DIR)) { foreach ($this->getData(['languages']) as $lang => $value) { self::$i18nFiles[$lang] = self::$languages[$lang]; - ; } } @@ -150,6 +148,12 @@ class install extends common // La langue du site est la langue de l'UI $_SESSION['ZWII_CONTENT'] = $_SESSION['ZWII_UI']; + // Efface les langues déjà installées + foreach ($this->getData(['languages']) as $lang => $value) { + if (is_dir(self::DATA_DIR . $lang)) + $this->removeDir(self::DATA_DIR . $lang); + } + // 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']); @@ -163,6 +167,7 @@ class install extends common ) { $this->initData('page', $_SESSION['ZWII_CONTENT'], true); $this->initData('module', $_SESSION['ZWII_CONTENT'], true); + $this->initData('locale', $_SESSION['ZWII_CONTENT'], true); $this->setData(['module', 'blog', 'posts', 'mon-premier-article', 'userId', $userId]); $this->setData(['module', 'blog', 'posts', 'mon-deuxieme-article', 'userId', $userId]); $this->setData(['module', 'blog', 'posts', 'mon-troisieme-article', 'userId', $userId]); @@ -172,9 +177,7 @@ class install extends common if ($_SESSION['ZWII_CONTENT'] !== 'fr_FR') { $this->initData('page', $_SESSION['ZWII_CONTENT'], false); $this->initData('module', $_SESSION['ZWII_CONTENT'], false); - // Supprime l'installation FR générée par défaut. - if (is_dir(self::DATA_DIR . 'fr_FR')) - $this->removeDir(self::DATA_DIR . 'fr_FR'); + $this->initData('locale', $_SESSION['ZWII_CONTENT'], false); } // Sauvegarder la configuration du Proxy