public function executeFeed(sfWebRequest $request)
 {
     $format = $request->getParameter('format');
     if ($format === 'atom') {
         $format = 'atom1';
     } elseif ($format === 'rss') {
         $format = 'rss201';
     }
     $feed = sfFeedPeer::newInstance($format);
     $feed->setTitle(sfConfig::get('app_rt_blog_title', 'Latest News'));
     $feed->setLink('http://' . rtSiteToolkit::getCurrentDomain());
     $feed->setAuthorEmail(sfConfig::get('app_rt_blog_author_email'));
     $feed->setAuthorName(sfConfig::get('app_rt_blog_author_name', 'News Editor'));
     //    $feedImage = new sfFeedImage();
     //    $feedImage->setFavicon('http://'.rtSiteToolkit::getCurrentDomain().'/favicon.ico');
     //    $feed->setImage($feedImage);
     $query = Doctrine::getTable('rtBlogPage')->addPublishedQuery();
     $query->limit(20)->orderBy('page.id DESC');
     $posts = $query->execute();
     foreach ($posts as $rt_blog_page) {
         $item = new sfFeedItem();
         $item->setTitle($rt_blog_page->getTitle());
         $item->setLink($this->generateUrl('rt_blog_page_show', $rt_blog_page, array('absolute' => true)));
         $item->setAuthorName($rt_blog_page->getAuthorName());
         $item->setAuthorEmail($rt_blog_page->getAuthorEmail());
         $item->setPubdate(strtotime($rt_blog_page->getCreatedAt()));
         $item->setUniqueId($rt_blog_page->getSlug());
         $item->setDescription($rt_blog_page->getDescription());
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Exemplo n.º 2
0
 private function getFeed($format = 'atom1')
 {
     $feed = sfFeedPeer::newInstance($format);
     $feed->setTitle('PluginsKit - Latest');
     $feed->setLink('@homepage');
     $feedImage = new sfFeedImage();
     $feedImage->setLink('@homepage');
     $feed->setImage($feedImage);
     return $feed;
 }
 public function run(sfEvent $event)
 {
     if (isset($event['pager'])) {
         $pager = $event['pager'];
         $context = sfContext::getInstance();
         $response = $context->getResponse();
         $request = $context->getRequest();
         $className = 'sf' . ucfirst($event['format']) . 'Feed';
         if (!class_exists($className)) {
             return false;
         }
         $feed = sfFeedPeer::newInstance($event['format']);
         $feed->initialize(array('title' => $response->getTitle(), 'link' => $request->getUri()));
         $items = sfFeedPeer::convertObjectsToItems($pager->getResults());
         $feed->addItems($items);
         $event->setProcessed(true);
         $event->setReturnValue($feed->asXml());
         $request->setRequestFormat($event['format']);
         return true;
     } else {
         return false;
     }
 }