From aea20bb2ae9e6e693e1bf3bee83f5498a30f7c53 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 28 Mar 2022 16:57:53 +0200 Subject: [PATCH 1/2] galerie : masquege de l'index d'une galerie unique en option --- module/gallery/gallery.php | 10 +- module/gallery/view/config/config.php | 29 +-- module/gallery/view/edit/edit.php | 30 +-- module/gallery/view/gallery/gallery.php | 3 +- module/gallery/view/theme/theme.php | 242 +++++++++++++----------- 5 files changed, 170 insertions(+), 144 deletions(-) diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index ce847183..00db305b 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -605,9 +605,10 @@ class gallery extends common { // Mise à jour des données de module $this->update(); // Une seule galerie, bifurquer sur celle-ci - $gallery = count($this->getData(['module', $this->getUrl(0), 'content'])) === 1 - ? array_key_first($this->getData(['module', $this->getUrl(0), 'content'])) - : $this->getUrl(1); + $gallery = $this->getData(['module', $this->getUrl(0), 'theme', 'showUniqueGallery']) === true && + count($this->getData(['module', $this->getUrl(0), 'content'])) === 1 + ? array_key_first($this->getData(['module', $this->getUrl(0), 'content'])) + : $this->getUrl(1); // Images d'une galerie if($gallery) { // La galerie n'existe pas @@ -775,7 +776,8 @@ class gallery extends common { 'legendAlign' => $this->getinput('galleryThemeLegendAlign', helper::FILTER_STRING_SHORT), 'legendTextColor' => $this->getinput('galleryThemeLegendTextColor', helper::FILTER_STRING_SHORT), 'legendBgColor' => $this->getinput('galleryThemeLegendBgColor', helper::FILTER_STRING_SHORT), - 'style' => self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' + 'showUniqueGallery' => $this->getinput('galleryThemeShowUniqueGallery', helper::FILTER_BOOLEAN), + 'style' => self::DATADIRECTORY . $this->getUrl(0) . '/theme.css', ]]); // Création des fichiers CSS $content = file_get_contents('module/gallery/ressource/vartheme.css'); diff --git a/module/gallery/view/config/config.php b/module/gallery/view/config/config.php index 516d3a02..ad2a3655 100644 --- a/module/gallery/view/config/config.php +++ b/module/gallery/view/config/config.php @@ -2,7 +2,6 @@
'buttonGrey', 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), 'ico' => 'left', 'value' => 'Retour' @@ -50,17 +49,23 @@ 'help' => 'Tri manuel : déplacez le images dans le tableau ci-dessous. L\'ordre est sauvegardé automatiquement.' ]); ?>
-
- $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']), - 'help' => 'A l\'ouverture de la galerie, la première image est affichée en plein écran.' - ]); ?> -
-
- $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']), - 'help' => 'Le contenu de la page est toujours affiché dans la liste des galeries. Quand une seule galerie est disponible, il est possible de l\'afficher directement, cette option est utile dans ce cas précis.' - ]); ?> +
+
+
+ $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']), + 'help' => 'A l\'ouverture de la galerie, la première image est affichée en plein écran.' + ]); ?> +
+
+
+
+ $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']), + 'help' => 'Le contenu de la page est toujours affiché dans la liste des galeries. Quand une seule galerie est disponible, il est possible de l\'afficher directement, cette option est utile dans ce cas précis.' + ]); ?> +
+
diff --git a/module/gallery/view/edit/edit.php b/module/gallery/view/edit/edit.php index 5b80327d..49f2b4dc 100644 --- a/module/gallery/view/edit/edit.php +++ b/module/gallery/view/edit/edit.php @@ -2,7 +2,6 @@
'buttonGrey', 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', 'ico' => 'left', 'value' => 'Retour' @@ -42,17 +41,24 @@ 'help' => 'Tri manuel : déplacez le images dans le tableau ci-dessous. L\'ordre est sauvegardé automatiquement.' ]); ?>
-
- $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']), - 'help' => 'A l\'ouverture de la galerie, la première image est affichée en plein écran.' - ]); ?> -
-
- $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']), - 'help' => 'Le contenu de la page est toujours affiché dans la liste des galeries. Quand une seule galerie est disponible, il est possible de l\'afficher directement, cette option est utile dans ce cas précis.' - ]); ?> +
+
+
+ $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']), + 'help' => 'A l\'ouverture de la galerie, la première image est affichée en plein écran.' + ]); ?> +
+
+
+
+ $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']), + 'help' => 'Le contenu de la page est toujours affiché dans la liste des galeries. Quand une seule galerie est disponible, il est possible de l\'afficher directement, cette option est utile dans ce cas précis.' + ]); ?> +
+
+
diff --git a/module/gallery/view/gallery/gallery.php b/module/gallery/view/gallery/gallery.php index be4db754..fda256ae 100644 --- a/module/gallery/view/gallery/gallery.php +++ b/module/gallery/view/gallery/gallery.php @@ -19,10 +19,9 @@
'buttonGrey', 'href' => helper::baseUrl() . $this->getUrl(0), 'ico' => 'left', - 'value' => 'Retour' + 'value' => '' ]); ?>
diff --git a/module/gallery/view/theme/theme.php b/module/gallery/view/theme/theme.php index 8da3639e..456f32b0 100644 --- a/module/gallery/view/theme/theme.php +++ b/module/gallery/view/theme/theme.php @@ -1,140 +1,154 @@ - -
-
- 'buttonGrey', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'ico' => 'left', - 'value' => 'Retour' - ]); ?> -
-
- -
-
-
-
-
-

