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'][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'][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'][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'][0] = 'Back';
|
||||||
$text['core_theme_view']['menu'][1] = 'Help';
|
$text['core_theme_view']['menu'][1] = 'Help';
|
||||||
$text['core_theme_view']['menu'][2] = 'Save';
|
$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'][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'][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'][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'][0] = 'Retour';
|
||||||
$text['core_theme_view']['menu'][1] = 'Aide';
|
$text['core_theme_view']['menu'][1] = 'Aide';
|
||||||
$text['core_theme_view']['menu'][2] = 'Enregistrer';
|
$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');
|
include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php');
|
||||||
|
|
||||||
if($this->isPost() ) {
|
if($this->isPost() ) {
|
||||||
|
if( isset( $_POST['themeSaveTheme'])){
|
||||||
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
$this->save('theme',$this->getInput('themeSaveName'));
|
||||||
$data = $this->import(self::FILE_DIR.'source/' . $zipFilename);
|
} elseif( isset( $_POST['themeSaveAdmin'])){
|
||||||
if ($data['success']) {
|
$this->save('admin',$this->getInput('themeSaveName'));
|
||||||
header("Refresh:0");
|
} elseif( isset( $_POST['themeExportTheme'])){
|
||||||
// Régénérer theme.css et admin.css
|
$this->export('theme',$this->getInput('themeExportName'));
|
||||||
if (file_exists(self::DATA_DIR . 'theme.css')) unlink(self::DATA_DIR . 'theme.css');
|
} elseif( isset( $_POST['themeExportAdmin'])){
|
||||||
//$this->setData(['admin', 'maj', true]);
|
$this->export('admin',$this->getInput('themeExportName'));
|
||||||
} else {
|
}else {
|
||||||
// Valeurs en sortie
|
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
||||||
$this->addOutput([
|
$data = $this->import(self::FILE_DIR.'source/' . $zipFilename);
|
||||||
'notification' => $data['notification'],
|
if ($data['success']) {
|
||||||
'state' => $data['success'],
|
header("Refresh:0");
|
||||||
'title' => $text['core_theme']['manage'][0],
|
// Régénérer theme.css et admin.css
|
||||||
'view' => 'manage'
|
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
|
// Valeurs en sortie
|
||||||
@ -842,9 +851,9 @@ class theme extends common {
|
|||||||
/**
|
/**
|
||||||
* Export du thème
|
* Export du thème
|
||||||
*/
|
*/
|
||||||
public function export() {
|
public function export($modele, $name) {
|
||||||
// Make zip
|
// Make zip
|
||||||
$zipFilename = $this->zipTheme($this->getUrl(2));
|
$zipFilename = $this->zipTheme($modele, $name);
|
||||||
// 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');
|
||||||
@ -860,11 +869,11 @@ class theme extends common {
|
|||||||
/**
|
/**
|
||||||
* Export du thème
|
* Export du thème
|
||||||
*/
|
*/
|
||||||
public function save() {
|
public function save($modele, $name) {
|
||||||
// Lexique
|
// Lexique
|
||||||
include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php');
|
include('./core/module/theme/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_theme.php');
|
||||||
// Make zip
|
// Make zip
|
||||||
$zipFilename = $this->zipTheme($this->getUrl(2));
|
$zipFilename = $this->zipTheme($modele, $name);
|
||||||
// Téléchargement du ZIP
|
// Téléchargement du ZIP
|
||||||
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
||||||
mkdir(self::FILE_DIR.'source/theme', 0755);
|
mkdir(self::FILE_DIR.'source/theme', 0755);
|
||||||
@ -885,7 +894,7 @@ class theme extends common {
|
|||||||
*/
|
*/
|
||||||
public function sauve( $type ) {
|
public function sauve( $type ) {
|
||||||
// Make zip
|
// Make zip
|
||||||
$zipFilename = $this->zipTheme( $type );
|
$zipFilename = $this->zipTheme( $type, '' );
|
||||||
// Téléchargement du ZIP
|
// Téléchargement du ZIP
|
||||||
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
||||||
mkdir(self::FILE_DIR.'source/theme', 0755);
|
mkdir(self::FILE_DIR.'source/theme', 0755);
|
||||||
@ -900,9 +909,14 @@ class theme extends common {
|
|||||||
* construction du zip
|
* construction du zip
|
||||||
* @param string $modele theme ou admin
|
* @param string $modele theme ou admin
|
||||||
*/
|
*/
|
||||||
private function zipTheme($modele) {
|
private function zipTheme($modele, $name) {
|
||||||
// Creation du dossier
|
// 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();
|
$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) {
|
||||||
switch ($modele) {
|
switch ($modele) {
|
||||||
|
@ -20,3 +20,9 @@ $("#themeImportSubmit").on("click", function() {
|
|||||||
$('#themeManageForm').submit();
|
$('#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="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="row">
|
||||||
<div class="col6">
|
<div class="col6">
|
||||||
<?php echo template::button('themeSave', [
|
<?php echo template::submit('themeSaveTheme', [
|
||||||
'href' => helper::baseUrl() . 'theme/save/theme',
|
'class' => 'themeSave',
|
||||||
'ico' => 'download-cloud',
|
'ico' => 'download-cloud',
|
||||||
'value' => $text['core_theme_view']['manage'][9]
|
'value' => $text['core_theme_view']['manage'][9]
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col6">
|
<div class="col6">
|
||||||
<?php echo template::button('themeSaveAdmin', [
|
<?php echo template::submit('themeSaveAdmin', [
|
||||||
'href' => helper::baseUrl() . 'theme/save/admin',
|
'class' => 'themeSave',
|
||||||
'ico' => 'download-cloud',
|
'ico' => 'download-cloud',
|
||||||
'value' => $text['core_theme_view']['manage'][10]
|
'value' => $text['core_theme_view']['manage'][10]
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -78,20 +86,28 @@ echo template::formOpen('themeManageForm'); ?>
|
|||||||
<div class="blockTitle"><?php echo $text['core_theme_view']['manage'][11]; ?></div>
|
<div class="blockTitle"><?php echo $text['core_theme_view']['manage'][11]; ?></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col6">
|
<div class="col6">
|
||||||
<?php echo template::button('themeExport', [
|
<?php echo template::submit('themeExportTheme', [
|
||||||
'href' => helper::baseUrl() . 'theme/export/theme',
|
'class' => 'themeSave',
|
||||||
'ico' => 'download',
|
'ico' => 'download',
|
||||||
'value' => $text['core_theme_view']['manage'][12]
|
'value' => $text['core_theme_view']['manage'][12]
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col6">
|
<div class="col6">
|
||||||
<?php echo template::button('themeExport', [
|
<?php echo template::submit('themeExportAdmin', [
|
||||||
'href' => helper::baseUrl() . 'theme/export/admin',
|
'class' => 'themeSave',
|
||||||
'ico' => 'download',
|
'ico' => 'download',
|
||||||
'value' => $text['core_theme_view']['manage'][13]
|
'value' => $text['core_theme_view']['manage'][13]
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user