From 5f682826f271f968ba28f1c950a0028a7887f929 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 6 Sep 2016 15:33:36 -0400 Subject: [PATCH] Made Album::getSubAlbums and Album::addSubAlbumIDs static methods. Changed Thumb URL for Albums.php to get sub album IDs and use their thumbnails in the response. --- php/Modules/Album.php | 11 ++++++----- php/Modules/Albums.php | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/php/Modules/Album.php b/php/Modules/Album.php index 95ebee5..8100bfb 100644 --- a/php/Modules/Album.php +++ b/php/Modules/Album.php @@ -475,26 +475,27 @@ final class Album { } - private function getSubAlbums($albumID) { + public static function getSubAlbums($albumID) { $query = Database::prepare(Database::get(), "SELECT id FROM ? WHERE parent = '?'", array(LYCHEE_TABLE_ALBUMS, $albumID)); $albums = Database::execute(Database::get(), $query, __METHOD__, __LINE__); $ids = array(); while($album = $albums->fetch_assoc()) { - $ids = array_merge($ids, array($album['id']), $this->getSubAlbums($album['id'])); + $ids = array_merge($ids, array($album['id']), self::getSubAlbums($album['id'])); } return $ids; } - private function addSubAlbumIDs($ids) { + + public static function addSubAlbumIDs($ids) { $res = array(); foreach(explode(',', $ids) as $id) - $res = array_merge($res, array($id), $this->getSubAlbums($id)); + $res = array_merge($res, array($id), self::getSubAlbums($id)); return implode(',', $res); @@ -751,4 +752,4 @@ final class Album { } -?> \ No newline at end of file +?> diff --git a/php/Modules/Albums.php b/php/Modules/Albums.php index f3aa9c3..8967f65 100644 --- a/php/Modules/Albums.php +++ b/php/Modules/Albums.php @@ -51,7 +51,7 @@ final class Albums { ($public===false)) { // Execute query - $query = Database::prepare(Database::get(), "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr(Settings::get()['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id'])); + $query = Database::prepare(Database::get(), "SELECT thumbUrl FROM ? WHERE album IN (?) ORDER BY star DESC, " . substr(Settings::get()['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, Album::addSubAlbumIDs($album['id']))); $thumbs = Database::execute(Database::get(), $query, __METHOD__, __LINE__); if ($thumbs===false) return false; @@ -188,4 +188,4 @@ final class Albums { } -?> \ No newline at end of file +?>