Location: PHPKode > scripts > phpFlickrSynch > phpflickrsynch/_publicApi/class_PhotoCollection.php
<?php
	/**
	  * Entry point to the entire photo collection. 
	  * Contains various methods to get lists of photo albums, numbers of albums, photos, tags in the collection.
	  */
	class PhotoCollection {
	
		private $groupName = NULL;
		private $groupId = 0;
	
		/**
		  * Constructor
		  * @param $groupName Group name - only returns albums tagged with this group name ; default: null		  
		  */
		public function __construct($groupName = NULL) {
			// Retrieves the groupID corresponding to the given group name
			$groupId = 0;
			if ($groupName != NULL) {
				$groupId = Group::getId($groupName);
			}			
			$this->groupName = $groupName;
			$this->groupId = $groupId;
		}
		
		/**
		  * Returns the last photo albums registered
		  * @param $nbAlbums Number of photo albums to return ; 5 by default
		  * @param $nbPhotosPerAlbum Number of photo per photo album to return ; 3 by default
		  * @param $size Size of photos to be returned ; default is 'Thumbnail'
		  * @return An associative array "porID => details"
		  */
		public function getLastPhotoAlbums($nbAlbums = 5, $nbPhotosPerAlbum = 3, $size = 'Thumbnail') {			
			$DB = new TableFlickrPortfolio();
			return $DB->getLastAlbums($nbAlbums, $nbPhotosPerAlbum, $size, $this->groupId);		
		}
		
		/**
		  * Returns the list of photo albums for a given date
		  * @param $year Year
		  * @param $month Month
		  * @param $day Day
		  * @param $nbPhotosPerAlbum Number of photo per photo album to return ; 3 by default
		  * @param $size Size of photos to be returned ; default is 'Thumbnail'
		  * @return An associative array "porID => details"		  
		  */
		public function getArchives($year = NULL, $month = NULL, $day = NULL, $nbPhotosPerAlbum = 3, $size = 'Thumbnail') {
			$DB = new TableFlickrPortfolio();
			return $DB->getAlbums($year, $month, $day, $nbPhotosPerAlbum, $size, $this->groupId);		
		}

		/**
		  * Retrieve the list of photo albums with geo data along with useful data to be shown on a map
		  * @return An array with key = Photo Album ID ; value = an array with "lat" (latitude), "lon" (longitude), "title" (photo album title), "datetime" (creation date)
		  */	
		public function getAllPhotoAlbumsWithGeoData() {
			$DB = new TableFlickrPortfolio();
			return $DB->getAllPhotoAlbumsWithGeoData($this->groupId);
		}

		/**
		  * Returns the total number of photo albums
		  */
		public function getNumberOfAlbums() {
			$DB = new TableFlickrPortfolio();
			return $DB->getNumberOfAlbums($this->groupId);
		}

		/**
		  * Returns the total number of photos
		  */
		public function getNumberOfPhotos() {
			$DB = new TableFlickrPhoto();
			return $DB->getNumberOfPhotos($this->groupId);
		}

		/**
		  * Returns the total number of tags
		  */
		public function getNumberOfTags() {
			$DB = new TableFlickrTag();
			return $DB->getNumberOfTags($this->groupId);
		}	

		/**
		  * Computes a tag cloud
		  * @param $pmin Minimum size of tag
		  * @param $pmax Maximum size of tag
		  * @param $order 1 means sorting by tag name ; 2 means sorting by popularity
		  * @param $limit Number of tags in the tag cloud ; default: 100		  
		  */
		public function getTagCloud($pmin, $pmax, $order=1, $limit=100) {
			$DB = new TableFlickrTag();
			return $DB->getTagCloud($pmin, $pmax, $order, $limit);
		}
	}
?>
Return current item: phpFlickrSynch