/**
  * RSS feed for recently added modules
  * @return FeedModel
  */
 public function feedAction()
 {
     // Prepare the feed
     $feed = new Feed();
     $feed->setTitle('ZF2 Modules');
     $feed->setDescription('Recently added modules.');
     $feed->setFeedLink('http://modules.zendframework.com/feed', 'atom');
     $feed->setLink('http://modules.zendframework.com');
     // Get the recent modules
     $page = 1;
     $mapper = $this->getServiceLocator()->get('zfmodule_mapper_module');
     $repositories = $mapper->pagination($page, self::MODULES_PER_PAGE, null, 'created_at', 'DESC');
     // Load them into the feed
     foreach ($repositories as $module) {
         $entry = $feed->createEntry();
         $entry->setTitle($module->getName());
         if ($module->getDescription() == '') {
             $moduleDescription = "No Description available";
         } else {
             $moduleDescription = $module->getDescription();
         }
         $entry->setDescription($moduleDescription);
         $entry->setLink($module->getUrl());
         $entry->setDateCreated(strtotime($module->getCreatedAt()));
         $feed->addEntry($entry);
     }
     // Render the feed
     $feedmodel = new FeedModel();
     $feedmodel->setFeed($feed);
     return $feedmodel;
 }
Пример #2
0
 public function feedAction()
 {
     /* @var \UthandoNews\Options\NewsOptions $options */
     $options = $this->getService('UthandoNewsOptions');
     /* @var \UthandoNews\Options\FeedOptions $feedOptions */
     $feedOptions = $this->getService('UthandoNewsFeedOptions');
     $newService = $this->getService();
     $newsItems = $newService->search(['sort' => $options->getSortOrder()]);
     $uri = $this->getRequest()->getUri();
     $base = sprintf('%s://%s', $uri->getScheme(), $uri->getHost());
     $feed = new Feed();
     $feed->setTitle($feedOptions->getTitle());
     $feed->setFeedLink($base . $this->url()->fromRoute('home'), 'atom');
     $feed->setDescription($feedOptions->getDescription());
     $feed->setLink($base . $this->url()->fromRoute('home'));
     $feed->setDateModified(time());
     /* @var \UthandoNews\Model\News $item */
     foreach ($newsItems as $item) {
         $entry = $feed->createEntry();
         $entry->addAuthor(['name' => $item->getArticle()->getUser()->getFullName()]);
         $entry->setTitle($item->getArticle()->getTitle());
         $entry->setLink($base . $this->url()->fromRoute('news', ['news-item' => $item->getArticle()->getSlug()]));
         $entry->setDescription($item->getArticle()->getDescription());
         $entry->setDateModified($item->getDateModified()->getTimestamp());
         $entry->setDateCreated($item->getArticle()->getDateCreated()->getTimestamp());
         $feed->addEntry($entry);
     }
     $feed->export('rss');
     $feedModel = new FeedModel();
     $feedModel->setFeed($feed);
     return $feedModel;
 }
 /**
  * @return FeedModel
  */
 public function rssAction()
 {
     $feed = new Feed();
     $feed->setTitle('Sample Blog');
     $feed->setFeedLink($this->getUrl() . '/news/rss', 'atom');
     $feed->addAuthor(array('name' => 'Sample Blog Inc.', 'email' => 'contact@' . $this->getRequest()->getUri()->getHost(), 'uri' => $this->getUrl()));
     $feed->setDescription('Description of this feed');
     $feed->setLink($this->getUrl());
     $feed->setDateModified(time());
     $news = $this->getNewsTable()->top();
     foreach ($news as $row) {
         $entry = $feed->createEntry();
         $entry->setTitle($row->title);
         $entry->setLink($this->getUrl() . '/news/read/' . $row->news_id);
         $entry->setContent($row->text);
         $entry->setDescription($row->highlight);
         $entry->setDateModified(strtotime($row->updated_at));
         $entry->setDateCreated(strtotime($row->created_at));
         $feed->addEntry($entry);
     }
     $feed->export('rss');
     $feed_model = new FeedModel();
     $feed_model->setFeed($feed);
     return $feed_model;
 }
Пример #4
0
 public function testRendersFeedModelAccordingToTypeProvidedInModel()
 {
     $model = new FeedModel($this->getFeedData('atom'));
     $model->setOption('feed_type', 'atom');
     $xml = $this->renderer->render($model);
     $this->assertContains('<' . '?xml', $xml);
     $this->assertContains('atom', $xml);
 }
 /**
  * RSS feed for recently added modules
  * @return FeedModel
  */
 public function feedAction()
 {
     $url = $this->plugin('url');
     // Prepare the feed
     $feed = new Feed();
     $feed->setTitle('ZF2 Modules');
     $feed->setDescription('Recently added ZF2 modules');
     $feed->setFeedLink($url->fromRoute('feed', [], ['force_canonical' => true]), 'atom');
     $feed->setLink($url->fromRoute('home', [], ['force_canonical' => true]));
     // Get the recent modules
     $page = 1;
     $modules = $this->moduleMapper->pagination($page, self::MODULES_PER_PAGE, null, 'created_at', 'DESC');
     // Load them into the feed
     $mapper = new Mapper\ModuleToFeed($feed, $url);
     $mapper->addModules($modules);
     // Render the feed
     $feedmodel = new FeedModel();
     $feedmodel->setFeed($feed);
     return $feedmodel;
 }
