Location: PHPKode > scripts > phpFlickrSynch > phpflickrsynch/_publicApi/class_PhotoSearch.php
<?php
/**
  * To search the local phpFlickrSynch database
  */
	class PhotoSearch {

		private $query = NULL;
		private $tagId = 0;
		private $totalNbTagSearch = 0;

		/**
		  * Constructor
		  * @param $query This is the search term
		  */
		public function __construct($query) {
			$this->query = $query;
			// Is the query a tag ?			
			$this->tagId = Tag::getId($this->query);		
		}
		
		/**
		  * Check if the search term is a tag
		  * @return The corresponding tagId or 0 if it is not a tag
		  */
		public function isTag() { return $this->tagId;}
		
		/**
		  * If the search term is a tag, returns the corresponding Tag object
		  * @return a Tag object or NULL if it is not a tag
		  */
		public function getTag($groupName = NULL) {
			if ($this->tagId > 0) {
				return new Tag($this->tagId, $groupName);
			} else {
				return NULL;
			}
		}
		
		/**
		  * Perform a full-text search on photo albums
		  * @param $nbPhotosPerAlbum Number of photo per photo album to return ; 3 by default
		  * @param $size Size of photos to be returned ; default is 'Thumbnail'
		  * @param $groupName Group name - only returns albums tagged with this group name ; default: null		  		  
		  * @return An associative array "porID => details"
		  */
		public function performPhotoAlbumSearch($nbPhotosPerAlbum = 3, $size = 'Thumbnail', $groupName = NULL) {
			$groupId = ($groupName == NULL) ? 0 : Group::getId($groupName);
			
			$DB = new TableFlickrPortfolio();
			return $DB->search($this->query, $nbPhotosPerAlbum, $size, $groupId);			
		}

		/**
		  * Perform a full-text search on photos
		  * @param $nbPhotos Number of photos to return ; 3 by default
		  * @param $size Size of photos to be returned ; default is 'Thumbnail'
		  * @param $groupName Group name - only returns albums tagged with this group name ; default: null		  		  
		  * @return The collection of photos as an array
		  */
		public function performPhotoSearch($nbPhotos = 3, $size = 'Thumbnail', $groupName = NULL) {	
			$groupId = ($groupName == NULL) ? 0 : Group::getId($groupName);
			
			$DB = new TableFlickrPhoto();
			return $DB->search($this->query, $nbPhotos, $size, $groupId);			
		}
	}
?>
Return current item: phpFlickrSynch