Vignettes - -

-
-
- 'Largeur', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbWidth']) +
+
+ helper::baseUrl() . $this->getUrl(0) . '/config', + 'ico' => 'left', + 'value' => 'Retour' + ]); ?> +
+
+ +
+
+
+
+
+

Galerie unique

+
+
+ count($this->getData(['module', $this->getUrl(0), 'content'])) === 1 + ? $this->getData(['module', $this->getUrl(0), 'theme', 'showUniqueGallery']) + : false, + 'disabled' => count($this->getData(['module', $this->getUrl(0), 'content'])) > 1 ]); ?> -
-
- 'Hauteur', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbHeight']) - ]); ?> -
-
- 'Alignement', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbAlign']) - ]); ?> -
-
- 'Marge', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbMargin']) - ]); ?> -
-
-
-
- 'Bordure', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbBorder']) - ]); ?> -
-
- 'colorPicker', - 'help' => 'Le curseur horizontal règle le niveau de transparence.', - 'label' => 'Couleur de la bordure', - 'value' => $this->getData(['module', $this->getUrl(0), 'theme','thumbBorderColor']) - ]); ?> -
-
- 'Arrondi des angles', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbRadius']) - ]); ?> -
-
-
-
- 'Ombre', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbShadows']) - ]); ?> -
-
- 'colorPicker', - 'help' => 'Le curseur horizontal règle le niveau de transparence.', - 'label' => 'Couleur de l\'ombre', - 'value' => $this->getData(['module', $this->getUrl(0), 'theme','thumbShadowsColor']) - ]); ?> -
-
- 'Opacité au survol', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbOpacity']) - ]); ?> -
-
-
-
-

Légendes +

+
+
+
+

Vignettes + ?>

