diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-10-23 15:01:00 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-10-23 15:01:00 +0000 |
commit | f1f08168b325605a489b5f21cfdfff96312d55f8 (patch) | |
tree | 15d8e30d9b645c3fe229cb9a336e7a7708e46070 /lib | |
parent | bff17c5857d0365038e6783c3c00b53204f4a10e (diff) | |
download | elgg-f1f08168b325605a489b5f21cfdfff96312d55f8.tar.gz elgg-f1f08168b325605a489b5f21cfdfff96312d55f8.tar.bz2 |
moved cover code into album class
Diffstat (limited to 'lib')
-rw-r--r-- | lib/album.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/album.php b/lib/album.php index 472bf69d8..916ccbc31 100644 --- a/lib/album.php +++ b/lib/album.php @@ -67,7 +67,43 @@ class TidypicsAlbum extends ElggObject { $count = $this->getSize(); - return elgg_view_entity_list($images, $count, $offset, $limit, FALSE, FALSE, TRUE); + return elgg_view_entity_list($images, $count, $offset, $limit, false, false, true); + } + + /** + * Get the GUID of the album cover + * + * @return int + */ + public function getCoverImageGuid() { + if ($this->getSize() == 0) { + return 0; + } + + $guid = $this->cover; + $imageList = $this->getImageList(); + if (!in_array($guid, $imageList)) { + // select random photo to be cover + $index = array_rand($imageList, 1); + $guid = $imageList[$index]; + $this->cover = $guid; + } + return $guid; + } + + /** + * Set the GUID for the album cover + * + * @param int $guid + * @return bool + */ + public function setCoverImageGuid($guid) { + $imageList = $this->getImageList(); + if (!in_array($guid, $imageList)) { + return false; + } + $this->cover = $guid; + return true; } /** |