sauvegarde themes
This commit is contained in:
parent
f0c42b9ded
commit
d6cd62e830
@ -202,6 +202,7 @@ $text['core_theme_view']['manage'][12] = 'Site theme';
|
||||
$text['core_theme_view']['manage'][13] = 'Administration theme';
|
||||
$text['core_theme_view']['manage'][14] = "Are you sure you want to reset the site theme to its original state ?";
|
||||
$text['core_theme_view']['manage'][15] = "Your custom.css file will be overwritten, you will be able to find it in the automatic backup that will be created, continue?";
|
||||
$text['core_theme_view']['manage'][16] = "Enter a name without extension (optional)";
|
||||
$text['core_theme_view']['menu'][0] = 'Back';
|
||||
$text['core_theme_view']['menu'][1] = 'Help';
|
||||
$text['core_theme_view']['menu'][2] = 'Save';
|
||||
|
@ -202,6 +202,7 @@ $text['core_theme_view']['manage'][12] = 'Thème du site';
|
||||
$text['core_theme_view']['manage'][13] = 'Thème de l\'administration';
|
||||
$text['core_theme_view']['manage'][14] = "Êtes-vous sûr de vouloir réinitialiser à son état d\'origine le thème du site ?";
|
||||
$text['core_theme_view']['manage'][15] = "Votre fichier custom.css va être écrasé, vous pourrez le retrouver dans la sauvegarde automatique qui va être créée, continuez ?";
|
||||
$text['core_theme_view']['manage'][16] = "Saisissez un nom sans extension (facultatif)";
|
||||
$text['core_theme_view']['menu'][0] = 'Retour';
|
||||
$text['core_theme_view']['menu'][1] = 'Aide';
|
||||
$text['core_theme_view']['menu'][2] = 'Enregistrer';
|
||||
|
@ -739,22 +739,31 @@ class theme extends common {
|
||||
include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php');
|
||||
|
||||
if($this->isPost() ) {
|
||||
|
||||
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
||||
$data = $this->import(self::FILE_DIR.'source/' . $zipFilename);
|
||||
if ($data['success']) {
|
||||
header("Refresh:0");
|
||||
// Régénérer theme.css et admin.css
|
||||
if (file_exists(self::DATA_DIR . 'theme.css')) unlink(self::DATA_DIR . 'theme.css');
|
||||
//$this->setData(['admin', 'maj', true]);
|
||||
} else {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => $data['notification'],
|
||||
'state' => $data['success'],
|
||||
'title' => $text['core_theme']['manage'][0],
|
||||
'view' => 'manage'
|
||||
]);;
|
||||
if( isset( $_POST['themeSaveTheme'])){
|
||||
$this->save('theme',$this->getInput('themeSaveName'));
|
||||
} elseif( isset( $_POST['themeSaveAdmin'])){
|
||||
$this->save('admin',$this->getInput('themeSaveName'));
|
||||
} elseif( isset( $_POST['themeExportTheme'])){
|
||||
$this->export('theme',$this->getInput('themeExportName'));
|
||||
} elseif( isset( $_POST['themeExportAdmin'])){
|
||||
$this->export('admin',$this->getInput('themeExportName'));
|
||||
}else {
|
||||
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
||||
$data = $this->import(self::FILE_DIR.'source/' . $zipFilename);
|
||||
if ($data['success']) {
|
||||
header("Refresh:0");
|
||||
// Régénérer theme.css et admin.css
|
||||
if (file_exists(self::DATA_DIR . 'theme.css')) unlink(self::DATA_DIR . 'theme.css');
|
||||
//$this->setData(['admin', 'maj', true]);
|
||||
} else {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => $data['notification'],
|
||||
'state' => $data['success'],
|
||||
'title' => $text['core_theme']['manage'][0],
|
||||
'view' => 'manage'
|
||||
]);;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Valeurs en sortie
|
||||
@ -842,9 +851,9 @@ class theme extends common {
|
||||
/**
|
||||
* Export du thème
|
||||
*/
|
||||
public function export() {
|
||||
public function export($modele, $name) {
|
||||
// Make zip
|
||||
$zipFilename = $this->zipTheme($this->getUrl(2));
|
||||
$zipFilename = $this->zipTheme($modele, $name);
|
||||
// Téléchargement du ZIP
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
@ -860,11 +869,11 @@ class theme extends common {
|
||||
/**
|
||||
* Export du thème
|
||||
*/
|
||||
public function save() {
|
||||
public function save($modele, $name) {
|
||||
// Lexique
|
||||
include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php');
|
||||
// Make zip
|
||||
$zipFilename = $this->zipTheme($this->getUrl(2));
|
||||
$zipFilename = $this->zipTheme($modele, $name);
|
||||
// Téléchargement du ZIP
|
||||
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
||||
mkdir(self::FILE_DIR.'source/theme', 0755);
|
||||
@ -885,7 +894,7 @@ class theme extends common {
|
||||
*/
|
||||
public function sauve( $type ) {
|
||||
// Make zip
|
||||
$zipFilename = $this->zipTheme( $type );
|
||||
$zipFilename = $this->zipTheme( $type, '' );
|
||||
// Téléchargement du ZIP
|
||||
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
||||
mkdir(self::FILE_DIR.'source/theme', 0755);
|
||||
@ -900,9 +909,14 @@ class theme extends common {
|
||||
* construction du zip
|
||||
* @param string $modele theme ou admin
|
||||
*/
|
||||
private function zipTheme($modele) {
|
||||
private function zipTheme($modele, $name) {
|
||||
// Creation du dossier
|
||||
$zipFilename = $modele . date('Y-m-d-H-i-s', time()) . '.zip';
|
||||
if( $name === '' || $name === null){
|
||||
$name = $modele . date('Y-m-d-H-i-s', time()) ;
|
||||
} else {
|
||||
$name = str_replace('.','',$name);
|
||||
}
|
||||
$zipFilename = $name . '.zip';
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) === TRUE) {
|
||||
switch ($modele) {
|
||||
|
@ -5,4 +5,4 @@
|
||||
|
||||
/** NE PAS EFFACER
|
||||
* admin.css
|
||||
*/
|
||||
*/
|
||||
|
@ -19,4 +19,10 @@ $("#themeImportSubmit").on("click", function() {
|
||||
return core.confirm(textConfirm2, function() {
|
||||
$('#themeManageForm').submit();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Couleur des boutons submit de sauvegarde et d'export
|
||||
var bgcolor = <?php echo '"'.$this->getData(['admin', 'backgroundColorButton' ]).'"'; ?>;
|
||||
var color = <?php echo '"'.helper::colorVariants($this->getData(['admin', 'backgroundColorButton']))['text'].'"'; ?>;
|
||||
$(".themeSave").css('background-color', bgcolor);
|
||||
$(".themeSave").css('color', color);
|
@ -56,20 +56,28 @@ echo template::formOpen('themeManageForm'); ?>
|
||||
<div class="blockTitle"><?php echo $text['core_theme_view']['manage'][6]; ?><a href="<?php echo helper::baseUrl(false); ?>core/vendor/filemanager/dialog.php?fldr=theme&type=0&akey=<?php echo md5_file(self::DATA_DIR.'core.json'); ?>" data-lity><?php echo $text['core_theme_view']['manage'][7]; ?></a><?php echo $text['core_theme_view']['manage'][8]; ?></div>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::button('themeSave', [
|
||||
'href' => helper::baseUrl() . 'theme/save/theme',
|
||||
<?php echo template::submit('themeSaveTheme', [
|
||||
'class' => 'themeSave',
|
||||
'ico' => 'download-cloud',
|
||||
'value' => $text['core_theme_view']['manage'][9]
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col6">
|
||||
<?php echo template::button('themeSaveAdmin', [
|
||||
'href' => helper::baseUrl() . 'theme/save/admin',
|
||||
<?php echo template::submit('themeSaveAdmin', [
|
||||
'class' => 'themeSave',
|
||||
'ico' => 'download-cloud',
|
||||
'value' => $text['core_theme_view']['manage'][10]
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col6 offset3">
|
||||
<?php echo template::text('themeSaveName', [
|
||||
'label' => $text['core_theme_view']['manage'][16],
|
||||
'value' => ''
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -78,20 +86,28 @@ echo template::formOpen('themeManageForm'); ?>
|
||||
<div class="blockTitle"><?php echo $text['core_theme_view']['manage'][11]; ?></div>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::button('themeExport', [
|
||||
'href' => helper::baseUrl() . 'theme/export/theme',
|
||||
<?php echo template::submit('themeExportTheme', [
|
||||
'class' => 'themeSave',
|
||||
'ico' => 'download',
|
||||
'value' => $text['core_theme_view']['manage'][12]
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col6">
|
||||
<?php echo template::button('themeExport', [
|
||||
'href' => helper::baseUrl() . 'theme/export/admin',
|
||||
<?php echo template::submit('themeExportAdmin', [
|
||||
'class' => 'themeSave',
|
||||
'ico' => 'download',
|
||||
'value' => $text['core_theme_view']['manage'][13]
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col6 offset3">
|
||||
<?php echo template::text('themeExportName', [
|
||||
'label' => $text['core_theme_view']['manage'][16],
|
||||
'value' => ''
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user