/**
  * RSS feed
  *
  * @Route("/blog/rss", name="blog_rss")
  *
  * @return Response
  */
 public function rssAction()
 {
     $feed = new \Zend\Feed\Writer\Feed();
     $config = $this->container->getParameter('stfalcon_blog.config');
     $feed->setTitle($config['rss']['title']);
     $feed->setDescription($config['rss']['description']);
     $feed->setLink($this->generateUrl('blog_rss', array(), true));
     $posts = $this->get('doctrine')->getEntityManager()->getRepository("StfalconBlogBundle:Post")->getAllPosts();
     foreach ($posts as $post) {
         $entry = new \Zend\Feed\Writer\Entry();
         $entry->setTitle($post->getTitle());
         $entry->setLink($this->generateUrl('blog_post_view', array('slug' => $post->getSlug()), true));
         $feed->addEntry($entry);
     }
     return new Response($feed->export('rss'));
 }
Example #2
0
 /**
  * RSS news feed
  *
  * @Route("/rss", name="rss")
  * @return Response
  */
 public function rssAction()
 {
     $feed = new \Zend\Feed\Writer\Feed();
     $feed->setTitle($this->container->getParameter('rss.title'));
     $feed->setDescription($this->container->getParameter('rss.description'));
     $feed->setLink($this->generateUrl('rss', array(), true));
     $news = $this->_getNews();
     foreach ($news as $one_news) {
         // create entry and set fields
         $entry = new \Zend\Feed\Writer\Entry();
         $entry->setTitle($one_news->getTitle());
         $entry->setDescription($one_news->getPreview());
         $entry->setLink($this->generateUrl('news_show', array('slug' => $one_news->getSlug()), true));
         // add it to feed
         $feed->addEntry($entry);
     }
     // return rss 2.0 xml
     return new Response($feed->export('rss'));
 }
Example #3
0
 /**
  * RSS news feed
  *
  * @Route("/rss", name="rss")
  * @return Response
  */
 public function rssAction()
 {
     $feed = new \Zend\Feed\Writer\Feed();
     // @todo text to config
     $feed->setTitle('Frameworks Days');
     $feed->setDescription('Новости событий, которые проходят под эгидой Frameworks Days');
     $feed->setLink($this->generateUrl('rss', array(), true));
     $news = $this->_getNews();
     foreach ($news as $one_news) {
         // create entry and set fields
         $entry = new \Zend\Feed\Writer\Entry();
         $entry->setTitle($one_news->getTitle());
         $entry->setDescription($one_news->getPreview());
         $entry->setLink($this->generateUrl('news_show', array('slug' => $one_news->getSlug()), true));
         // add it to feed
         $feed->addEntry($entry);
     }
     // return rss 2.0 xml
     return new Response($feed->export('rss'));
 }
Example #4
0
 public function getOutput($request = null)
 {
     $pl = $this->getPageListObject();
     if ($this->cParentID) {
         $parent = Page::getByID($this->cParentID);
         $link = $parent->getCollectionLink();
     }
     $pagination = $pl->getPagination();
     if ($pagination->getTotalResults() > 0) {
         $writer = new \Zend\Feed\Writer\Feed();
         $writer->setTitle($this->getTitle());
         $writer->setDescription($this->getDescription());
         $writer->setLink((string) $link);
         foreach ($pagination->getCurrentPageResults() as $p) {
             $entry = $writer->createEntry();
             $entry->setTitle($p->getCollectionName());
             $entry->setDateCreated(strtotime($p->getCollectionDatePublic()));
             $content = $this->getPageFeedContent($p);
             if (!$content) {
                 $content = t('No Content.');
             }
             $entry->setDescription($content);
             $entry->setLink((string) $p->getCollectionLink(true));
             $writer->addEntry($entry);
         }
         $ev = new FeedEvent($parent);
         $ev->setFeedObject($this);
         $ev->setWriterObject($writer);
         $ev->setRequest($request);
         $ev = \Events::dispatch('on_page_feed_output', $ev);
         $writer = $ev->getWriterObject();
         return $writer->export('rss');
     }
 }
