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.
This commit is contained in:
parent
a2def81b52
commit
5f682826f2
@ -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 {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -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 {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user