[10.0.03.dev] import ok

This commit is contained in:
fredtempez 2019-08-20 16:11:54 +02:00
parent 2dd10e0c58
commit 263ca87d83
1 changed files with 37 additions and 34 deletions

View File

@ -142,18 +142,22 @@ class common {
$this->input['_COOKIE'] = $_COOKIE; $this->input['_COOKIE'] = $_COOKIE;
} }
// Import version 9 ou initialisation // Import version 9
// if (file_exists(self::DATA_DIR . 'config.json') === true && if (file_exists(self::DATA_DIR . 'core.json') === true &&
// $this->getData(['config','dataVersion']) < 10000) { $this->getData(['core','dataVersion']) < 10000) {
// $this->importData(); $this->importData();
// }
if (file_exists(self::DATA_DIR . 'config.json') === false ||
file_exists(self::DATA_DIR . 'core.json') === false ||
file_exists(self::DATA_DIR . 'theme.json') === false ||
file_exists(self::DATA_DIR . 'user.json') === false ) {
$this->iniData();
} }
// Installation fraîche, initialisation des modules manquants
foreach (self::$dataStage as $stageId) {
$folder = $this->dirData ($stageId, 'fr');
if (file_exists($folder . $stageId .'.json') === false) {
$this->iniData($stageId);
// Prévoir une notification ici
}
}
// Mise à jour des données core // Mise à jour des données core
$this->update(); $this->update();
@ -533,7 +537,7 @@ class common {
$this->setData(['user',$tempData['user']]); $this->setData(['user',$tempData['user']]);
$this->setData(['page',$tempData['page']]); $this->setData(['page',$tempData['page']]);
$this->setData(['module',$tempData['module']]); $this->setData(['module',$tempData['module']]);
$this->setData(['theme',$tempTheme]); $this->setData(['theme',$tempTheme['theme']]);
} }
/** /**
@ -607,7 +611,7 @@ class common {
// Sauf pour les pages et les modules // Sauf pour les pages et les modules
if ($stageId === 'page' || if ($stageId === 'page' ||
$stageId === 'module') { $stageId === 'module') {
$folder = self::DATA_DIR . $lang . DIRECTORY_SEPARATOR ; $folder = self::DATA_DIR . $lang . '/' ;
} else { } else {
$folder = self::DATA_DIR; $folder = self::DATA_DIR;
} }
@ -823,32 +827,31 @@ class common {
/** /**
* Initialisation des données * Initialisation des données
* @param array $keys Clé(s) des données * @param array $module : nom du module à générer
* choix valides : core config user theme page module
*/ */
public function iniData() { public function iniData($module) {
// Initialisation des 5 zones de stockage // Tableau avec les données vierges
require_once('core/module/install/ressource/defaultdata.php'); require_once('core/module/install/ressource/defaultdata.php');
// Langue et chemin pour page et module // Langue
$lang='fr'; $lang='fr';
foreach (self::$dataStage as $stageId) {
// Stockage dans un sous-dossier localisé // Stockage dans un sous-dossier localisé
// Le dossier de langue existe t-il ? // Le dossier de langue existe t-il ?
if (!file_exists(self::DATA_DIR . '/' . $lang)) { if (!file_exists(self::DATA_DIR . '/' . $lang)) {
mkdir (self::DATA_DIR . '/' . $lang); mkdir (self::DATA_DIR . '/' . $lang);
} }
$folder = $this->dirData ($stageId,$lang); $folder = $this->dirData ($module,$lang);
// Constructeur // Constructeur
$db[$stageId] = new \Prowebcraft\JsonDb([ $db = new \Prowebcraft\JsonDb([
'name' => $stageId . '.json', 'name' => $module . '.json',
'dir' => $folder, 'dir' => $folder,
'template' => self::TEMP_DIR . 'data.template.json' 'template' => self::TEMP_DIR . 'data.template.json'
]); ]);
$db[$stageId]->set($stageId,initdata::$defaultData[$stageId]); $db->set($module,initdata::$defaultData[$module]);
$db[$stageId]->save; $db->save;
}
} }