protected function initDimension($shortname = null) { if ($shortname === null) { if (isset($this->app->cookie->display_dimension)) { $shortname = $this->app->cookie->display_dimension; } else { $shortname = $this->default_dimension; } } $class_name = SwatDBClassMap::get('PinholeImageDimension'); $display_dimension = new $class_name(); $display_dimension->setDatabase($this->app->db); $found = $display_dimension->loadByShortname('photos', $shortname); if ($found && !$display_dimension->selectable) { throw new SiteNotFoundException(sprintf('Dimension “%s” is not ' . 'a selectable photo dimension', $shortname)); } $dimension = $this->photo->getClosestSelectableDimensionTo($shortname); $this->app->cookie->setCookie('display_dimension', $dimension->shortname, strtotime('+1 year'), '/', $this->app->getBaseHref()); return $dimension; }
protected function getEntry(PinholePhoto $photo) { $cache_key = sprintf('PinholeAtomPage.entry.%s.%s.%s.%s', (string) $this->tag_list, $photo->id, $this->dimension->shortname, $this->app->session->isLoggedIn() ? 'private' : 'public'); $entry = $this->app->getCacheValue($cache_key, 'photos'); if ($entry !== false) { return $entry; } $uri = sprintf('%sphoto/%s/%s', $this->getPinholeBaseHref(), $photo->id, $this->dimension->shortname); if (count($this->tag_list) > 0) { $uri .= '?' . $this->tag_list->__toString(); } $entry = new XML_Atom_Entry($uri, $photo->getTitle(), $photo->publish_date); $this->app->addCacheValue($entry, $cache_key, 'photos'); if ($photo->hasDimension($this->dimension->shortname)) { $dimension = $this->dimension; } else { $dimension = $photo->getClosestSelectableDimensionTo($this->dimension->shortname); } $entry->setContent($this->getPhotoContent($photo, $dimension), 'html'); foreach ($photo->tags as $tag) { $entry->addCategory($tag->name, '', $tag->title); } //$entry->addAuthor($author_name, $author_uri, $author_email); $entry->addAuthor($this->app->config->site->title); $uri = sprintf('%sphoto/%s', $this->getPinholeBaseHref(), $photo->id); $entry->addLink($uri, 'alternate', 'text/html'); // add enclosure $photo_uri = $photo->getUri($dimension->shortname); $link = new XML_Atom_Link($this->app->getBaseHref() . $photo_uri, 'enclosure', $photo->getMimeType($dimension->shortname)); $link->setTitle($photo->getTitle()); //$link->setLength(); $entry->addLink($link); return $entry; }