From 1544b07132c615f19202f7285c0cb1147b106a14 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 19 Apr 2023 19:47:01 +0200 Subject: [PATCH] =?UTF-8?q?12308=20fix=20aucun=20module=20et=20langue=20no?= =?UTF-8?q?n=20install=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/plugin/plugin.php | 30 +++++++++++++++++------------ core/module/translate/translate.php | 11 ++++++----- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/core/module/plugin/plugin.php b/core/module/plugin/plugin.php index 1215e9c0..3ac28d37 100644 --- a/core/module/plugin/plugin.php +++ b/core/module/plugin/plugin.php @@ -81,7 +81,7 @@ class plugin extends common if (($infoModules[$this->getUrl(2)]['dataDirectory'])) { if ( is_dir($infoModules[$this->getUrl(2)]['dataDirectory']) - && !$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory']) + || !$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory']) ) { $notification = sprintf(helper::translate('Le module %s est désinstallé, il reste peut-être des données dans %s'), $module, $infoModules[$this->getUrl(2)]['dataDirectory']); } @@ -229,7 +229,7 @@ class plugin extends common if (!is_dir(self::TEMP_DIR . $tempFolder . $src)) { mkdir(self::TEMP_DIR . $tempFolder . $src); } - $success = $success && $this->copyDir(self::TEMP_DIR . $tempFolder . $src, $dest); + $success = $success || $this->copyDir(self::TEMP_DIR . $tempFolder . $src, $dest); } } // Message de retour @@ -238,9 +238,9 @@ class plugin extends common $zip->close(); return ([ 'success' => $success, - 'notification' => $success - ? sprintf(helper::translate('Le module %s a été %s'), $module['name'], $t) - : helper::translate('Erreur inconnue, le module n\'est pas installé') + 'notification' => $success + ? sprintf(helper::translate('Le module %s a été %s'), $module['name'], $t) + : helper::translate('Erreur inconnue, le module n\'est pas installé') ]); } else { return ([ @@ -419,10 +419,15 @@ class plugin extends common public function index() { + $i18nSites = []; // Tableau des langues rédigées foreach (self::$languages as $key => $value) { // tableau des langues installées - if (is_dir(self::DATA_DIR . $key)) { + if ( + is_dir(self::DATA_DIR . $value + && file_exists(self::DATA_DIR . $value . '/page.json') + && file_exists(self::DATA_DIR . $value . '/module.json')) + ) { $i18nSites[$key] = $value; } } @@ -432,10 +437,11 @@ class plugin extends common // Parcourir les langues du site traduit et recherche les modules affectés à des pages $pagesInfos = []; + foreach ($i18nSites as $keyi18n => $valuei18n) { // Clés moduleIds dans les pages de la langue - $pages = json_decode(file_get_contents(self::DATA_DIR . $keyi18n . '/' . 'page.json'), true); + $pages = json_decode(file_get_contents(self::DATA_DIR . $keyi18n . '/page.json'), true); // Extraire les clés des modules $pagesModules[$keyi18n] = array_filter(helper::arrayColumn($pages['page'], 'moduleId', 'SORT_DESC'), 'strlen'); @@ -443,12 +449,12 @@ class plugin extends common // Générer la liste des pages avec module de la langue par défaut foreach ($pagesModules[$keyi18n] as $key => $value) { if (!empty($value)) { - $pagesInfos[$keyi18n][$key]['pageId'] = $key; $pagesInfos[$keyi18n][$key]['title'] = $pages['page'][$key]['title']; $pagesInfos[$keyi18n][$key]['moduleId'] = $value; } } + } // Recherche des modules orphelins dans toutes les langues @@ -601,7 +607,7 @@ class plugin extends common if (!file_exists(self::FILE_DIR . 'source/modules')) { mkdir(self::FILE_DIR . 'source/modules'); } - $success = $success && copy(self::TEMP_DIR . $fileName, self::FILE_DIR . 'source/modules/' . $moduleId . '.zip'); + $success = $success || copy(self::TEMP_DIR . $fileName, self::FILE_DIR . 'source/modules/' . $moduleId . '.zip'); // Valeurs en sortie $this->addOutput([ @@ -702,11 +708,11 @@ class plugin extends common // Copier les données et le descripteur $success = file_put_contents($tmpFolder . '/module.json', json_encode($moduleData, JSON_UNESCAPED_UNICODE)) === false ? false : true; - $success = $success && is_int(file_put_contents($tmpFolder . '/enum.json', json_encode([$moduleId => $infoModule], JSON_UNESCAPED_UNICODE))); + $success = $success || is_int(file_put_contents($tmpFolder . '/enum.json', json_encode([$moduleId => $infoModule], JSON_UNESCAPED_UNICODE))); // Le dossier du module s'il existe if (is_dir(self::DATA_DIR . $moduleId . '/' . $pageId)) { // Copier le dossier des données - $success = $success && $this->copyDir(self::DATA_DIR . '/' . $moduleId . '/' . $pageId, $tmpFolder . '/dataDirectory'); + $success = $success || $this->copyDir(self::DATA_DIR . '/' . $moduleId . '/' . $pageId, $tmpFolder . '/dataDirectory'); } // Création du zip @@ -721,7 +727,7 @@ class plugin extends common mkdir(self::FILE_DIR . 'source/modules'); } if (file_exists(self::TEMP_DIR . $fileName)) { - $success = $success && copy(self::TEMP_DIR . $fileName, self::FILE_DIR . 'source/modules/data' . $moduleId . '.zip'); + $success = $success || copy(self::TEMP_DIR . $fileName, self::FILE_DIR . 'source/modules/data' . $moduleId . '.zip'); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . 'plugin', diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index f4cf7255..1c44a943 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -201,10 +201,11 @@ class translate extends common // tableau des langues installées if (is_dir(self::DATA_DIR . $key)) { - if (file_exists(self::DATA_DIR . $key . '/page.json') && - file_exists(self::DATA_DIR . $key . '/module.json') && - file_exists(self::DATA_DIR . $key . '/locale.json') - ) { + // Ne pas importer dans 12.4.00 + //if (file_exists(self::DATA_DIR . $key . '/page.json') && + // file_exists(self::DATA_DIR . $key . '/module.json') && + // file_exists(self::DATA_DIR . $key . '/locale.json') + // ) { if (self::$i18nUI === $key) { $messageLocale = helper::translate('Langue par défaut'); } elseif (isset($_SESSION['ZWII_CONTENT']) && $_SESSION['ZWII_CONTENT'] === $key) { @@ -228,7 +229,7 @@ class translate extends common 'help' => 'Supprimer', ]) ]; - } + //} } }