import theme à l'installation
This commit is contained in:
parent
6266ab4ff7
commit
c3ae90b746
|
@ -932,80 +932,71 @@ class theme extends common {
|
|||
*/
|
||||
|
||||
public function import($zipName = '') {
|
||||
// Autorisation
|
||||
$group = $this->getUser('group');
|
||||
if ($group === false ) $group = 0;
|
||||
if( $group < theme::$actions['import'] ) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
} else {
|
||||
// Lexique
|
||||
include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php');
|
||||
// Pas de sécurité car cette fonction est utilisée à l'installation
|
||||
// Lexique
|
||||
include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php');
|
||||
|
||||
if ($zipName !== '' &&
|
||||
file_exists($zipName)) {
|
||||
// Init variables de retour
|
||||
$success = false;
|
||||
$notification = '';
|
||||
// Dossier temporaire
|
||||
$tempFolder = uniqid();
|
||||
// Ouvrir le zip
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipName) === TRUE) {
|
||||
mkdir (self::TEMP_DIR . $tempFolder, 0755);
|
||||
$zip->extractTo(self::TEMP_DIR . $tempFolder );
|
||||
$modele = '';
|
||||
// Archive de thème ?
|
||||
if (
|
||||
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
|
||||
) {
|
||||
$modele = 'theme';
|
||||
$this->sauve( $modele );
|
||||
}
|
||||
if(
|
||||
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css')
|
||||
if ($zipName !== '' &&
|
||||
file_exists($zipName)) {
|
||||
// Init variables de retour
|
||||
$success = false;
|
||||
$notification = '';
|
||||
// Dossier temporaire
|
||||
$tempFolder = uniqid();
|
||||
// Ouvrir le zip
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipName) === TRUE) {
|
||||
mkdir (self::TEMP_DIR . $tempFolder, 0755);
|
||||
$zip->extractTo(self::TEMP_DIR . $tempFolder );
|
||||
$modele = '';
|
||||
// Archive de thème ?
|
||||
if (
|
||||
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
|
||||
) {
|
||||
$modele = 'admin';
|
||||
$this->sauve( $modele );
|
||||
$modele = 'theme';
|
||||
$this->sauve( $modele );
|
||||
}
|
||||
if (!empty($modele)
|
||||
) {
|
||||
// traiter l'archive
|
||||
$importFolder = './site/file/import';
|
||||
mkdir ($importFolder, 0755);
|
||||
$success = $zip->extractTo($importFolder);
|
||||
// $path = $importFolder.'/site/file/source/';
|
||||
// Modifie le nom de tous les fichiers de $path et leur nom dans theme.json
|
||||
// $this->changeName($path);
|
||||
$this->copyDir( $importFolder, './');
|
||||
$this->removeDir($importFolder);
|
||||
// traitement de l'erreur
|
||||
$notification = $success ? $text['core_theme']['import'][0] : $text['core_theme']['import'][1];
|
||||
|
||||
|
||||
} else {
|
||||
// pas une archive de thème
|
||||
$success = false;
|
||||
$notification = $text['core_theme']['import'][2];
|
||||
}
|
||||
// Supprimer le dossier temporaire même si le thème est invalide
|
||||
$this->removeDir(self::TEMP_DIR . $tempFolder);
|
||||
$zip->close();
|
||||
} else {
|
||||
// erreur à l'ouverture
|
||||
$success = false;
|
||||
$notification = $text['core_theme']['import'][3];
|
||||
if(
|
||||
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json')
|
||||
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css')
|
||||
) {
|
||||
$modele = 'admin';
|
||||
$this->sauve( $modele );
|
||||
}
|
||||
return (['success' => $success, 'notification' => $notification]);
|
||||
}
|
||||
if (!empty($modele)
|
||||
) {
|
||||
// traiter l'archive
|
||||
$importFolder = './site/file/import';
|
||||
mkdir ($importFolder, 0755);
|
||||
$success = $zip->extractTo($importFolder);
|
||||
// $path = $importFolder.'/site/file/source/';
|
||||
// Modifie le nom de tous les fichiers de $path et leur nom dans theme.json
|
||||
// $this->changeName($path);
|
||||
$this->copyDir( $importFolder, './');
|
||||
$this->removeDir($importFolder);
|
||||
// traitement de l'erreur
|
||||
$notification = $success ? $text['core_theme']['import'][0] : $text['core_theme']['import'][1];
|
||||
|
||||
return (['success' => false, 'notification' => $text['core_theme']['import'][4]]);
|
||||
|
||||
} else {
|
||||
// pas une archive de thème
|
||||
$success = false;
|
||||
$notification = $text['core_theme']['import'][2];
|
||||
}
|
||||
// Supprimer le dossier temporaire même si le thème est invalide
|
||||
$this->removeDir(self::TEMP_DIR . $tempFolder);
|
||||
$zip->close();
|
||||
} else {
|
||||
// erreur à l'ouverture
|
||||
$success = false;
|
||||
$notification = $text['core_theme']['import'][3];
|
||||
}
|
||||
return (['success' => $success, 'notification' => $notification]);
|
||||
}
|
||||
|
||||
return (['success' => false, 'notification' => $text['core_theme']['import'][4]]);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue