From 2c981072a6a326e72800b39c2fff5e741199c766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Mon, 21 Mar 2022 19:16:11 +0100 Subject: [PATCH] Gallery affiche directement la galerie seule + bug style absent --- core/core.php | 3 +-- module/gallery/gallery.php | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/core/core.php b/core/core.php index a2466dd6..a9015382 100644 --- a/core/core.php +++ b/core/core.php @@ -2982,8 +2982,7 @@ class core extends common { 'style' => file_get_contents($stylePath) ]); } - if ($output['style'] && - file_exists($output['style'])) { + if ($output['style']) { $this->addOutput([ 'style' => $this->output['style'] . file_get_contents($output['style']) ]); diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 7c8f43ff..0c1f4d7a 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -17,7 +17,7 @@ class gallery extends common { - const VERSION = '3.3'; + const VERSION = '3.4'; const REALNAME = 'Galerie'; const DELETE = true; const UPDATE = '0.0'; @@ -601,10 +601,14 @@ class gallery extends common { // Mise à jour des données de module $this->update(); + // Une seule galerie, bifurquer sur celle-ci + $gallery = count($this->getData(['module', $this->getUrl(0), 'content'])) === 1 + ? array_key_first($this->getData(['module', $this->getUrl(0), 'content'])) + : $this->getUrl(1); // Images d'une galerie - if($this->getUrl(1)) { + if($gallery) { // La galerie n'existe pas - if($this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(1)]) === null) { + if($this->getData(['module', $this->getUrl(0), 'content', $gallery]) === null) { // Valeurs en sortie $this->addOutput([ 'access' => false @@ -613,13 +617,13 @@ class gallery extends common { // La galerie existe else { // Images de la galerie - $directory = $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(1), 'config', 'directory']); + $directory = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'directory']); if(is_dir($directory)) { $iterator = new DirectoryIterator($directory); foreach($iterator as $fileInfos) { if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) { - self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(1), 'legend', str_replace('.','',$fileInfos->getFilename())]); - $picturesSort[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(1), 'positions', str_replace('.','',$fileInfos->getFilename())]); + self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.','',$fileInfos->getFilename())]); + $picturesSort[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'positions', str_replace('.','',$fileInfos->getFilename())]); // Créer la miniature si manquante if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) { $this->makeThumb($fileInfos->getPathname(), @@ -633,7 +637,7 @@ class gallery extends common { } } // Tri des images par ordre alphabétique - switch ($this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(1), 'config', 'sort'])) { + switch ($this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'sort'])) { case self::SORT_HAND: asort($picturesSort); if ($picturesSort) { @@ -657,7 +661,7 @@ class gallery extends common { // Valeurs en sortie $this->addOutput([ 'showBarEditButton' => true, - 'title' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(1), 'config', 'name']), + 'title' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'name']), 'view' => 'gallery', 'style' => $this->getData(['module', $this->getUrl(0), 'theme', 'style']) ]); @@ -722,7 +726,9 @@ class gallery extends common { 'showBarEditButton' => true, 'showPageContent' => true, 'view' => 'index', - 'style' => $this->getData(['module', $this->getUrl(0), 'theme', 'style']) + 'style' => file_exists($this->getData(['module', $this->getUrl(0), 'theme', 'style'])) + ? $this->getData(['module', $this->getUrl(0), 'theme', 'style']) + : '' ]); } }