Location: PHPKode > scripts > phpFlickrSynch > phpflickrsynch/_publicApi/class_PhotoAlbum.php
<?php
	/**
	  * Class to access a specific photo album in the photo collection
	  */	 
	class PhotoAlbum {

		private $porId = 0;
		private $flickrId = '';
		private $groupId = 0;
		
		private $southWestLatitude = NULL;
		private $southWestLongitude = NULL;
		private $northEastLatitude = NULL;
		private $northEastLongitude = NULL;
		private $centroidLatitude = NULL;
		private $centroidLongitude = NULL;
		private $title = NULL;
		private $description = NULL;		
		
		/**
		  * Constructor.
		  * Checks if a photo album with the given ID exists in the DB
		  * Retrieve properties of the photo album
		  * @param $porId Photo Album ID
		  */
		function __construct($porId) {
			$this->porId = $porId;
			
			$DB = new TableFlickrPortfolio();
			$flickr_id = $DB->checkAlbum($this->porId);			
			if ($flickr_id == NULL) {
				// Photo album not found.
				throw new Exception('Photo album ' . $porId . ' not found in local database');
			} else {
				// Retrieves data from database
				$this->flickrId = $flickr_id;
				$details = $DB->getDetails($porId);

				$this->southWestLatitude = $details['sw_lat'];
				$this->southWestLongitude = $details['sw_lon'];
				$this->northEastLatitude = $details['ne_lat']; 
				$this->northEastLongitude = $details['ne_lon']; 
				$this->centroidLatitude = $details['cent_lat']; 
				$this->centroidLongitude = $details['cent_lon'];
				
				$this->title = $details['title'];
				$this->description = $details['description'];
				$this->groupId = $details['groupid'];
			}		
		}		

		/**
		  * @return the ID of the photo album
		  */
		public function getId() { return $this->porId;}
		
		/**
		  * @return the title of the photo album
		  */		
		public function getTitle() { return $this->title;}
		
		/**
		  * @return the description of the photo album
		  */		
		public function getDescription() { return $this->description;}		

		/**
		  * @return the group ID associated to this photo album ; 0 if no group assigned
		  */
		public function getGroupId() { return $this->groupId();}
		
		/**
		  * Checks if this photo album is in given group
		  * @param $groupName Group name
		  * @return true / false
		  */
		public function isInGroup($groupName) {
			if ($this->groupId > 0) {
				$id = Group::getId($groupName);
				return $id > 0 && $id == $this->groupId;
			} else {
				return false;
			} 			
		}

		/**
		  * Returns the bounding box for all the photos of this photo album
		  */
		public function getSouthWestLatitude() { return $this->southWestLatitude; }
		public function getSouthWestLongitude() { return $this->southWestLongitude; }
		public function getNorthEastLatitude() { return $this->northEastLatitude; }
		public function getNorthEastLongitude() { return $this->northEastLongitude; }
		public function getCentroidLatitude() { return $this->centroidLatitude; }
		public function getCentroidLongitude() { return $this->centroidLongitude; }

		/**
		  * Apply some transformation on raw description for better display
		  * Transform carriage returns into <br> tags
		  * @return description to be displayed
		  */
		public function getDisplayDescription() {
			$order = array("\r\n", "\n", "\r");
			$replace = '<br/>';
			return str_replace($order, $replace, $this->getDescription());			
		}

		/**
		  * Returns the list of photos in this photo album
		  * @param $limit Max number of photos to be retrieved
		  * @return An array containing list of photos
		  */
		public function getPhotos($limit = 100) {	
			$DB = new TableFlickrPhoto();			
			return $DB->getPhotos($this->porId, $limit);
		}
	}
?>
Return current item: phpFlickrSynch