[10.0.02.dev] delete ok
This commit is contained in:
parent
2084dca548
commit
2dd10e0c58
|
@ -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 = '9.3.00.dev';
|
const ZWII_VERSION = '10.0.02.dev';
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
public static $coreModuleIds = [
|
public static $coreModuleIds = [
|
||||||
|
@ -142,21 +142,18 @@ class common {
|
||||||
$this->input['_COOKIE'] = $_COOKIE;
|
$this->input['_COOKIE'] = $_COOKIE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import des données d'une version 8 et 9
|
// Import version 9 ou initialisation
|
||||||
$this->importData();
|
// if (file_exists(self::DATA_DIR . 'config.json') === true &&
|
||||||
|
// $this->getData(['config','dataVersion']) < 10000) {
|
||||||
// Génère le fichier de données lorque les deux fichiers sont absents ou seulement le thème est - installation fraîche par défaut
|
// $this->importData();
|
||||||
if(
|
// }
|
||||||
file_exists(self::DATA_DIR.'config.json') === false ||
|
if (file_exists(self::DATA_DIR . 'config.json') === false ||
|
||||||
file_exists(self::DATA_DIR . 'core.json') === false ||
|
file_exists(self::DATA_DIR . 'core.json') === false ||
|
||||||
file_exists(self::DATA_DIR . 'theme.json') === false ||
|
file_exists(self::DATA_DIR . 'theme.json') === false ||
|
||||||
file_exists(self::DATA_DIR . 'user.json') === false ) {
|
file_exists(self::DATA_DIR . 'user.json') === false ) {
|
||||||
// Initialisation
|
|
||||||
$this->iniData();
|
$this->iniData();
|
||||||
//$this->saveData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Mise à jour des données core
|
// Mise à jour des données core
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
|
@ -270,27 +267,44 @@ class common {
|
||||||
* @param array $keys Clé(s) des données
|
* @param array $keys Clé(s) des données
|
||||||
*/
|
*/
|
||||||
public function deleteData($keys) {
|
public function deleteData($keys) {
|
||||||
|
// Langue et chemin pour page et module
|
||||||
|
$lang='fr';
|
||||||
|
//Retourne une chaine contenant le dossier à créer
|
||||||
|
$folder = $this->dirData ($keys[0],$lang);
|
||||||
|
// Constructeur
|
||||||
|
$db = new \Prowebcraft\JsonDb([
|
||||||
|
'name' => $keys[0] . '.json',
|
||||||
|
'dir' => $folder,
|
||||||
|
'template' => self::TEMP_DIR . 'data.template.json'
|
||||||
|
]);
|
||||||
switch(count($keys)) {
|
switch(count($keys)) {
|
||||||
case 1:
|
case 1:
|
||||||
unset($this->data[$keys[0]]);
|
$db->delete($keys[0]);
|
||||||
|
$db->save();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
unset($this->data[$keys[0]][$keys[1]]);
|
$db->delete($keys[0].'.'.$keys[1]);
|
||||||
|
$db->save();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
unset($this->data[$keys[0]][$keys[1]][$keys[2]]);
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2]);
|
||||||
|
$db->save();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
unset($this->data[$keys[0]][$keys[1]][$keys[2]][$keys[3]]);
|
$db->deleteet($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3]);
|
||||||
|
$db->save();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
unset($this->data[$keys[0]][$keys[1]][$keys[2]][$keys[3]][$keys[4]]);
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4]);
|
||||||
|
$db->save();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
unset($this->data[$keys[0]][$keys[1]][$keys[2]][$keys[3]][$keys[4]][$keys[5]]);
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5]);
|
||||||
|
$db->save();
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
unset($this->data[$keys[0]][$keys[1]][$keys[2]][$keys[3]][$keys[4]][$keys[5]][$keys[6]]);
|
$db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5].'.'.$keys[6]);
|
||||||
|
$db->save();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,9 +511,6 @@ 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() {
|
||||||
// Détecter les fichiers d'une V9
|
|
||||||
if ($this->getData(['config','dataVersion'] < 10000)) {
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -513,16 +524,16 @@ class common {
|
||||||
// Pause de 10 millisecondes
|
// Pause de 10 millisecondes
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
|
// Backup
|
||||||
rename (self::DATA_DIR.'core.json',self::DATA_DIR.'imported_data.json');
|
rename (self::DATA_DIR.'core.json',self::DATA_DIR.'imported_data.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');
|
||||||
|
// Ecriture des données
|
||||||
$this->setData(['config',$tempData['config']]);
|
$this->setData(['config',$tempData['config']]);
|
||||||
$this->setData(['core',$tempData['core']]);
|
$this->setData(['core',$tempData['core']]);
|
||||||
$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]);
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -997,6 +1008,12 @@ class common {
|
||||||
$this->setData(['core', 'dataVersion', 9205]);
|
$this->setData(['core', 'dataVersion', 9205]);
|
||||||
//$this->saveData();
|
//$this->saveData();
|
||||||
}
|
}
|
||||||
|
// Version 10.0.00
|
||||||
|
if($this->getData(['core', 'dataVersion']) < 10000) {
|
||||||
|
$this->setData(['core', 'dataVersion', 10000]);
|
||||||
|
//$this->saveData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue