From ea2085d584e8d6741e802cf18184883b48a45e63 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Mon, 13 Apr 2020 18:13:01 +0200 Subject: [PATCH] =?UTF-8?q?[2.4]=20Constantes=20de=20tri=20-=20pas=20de=20?= =?UTF-8?q?tri=20dans=20la=20cr=C3=A9ation=20de=20galerie=20dans=20la=20co?= =?UTF-8?q?nfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/gallery/gallery.php | 26 +++++++++++++++----------- module/gallery/view/config/config.php | 10 ++-------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index fb8e279f..47540c5c 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -14,6 +14,10 @@ class gallery extends common { + const SORT_ASC = 'SORT_ASC'; + const SORT_DSC = 'SORT_DSC'; + const SORT_HAND = 'SORT_HAND'; + public static $actions = [ 'config' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR, @@ -24,9 +28,9 @@ class gallery extends common { ]; public static $sort = [ - 'SORT_ASC' => 'Alphabétique ', - 'SORT_DSC' => 'Alphabétique inversé', - 'SORT_HAND' => 'Tri manuel' + self::SORT_ASC => 'Alphabétique ', + self::SORT_DSC => 'Alphabétique inversé', + self::SORT_HAND => 'Tri manuel' ]; public static $directories = []; @@ -140,7 +144,7 @@ class gallery extends common { 'name' => $this->getInput('galleryConfigName'), 'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true), 'homePicture' => $homePicture, - 'sort' => $this->getInput('galleryConfigSort'), + 'sort' => self::SORT_ASC, 'position' => count($this->getData(['module',$this->getUrl(0)])) + 1 ], 'legend' => [], @@ -235,7 +239,7 @@ class gallery extends common { */ $picturesPosition = []; if ($this->getInput('galleryEditFormResponse') && - $this->getInput('galleryEditSort') === 'SORT_HAND') { + $this->getInput('galleryEditSort') === self::SORT_HAND) { // Tri des images si valeur de retour et choix manuel $picturesPosition = explode('&',($this->getInput('galleryEditFormResponse'))); $picturesPosition = str_replace('galleryTable%5B%5D=','',$picturesPosition); @@ -306,7 +310,7 @@ class gallery extends common { } // Tri des images switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) { - case 'SORT_HAND': + case self::SORT_HAND: $positions = $this->getdata(['module',$this->getUrl(0), $this->getUrl(2),'position']); if ($positions) { foreach ($positions as $position => $name) { @@ -317,11 +321,11 @@ class gallery extends common { self::$picturesId = $tempPicturesId; } break; - case 'SORT_ASC': + case self::SORT_ASC: ksort(self::$pictures,SORT_NATURAL); sort(self::$picturesId,SORT_NATURAL); break; - case 'SORT_DSC': + case self::SORT_DSC: krsort(self::$pictures,SORT_NATURAL); rsort(self::$picturesId,SORT_NATURAL); break; @@ -375,7 +379,7 @@ class gallery extends common { } // Tri des images par ordre alphabétique switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'sort'])) { - case 'SORT_HAND': + case self::SORT_HAND: asort($picturesSort); if ($picturesSort) { foreach ($picturesSort as $name => $position) { @@ -384,10 +388,10 @@ class gallery extends common { self::$pictures = $temp; break; } - case 'SORT_DSC': + case self::SORT_DSC: krsort(self::$pictures,SORT_NATURAL); break; - case 'SORT_ASC': + case self::SORT_ASC: default: ksort(self::$pictures,SORT_NATURAL); break; diff --git a/module/gallery/view/config/config.php b/module/gallery/view/config/config.php index bac7122b..3865564b 100644 --- a/module/gallery/view/config/config.php +++ b/module/gallery/view/config/config.php @@ -14,12 +14,12 @@

Ajouter une galerie

-
+
'Nom' ]); ?>
-
+
true // Désactivé à cause des modifications en ajax ]); ?> @@ -28,12 +28,6 @@ 'noDirty' => true // Désactivé à cause des modifications en ajax ]); ?>
-
- 'Tri des images', - 'help' => 'Les images sont triées par nom de fichier grâce à la méthode naturelle qui donne de meilleurs résultats lorsque les images sont numérotées.' - ]); ?> -
'',