User Album::prepareData to prepare an Album, even for single albums

This commit is contained in:
Tobias Reich 2015-12-21 15:01:19 +01:00
parent 76a7d53fba
commit db4f3d65fb

View File

@ -69,14 +69,20 @@ class Album extends Module {
$album['title'] = $data['title']; $album['title'] = $data['title'];
$album['public'] = $data['public']; $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 # Parse date
$album['sysdate'] = date('F Y', $data['sysstamp']); $album['sysdate'] = date('F Y', $data['sysstamp']);
# Parse password # Parse password
$album['password'] = ($data['password']=='' ? '0' : '1'); $album['password'] = ($data['password']=='' ? '0' : '1');
# Set placeholder for thumbs # Parse thumbs or set default value
$album['thumbs'] = array(); $album['thumbs'] = (isset($data['thumbs']) ? explode(',', $data['thumbs']) : array());
return $album; 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)); default: $query = Database::prepare($this->database, "SELECT * FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$albums = $this->database->query($query); $albums = $this->database->query($query);
$return = $albums->fetch_assoc(); $return = $albums->fetch_assoc();
$return['sysdate'] = date('d M. Y', $return['sysstamp']); $return = Album::prepareData($return);
$return['password'] = ($return['password']=='' ? '0' : '1');
$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)); $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; break;