From 9c00248a7f0926c7d11cac2bab555b372f2237dd Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 14 Jan 2024 22:17:09 +0100 Subject: [PATCH] ViewPhotoAlbum: don't populate filter box if there are no album contributors --- controllers/ViewPhotoAlbum.php | 20 ++++++++++++-------- templates/AlbumButtonBox.php | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/controllers/ViewPhotoAlbum.php b/controllers/ViewPhotoAlbum.php index 0ff4129..c15175e 100644 --- a/controllers/ViewPhotoAlbum.php +++ b/controllers/ViewPhotoAlbum.php @@ -47,15 +47,19 @@ class ViewPhotoAlbum extends HTMLController $contributors = $tag->getContributorList(); // Enumerate possible filters - $filters = ['' => ['id_user' => null, 'caption' => 'Show all photos', 'link' => $tag->getUrl()]]; - foreach ($contributors as $contributor) + $filters = []; + if (!empty($contributors)) { - $filters[$contributor['slug']] = [ - 'id_user' => $contributor['id_user'], - 'caption' => sprintf('By %s (%s photos)', - $contributor['first_name'], $contributor['num_assets']), - 'link' => $tag->getUrl() . '/?by=' . $contributor['slug'], - ]; + $filters[''] = ['id_user' => null, 'caption' => 'Show all photos', 'link' => $tag->getUrl()]; + foreach ($contributors as $contributor) + { + $filters[$contributor['slug']] = [ + 'id_user' => $contributor['id_user'], + 'caption' => sprintf('By %s (%s photos)', + $contributor['first_name'], $contributor['num_assets']), + 'link' => $tag->getUrl() . '/?by=' . $contributor['slug'], + ]; + } } // Limit to a particular uploader? diff --git a/templates/AlbumButtonBox.php b/templates/AlbumButtonBox.php index 469fb34..ea631ea 100644 --- a/templates/AlbumButtonBox.php +++ b/templates/AlbumButtonBox.php @@ -28,26 +28,31 @@ class AlbumButtonBox extends Template echo ' ', $button['caption'], ''; - echo ' + if (!empty($this->filters)) + { + echo ' '; } echo ' - - '; } }