From b6839bc0ac01ca48dd3fc8a6cf7171b4af60ae9d Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sun, 8 Mar 2020 14:56:10 +0100 Subject: [PATCH 1/2] init WIp --- core/core.php | 2 +- module/gallery/gallery.php | 41 +++++++++++++++++++----- module/gallery/view/config/config.js.php | 11 +++++++ module/gallery/view/config/config.php | 2 +- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/core/core.php b/core/core.php index 13a42874..d48e585a 100644 --- a/core/core.php +++ b/core/core.php @@ -3332,7 +3332,7 @@ class template { $html .= ''; $i = 0; foreach($tr as $td) { - $html .= '' . $td . ''; + $html .= '' . $td . ''; } $html .= ''; } diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index da6f4a64..2cc514a3 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -23,8 +23,8 @@ class gallery extends common { ]; public static $sort = [ - 'asc' => 'Alphabétique naturel', - 'dsc' => 'Alphabétique naturel inverse', + 'SORT_ASC' => 'Alphabétique naturel', + 'SORT_DSC' => 'Alphabétique naturel inverse', 'none' => 'Aucun tri', ]; @@ -44,8 +44,24 @@ class gallery extends common { public function config() { // Liste des galeries $galleries = $this->getData(['module', $this->getUrl(0)]); + $countGalleries = count($this->getData(['module',$this->getUrl(0)])); + // Tri des éléments de la galerie + /* + echo "
";	
+		if($galleries) {	
+			foreach($galleries as $galleryId => $gallery) {
+				echo $galleryId;
+				echo "|";
+				echo $gallery['config']['order'] ;
+				echo '

'; + } + } + + + echo "

"; + */ + if($galleries) { - ksort($galleries,SORT_NATURAL); foreach($galleries as $galleryId => $gallery) { // Erreur dossier vide if(is_dir($gallery['config']['directory'])) { @@ -57,10 +73,18 @@ class gallery extends common { else { $gallery['config']['directory'] = '' . $gallery['config']['directory'] . ' (dossier introuvable)'; } + // Ordre des galeries + // Element 0 chaine vide + $galeryOrder = range(1,count($this->getData(['module',$this->getUrl(0)]))); // Met en forme le tableau self::$galleries[] = [ $gallery['config']['name'], $gallery['config']['directory'], + template::select('galleryConfigOrder', $galeryOrder , [ + 'selected' => $gallery['config']['order'], + 'class' => 'configOrder' + + ]), template::button('galleryConfigEdit' . $galleryId , [ 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'], 'value' => template::ico('pencil') @@ -80,7 +104,8 @@ class gallery extends common { 'config' => [ 'name' => $this->getInput('galleryConfigName'), 'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true), - 'sort' => $this->getInput('galleryConfigSort') + 'sort' => $this->getInput('galleryConfigSort'), + 'order' => count($this->getData(['module',$this->getUrl(0)])) + 1 ], 'legend' => [] ]]); @@ -223,10 +248,10 @@ class gallery extends common { switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) { case 'none': break; - case 'dsc': + case 'SORT_DSC': krsort(self::$pictures,SORT_NATURAL); break; - case 'asc': + case 'SORT_ASC': default: ksort(self::$pictures,SORT_NATURAL); break; @@ -268,10 +293,10 @@ class gallery extends common { switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'sort'])) { case 'none': break; - case 'dsc': + case 'SORT_DSC': krsort(self::$pictures,SORT_NATURAL); break; - case 'asc': + case 'SORT_ASC': default: ksort(self::$pictures,SORT_NATURAL); break; diff --git a/module/gallery/view/config/config.js.php b/module/gallery/view/config/config.js.php index 39e47491..03c26eba 100644 --- a/module/gallery/view/config/config.js.php +++ b/module/gallery/view/config/config.js.php @@ -58,4 +58,15 @@ setInterval(function() { */ directoryDOM.on("change", function() { directoryOldDOM.val($(this).val()); +}); + + +/** + * Tri de la galerie + */ + +$( document ).ready(function() { + $('tbody > tr').sort(function (a, b) { + return +$('td#pos3', b).text() > +$('td#pos3', a).text(); + }).appendTo('tbody'); }); \ No newline at end of file diff --git a/module/gallery/view/config/config.php b/module/gallery/view/config/config.php index 508b07a0..a124965c 100644 --- a/module/gallery/view/config/config.php +++ b/module/gallery/view/config/config.php @@ -45,7 +45,7 @@ - + From cfc044a9f3de050857ee6612f31823c0ba65e26a Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sun, 8 Mar 2020 14:57:42 +0100 Subject: [PATCH 2/2] Texte au lieu de select --- module/gallery/gallery.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 2cc514a3..6663ca17 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -80,11 +80,13 @@ class gallery extends common { self::$galleries[] = [ $gallery['config']['name'], $gallery['config']['directory'], + $gallery['config']['order'], + /* template::select('galleryConfigOrder', $galeryOrder , [ 'selected' => $gallery['config']['order'], 'class' => 'configOrder' - ]), + ]),*/ template::button('galleryConfigEdit' . $galleryId , [ 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'], 'value' => template::ico('pencil')