From 1475ff30faa51af79cf1ea956e3db5d97c6ad8cc Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Mon, 18 May 2020 18:26:21 +0200 Subject: [PATCH] 10.1 Sauvegarde du theme ou de l'admin --- core/module/theme/theme.php | 42 ++++++++------ core/module/theme/view/manage/manage.php | 74 +++++++++++++++--------- 2 files changed, 73 insertions(+), 43 deletions(-) diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 2c924a55..2bf4a420 100755 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -639,7 +639,7 @@ class theme extends common { */ public function export() { // Make zip - $zipFilename = $this->makezip(); + $zipFilename = $this->makezip($this->getUrl(2)); // Téléchargement du ZIP header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); @@ -657,7 +657,7 @@ class theme extends common { */ public function save() { // Make zip - $zipFilename = $this->makezip(); + $zipFilename = $this->makezip($this->getUrl(2)); // Téléchargement du ZIP mkdir(self::FILE_DIR.'source/theme'); copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename); @@ -673,25 +673,33 @@ class theme extends common { /** * construction du zip + * @param string $modele theme ou admin */ - public function makezip() { + public function makezip($modele) { // Creation du dossier - // $zipFilename = 'theme-'.date('dmY').'-'.date('hm').'-'.rand(10,99).'.zip'; - $zipFilename = 'theme '.date('d m Y').' '.date('H i s ').'.zip'; + $zipFilename = $modele . ' ' .date('d m Y').' '.date('H i s ').'.zip'; $zip = new ZipArchive(); if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) === TRUE) { - $zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'theme.json'); - $zip->addFile(self::DATA_DIR.'theme.css',self::DATA_DIR.'theme.css'); - $zip->addFile(self::DATA_DIR.'custom.css',self::DATA_DIR.'custom.css'); - if ($this->getData(['theme','body','image']) !== '' ) { - $zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','body','image']), - self::FILE_DIR.'source/'.$this->getData(['theme','body','image']) - ); - } - if ($this->getData(['theme','header','image']) !== '' ) { - $zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','header','image']), - self::FILE_DIR.'source/'.$this->getData(['theme','header','image']) - ); + switch ($modele) { + case 'admin': + $zip->addFile(self::DATA_DIR.'admin.json',self::DATA_DIR.'admin.json'); + $zip->addFile(self::DATA_DIR.'admin.css',self::DATA_DIR.'admin.css'); + break; + case 'theme': + $zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'theme.json'); + $zip->addFile(self::DATA_DIR.'theme.css',self::DATA_DIR.'theme.css'); + $zip->addFile(self::DATA_DIR.'custom.css',self::DATA_DIR.'custom.css'); + if ($this->getData(['theme','body','image']) !== '' ) { + $zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','body','image']), + self::FILE_DIR.'source/'.$this->getData(['theme','body','image']) + ); + } + if ($this->getData(['theme','header','image']) !== '' ) { + $zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','header','image']), + self::FILE_DIR.'source/'.$this->getData(['theme','header','image']) + ); + } + break; } $ret = $zip->close(); } diff --git a/core/module/theme/view/manage/manage.php b/core/module/theme/view/manage/manage.php index 5f568e0a..ad86da93 100755 --- a/core/module/theme/view/manage/manage.php +++ b/core/module/theme/view/manage/manage.php @@ -12,40 +12,62 @@
-

Appliquer un thème archivé

-
- 'Archive ZIP :', - 'type' => 2 - ]); ?> +

Installer un thème archivé

+
+
+ 'Archive ZIP :', + 'type' => 2 + ]); ?> +
+
+
+
+ 'Appliquer' + ]); ?> +
-
- 'Appliquer' - ]); ?> -

Sauvegarder le thème

-
-
- helper::baseUrl() . 'theme/save', - 'ico' => 'upload-cloud', - 'value' => 'Sauvegarder dans les fichiers' - ]); ?> +
+
+ helper::baseUrl() . 'theme/save/theme', + 'ico' => 'download-cloud', + 'value' => 'Thème site' + ]); ?> +
+
+ helper::baseUrl() . 'theme/save/admin', + 'ico' => 'download-cloud', + 'value' => 'Thème administration' + ]); ?> +
-
-
- helper::baseUrl() . 'theme/export', - 'ico' => 'download', - 'value' => 'Télécharger' - ]); ?> -
+
+

Télécharger le thème

+
+
+ helper::baseUrl() . 'theme/export/theme', + 'ico' => 'download', + 'value' => 'Thème site' + ]); ?> +
+
+ helper::baseUrl() . 'theme/export/admin', + 'ico' => 'download', + 'value' => 'Thème administration' + ]); ?> +
+