protected function buildPost(XML_Atom_Feed $feed, BlorgPost $post) { $site_base_href = $this->app->getBaseHref(); $blorg_base_href = $site_base_href . $this->app->config->blorg->path; $path = $blorg_base_href . 'archive'; $date = clone $post->publish_date; $date->convertTZ($this->app->default_time_zone); $year = $date->getYear(); $month_name = BlorgPageFactory::$month_names[$date->getMonth()]; $post_uri = sprintf('%s/%s/%s/%s', $path, $year, $month_name, $post->shortname); $entry = new XML_Atom_Entry($post_uri, $post->getTitle(), $post->publish_date); if ($post->extended_bodytext != '') { $full_bodytext = $post->bodytext . $post->extended_bodytext; $entry->setSummary($post->bodytext, 'html'); $entry->setContent($full_bodytext, 'html'); } else { $entry->setContent($post->bodytext, 'html'); } foreach ($post->getTags() as $tag) { $entry->addCategory($tag->shortname, $blorg_base_href, $tag->title); } $entry->addLink($post_uri, 'alternate', 'text/html'); foreach ($post->getVisibleFiles() as $file) { $link = new XML_Atom_Link($site_base_href . $file->getRelativeUri($this->app->config->blorg->path), 'enclosure', $file->mime_type); $link->setTitle($file->getDescription()); $link->setLength($file->filesize); $entry->addLink($link); } if ($post->author->visible) { $author_uri = $blorg_base_href . 'author/' . $post->author->shortname; } else { $author_uri = ''; } $entry->addAuthor($post->author->name, $author_uri, $post->author->email); $visible_comment_count = $post->getVisibleCommentCount(); if ($post->comment_status == SiteCommentStatus::OPEN || $post->comment_status == SiteCommentStatus::MODERATED || $post->comment_status == SiteCommentStatus::LOCKED && $visible_comment_count > 0) { $entry->addLink($post_uri . '#comments', 'comments', 'text/html'); } $feed->addEntry($entry); }
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; }