- 'colorPicker', - 'help' => 'Le curseur horizontal règle le niveau de transparence.', - 'label' => 'Texte', - 'value' => $this->getData(['module', $this->getUrl(0), 'theme','legendTextColor']) + 'Largeur', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbWidth']) ]); ?>
- 'colorPicker', - 'help' => 'Le curseur horizontal règle le niveau de transparence.', - 'label' => 'Arrière-plan', - 'value' => $this->getData(['module', $this->getUrl(0), 'theme','legendBgColor']) - ]); ?> -
-
- 'Hauteur', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','legendHeight']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbHeight']) ]); ?>
-
- + 'Alignement', - 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','legendAlign']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbAlign']) + ]); ?> +
+
+ 'Marge', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbMargin']) + ]); ?> +
+
+
+
+ 'Bordure', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbBorder']) + ]); ?> +
+
+ 'colorPicker', + 'help' => 'Le curseur horizontal règle le niveau de transparence.', + 'label' => 'Couleur de la bordure', + 'value' => $this->getData(['module', $this->getUrl(0), 'theme','thumbBorderColor']) + ]); ?> +
+
+ 'Arrondi des angles', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbRadius']) + ]); ?> +
+
+
+
+ 'Ombre', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbShadows']) + ]); ?> +
+
+ 'colorPicker', + 'help' => 'Le curseur horizontal règle le niveau de transparence.', + 'label' => 'Couleur de l\'ombre', + 'value' => $this->getData(['module', $this->getUrl(0), 'theme','thumbShadowsColor']) + ]); ?> +
+
+ 'Opacité au survol', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','thumbOpacity']) ]); ?>
- +
+
+
+
+

Légendes + +

