From b44ef817e85bd0874d79a9935706e4e7bc158667 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 8 Apr 2020 22:22:40 +0200 Subject: [PATCH] =?UTF-8?q?Rafraichissement=20forc=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/gallery/gallery.php | 73 ++++++++++++------------ module/gallery/view/config/config.js.php | 10 +++- module/gallery/view/config/config.php | 7 ++- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 499ac383..5eaa7137 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -49,7 +49,37 @@ class gallery extends common { * Configuration */ public function config() { - // Tri des galeries + + /* + * Le traitement du tri s'effectue en début de fonction + */ + // Soumission du formulaire + if($this->isPost()) { + if ($this->getInput('galleryConfigFilterResponse')) { + $data = explode('&',($this->getInput('galleryConfigFilterResponse'))); + $data = str_replace('galleryTable%5B%5D=','',$data); + for($i=0;$isetData(['module', $this->getUrl(0), $data[$i], [ + 'config' => [ + 'name' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','name']), + 'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']), + 'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']), + 'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']), + 'position' => $i + ], + 'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend']) + ]]); + } + } + // Valeurs en sortie + //header('Refresh: 0;url='. helper::baseUrl() . $this->getUrl() . '#galleryConfigFilterForm' ); + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl() . '#galleryConfigFilterForm', + 'notification' => 'Modifications enregistrées', + 'state' => true + ]); + } + // Tri pour l'affichage de la galerie $g = $this->getData(['module', $this->getUrl(0)]); $p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position'); asort($p,SORT_NUMERIC); @@ -89,36 +119,10 @@ class gallery extends common { self::$galleriesId[] = $galleryId; } } - // Soumission du formulaire + // Soumission du formulaire d'ajouter d'une galerie if($this->isPost()) { - // Tri de la galerie - if ($this->getInput('galleryConfigFilterResponse')) { - $data = explode('&',($this->getInput('galleryConfigFilterResponse'))); - $data = str_replace('galleryTable%5B%5D=','',$data); - for($i=0;$isetData(['module', $this->getUrl(0), $data[$i], [ - 'config' => [ - 'name' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','name']), - 'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']), - 'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']), - 'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']), - 'position' => $i - ], - 'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend']) - ]]); - } - $this->saveData(); - // Valeurs en sortie - $this->addOutput([ - 'title' => 'Configuration du module', - 'view' => 'config', - 'vendor' => [ - 'tablednd' - ] - ]); - } else { - $galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)])); - // La première image est celle de la couverture de l'album + if (!$this->getInput('galleryConfigFilterResponse')) { + $galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)])); $directory = $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true); $iterator = new DirectoryIterator($directory); foreach($iterator as $fileInfos) { @@ -149,7 +153,7 @@ class gallery extends common { ]]); // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(), + 'redirect' => helper::baseUrl() . $this->getUrl(). '#galleryConfigForm', 'notification' => 'Modifications enregistrées', 'state' => true ]); @@ -269,8 +273,7 @@ class gallery extends common { ]]); // Valeurs en sortie $this->addOutput([ - //'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $this->getUrl(2) . '/' . $_SESSION['csrf'], + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $this->getUrl(2) . '/' . $_SESSION['csrf'] , 'notification' => 'Modifications enregistrées', 'state' => true ]); @@ -304,8 +307,7 @@ class gallery extends common { self::$picturesId [] = str_replace('.','',$fileInfos->getFilename()); } } - // Tri des images par ordre alphabétique - + // Tri des images switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) { case 'SORT_HAND': $positions = $this->getdata(['module',$this->getUrl(0), $this->getUrl(2),'position']); @@ -326,7 +328,6 @@ class gallery extends common { krsort(self::$pictures,SORT_NATURAL); rsort(self::$picturesId,SORT_NATURAL); break; - } } // Valeurs en sortie diff --git a/module/gallery/view/config/config.js.php b/module/gallery/view/config/config.js.php index c79e46ce..29e35f2e 100644 --- a/module/gallery/view/config/config.js.php +++ b/module/gallery/view/config/config.js.php @@ -22,8 +22,17 @@ $( document ).ready(function() { }, serializeRegexp: "[^\_]*$" }); + + /* + var href = window.location.href; + if(href.indexOf("#") > 0){ + href = href.split("#")[0] + href.split("#")[1]; + window.location.href = href; + }*/ }); + + // Activer le bouton de tri uniquement après un tri $("#galleryTable").click(function() { if ($("#galleryConfigFilterResponse").val() != "") { @@ -82,4 +91,3 @@ setInterval(function() { directoryDOM.on("change", function() { directoryOldDOM.val($(this).val()); }); - diff --git a/module/gallery/view/config/config.php b/module/gallery/view/config/config.php index 6e54e111..59fe7d85 100644 --- a/module/gallery/view/config/config.php +++ b/module/gallery/view/config/config.php @@ -37,7 +37,8 @@
'', - 'value' => template::ico('plus') + 'value' => template::ico('plus'), + 'class' => 'gallerySubmit' ]); ?>
@@ -52,7 +53,9 @@

Galeries installées

true + 'value' => 'Trier', + 'disabled' => true, + 'class' => 'gallerySubmit' ]); ?>