From 2a87b98d9a0866250f491b70881336ba564f5ebb Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 3 May 2023 19:47:37 +0200 Subject: [PATCH] =?UTF-8?q?For=C3=A7age=20sauvegarde=20=20JSON=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 1 + core/class/jsondb/JsonDb.class.php | 2 +- core/core.php | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f57fe78c..0d64f586 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ # Améliorations - Gestion des groupes de profils d'utilisateurs. - Améliore la gestion de la base de données et la génération du fichier de journalisation. +- Stockage des données JSON, forçage au format objet. ## Version 12.3.10 - Mise à jour du fichier dialog.php de Responsive File Manager diff --git a/core/class/jsondb/JsonDb.class.php b/core/class/jsondb/JsonDb.class.php index 76171c77..8344c045 100644 --- a/core/class/jsondb/JsonDb.class.php +++ b/core/class/jsondb/JsonDb.class.php @@ -143,7 +143,7 @@ class JsonDb extends \Prowebcraft\Dot public function save() { //$v = json_encode($this->data, JSON_UNESCAPED_UNICODE ); - $v = json_encode($this->data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE ); + $v = json_encode($this->data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); $l = strlen($v); $t = 0; while ($t < 5) { diff --git a/core/core.php b/core/core.php index 92427713..0b8b07e7 100644 --- a/core/core.php +++ b/core/core.php @@ -624,7 +624,7 @@ class common } // Site en français avec site exemple if ($lang == 'fr_FR' && $sampleSite === true) { - file_put_contents(self::DATA_DIR . $lang . '/' . $module . '.json', json_encode([$module => init::$siteTemplate[$module]], JSON_PRETTY_PRINT)); + file_put_contents(self::DATA_DIR . $lang . '/' . $module . '.json', json_encode([$module => init::$siteTemplate[$module]], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT)); // Site de test ou page simple foreach (init::$siteContent as $key => $value) { // Creation du contenu de la page @@ -640,7 +640,7 @@ class common if (!isset(init::$defaultDataI18n[$lang])) { $langDefault = 'default'; } - file_put_contents(self::DATA_DIR . $lang . '/' . $module . '.json', json_encode([$module => init::$defaultDataI18n[$langDefault][$module]], JSON_PRETTY_PRINT)); + file_put_contents(self::DATA_DIR . $lang . '/' . $module . '.json', json_encode([$module => init::$defaultDataI18n[$langDefault][$module]], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT)); // Créer la page d'accueil $pageId = init::$defaultDataI18n[$langDefault]['locale']['homePageId']; $content = init::$defaultDataI18n[$langDefault]['html']; @@ -648,7 +648,7 @@ class common } } else { // Installation des données du module - file_put_contents(self::DATA_DIR . $module . '.json', json_encode([$module => init::$defaultData[$module]], JSON_PRETTY_PRINT)); + file_put_contents(self::DATA_DIR . $module . '.json', json_encode([$module => init::$defaultData[$module]], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT)); } }