From f204b3020f6135c7b26abe13dc65ac197525988b Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Mon, 20 Feb 2023 15:22:58 +0100 Subject: [PATCH] Bug langue installation --- core/core.php | 9 ++++++--- core/include/update.inc.php | 6 ++++-- core/module/install/install.php | 29 ++++++++++++++++++----------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/core/core.php b/core/core.php index 7111ebcd..694cdd18 100644 --- a/core/core.php +++ b/core/core.php @@ -351,10 +351,13 @@ class common && !file_exists(self::I18N_DIR . self::$i18nUI . '.json') ? 'fr_FR' : self::$i18nUI; + } else { + // Installation + self::$i18nUI = $this->getInput('ZWII_UI') ? $this->getInput('ZWII_UI') : 'fr_FR' ; } // Stocker le cookie de langue pour l'éditeur de texte - setcookie('ZWII_UI', self::$i18nUI, time() + 3600, '/', '', false, false); + setcookie('ZWII_UI', self::$i18nUI, time() + 3600, '/', '', helper::isHttps(), false); // Utilisateur connecté if ($this->user === []) { @@ -1547,7 +1550,7 @@ class common // Affichage du sitemap $items .= 'getData(['theme', 'footer', 'displaySiteMap']) === false ? ' class="displayNone"' : ''; - $label = empty($this->getData(['locale', 'sitemapPageLabel'])) ? 'Plan du site' : $this->getData(['locale', 'sitemapPageLabel']); + $label = ($this->getData(['locale', 'sitemapPageLabel']) === 'none') ? 'Plan du site' : $this->getData(['locale', 'sitemapPageLabel']); $items .= '> | ' . $label . ''; $items .= ''; // Affichage du module de recherche @@ -2073,7 +2076,7 @@ class common $notificationClass = 'notificationError'; } if (common::$coreNotices) { - $notification = 'Données absentes, restauration de

| '; + $notification = sprintf('%s

| ', helper::translate( 'Restauration des bases de données absentes')); foreach (common::$coreNotices as $item) $notification .= $item . ' | '; $notificationClass = 'notificationError'; diff --git a/core/include/update.inc.php b/core/include/update.inc.php index df06610d..2f8e3a0a 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -939,8 +939,10 @@ if ($this->getData(['core', 'dataVersion']) < 12300) { rename(self::I18N_DIR . 'gr_GR.json', self::I18N_DIR . 'el_GR.json'); } $d = $this->getData(['languages', 'gr_GR']); - $this->setData(['languages', 'el_GR', $d]); - $this->deleteData(['languages', 'gr_GR']); + if ($d) { + $this->setData(['languages', 'el_GR', $d]); + $this->deleteData(['languages', 'gr_GR']); + } // Idem pour les modules $moduleIds = ['blog', 'news', 'gallery', 'search', 'redirection', 'form']; foreach ($moduleIds as $key => $value) { diff --git a/core/module/install/install.php b/core/module/install/install.php index 2464a937..21a07cdc 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -55,7 +55,8 @@ class install extends common // Soumission du formulaire if ($this->isPost()) { $lang = $this->getInput('installLanguage'); - setcookie('ZWII_UI', $lang, time() + 3600, helper::baseUrl(false, false), '', helper::isHttps(), true); + // Place le cookie pour la suite de l'installation + //setcookie('ZWII_UI', $lang, time() + 3600, helper::baseUrl(false, false), '', helper::isHttps(), true); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . 'install/postinstall/' . $lang @@ -66,7 +67,8 @@ class install extends common // Liste des langues UI disponibles if (is_dir(self::I18N_DIR)) { foreach ($this->getData(['languages']) as $lang => $value) { - self::$i18nFiles [$lang] = self::$languages[$lang];; + self::$i18nFiles[$lang] = self::$languages[$lang]; + ; } } @@ -97,8 +99,12 @@ class install extends common $success = true; // Validation de la langue transmise - $lang = array_key_exists($this->getUrl(2), self::$languages) ? $this->getUrl(2) : 'fr_FR'; - setcookie('ZWII_CONTENT', $lang, time() + 3600, helper::baseUrl(false, false), '', helper::isHttps(), true); + self::$i18nUI = $this->getUrl(2); + self::$i18nUI = array_key_exists(self::$i18nUI, self::$languages) ? self::$i18nUI : 'fr_FR'; + + // par défaut le contenu est la langue d'installation + self::$i18nContent = self::$i18nUI; + setcookie('ZWII_CONTENT', self::$i18nContent, time() + 3600, helper::baseUrl(false, false), '', helper::isHttps(), true); // Double vérification pour le mot de passe @@ -126,7 +132,7 @@ class install extends common 'signature' => 1, 'mail' => $userMail, 'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true), - 'language' => $lang + 'language' => self::$i18nUI ] ]); @@ -147,7 +153,7 @@ class install extends common // Installation du site de test if ( $this->getInput('installDefaultData', helper::FILTER_BOOLEAN) === false - && $lang === 'fr_FR' + && self::$i18nContent === 'fr_FR' ) { $this->initData('page', self::$i18nContent, true); $this->initData('module', self::$i18nContent, true); @@ -157,9 +163,11 @@ class install extends common } // Jeu réduit pour les pages étrangères - if ($lang !== 'fr_FR') { + if (self::$i18nContent !== 'fr_FR') { $this->initData('page', self::$i18nContent, false); $this->initData('module', self::$i18nContent, false); + // Supprime l'installation FR générée par défaut. + $this->removeDir(self::DATA_DIR . 'fr_FR'); } // Sauvegarder la configuration du Proxy @@ -188,8 +196,6 @@ class install extends common // Nettoyage unlink(self::TEMP_DIR . 'files.tar.gz'); unlink(self::TEMP_DIR . 'files.tar'); - helper::deleteCookie('ZWII_UI'); - // Créer le dossier des fontes if (!is_dir(self::DATA_DIR . 'fonts')) { @@ -223,13 +229,14 @@ class install extends common unlink(self::I18N_DIR . 'languages.json'); // Créer sitemap - $this->createSitemap(); + // $this->createSitemap(); + // Mise à jour de la liste des pages pour TinyMCE $this->listPages(); // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl(false), + 'redirect' => helper::baseUrl(true) . $this->getData(['locale', 'homePageId']), 'notification' => $sent === true ? helper::translate('Installation terminée') : $sent, 'state' => ($sent === true && $success === true) ? true : null ]);