Пример #6
0
 public function feedAction()
 {
     $blogDao = $this->getServiceLocator()->get('dao_blog_blog');
     $blogList = $blogDao->getBlogListForFeed();
     $feed = new Feed();
     $feed->setTitle('Ginosi\'s Blog');
     $feed->setLink('//www.ginosi.com');
     $feed->setFeedLink('//www.ginosi.com/blog/feed', 'rss');
     $feed->setDateModified(time());
     $feed->addHub('//pubsubhubbub.appspot.com/');
     $feed->setDescription('Ginosi\'s Blog');
     foreach ($blogList as $row) {
         preg_match('/<p>(.*)<\\/p>/', $row->getContent(), $matches);
         if (isset($matches[1]) && !is_null($matches[1])) {
             $desc = $matches[1];
         } else {
             $contents = preg_split('/\\n/', $row->getContent());
             $desc = $contents[0];
         }
         $entry = $feed->createEntry();
         $entry->setTitle($row->getTitle());
         $entry->setLink("//" . DomainConstants::WS_DOMAIN_NAME . "/blog/" . Helper::urlForSite($row->getTitle()));
         $entry->setDateModified(strtotime($row->getDate()));
         $entry->setDateCreated(strtotime($row->getDate()));
         $entry->setDescription($desc);
         $entry->setContent($row->getContent());
         $feed->addEntry($entry);
     }
     /**
      * Render the resulting feed to Atom 1.0 and assign to $out.
      * You can substitute "atom" with "rss" to generate an RSS 2.0 feed.
      */
     $feed->export('rss');
     $feedmodel = new FeedModel();
     $feedmodel->setFeed($feed);
     $this->getServiceLocator()->get('Application')->getEventManager()->attach(\Zend\Mvc\MvcEvent::EVENT_RENDER, function ($event) {
         $event->getResponse()->getHeaders()->addHeaderLine('Content-Type', 'text/xml; charset=UTF-8');
     }, -10000);
     return $feedmodel;
 }
Пример #7
0
 public function indexAction()
 {
     $moduleConfig = $this->getServiceLocator()->get('config');
     $feedClassMap = $moduleConfig['feed_class_map'];
     $appServiceLoader = $this->recoverAppServiceLoader();
     $configurations = $appServiceLoader->recoverService('configurations');
     $input = array_merge($configurations, $appServiceLoader->getProperties());
     $resourceClassName = isset($feedClassMap[$this->params()->fromRoute('resource')]) ? $feedClassMap[$this->params()->fromRoute('resource')] : null;
     if (empty($resourceClassName) or !class_exists($resourceClassName)) {
         return $this->redirect()->toRoute('home', array('lang' => 'it'));
     }
     /**
      * @var \Feed\Model\FeedBuilderAbstract $resourceClassInstance
      */
     $resourceClassInstance = new $resourceClassName();
     $resourceClassInstance->setInput($input);
     $feed = new Feed();
     $feed->setTitle($resourceClassInstance->getTitle());
     $feed->setFeedLink($resourceClassInstance->getFeedLink(), $resourceClassInstance->getFeedType());
     // $feed->addAuthor($resourceClassInstance->getAuthor());
     $feed->setDescription($resourceClassInstance->getDescription());
     $feed->setLink($resourceClassInstance->getLink());
     $feed->setDateModified(time());
     $data = $resourceClassInstance->formatRecords($resourceClassInstance->recoverRecords());
     foreach ($data as $row) {
         $entry = $feed->createEntry();
         $entry->setTitle($row['title']);
         $entry->setLink($row['link']);
         $entry->setDescription($row['content']);
         $entry->setDateModified(strtotime($row['date_created']));
         $entry->setDateCreated(strtotime($row['date_modified']));
         $feed->addEntry($entry);
     }
     $feed->export('rss');
     $feedmodel = new FeedModel();
     $feedmodel->setFeed($feed);
     return $feedmodel;
 }
Пример #8
0
 /**
  * RSS feed of published blog posts
  *
  * @param void
  * @return FeedModel
  * @throws AccessProhibitedException
  **/
 public function rssAction()
 {
     $this->_checkAcl('rss');
     $feed = $this->_postService->getRssFeed();
     $feedModel = new FeedModel();
     $feedModel->setFeed($feed);
     return $feedModel;
 }
Пример #9
0
 /**
  * Handle rss page
  */
 public function rssAction()
 {
     // set page and max blog per page
     $page = 1;
     $maxPage = 10;
     // get blog entries
     $blogList = $this->getBlogService()->fetchList($page, $maxPage);
     // create feed
     $feed = new Feed();
     $feed->setTitle('Luigis Pizza-Blog');
     $feed->setFeedLink('http://luigis-pizza.local/blog/rss', 'atom');
     $feed->addAuthor(array('name' => 'Luigi Bartoli', 'email' => '*****@*****.**', 'uri' => 'http://luigis-pizza.local'));
     $feed->setDescription('Luigis Pizza-Blog Beiträge');
     $feed->setLink('http://luigis-pizza.local');
     $feed->setDateModified(time());
     // add blog entries
     foreach ($blogList as $blog) {
         $entry = $feed->createEntry();
         $entry->setTitle($blog->getTitle());
         $entry->setLink('http://luigis-pizza.local/blog/' . $blog->getUrl());
         $entry->setDescription($blog->getContent());
         $entry->setDateCreated(strtotime($blog->getCdate()));
         $feed->addEntry($entry);
     }
     // create feed model
     $feedmodel = new FeedModel();
     $feedmodel->setFeed($feed);
     return $feedmodel;
 }
Пример #10
0
 /**
  * RSS feed for all news
  *
  * Get all news from two months back in time
  *
  * @return array|FeedModel
  */
 public function rssNewsAction()
 {
     $sm = $this->getServiceLocator();
     $groupService = $sm->get('Stjornvisi\\Service\\Group');
     //ITEM FOUND
     //  item is in storage
     if (($group = $groupService->get($this->params()->fromRoute('name', 0))) != null) {
         $sm = $this->getServiceLocator();
         $newsService = $sm->get('Stjornvisi\\Service\\News');
         $from = new DateTime();
         $from->sub(new DateInterval('P2M'));
         $to = new DateTime();
         $to->add(new DateInterval('P2M'));
         $feed = new Feed();
         $feed->setTitle('Feed Example');
         $feed->setFeedLink('http://ourdomain.com/rss', 'atom');
         $feed->addAuthor(['name' => 'Stjórnvísi', 'email' => '*****@*****.**', 'uri' => 'http://stjornvisi.is']);
         $feed->setDescription('Fréttir');
         $feed->setLink('http://ourdomain.com');
         $feed->setDateModified(new DateTime());
         $data = [];
         foreach ($newsService->getRangeByGroup($group->id, $from, $to) as $row) {
             //create entry...
             $entry = $feed->createEntry();
             $entry->setTitle($row->title);
             $entry->setLink('http://stjornvisi.is/');
             $entry->setDescription($row->body . '.');
             $entry->setDateModified($row->created_date);
             $entry->setDateCreated($row->created_date);
             $feed->addEntry($entry);
         }
         $feed->export('rss');
         $feedmodel = new FeedModel();
         $feedmodel->setFeed($feed);
         return $feedmodel;
         //ITEM NOT FOUND
         //
     } else {
         return $this->notFoundAction();
     }
 }
Пример #11
0
 public function rssAction()
 {
     $feed = new Feed();
     $type = $this->params('type');
     $age = (int) $this->params('age');
     $maxAge = new DateTime($age . ' days ago');
     $entities = $this->getEntityManager()->findEntitiesByTypeName($type);
     $chain = new FilterChain();
     $chain->attach(new EntityAgeCollectionFilter($maxAge));
     $chain->attach(new NotTrashedCollectionFilter());
     $entities = $chain->filter($entities);
     $data = $this->normalize($entities);
     foreach ($data as $item) {
         try {
             $entry = $feed->createEntry();
             $entry->setTitle($item['title']);
             $entry->setDescription($item['description']);
             $entry->setId($item['guid']);
             $entry->setLink($item['link']);
             foreach ($item['categories'] as $keyword) {
                 $entry->addCategory(['term' => $keyword]);
             }
             $entry->setDateModified($item['lastModified']);
             $feed->addEntry($entry);
         } catch (\Exception $e) {
             // Invalid Item, do not add
         }
     }
     $feed->setTitle($this->brand()->getHeadTitle());
     $feed->setDescription($this->brand()->getDescription());
     $feed->setDateModified(time());
     $feed->setLink($this->url()->fromRoute('home', [], ['force_canonical' => true]));
     $feed->setFeedLink($this->url()->fromRoute('entity/api/rss', ['type' => $type, 'age' => $age], ['force_canonical' => true]), 'atom');
     $feed->export('atom');
     $feedModel = new FeedModel();
     $feedModel->setFeed($feed);
     return $feedModel;
 }