+
+
+ 'colorPicker', + 'help' => 'Le curseur horizontal règle le niveau de transparence.', + 'label' => 'Texte', + 'value' => $this->getData(['module', $this->getUrl(0), 'theme','legendTextColor']) + ]); ?> +
+
+ 'colorPicker', + 'help' => 'Le curseur horizontal règle le niveau de transparence.', + 'label' => 'Arrière-plan', + 'value' => $this->getData(['module', $this->getUrl(0), 'theme','legendBgColor']) + ]); ?> +
+
+ 'Hauteur', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','legendHeight']) + ]); ?> +
+
+ 'Alignement', + 'selected' => $this->getData(['module', $this->getUrl(0), 'theme','legendAlign']) + ]); ?> +
+
+
+
From 8da52e715aa0494275d4dd0f441113637f51d07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Mon, 28 Mar 2022 18:57:06 +0200 Subject: [PATCH 2/2] galerie avec nouvelles options --- module/gallery/gallery.php | 89 +++++++++++++++++++++ module/gallery/view/add/add.css | 19 +++++ module/gallery/view/add/add.js.php | 87 +++++++++++++++++++++ module/gallery/view/add/add.php | 68 ++++++++++++++++ module/gallery/view/config/config.js.php | 61 +-------------- module/gallery/view/config/config.php | 98 +++++++----------------- module/gallery/view/option/option.php | 39 ++++++++++ module/gallery/view/option/options.css | 18 +++++ 8 files changed, 352 insertions(+), 127 deletions(-) create mode 100644 module/gallery/view/add/add.css create mode 100644 module/gallery/view/add/add.js.php create mode 100644 module/gallery/view/add/add.php create mode 100644 module/gallery/view/option/option.php create mode 100644 module/gallery/view/option/options.css diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 00db305b..aad375f0 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -51,7 +51,9 @@ class gallery extends common { 'sortGalleries' => self::GROUP_MODERATOR, 'sortPictures' => self::GROUP_MODERATOR, 'edit' => self::GROUP_MODERATOR, + 'add' => self::GROUP_MODERATOR, 'theme' => self::GROUP_MODERATOR, + 'option' => self::GROUP_MODERATOR, 'index' => self::GROUP_VISITOR ]; @@ -411,6 +413,58 @@ class gallery extends common { ]); } + /** + * Ajout d'une galerie + */ + public function add() { + // Soumission du formulaire d'ajout d'une galerie + if($this->isPost()) { + if (!$this->getInput('galleryAddFilterResponse')) { + $galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content'])); + // définir une vignette par défaut + $directory = $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true); + $iterator = new DirectoryIterator($directory); + foreach($iterator as $fileInfos) { + if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) { + // Créer la miniature si manquante + if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) { + $this->makeThumb($fileInfos->getPathname(), + str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()), + self::THUMBS_WIDTH); + } + // Miniatures + $homePicture = strtolower($fileInfos->getFilename()); + break; + } + } + $this->setData(['module', $this->getUrl(0), 'content', $galleryId, [ + 'config' => [ + 'name' => $this->getInput('galleryAddName'), + 'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true), + 'homePicture' => $homePicture, + 'sort' => $this->getInput('galleryAddSort'), + 'position' => count($this->getData(['module', $this->getUrl(0), 'content'])) + 1, + 'fullScreen' => $this->getInput('galleryAddFullscreen', helper::FILTER_BOOLEAN), + 'showPageContent' => $this->getInput('galleryAddShowPageContent', helper::FILTER_BOOLEAN) + ], + 'legend' => [], + 'positions' => [] + ]]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', // '#galleryAddForm'*/, + 'notification' => 'Modifications enregistrées', + 'state' => true + ]); + } + } else { + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Ajout d\'une galerie', + 'view' => 'add' + ]); + } + } /** * Suppression */ @@ -815,6 +869,41 @@ class gallery extends common { ]); } + /** + * Option de configuration de la galerie + */ + public function option() { + // Jeton incorrect + if ($this->getUrl(2) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', + 'notification' => 'Action non autorisée' + ]); + } + // Soumission du formulaire + if($this->isPost()) { + // Dossier de l'instance + if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) { + mkdir (self::DATADIRECTORY . $this->getUrl(0), 0755, true); + } + $this->setData(['module', $this->getUrl(0), 'config', [ + 'showUniqueGallery' => $this->getinput('galleryOptionShowUniqueGallery', helper::FILTER_BOOLEAN) + ]]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl() . '/option', + 'notification' => 'Modifications enregistrées', + 'state' => true + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'title' => "Options", + 'view' => 'option' + ]); + } + } class galleriesHelper extends helper { diff --git a/module/gallery/view/add/add.css b/module/gallery/view/add/add.css new file mode 100644 index 00000000..56181936 --- /dev/null +++ b/module/gallery/view/add/add.css @@ -0,0 +1,19 @@ +/** + * 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 + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2022, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/module/gallery/view/add/add.js.php b/module/gallery/view/add/add.js.php new file mode 100644 index 00000000..46d48000 --- /dev/null +++ b/module/gallery/view/add/add.js.php @@ -0,0 +1,87 @@ +/** + * 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 + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2022, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + $( document ).ready(function() { + + + /** + * Tri de la galerie avec drag and drop + */ + $("#galleryTable").tableDnD({ + onDrop: function(table, row) { + $("#galleryAddFilterResponse").val($.tableDnD.serialize()); + }, + onDragStop : function(table, row) { + // Affiche le bouton de tri après un déplacement + //$(":input[type='submit']").prop('disabled', false); + // Sauvegarde le tri + sortGalleries(); + }, + // Supprime le tiret des séparateurs + serializeRegexp: "" + }); + + + + /** + * Confirmation de suppression + */ + $(".galleryAddDelete").on("click", function() { + var _this = $(this); + return core.confirm("Êtes-vous sûr de vouloir supprimer cette galerie ?", function() { + $(location).attr("href", _this.attr("href")); + }); + }); + +}); + +/** + * Liste des dossiers + */ +var oldResult = []; +var directoryDOM = $("#galleryAddDirectory"); +var directoryOldDOM = $("#galleryAddDirectoryOld"); +function dirs() { + $.ajax({ + type: "POST", + url: "getUrl(0); ?>/dirs", + success: function(result) { + if($(result).not(oldResult).length !== 0 || $(oldResult).not(result).length !== 0) { + directoryDOM.empty(); + for(var i = 0; i < result.length; i++) { + directoryDOM.append(function(i) { + var option = $("