From db4f3d65fb9fb8ad0ebe8f34bc47b684b8702b6a Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Mon, 21 Dec 2015 15:01:19 +0100 Subject: [PATCH] User Album::prepareData to prepare an Album, even for single albums --- php/modules/Album.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/php/modules/Album.php b/php/modules/Album.php index 708dab1..1b8d1c5 100644 --- a/php/modules/Album.php +++ b/php/modules/Album.php @@ -69,14 +69,20 @@ class Album extends Module { $album['title'] = $data['title']; $album['public'] = $data['public']; + # Additional attributes + # Only part of $album when available + if (isset($data['description'])) $album['description'] = $data['description']; + if (isset($data['visible'])) $album['visible'] = $data['visible']; + if (isset($data['downloadable'])) $album['downloadable'] = $data['downloadable']; + # Parse date $album['sysdate'] = date('F Y', $data['sysstamp']); # Parse password $album['password'] = ($data['password']=='' ? '0' : '1'); - # Set placeholder for thumbs - $album['thumbs'] = array(); + # Parse thumbs or set default value + $album['thumbs'] = (isset($data['thumbs']) ? explode(',', $data['thumbs']) : array()); return $album; @@ -112,8 +118,7 @@ class Album extends Module { default: $query = Database::prepare($this->database, "SELECT * FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs)); $albums = $this->database->query($query); $return = $albums->fetch_assoc(); - $return['sysdate'] = date('d M. Y', $return['sysstamp']); - $return['password'] = ($return['password']=='' ? '0' : '1'); + $return = Album::prepareData($return); $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = '?' " . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs)); break;