[10.0.04.dev] ajout d'une ,otification d'importation et de réparation
This commit is contained in:
parent
4886a8e371
commit
7e3ce76e4c
@ -35,7 +35,7 @@ class common {
|
|||||||
const TEMP_DIR = 'site/tmp/';
|
const TEMP_DIR = 'site/tmp/';
|
||||||
|
|
||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_VERSION = '10.0.03.dev';
|
const ZWII_VERSION = '10.0.04.dev';
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
public static $coreModuleIds = [
|
public static $coreModuleIds = [
|
||||||
@ -68,6 +68,8 @@ class common {
|
|||||||
];
|
];
|
||||||
public static $inputBefore = [];
|
public static $inputBefore = [];
|
||||||
public static $inputNotices = [];
|
public static $inputNotices = [];
|
||||||
|
public static $importNotices = [];
|
||||||
|
public static $coreNotices = [];
|
||||||
public $output = [
|
public $output = [
|
||||||
'access' => true,
|
'access' => true,
|
||||||
'content' => '',
|
'content' => '',
|
||||||
@ -146,6 +148,7 @@ class common {
|
|||||||
if (file_exists(self::DATA_DIR . 'core.json') === true &&
|
if (file_exists(self::DATA_DIR . 'core.json') === true &&
|
||||||
$this->getData(['core','dataVersion']) < 10000) {
|
$this->getData(['core','dataVersion']) < 10000) {
|
||||||
$this->importData();
|
$this->importData();
|
||||||
|
common::$importNotices [] = "Importation réalisée avec succès" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Installation fraîche, initialisation des modules manquants
|
// Installation fraîche, initialisation des modules manquants
|
||||||
@ -153,6 +156,7 @@ class common {
|
|||||||
$folder = $this->dirData ($stageId, 'fr');
|
$folder = $this->dirData ($stageId, 'fr');
|
||||||
if (file_exists($folder . $stageId .'.json') === false) {
|
if (file_exists($folder . $stageId .'.json') === false) {
|
||||||
$this->iniData($stageId);
|
$this->iniData($stageId);
|
||||||
|
common::$coreNotices [] = $stageId ;
|
||||||
// Prévoir une notification ici
|
// Prévoir une notification ici
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -515,6 +519,7 @@ class common {
|
|||||||
* Convertit un fichier de données data.json puis le renomme
|
* Convertit un fichier de données data.json puis le renomme
|
||||||
*/
|
*/
|
||||||
public function importData() {
|
public function importData() {
|
||||||
|
$lang = 'fr';
|
||||||
// Trois tentatives de lecture
|
// Trois tentatives de lecture
|
||||||
for($i = 0; $i < 3; $i++) {
|
for($i = 0; $i < 3; $i++) {
|
||||||
$tempData=json_decode(file_get_contents(self::DATA_DIR.'core.json'), true);
|
$tempData=json_decode(file_get_contents(self::DATA_DIR.'core.json'), true);
|
||||||
@ -529,8 +534,12 @@ class common {
|
|||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
// Backup
|
// Backup
|
||||||
rename (self::DATA_DIR.'core.json',self::DATA_DIR.'imported_data.json');
|
rename (self::DATA_DIR.'core.json',self::DATA_DIR.'imported_core.json');
|
||||||
rename (self::DATA_DIR.'theme.json',self::DATA_DIR.'imported_theme.json');
|
rename (self::DATA_DIR.'theme.json',self::DATA_DIR.'imported_theme.json');
|
||||||
|
// Dossier de langues
|
||||||
|
if (!file_exists(self::DATA_DIR . '/' . $lang)) {
|
||||||
|
mkdir (self::DATA_DIR . '/' . $lang);
|
||||||
|
}
|
||||||
// Ecriture des données
|
// Ecriture des données
|
||||||
$this->setData(['config',$tempData['config']]);
|
$this->setData(['config',$tempData['config']]);
|
||||||
$this->setData(['core',$tempData['core']]);
|
$this->setData(['core',$tempData['core']]);
|
||||||
@ -2453,6 +2462,15 @@ class layout extends common {
|
|||||||
* Affiche la notification
|
* Affiche la notification
|
||||||
*/
|
*/
|
||||||
public function showNotification() {
|
public function showNotification() {
|
||||||
|
if (common::$importNotices) {
|
||||||
|
$notification = common::$importNotices [0];
|
||||||
|
$notificationClass = 'notificationSuccess';
|
||||||
|
}
|
||||||
|
if (common::$coreNotices) {
|
||||||
|
$notification = 'Données absentes, restauration de <p> | ';
|
||||||
|
foreach (common::$coreNotices as $item) $notification .= $item . ' | ';
|
||||||
|
$notificationClass = 'notificationError';
|
||||||
|
}
|
||||||
if(common::$inputNotices) {
|
if(common::$inputNotices) {
|
||||||
$notification = 'Impossible de soumettre le formulaire, car il contient des erreurs';
|
$notification = 'Impossible de soumettre le formulaire, car il contient des erreurs';
|
||||||
$notificationClass = 'notificationError';
|
$notificationClass = 'notificationError';
|
||||||
|
Loading…
Reference in New Issue
Block a user