10.1 Sauvegarde du theme ou de l'admin

This commit is contained in:
Fred Tempez 2020-05-18 18:26:21 +02:00
parent 5647416cbc
commit 1475ff30fa
2 changed files with 73 additions and 43 deletions

View File

@ -639,7 +639,7 @@ class theme extends common {
*/ */
public function export() { public function export() {
// Make zip // Make zip
$zipFilename = $this->makezip(); $zipFilename = $this->makezip($this->getUrl(2));
// Téléchargement du ZIP // Téléchargement du ZIP
header('Content-Description: File Transfer'); header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
@ -657,7 +657,7 @@ class theme extends common {
*/ */
public function save() { public function save() {
// Make zip // Make zip
$zipFilename = $this->makezip(); $zipFilename = $this->makezip($this->getUrl(2));
// Téléchargement du ZIP // Téléchargement du ZIP
mkdir(self::FILE_DIR.'source/theme'); mkdir(self::FILE_DIR.'source/theme');
copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename); copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename);
@ -673,25 +673,33 @@ class theme extends common {
/** /**
* construction du zip * construction du zip
* @param string $modele theme ou admin
*/ */
public function makezip() { public function makezip($modele) {
// Creation du dossier // Creation du dossier
// $zipFilename = 'theme-'.date('dmY').'-'.date('hm').'-'.rand(10,99).'.zip'; $zipFilename = $modele . ' ' .date('d m Y').' '.date('H i s ').'.zip';
$zipFilename = 'theme '.date('d m Y').' '.date('H i s ').'.zip';
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) === TRUE) { if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) === TRUE) {
$zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'theme.json'); switch ($modele) {
$zip->addFile(self::DATA_DIR.'theme.css',self::DATA_DIR.'theme.css'); case 'admin':
$zip->addFile(self::DATA_DIR.'custom.css',self::DATA_DIR.'custom.css'); $zip->addFile(self::DATA_DIR.'admin.json',self::DATA_DIR.'admin.json');
if ($this->getData(['theme','body','image']) !== '' ) { $zip->addFile(self::DATA_DIR.'admin.css',self::DATA_DIR.'admin.css');
$zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','body','image']), break;
self::FILE_DIR.'source/'.$this->getData(['theme','body','image']) 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');
if ($this->getData(['theme','header','image']) !== '' ) { $zip->addFile(self::DATA_DIR.'custom.css',self::DATA_DIR.'custom.css');
$zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','header','image']), if ($this->getData(['theme','body','image']) !== '' ) {
self::FILE_DIR.'source/'.$this->getData(['theme','header','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(); $ret = $zip->close();
} }

View File

@ -12,39 +12,61 @@
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<div class="block"> <div class="block">
<h4>Appliquer un thème archivé</h4> <h4>Installer un thème archivé</h4>
<div class="col10 offset1"> <div class="row">
<?php echo template::file('themeManageImport', [ <div class="col12">
'label' => 'Archive ZIP :', <?php echo template::file('themeManageImport', [
'type' => 2 'label' => 'Archive ZIP :',
]); ?> 'type' => 2
]); ?>
</div>
</div> </div>
<div class="col5 offset3"> <div class="row">
<?php echo template::submit('themeImportSubmit', [ <div class="col5 offset3">
'value' => 'Appliquer' <?php echo template::submit('themeImportSubmit', [
]); ?> 'value' => 'Appliquer'
]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="col6"> <div class="col6">
<div class="block"> <div class="block">
<h4>Sauvegarder le thème</h4> <h4>Sauvegarder le thème</h4>
<div class="row"> <div class="row">
<div class="col8 offset2"> <div class="col6">
<?php echo template::button('themeSave', [ <?php echo template::button('themeSave', [
'href' => helper::baseUrl() . 'theme/save', 'href' => helper::baseUrl() . 'theme/save/theme',
'ico' => 'upload-cloud', 'ico' => 'download-cloud',
'value' => 'Sauvegarder dans les fichiers' 'value' => 'Thème site'
]); ?> ]); ?>
</div>
<div class="col6">
<?php echo template::button('themeSaveAdmin', [
'href' => helper::baseUrl() . 'theme/save/admin',
'ico' => 'download-cloud',
'value' => 'Thème administration'
]); ?>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="block">
<div class="col8 offset2"> <h4>Télécharger le thème</h4>
<?php echo template::button('themeExport', [ <div class="row">
'href' => helper::baseUrl() . 'theme/export', <div class="col6">
'ico' => 'download', <?php echo template::button('themeExport', [
'value' => 'Télécharger' 'href' => helper::baseUrl() . 'theme/export/theme',
]); ?> 'ico' => 'download',
'value' => 'Thème site'
]); ?>
</div>
<div class="col6">
<?php echo template::button('themeExport', [
'href' => helper::baseUrl() . 'theme/export/admin',
'ico' => 'download',
'value' => 'Thème administration'
]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>