From 4e84e4fb3879fbc15bff13adc81dc7ab2db2bb54 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 26 Oct 2022 15:53:26 +0200 Subject: [PATCH] =?UTF-8?q?dev017=20Bug=20installation=20Drapeau=20de=20la?= =?UTF-8?q?ngue=20affich=C3=A9=20sur=20un=20site=20non=20multilangue=20Eff?= =?UTF-8?q?acement=20de=20la=20langue=20de=20site=20active?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 52 ++++++++++++------- core/include/update.inc.php | 5 +- core/module/install/install.php | 3 +- core/module/install/ressource/i18n/es.json | 9 ++-- core/module/install/ressource/i18n/fr_FR.json | 11 ++-- core/module/translate/translate.php | 22 +++++--- core/module/translate/view/index/index.php | 6 +-- site/i18n/es.json | 11 ++-- site/i18n/fr_FR.json | 11 ++-- 9 files changed, 78 insertions(+), 52 deletions(-) diff --git a/core/core.php b/core/core.php index 2fd1ac17..0941e85a 100644 --- a/core/core.php +++ b/core/core.php @@ -49,7 +49,7 @@ class common // Numéro de version const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; - const ZWII_VERSION = '12.0.00-dev017'; + const ZWII_VERSION = '12.0.00-dev018'; const ZWII_UPDATE_CHANNEL = "test"; public static $actions = []; @@ -1680,7 +1680,6 @@ class common file_exists(self::FILE_DIR . 'source/' . $faviconDark) ) { echo ''; - //echo ''; echo ''; } } @@ -1738,7 +1737,18 @@ class common } // Retourne les items du menu echo ''; } @@ -2308,27 +2318,26 @@ class common /** * Affiche le cadre avec les drapeaux sélectionnés */ - public function showi18n() + public function showi18n($lang) { - foreach (self::$languages as $key => $value) { + if ( + is_dir(self::DATA_DIR . $lang) + ) { if ( - is_dir(self::DATA_DIR . $key) + (isset($_COOKIE['ZWII_CONTENT']) + and $_COOKIE['ZWII_CONTENT'] === $lang + ) ) { - if ( - (isset($_COOKIE['ZWII_CONTENT']) - and $_COOKIE['ZWII_CONTENT'] === $key - ) - ) { - $select = ' class="i18nFlagSelected" '; - } else { - $select = ' class="i18nFlag" '; - } - - echo '
  • '; - echo '' .  $value . ''; - echo '
  • '; + $select = ' class="i18nFlagSelected" '; + } else { + $select = ' class="i18nFlag" '; } + + $items = '
  • '; + $items .= '' .  self::$languages[$lang] . ''; + $items .= '
  • '; } + return $items; } } @@ -2464,6 +2473,9 @@ class core extends common $fontFile = $gf ? '' . $fontFile : $fontFile; // Enregistre la personnalisation + if (!is_dir(self::DATA_DIR . 'fonts')) { + mkdir(self::DATA_DIR . 'fonts'); + } file_put_contents(self::DATA_DIR . 'fonts/fonts.html', $fontFile); /** @@ -2885,7 +2897,7 @@ class core extends common // Accès concurrent stocke la page visitée if ( $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') - and $this->getUser('id') + && $this->getUser('id') ) { $this->setData(['user', $this->getUser('id'), 'accessUrl', $this->getUrl()]); $this->setData(['user', $this->getUser('id'), 'accessTimer', time()]); diff --git a/core/include/update.inc.php b/core/include/update.inc.php index 0673831e..2e9d69d3 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -920,7 +920,10 @@ if ($this->getData(['core', 'dataVersion']) < 12000) { } // Langue de l'interface $this->deleteData(['config', 'i18n']); - $this->setData(['user', $this->getUser('id'), 'language', 'fr_FR']); + // Pas à l'installation + if ($this->getUser('id')) { + $this->setData(['user', $this->getUser('id'), 'language', 'fr_FR']); + } // Mise à jour $this->setData(['core', 'dataVersion', 12000]); } diff --git a/core/module/install/install.php b/core/module/install/install.php index e3a583b5..7b3de731 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -132,7 +132,8 @@ class install extends common 'pseudo' => 'Admin', 'signature' => 1, 'mail' => $userMail, - 'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true) + 'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true), + 'language' => self::$i18nUI ] ]); diff --git a/core/module/install/ressource/i18n/es.json b/core/module/install/ressource/i18n/es.json index 7782435d..910dd1da 100644 --- a/core/module/install/ressource/i18n/es.json +++ b/core/module/install/ressource/i18n/es.json @@ -306,11 +306,10 @@ "Gestion": "Administrar", "Administration": "Administración", "Langues": "Idiomas", - "Traductions de l'interface": "Idiomas interfaz", + "Langues de l'interface": "Idiomas interfaz", "Éditer les dialogues": "Editar los diálogos", - "Traductions installées": "Idiomas instalados", + "Langues du site": "Idiomas instalados", "Traduction supprimée": "Traducción eliminada", - "Traductions du site": "Idiomas sitio", "Langue de l'administration": "Idioma de la administración", "Langues installées": "Idiomas instalados", "Dans quelle langue utiliserez-vous Zwii ?": "¿En qué idioma usará Zwii?", @@ -489,5 +488,7 @@ "Interface": "Interfaz", "Importer dans": "Importar a", "Archive ZIP": "Archivo ZIP", - "Archive": "Archivo" + "Archive": "Archivo", + "Langue par défaut": "Idioma predeterminado", + "Langue du site sélectionnée": "Idioma del sitio web seleccionado" } \ No newline at end of file diff --git a/core/module/install/ressource/i18n/fr_FR.json b/core/module/install/ressource/i18n/fr_FR.json index 6971d69b..da5adc0f 100644 --- a/core/module/install/ressource/i18n/fr_FR.json +++ b/core/module/install/ressource/i18n/fr_FR.json @@ -305,13 +305,12 @@ "Gestion": "", "Administration": "", "Langues": "", - "Traductions de l'interface": "", + "Langues de l'interface": "", "Éditer les dialogues": "", - "Traductions installées": "", - "Traductions du site": "", + "Langues installées": "", + "Langues du site": "", "Interface": "", "Langue de l'administration": "", - "Langues installées": "", "Dans quelle langue utiliserez-vous Zwii ?": "", "Maintenance": "", "Scripts externes": "", @@ -486,5 +485,7 @@ "Menu accessoire": "", "Activer": "", "Importer dans": "", - "Archive": "" + "Archive": "", + "Langue par défaut": "", + "Langue du site sélectionnée": "" } \ No newline at end of file diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index e98d5a4b..13fa7810 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -129,21 +129,27 @@ class translate extends common foreach (self::$languages as $key => $value) { // tableau des langues installées if (is_dir(self::DATA_DIR . $key)) { + if (self::$i18nUI === $key) { + $message = helper::translate('Langue par défaut'); + } elseif (isset($_COOKIE['ZWII_CONTENT']) && $_COOKIE['ZWII_CONTENT'] === $key) { + $message = helper::translate('Langue du site sélectionnée'); + } else { + $message = ''; + } self::$languagesInstalled[] = [ template::flag($key, '20 %'), $value . ' (' . $key . ')', - self::$i18nUI === $key ? helper::translate('Interface') : '', - '', + $message, template::button('translateContentLanguageEdit' . $key, [ 'href' => helper::baseUrl() . $this->getUrl(0) . '/locale/' . $key, 'value' => template::ico('pencil'), 'help' => 'Éditer' ]), template::button('translateContentLanguageDelete' . $key, [ - 'class' => 'translateDelete buttonRed' . (self::$i18nUI === $key ? ' disabled' : ''), + 'class' => 'translateDelete buttonRed' . ($message ? ' disabled' : ''), 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $key . '/' . $_SESSION['csrf'], 'value' => template::ico('trash'), - 'help' => 'Supprimer' + 'help' => 'Supprimer', ]) ]; } @@ -445,9 +451,10 @@ class translate extends common public function delete() { // Jeton incorrect ou URl avec le code langue incorrecte + $lang = $this->getUrl(2); if ( $this->getUrl(3) !== $_SESSION['csrf'] - || !array_key_exists($this->getUrl(2), self::$languages) + || !array_key_exists($lang, self::$languages) ) { // Valeurs en sortie $this->addOutput([ @@ -456,10 +463,9 @@ class translate extends common 'notification' => helper::translate('Action interdite') ]); } - // Effacement d'une langue installée - if (is_dir(self::DATA_DIR . $this->getUrl(2)) === true) { - $success = $this->removeDir(self::DATA_DIR . $this->getUrl(2)); + if (is_dir(self::DATA_DIR . $lang) === true) { + $success = $this->removeDir(self::DATA_DIR . $lang); } // Valeurs en sortie $this->addOutput([ diff --git a/core/module/translate/view/index/index.php b/core/module/translate/view/index/index.php index 687d1049..72b20659 100644 --- a/core/module/translate/view/index/index.php +++ b/core/module/translate/view/index/index.php @@ -36,11 +36,11 @@
    'Traductions du site', + 'value' => 'Langues du site', 'class' => 'buttonTab' ]); ?> 'Traductions de l\'interface', + 'value' => 'Langues de l\'interface', 'class' => 'buttonTab' ]); ?>
    @@ -58,7 +58,7 @@
    - +
    diff --git a/site/i18n/es.json b/site/i18n/es.json index 48feefc0..910dd1da 100644 --- a/site/i18n/es.json +++ b/site/i18n/es.json @@ -130,7 +130,7 @@ "Supprimer le module": "Eliminar módulo", "Sauvegarder le module dans le gestionnaire de fichiers": "Guardar módulo en el administrador de archivos", "Sauvegarder et télécharger le module": "Guardar y descargar módulo", - "Sauvegarder les données du module dans le gestionnaire de fichiers": "Guardar de los datos del módulo en el administrador de archivos", + "Sauvegarder les données du module dans le gestionnaire de fichiers": "Guardar de los datos del módulo en el administrador de archivos", "'Sauvegarder et télécharger les données du module": "Guardar y descargar de los datos del módulo", "Installer depuis le catalogue en ligne": "Instalar desde el archivo en línea", "Installer depuis une archive": "Instalar desde un archivo", @@ -306,11 +306,10 @@ "Gestion": "Administrar", "Administration": "Administración", "Langues": "Idiomas", - "Traductions de l'interface": "Idiomas interfaz", + "Langues de l'interface": "Idiomas interfaz", "Éditer les dialogues": "Editar los diálogos", - "Traductions installées": "Idiomas instalados", + "Langues du site": "Idiomas instalados", "Traduction supprimée": "Traducción eliminada", - "Traductions du site": "Idiomas sitio", "Langue de l'administration": "Idioma de la administración", "Langues installées": "Idiomas instalados", "Dans quelle langue utiliserez-vous Zwii ?": "¿En qué idioma usará Zwii?", @@ -489,5 +488,7 @@ "Interface": "Interfaz", "Importer dans": "Importar a", "Archive ZIP": "Archivo ZIP", - "Archive": "Archivo" + "Archive": "Archivo", + "Langue par défaut": "Idioma predeterminado", + "Langue du site sélectionnée": "Idioma del sitio web seleccionado" } \ No newline at end of file diff --git a/site/i18n/fr_FR.json b/site/i18n/fr_FR.json index 6971d69b..da5adc0f 100644 --- a/site/i18n/fr_FR.json +++ b/site/i18n/fr_FR.json @@ -305,13 +305,12 @@ "Gestion": "", "Administration": "", "Langues": "", - "Traductions de l'interface": "", + "Langues de l'interface": "", "Éditer les dialogues": "", - "Traductions installées": "", - "Traductions du site": "", + "Langues installées": "", + "Langues du site": "", "Interface": "", "Langue de l'administration": "", - "Langues installées": "", "Dans quelle langue utiliserez-vous Zwii ?": "", "Maintenance": "", "Scripts externes": "", @@ -486,5 +485,7 @@ "Menu accessoire": "", "Activer": "", "Importer dans": "", - "Archive": "" + "Archive": "", + "Langue par défaut": "", + "Langue du site sélectionnée": "" } \ No newline at end of file