From 3da6f8970c11dea3cb5badd544f3aa8abc018dc1 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 4 Apr 2022 16:36:59 +0200 Subject: [PATCH] =?UTF-8?q?options=20des=20galeries=20=C3=A0=20v=C3=A9rifi?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/gallery/gallery.php | 68 +++++++++++++++++------- module/gallery/view/edit/edit.js.php | 47 ++-------------- module/gallery/view/edit/edit.php | 5 +- module/gallery/view/option/option.js.php | 46 ++++++++++++++++ module/gallery/view/option/option.php | 10 ++-- 5 files changed, 106 insertions(+), 70 deletions(-) diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index f9433173..3f656dbf 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -379,6 +379,7 @@ class gallery extends common { } } // Soumission du formulaire d'ajout d'une galerie + /* if($this->isPost()) { if (!$this->getInput('galleryConfigFilterResponse')) { $galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content'])); @@ -413,12 +414,13 @@ class gallery extends common { ]]); // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl() /*. '#galleryConfigForm'*/, + 'redirect' => helper::baseUrl() . $this->getUrl(), 'notification' => 'Modifications enregistrées', 'state' => true ]); } } + */ // Valeurs en sortie $this->addOutput([ 'title' => 'Configuration du module', @@ -536,6 +538,46 @@ class gallery extends common { 'notification' => 'Action non autorisée' ]); } + // Soumission du formulaire + if($this->isPost()) { + // Photo de la page de garde de l'album définie dans form + if (is_array($this->getInput('homePicture', null)) ) { + $d = array_keys($this->getInput('homePicture', null)); + $homePicture = $d[0]; + } + // légendes + $legends = []; + $homePicture =''; + foreach((array) $this->getInput('legend', null) as $file => $legend) { + // Image de couverture par défaut si non définie + $homePicture = $file; + $file = str_replace('.','',$file); + $legends[$file] = helper::filter($legend, helper::FILTER_STRING_SHORT); + + } + // Sauvegarder + $this->setData(['module', $this->getUrl(0), 'content', $this->getUrl(2), [ + 'config' => [ + 'name' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'name']), + 'directory' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'directory']), + 'homePicture' => $homePicture, + // pas de positions, on active le tri alpha + 'sort' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2),'config','sort']), + 'position' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2),'config', 'position']), + 'fullScreen' =>$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullscreen']), + 'showPageContent' =>$this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']) + + ], + 'legend' => $legends, + 'positions' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'positions']) + ]]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit/' .$this->getUrl(2) . '/' . $_SESSION['csrf'] , + 'notification' => 'Modifications enregistrées', + 'state' => true + ]); + } // La galerie n'existe pas if($this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2)]) === null) { // Valeurs en sortie @@ -863,6 +905,8 @@ class gallery extends common { 'backPosition' => $this->getinput('galleryOptionBackPosition', null), 'backAlign' => $this->getinput('galleryOptionBackAlign', null) ]]); + + // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl() . '/option', @@ -878,9 +922,10 @@ class gallery extends common { 'view' => 'option' ]); } elseif ($this->getUrl(2) === 'gallery') { + // Paramètre d'une galerie // Jeton incorrect - if ($this->getUrl(3) !== $_SESSION['csrf']) { + if ($this->getUrl(4) !== $_SESSION['csrf']) { // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit', @@ -899,35 +944,20 @@ class gallery extends common { // Supprime l'ancienne galerie $this->deleteData(['module', $this->getUrl(0), 'content', $this->getUrl(2)]); } - // légendes - $legends = []; - foreach((array) $this->getInput('legend', null) as $file => $legend) { - // Image de couverture par défaut si non définie - $homePicture = $file; - $file = str_replace('.','',$file); - $legends[$file] = helper::filter($legend, helper::FILTER_STRING_SHORT); - - } - // Photo de la page de garde de l'album définie dans form - if (is_array($this->getInput('homePicture', null)) ) { - $d = array_keys($this->getInput('homePicture', null)); - $homePicture = $d[0]; - } // Sauvegarder if ($this->getInput('galleryEditName')) { $this->setData(['module', $this->getUrl(0), 'content', $galleryId, [ 'config' => [ 'name' => $this->getInput('galleryEditName', helper::FILTER_STRING_SHORT, true), 'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true), - 'homePicture' => $homePicture, - // pas de positions, on active le tri alpha + 'homePicture' => $this->getData(['module', $this->getUrl(0), 'content', $galleryId, 'config', 'homePicture']), 'sort' => $this->getInput('galleryEditSort'), 'position' => $this->getData(['module', $this->getUrl(0), 'content', $galleryId,'config','position']), 'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN), 'showPageContent' => $this->getInput('galleryEditShowPageContent', helper::FILTER_BOOLEAN) ], - 'legend' => $legends, + 'legend' => $this->getData(['module', $this->getUrl(0), 'content', $galleryId, 'config', 'legend']), 'positions' => empty($oldPositions) ? $this->getData(['module', $this->getUrl(0), 'content', $galleryId, 'positions']) : $oldPositions ]]); } diff --git a/module/gallery/view/edit/edit.js.php b/module/gallery/view/edit/edit.js.php index 9b0eadb3..27096669 100644 --- a/module/gallery/view/edit/edit.js.php +++ b/module/gallery/view/edit/edit.js.php @@ -11,50 +11,7 @@ * @link http://zwiicms.fr/ */ -/** - * Liste des dossiers - */ -var oldResult = []; -var directoryDOM = $("#galleryEditDirectory"); -var directoryOldDOM = $("#galleryEditDirectoryOld"); -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 = $("