protected function getPhotos() { // load the photos uploaded in the last day $date = new SwatDate(); $date->subtractDays(1); $date->toUTC(); $instance_id = $this->app->getInstance() === null ? null : $this->app->getInstanceId(); $sql = sprintf('select PinholePhoto.* from PinholePhoto inner join ImageSet on PinholePhoto.image_set = ImageSet.id where ImageSet.instance %s %s and PinholePhoto.dav_upload = %s and PinholePhoto.upload_date > %s order by original_filename asc', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->app->db->quote(true, 'boolean'), $this->app->db->quote($date->getDate(), 'date')); $photos = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('PinholeSimplePhotoWrapper')); return $photos; }
/** * Gets the previous tag before this tag * * @return PinholeDateTag the previous tag before this tag or null if there * is no previous tag. */ public function prev() { $returned_tag = null; switch ($this->name) { case 'date': $date = new SwatDate($this->value); $date->subtractDays(1); $value = $date->formatLikeIntl('yyyy-MM-dd'); break; case 'week': if (ctype_digit($this->value)) { $value = $this->value > 1 ? $this->value - 1 : null; } else { // beginning of previous week $start_date = new SwatDate($this->value); $start_date->subtractDays(7 + $start_date->getDayOfWeek()); $value = $start_date->formatLikeIntl('yyyy-MM-dd'); } break; case 'year': $value = $this->value > 0 ? $this->value - 1 : null; break; case 'month': $value = $this->value > 1 ? $this->value - 1 : null; break; case 'day': $value = $this->value > 1 ? $this->value - 1 : null; break; default: $value = null; break; } if ($value !== null) { $string = sprintf('%s.%s=%s', self::NS, $this->name, $value); $tag = new PinholeDateTag(); if ($tag->parse($string, $this->db, $this->instance) !== false) { $returned_tag = $tag; } } return $returned_tag; }