From d486674d73a2dc051b2804d4d5e34eb6e1eef790 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sat, 7 Nov 2020 17:48:10 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9initialisation=20des=20th=C3=A8mes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 2 + core/module/theme/theme.php | 40 +++++++++-------- core/module/theme/view/admin/admin.js.php | 10 +++++ core/module/theme/view/admin/admin.php | 2 +- core/module/theme/view/advanced/advanced.php | 2 +- core/module/theme/view/manage/manage.js.php | 21 +++++++++ core/module/theme/view/manage/manage.php | 46 +++++++++++--------- 7 files changed, 82 insertions(+), 41 deletions(-) create mode 100644 core/module/theme/view/manage/manage.js.php diff --git a/CHANGES.md b/CHANGES.md index 0818cdaa..24751797 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,8 @@ - Suppression des commentaires en masse. - Limiter l'édition des articles et des commentaires à l'id de l'éditeur - Approbation des commentaires + - Gestion des thèmes : + - Bouton de réinitialisation avec confirmation ## version 10.3.04 - Corrections : diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 8d826ab8..d62d7543 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -24,7 +24,6 @@ class theme extends common { 'index' => self::GROUP_ADMIN, 'menu' => self::GROUP_ADMIN, 'reset' => self::GROUP_ADMIN, - 'resetAdmin' => self::GROUP_ADMIN, 'site' => self::GROUP_ADMIN, 'admin' => self::GROUP_ADMIN, 'manage' => self::GROUP_ADMIN, @@ -535,29 +534,32 @@ class theme extends common { */ public function reset() { // Supprime le fichier de personnalisation avancée - unlink(self::DATA_DIR.'custom.css'); + $redirect =''; + switch ($this->getUrl(2)) { + case 'admin': + $this->initData('admin'); + $redirect = helper::baseUrl() . 'theme/admin'; + break; + case 'manage': + $this->initData('theme'); + $redirect = helper::baseUrl() . 'theme/manage'; + break; + case 'custom': + unlink(self::DATA_DIR.'custom.css'); + $redirect = helper::baseUrl() . 'theme/advanced'; + break; + default : + $redirect = helper::baseUrl() . 'theme'; + } + // Valeurs en sortie $this->addOutput([ - 'notification' => 'Personnalisation avancée réinitialisée', - 'redirect' => helper::baseUrl() . 'theme/advanced', + 'notification' => 'Réinitialisation effectuée', + 'redirect' => $redirect, 'state' => true ]); } - /** - * Réinitialisation de la personnalisation avancée - */ - public function resetAdmin() { - // Supprime le fichier de personnalisation avancée - //unlink(self::DATA_DIR.'admin.json'); - $this->initData('admin'); - // Valeurs en sortie - $this->addOutput([ - 'notification' => 'Thème réinitialisé', - 'redirect' => helper::baseUrl() . 'theme/admin', - 'state' => true - ]); - } /** * Options du site @@ -635,7 +637,7 @@ class theme extends common { ) { $mode = 'admin'; } - if (!empty($modele) + if (!empty($modele) ) { // traiter l'archive $success = $zip->extractTo('.'); diff --git a/core/module/theme/view/admin/admin.js.php b/core/module/theme/view/admin/admin.js.php index 351891f5..e62011e2 100644 --- a/core/module/theme/view/admin/admin.js.php +++ b/core/module/theme/view/admin/admin.js.php @@ -46,3 +46,13 @@ $("input, select").on("change", function() { .appendTo("head"); }); + +/** + * Confirmation de réinitialisation + */ +$("#configAdminReset").on("click", function() { + var _this = $(this); + return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine le thème de l\'administration ?", function() { + $(location).attr("href", _this.attr("href")); + }); +}); diff --git a/core/module/theme/view/admin/admin.php b/core/module/theme/view/admin/admin.php index 97a57706..134e4bba 100644 --- a/core/module/theme/view/admin/admin.php +++ b/core/module/theme/view/admin/admin.php @@ -16,7 +16,7 @@
'buttonRed', - 'href' => helper::baseUrl() . 'theme/resetAdmin', + 'href' => helper::baseUrl() . 'theme/reset/admin', 'value' => 'Réinitialiser', 'ico' => 'cancel' ]); ?> diff --git a/core/module/theme/view/advanced/advanced.php b/core/module/theme/view/advanced/advanced.php index b3a82d33..c13fbd91 100644 --- a/core/module/theme/view/advanced/advanced.php +++ b/core/module/theme/view/advanced/advanced.php @@ -10,7 +10,7 @@
helper::baseUrl() . 'theme/reset', + 'href' => helper::baseUrl() . 'theme/reset/custom', 'class' => 'buttonRed', 'ico' => 'cancel', 'value' => 'Réinitialiser' diff --git a/core/module/theme/view/manage/manage.js.php b/core/module/theme/view/manage/manage.js.php new file mode 100644 index 00000000..765a9662 --- /dev/null +++ b/core/module/theme/view/manage/manage.js.php @@ -0,0 +1,21 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + +/** + * Confirmation de réinitialisation + */ +$("#configManageReset").on("click", function() { + var _this = $(this); + return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine le thème du site ?", function() { + $(location).attr("href", _this.attr("href")); + }); +}); \ No newline at end of file diff --git a/core/module/theme/view/manage/manage.php b/core/module/theme/view/manage/manage.php index ff7a28ba..68de0814 100644 --- a/core/module/theme/view/manage/manage.php +++ b/core/module/theme/view/manage/manage.php @@ -8,53 +8,59 @@ 'value' => 'Retour' ]); ?>
+
+ 'buttonRed', + 'href' => helper::baseUrl() . 'theme/reset/manage', + 'value' => 'Réinitialiser', + 'ico' => 'cancel' + ]); ?> +
+
+ 'Appliquer' + ]); ?> +
-
+
-

Installer un thème archivé

+

Installer un thème archivé (site ou administration)

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

Sauvegarder le thème

+

Sauvegarde du thème dans les fichiers du site

helper::baseUrl() . 'theme/save/theme', 'ico' => 'download-cloud', - 'value' => 'Thème site' + 'value' => 'Thème du site' ]); ?>
helper::baseUrl() . 'theme/save/admin', 'ico' => 'download-cloud', - 'value' => 'Thème administration' + 'value' => 'Thème de l\'administration' ]); ?>
-
-
- Le fichier de sauvegarde est généré dans le dossier Thème du gestionnaire de fichiers. -
-
+
+ +

Télécharger le thème

@@ -62,14 +68,14 @@ helper::baseUrl() . 'theme/export/theme', 'ico' => 'download', - 'value' => 'Thème site' + 'value' => 'Thème du site' ]); ?>
helper::baseUrl() . 'theme/export/admin', 'ico' => 'download', - 'value' => 'Thème administration' + 'value' => 'Thème de l\'administration' ]); ?>