public function getPoster() { if (Photo::photoExists($this->record['poster_id'])) { return Photo::getPhotoWithID($this->record['poster_id']); } else { $photos = $this->getPhotos(); return $photos[0]; } }
/** * Get an array of the popular photos * * @access public * @return array */ public function getPopularPhotos() { $popularPhotos = array(); $query = Database::select('photos', 'id', null, 'ORDER BY hits DESC limit 5'); while ($photo = $query->fetchAssoc()) { $popularPhotos[] = Photo::getPhotoWithID($photo['id']); } return $popularPhotos; }
/** * Returns photos per QUERY, privacy, and paging restrictions * * @access public * @return Photo[] */ public function getPhotos() { $sort = $this->photoSortSqlForOption($this->sort); $condition = $this->whereRestriction; if (!$this->showPrivatePhotos) { $condition .= ' AND status = 0'; } $query = Database::Select('ratings', 'photos.id', $condition, 'ORDER BY ' . $sort . ' ' . 'LIMIT ' . $this->offset . ',' . $this->pageSize, 'LEFT JOIN photos ON ratings.id = photos.id LEFT JOIN exif ON photos.id=exif.photoid and exif.tag="Date taken"'); $photos = array(); while ($row = $query->fetchAssoc()) { $photos[] = Photo::getPhotoWithID($row['id']); } return $photos; }
/** * Returns photos per QUERY, privacy, and paging restrictions * * @access public * @return Photo[] */ public function getPhotos() { $sort = $this->photoSortSqlForOption($this->sort); $conditions = array(); $binds = array(); $conditions[0] = "(path = :1)"; $binds[1] = $this->path; if (!$this->showPrivatePhotos) { $conditions[] = 'status = 0'; } $query = Database::select('photos', 'id', implode(' AND ', $conditions), 'ORDER BY ' . $sort . ' ' . 'LIMIT ' . $this->offset . ',' . $this->pageSize, 'LEFT JOIN exif ON photos.id=exif.photoid and exif.tag="Date taken"', $binds); $photos = array(); while ($row = $query->fetchAssoc()) { $photos[] = Photo::getPhotoWithID($row['id']); } return $photos; }
/** * Returns photos per QUERY, privacy, and paging restrictions * * @access public * @return Photo[] */ public function getPhotos() { $sort = $this->photoSortSqlForOption($this->sort); $conditions = array(); $binds = array(); foreach (preg_split('/\\s+/', $this->query) as $i => $queryPart) { $conditions[$i] = "(description LIKE :{$i} OR keywords LIKE :{$i})"; $binds[$i] = '%' . $queryPart . '%'; } if (!$this->showPrivatePhotos) { $conditions[] = 'status = 0'; } $query = Database::Select('photos', 'id', implode(' AND ', $conditions), 'ORDER BY ' . $sort . ' ' . 'LIMIT ' . $this->offset . ',' . $this->pageSize, 'LEFT JOIN exif ON photos.id=exif.photoid and exif.tag="Date taken"', $binds); $photos = array(); while ($row = $query->fetchAssoc()) { $photos[] = Photo::getPhotoWithID($row['id']); } return $photos; }
/** * Factory for the associated object * * @access public * @return mixed */ public function getObject() { if ($this->record['record_type'] == 'photo') { return Photo::getPhotoWithID($this->record['record_id']); } if ($this->record['record_type'] == 'album') { return new Album($this->record['record_id']); } if ($this->record['record_type'] == 'preference') { return $cameralife; } $cameralife->Error("Unknown receipt type: " . $this->record['record_type']); return false; }