From be3479085d475428a213868e13e8504e924e32ba Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 11 Dec 2011 20:59:29 -0500 Subject: added navigation when viewing full image --- classes/TidypicsAlbum.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'classes') diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php index e5a8e2c0c..e04344a6b 100644 --- a/classes/TidypicsAlbum.php +++ b/classes/TidypicsAlbum.php @@ -207,41 +207,45 @@ class TidypicsAlbum extends ElggObject { } /** - * Get the GUID of the image before the current one + * Get the previous image in the album * - * @param int $currentGuid - * @return int + * @param int $guid GUID of the current image + * @return TidypicsImage */ - public function getPreviousImageGuid($currentGuid) { + public function getPreviousImage($guid) { $imageList = $this->getImageList(); - $key = array_search($currentGuid, $imageList); + $key = array_search($guid, $imageList); if ($key === FALSE) { - return 0; + return null; } $key--; if ($key < 0) { - return 0; + return get_entity(end($imageList)); } - return $imageList[$key]; + return get_entity($imageList[$key]); } /** - * Get the GUID of the image after the current one + * Get the next image in the album * - * @param int $currentGuid - * @return int + * @param int $guid GUID of the current image + * @return TidypicsImage */ - public function getNextImageGuid($currentGuid) { + public function getNextImage($guid) { $imageList = $this->getImageList(); - $key = array_search($currentGuid, $imageList); + $key = array_search($guid, $imageList); if ($key === FALSE) { - return 0; + return null; } $key++; if ($key >= count($imageList)) { - return 0; + return get_entity($imageList[0]); } - return $imageList[$key]; + return get_entity($imageList[$key]); + } + + public function getIndex($guid) { + return array_search($guid, $this->getImageList()) + 1; } /** -- cgit v1.2.3