From 456b9599098bc9c25aaf47844a3edfd565dbb66e Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 23 Dec 2018 23:37:17 +0100 Subject: [PATCH] v9.0.0 dissocier data et theme --- CHANGES.MD | 1 + core/core.php | 50 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CHANGES.MD b/CHANGES.MD index b2ab57e5..f3f58f8b 100644 --- a/CHANGES.MD +++ b/CHANGES.MD @@ -3,6 +3,7 @@ ## Verison 8.5.2 * Correction : - Thème menu : aperçu quand le menu est au-dessus et en-dehors du site + ## Version 8.5.1 * Correction : - Nom de variable incorrect diff --git a/core/core.php b/core/core.php index cc7617bd..ada15220 100644 --- a/core/core.php +++ b/core/core.php @@ -24,7 +24,7 @@ class common { const GROUP_MEMBER = 1; const GROUP_MODERATOR = 2; const GROUP_ADMIN = 3; - const ZWII_VERSION = '8.6.0'; + const ZWII_VERSION = '9.0.0'; public static $actions = []; public static $coreModuleIds = [ @@ -294,7 +294,7 @@ class common { ] ] ], - 'user' => [], + 'user' => [], 'theme' => [ 'body' => [ 'backgroundColor' => 'rgba(236, 239, 241, 1)', @@ -453,17 +453,21 @@ class common { if(isset($_COOKIE)) { $this->input['_COOKIE'] = $_COOKIE; } + // Génère le fichier de donnée - if(file_exists('site/data/data.json') === false) { + if(file_exists('site/data/data.json') === false || + file_exists('site/data/theme.json') === false ) { $this->setData([$this->defaultData]); $this->saveData(); chmod('site/data/data.json', 0755); + chmod('site/data/theme.json', 0755); } + // Import des données if($this->data === []) { // Trois tentatives for($i = 0; $i < 3; $i++) { - $this->setData([json_decode(file_get_contents('site/data/data.json'), true)]); + $this->setData([json_decode(file_get_contents('site/data/data.json'), true) + json_decode(file_get_contents('site/data/theme.json'), true)]); if($this->data) { break; } @@ -473,7 +477,9 @@ class common { // Pause de 10 millisecondes usleep(10000); } + } + // Mise à jour $this->update(); // Utilisateur connecté @@ -783,9 +789,23 @@ class common { * Enregistre les données */ public function saveData() { + + // Save config core page module et user + // 5 premières clés principales // Trois tentatives for($i = 0; $i < 3; $i++) { - if(file_put_contents('site/data/data.json', json_encode($this->getData()), LOCK_EX) !== false) { + if(file_put_contents('site/data/data.json', json_encode(array_slice($this->getData(),0,5)) , LOCK_EX) !== false) { + break; + } + // Pause de 10 millisecondes + usleep(10000); + } + + // Save theme + // dernière clé principale + // Trois tentatives + for($i = 0; $i < 3; $i++) { + if(file_put_contents('site/data/theme.json', json_encode(array_slice($this->getData(),5)), LOCK_EX) !== false) { break; } // Pause de 10 millisecondes @@ -793,6 +813,8 @@ class common { } } + + /** * Envoi un mail * @param string|array $to Destinataire @@ -937,7 +959,13 @@ class common { $this->deleteData(['config','ItemsperPage']); $this->setData(['core', 'dataVersion', 851]); $this->SaveData(); - } + } + // Version 9.0.0 + if($this->getData(['core', 'dataVersion']) < 900) { + + $this->setData(['core', 'dataVersion', 900]); + $this->SaveData(); + } } } @@ -2105,11 +2133,11 @@ class layout extends common { $rightItems .= '
  • ' . template::ico('users') . '
  • '; $rightItems .= '
  • ' . template::ico('brush') . '
  • '; $rightItems .= '
  • ' . template::ico('gear') . '
  • '; - // menu image - if(helper::checkNewVersion()) { - $rightItems .= '
  • ' . template::ico('update colorRed') . '
  • '; - } - // menu image + // UA + // if(helper::checkNewVersion()) { + // $rightItems .= '
  • ' . template::ico('update colorRed') . '
  • '; + // } + // UA } $rightItems .= '
  • ' . template::ico('user', 'right') . $this->getUser('firstname') . ' ' . $this->getUser('lastname') . '
  • '; $rightItems .= '
  • ' . template::ico('logout') . '
  • ';