diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 9680fdd6..3fc1deaa 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -22,6 +22,12 @@ class gallery extends common { 'index' => self::GROUP_VISITOR ]; + public static $order = [ + 'asc' => 'Tri alphabétique naturel', + 'dsc' => 'Tri alphabétique naturel inverse', + 'none' => 'Aucun tri', + ]; + public static $directories = []; public static $firstPictures = []; @@ -38,7 +44,7 @@ class gallery extends common { public function config() { // Liste des galeries $galleries = $this->getData(['module', $this->getUrl(0)]); - if($galleries) { + if($galleries) { ksort($galleries,SORT_NATURAL); foreach($galleries as $galleryId => $gallery) { // Erreur dossier vide @@ -183,7 +189,8 @@ class gallery extends common { 'config' => [ 'name' => $this->getInput('galleryEditName', helper::FILTER_STRING_SHORT, true), 'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true), - 'homePicture' => $homePictures[$file] + 'homePicture' => $homePictures[$file], + 'order' => $this->getInput('galleryEditOrder') ], 'legend' => $legends ]]); @@ -249,7 +256,17 @@ class gallery extends common { } } // Tri des images par ordre alphabétique - ksort(self::$pictures,SORT_NATURAL); + switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'order'])) { + case 'none': + break; + case 'dsc': + krsort(self::$pictures,SORT_NATURAL); + break; + case 'asc': + default: + ksort(self::$pictures,SORT_NATURAL); + break; + } } // Affichage du template if(self::$pictures) { diff --git a/module/gallery/view/edit/edit.php b/module/gallery/view/edit/edit.php index 9d27a437..3655e5d0 100644 --- a/module/gallery/view/edit/edit.php +++ b/module/gallery/view/edit/edit.php @@ -34,6 +34,14 @@ ]); ?> +
+
+ '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.' + ]); ?> +
+