Example #5
0
/**
 * Get an episode
 */
$app->get('/episode/:episodeSlug', function ($episodeSlug) use($app) {
    $episode = $app->episodeLister->getEpisode($episodeSlug);
    if (is_null($episode)) {
        $app->notFound();
    } else {
        $app->render('episode.twig', ['episode' => $episode]);
    }
});
$app->get('/rss', function () use($app) {
    /**
     * Create the parent feed
     */
    $feed = new Zend\Feed\Writer\Feed();
    $feed->setTitle('Paddy\'s Blog');
    $feed->setLink('http://www.freethegeek.fm');
    $feed->setFeedLink('http://www.freethegeek.com/feed/rss', 'rss');
    $feed->addAuthor(array('name' => 'Matthew Setter', 'email' => '*****@*****.**', 'uri' => 'http://www.freethegeek.fm'));
    $feed->setDateModified(time());
    $feed->setDescription("Here's a description");
    /**
     * Add one or more entries. Note that entries must
     * be manually added once created.
     */
    $entry = $feed->createEntry();
    $entry->setTitle('All Your Base Are Belong To Us');
    $entry->setLink('http://www.example.com/all-your-base-are-belong-to-us');
    $entry->addAuthor(array('name' => 'Paddy', 'email' => '*****@*****.**', 'uri' => 'http://www.example.com'));
    $entry->setDateModified(time());
Example #6
0
 public function feedAction()
 {
     $this->doNotRender();
     if ($this->hasParam('id')) {
         $id = (int) $this->getParam('id');
         $record = Podcast::find($id);
         if (!$record instanceof Podcast) {
             throw new \DF\Exception\DisplayOnly('Show record not found!');
         }
         $feed_title = $record->name;
         $feed_desc = $record->description ? $record->description : 'A Ponyville Live! Show.';
         $cache_name = 'podcasts_' . $id . '_feed';
         $q = $this->em->createQuery('SELECT pe, p FROM Entity\\PodcastEpisode pe JOIN pe.podcast p WHERE p.is_approved = 1 AND p.id = :id ORDER BY pe.timestamp DESC')->setParameter('id', $id);
     } else {
         $feed_title = 'Ponyville Live! Shows';
         $feed_desc = 'The partner shows of the Ponyville Live! network, including commentary, interviews, episode reviews, convention coverage, and more.';
         $cache_name = 'podcasts_all_feed';
         $q = $this->em->createQuery('SELECT pe, p FROM Entity\\PodcastEpisode pe JOIN pe.podcast p WHERE p.is_approved = 1 AND pe.timestamp >= :threshold ORDER BY pe.timestamp DESC')->setParameter('threshold', strtotime('-3 months'));
     }
     $rss = \DF\Cache::get($cache_name);
     if (!$rss) {
         $records = $q->getArrayResult();
         // Initial RSS feed setup.
         $feed = new \Zend\Feed\Writer\Feed();
         $feed->setTitle($feed_title);
         $feed->setLink('http://ponyvillelive.com/');
         $feed->setDescription($feed_desc);
         $feed->addAuthor(array('name' => 'Ponyville Live!', 'email' => '*****@*****.**', 'uri' => 'http://ponyvillelive.com'));
         $feed->setDateModified(time());
         foreach ((array) $records as $episode) {
             try {
                 $podcast = $episode['podcast'];
                 $title = $episode['title'];
                 // Check for podcast name preceding episode name.
                 if (substr($title, 0, strlen($podcast['name'])) == $podcast['name']) {
                     $title = substr($title, strlen($podcast['name']));
                 }
                 $title = trim($title, " :-\t\n\r\v");
                 $title = $podcast['name'] . ' - ' . $title;
                 // Create record.
                 $entry = $feed->createEntry();
                 $entry->setTitle($title);
                 $entry->setLink($episode['web_url']);
                 $entry->addAuthor(array('name' => $podcast['name'], 'uri' => $podcast['web_url']));
                 $entry->setDateModified($episode['timestamp']);
                 $entry->setDateCreated($episode['timestamp']);
                 if ($podcast['description']) {
                     $entry->setDescription($podcast['description']);
                 }
                 if ($episode['body']) {
                     $entry->setContent($episode['body']);
                 }
                 $feed->addEntry($entry);
             } catch (\Exception $e) {
             }
         }
         // Export feed.
         $rss = $feed->export('rss');
         \DF\Cache::set($rss, $cache_name, array(), 60 * 15);
     }
     header("Content-Type: application/rss+xml");
     echo $rss;
 }
Example #7
0
 public function getOutput()
 {
     $pl = $this->getPageListObject();
     $link = BASE_URL;
     if ($this->cParentID) {
         $parent = Page::getByID($this->cParentID);
         $link = $parent->getCollectionLink(true);
     }
     $pagination = $pl->getPagination();
     if ($pagination->getTotalResults() > 0) {
         $writer = new \Zend\Feed\Writer\Feed();
         $writer->setTitle($this->getTitle());
         $writer->setDescription($this->getDescription());
         $writer->setLink($link);
         foreach ($pagination->getCurrentPageResults() as $p) {
             $entry = $writer->createEntry();
             $entry->setTitle($p->getCollectionName());
             $entry->setDateCreated(strtotime($p->getCollectionDatePublic()));
             $content = $this->getPageFeedContent($p);
             if (!$content) {
                 $content = t('No Content.');
             }
             $entry->setDescription($content);
             $entry->setLink($p->getCollectionLink(true));
             $writer->addEntry($entry);
         }
         return $writer->export('rss');
     }
 }
Example #8
0
 /**
  * Support method to turn a record driver object into an RSS entry.
  *
  * @param Zend\Feed\Writer\Feed             $feed   Feed to update
  * @param \VuFind\RecordDriver\AbstractBase $record Record to add to feed
  *
  * @return void
  */
 protected function addEntry($feed, $record)
 {
     $entry = $feed->createEntry();
     $title = $record->tryMethod('getTitle');
     $title = empty($title) ? $record->getBreadcrumb() : $title;
     $entry->setTitle(empty($title) ? $this->translate('Title not available') : $title);
     $serverUrl = $this->getView()->plugin('serverurl');
     $recordLink = $this->getView()->plugin('recordlink');
     try {
         $url = $serverUrl($recordLink->getUrl($record));
     } catch (\Zend\Mvc\Router\Exception\RuntimeException $e) {
         // No route defined? See if we can get a URL out of the driver.
         // Useful for web results, among other things.
         $url = $record->tryMethod('getUrl');
         if (empty($url) || !is_string($url)) {
             throw new \Exception('Cannot find URL for record.');
         }
     }
     $entry->setLink($url);
     if ($this->list) {
         if (method_exists($record, 'getListSavedDate')) {
             $saved = $record->getListSavedDate($this->list->id, $this->list->user_id);
             if ($saved) {
                 $entry->setDateModified(new \DateTime($saved));
             }
         }
     } else {
         $date = $this->getDateModified($record);
         if (!empty($date)) {
             $entry->setDateModified($date);
         }
     }
     $formats = $record->tryMethod('getFormats');
     if (is_array($formats)) {
         // Take only the most specific format and get rid of level indicator
         // and trailing slash
         $format = end($formats);
         $format = implode('/', array_slice(explode('/', $format), 1, -1));
         $entry->addDCFormat($format);
     }
     $dcDate = $this->getDcDate($record);
     if (!empty($dcDate)) {
         $entry->setDCDate($dcDate);
     }
     $urlHelper = $this->getView()->plugin('url');
     $recordHelper = $this->getView()->plugin('record');
     $recordImage = $this->getView()->plugin('recordImage');
     $imageUrl = $recordImage($recordHelper($record))->getLargeImage();
     $entry->setEnclosure(['uri' => $serverUrl($imageUrl), 'type' => 'image/jpeg', 'length' => 1]);
     $entry->setCommentCount(count($record->getComments()));
     $summaries = [];
     if (isset($this->list)) {
         $summaries = $record->getListNotes($this->list->id);
     }
     if (empty($summaries)) {
         $summaries = array_filter($record->tryMethod('getSummary'));
     }
     if (!empty($summaries)) {
         $entry->setDescription(implode(' -- ', $summaries));
     }
     $feed->addEntry($entry);
 }
Example #9
0
 public function getFeed($mode)
 {
     $feedMethod = 'rss';
     if ($mode == self::RSS) {
         $feedMethod = 'rss';
     } elseif ($mode == self::ATOM) {
         $feedMethod = 'atom';
     }
     $feed = new \Zend\Feed\Writer\Feed();
     $feed->setTitle(Yii::t('app', 'Introduce business'));
     $feed->setDescription(Yii::t('app', 'Introduce business'));
     $feed->setLink(Yii::$app->getRequest()->getHostInfo());
     $feed->setFeedLink(Yii::$app->getRequest()->getAbsoluteUrl(), $feedMethod);
     $feed->setGenerator('Admap', Yii::$app->version, Yii::$app->getRequest()->getHostInfo());
     $feed->addAuthor(['name' => 'Jafaripur', 'email' => '*****@*****.**', 'uri' => 'http://www.jafaripur.ir']);
     $feed->setDateModified(time());
     //$feed->addHub('http://pubsubhubbub.appspot.com/');
     foreach ($this->getModel(50) as $adver) {
         $entry = $feed->createEntry();
         $entry->setId($adver['id']);
         $entry->setTitle(Html::encode($adver['title']));
         $entry->addCategory(['term' => Html::encode($adver['category']['name']), 'label' => Html::encode($adver['category']['name'])]);
         $entry->setLink(urldecode(Adver::generateLink($adver['id'], $adver['title'], $adver['category']['name'], $adver['country']['name'], $adver['province']['name'], $adver['city']['name'], $adver['address'], $adver['lang'], true)));
         /*$entry->addAuthor(array(
         			'name'  => 'Paddy',
         			'email' => '*****@*****.**',
         			'uri'   => 'http://www.example.com',
         		));*/
         $entry->setDateModified((int) $adver['updated_at']);
         $entry->setDateCreated((int) $adver['created_at']);
         $entry->setDescription(\yii\helpers\StringHelper::truncate(strip_tags($adver['description']), 140));
         //$entry->setContent ($description);
         $feed->addEntry($entry);
     }
     return $feed->export($feedMethod);
 }
Example #10
0
 function generate_feed_from_data($data, $feed_descriptor)
 {
     require_once 'lib/smarty_tiki/modifier.sefurl.php';
     $tikilib = TikiLib::lib('tiki');
     $writer = new Zend\Feed\Writer\Feed();
     $writer->setTitle($feed_descriptor['feedTitle']);
     $writer->setDescription($feed_descriptor['feedDescription']);
     $writer->setLink($tikilib->tikiUrl(''));
     $writer->setDateModified(time());
     foreach ($data as $row) {
         $titleKey = $feed_descriptor['entryTitleKey'];
         $url = $row[$feed_descriptor['entryUrlKey']];
         $title = $row[$titleKey];
         if (isset($feed_descriptor['entryObjectDescriptors'])) {
             list($typeKey, $objectKey) = $feed_descriptor['entryObjectDescriptors'];
             $object = $row[$objectKey];
             $type = $row[$typeKey];
             if (empty($url)) {
                 $url = smarty_modifier_sefurl($object, $type);
             }
             if (empty($title)) {
                 $title = TikiLib::lib('object')->get_title($type, $object);
             }
         }
         $entry = $writer->createEntry();
         $entry->setTitle($title ? $title : tra('Unspecified'));
         $entry->setLink($tikilib->tikiUrl($url));
         $entry->setDateModified($row[$feed_descriptor['entryModificationKey']]);
         $writer->addEntry($entry);
     }
     return $writer;
 }