From 7d3ab166c71967bcd27b94e68ebfcab1f38d67c5 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 29 Sep 2019 14:12:30 +0200 Subject: [PATCH] Simplify template logic for photo index. --- templates/PhotosIndex.php | 96 ++++++++++----------------------------- 1 file changed, 23 insertions(+), 73 deletions(-) diff --git a/templates/PhotosIndex.php b/templates/PhotosIndex.php index e10436b..e6bf818 100644 --- a/templates/PhotosIndex.php +++ b/templates/PhotosIndex.php @@ -73,9 +73,9 @@ class PhotosIndex extends SubTemplate $name = str_replace(' ', '', strtolower($header)); echo ' -
+

', $header, ' -

'; + '; $this->previous_header = $header; } @@ -89,8 +89,11 @@ class PhotosIndex extends SubTemplate return $color; } - protected function photo(Image $image, $width, $height, $crop = true, $fit = true) + protected function photo(Image $image, $className, $width, $height, $crop = true, $fit = true) { + echo ' +
'; + if ($this->show_edit_buttons) echo ' Edit'; @@ -104,21 +107,15 @@ class PhotosIndex extends SubTemplate

', $image->getTitle(), '

'; echo ' - '; + + +
'; } protected function panorama(array $photos) { foreach ($photos as $image) - { - echo ' -
'; - - $this->photo($image, static::PANORAMA_WIDTH, static::PANORAMA_HEIGHT, false, false); - - echo ' -
'; - } + $this->photo($image, 'panorama', static::PANORAMA_WIDTH, static::PANORAMA_HEIGHT, false, false); } protected function portrait(array $photos) @@ -127,26 +124,16 @@ class PhotosIndex extends SubTemplate echo '
-
-
'; +
'; - $this->photo($image, static::PORTRAIT_WIDTH, static::PORTRAIT_HEIGHT, 'centre'); + $this->photo($image, 'portrait', static::PORTRAIT_WIDTH, static::PORTRAIT_HEIGHT, 'centre'); echo ' -
'; foreach ($photos as $image) - { - echo ' -
'; - - $this->photo($image, static::TILE_WIDTH, static::TILE_HEIGHT, 'centre'); - - echo ' -
'; - } + $this->photo($image, 'landscape', static::TILE_WIDTH, static::TILE_HEIGHT, 'centre'); echo '
@@ -159,26 +146,16 @@ class PhotosIndex extends SubTemplate echo '
-
-
'; +
'; - $this->photo($image, static::LANDSCAPE_WIDTH, static::LANDSCAPE_HEIGHT, 'top'); + $this->photo($image, 'landscape', static::LANDSCAPE_WIDTH, static::LANDSCAPE_HEIGHT, 'top'); echo ' -
'; foreach ($photos as $image) - { - echo ' -
'; - - $this->photo($image, static::TILE_WIDTH, static::TILE_HEIGHT, 'top'); - - echo ' -
'; - } + $this->photo($image, 'landscape', static::TILE_WIDTH, static::TILE_HEIGHT, 'top'); echo '
@@ -191,15 +168,7 @@ class PhotosIndex extends SubTemplate
'; foreach ($photos as $image) - { - echo ' -
'; - - $this->photo($image, static::DUO_WIDTH, static::DUO_HEIGHT, true); - - echo ' -
'; - } + $this->photo($image, 'duo', static::DUO_WIDTH, static::DUO_HEIGHT, true); echo '
'; @@ -207,16 +176,13 @@ class PhotosIndex extends SubTemplate protected function single(array $photos) { + echo ' +
'; + $image = array_shift($photos); + $this->photo($image, 'single', static::SINGLE_WIDTH, static::SINGLE_HEIGHT, 'top'); echo ' -
-
'; - - $this->photo($image, static::SINGLE_WIDTH, static::SINGLE_HEIGHT, 'top'); - - echo ' -
'; } @@ -226,15 +192,7 @@ class PhotosIndex extends SubTemplate
'; foreach ($photos as $image) - { - echo ' -
'; - - $this->photo($image, static::TILE_WIDTH, static::TILE_HEIGHT, true); - - echo ' -
'; - } + $this->photo($image, 'landscape', static::TILE_WIDTH, static::TILE_HEIGHT, true); echo '
'; @@ -246,15 +204,7 @@ class PhotosIndex extends SubTemplate
'; foreach ($photos as $image) - { - echo ' -
'; - - $this->photo($image, static::PORTRAIT_WIDTH, static::PORTRAIT_HEIGHT, true); - - echo ' -
'; - } + $this->photo($image, 'portrait', static::PORTRAIT_WIDTH, static::PORTRAIT_HEIGHT, true); echo '
';