/** Display the index page of comments.
  * @todo this sucks
  * @access public
  * @return void
  */
 public function indexAction()
 {
     $comments = $this->getComments()->getCommentsToFinds($this->getParam('page'));
     $context = $this->_helper->contextSwitch()->getCurrentContext();
     if (in_array($context, array('rss', 'atom'))) {
         $feed = new Zend_Feed_Writer_Feed();
         $feed->setTitle('All published comments on finds records');
         $feed->setLink($this->view->serverUrl());
         $feed->setFeedLink($this->view->CurUrl(), $context);
         $feed->addAuthor(array('name' => 'The Portable Antiquities Scheme', 'email' => '*****@*****.**', 'uri' => $this->view->serverUrl()));
         $feed->setDateModified(time());
         $feed->addHub('http://pubsubhubbub.appspot.com/');
         $feed->setDescription('This feed contains all published comments on the Scheme\'s database');
         /**
          * Add one or more entries. Note that entries must
          * be manually added once created.
          */
         foreach ($comments as $comment) {
             $entry = $feed->createEntry();
             $entry->setTitle('Comment entered on ' . $comment['old_findID']);
             $entry->setLink($this->view->serverUrl() . '/database/artefacts/record/id/' . $comment['id'] . '#comm');
             $entry->addAuthor(array('name' => $comment['comment_author'], 'email' => null, 'uri' => $comment['comment_author_url']));
             $entry->setDateModified(time());
             $entry->setDateCreated(time());
             $entry->setDescription('Comment regarding ' . $comment['old_findID']);
             $entry->setContent(strip_tags($comment['comment_content']));
             $feed->addEntry($entry);
         }
         $out = $feed->export($context);
         echo $out;
         $this->getResponse()->setHeader('Content-type', $context . '+xml');
     } else {
         $this->view->comments = $comments;
     }
 }
Esempio n. 2
0
 /**
  * Create a RSS file with the CMS pages and Products
  */
 public function indexAction()
 {
     $out = "";
     try {
         $ISP = Shineisp_Registry::get('ISP');
         $ns = new Zend_Session_Namespace();
         $localeID = $ns->idlang;
         $locale = $ns->lang;
         $feed = new Zend_Feed_Writer_Feed();
         $feed->setTitle($ISP->company);
         $feed->setLink($ISP->website);
         $feed->setFeedLink('http://' . $_SERVER['HTTP_HOST'] . '/rss', 'atom');
         $feed->addAuthor(array('name' => $ISP->company, 'email' => $ISP->email, 'uri' => $ISP->website));
         $feed->setEncoding('UTF8');
         $feed->setDateModified(time());
         $feed->addHub($ISP->website);
         // Get all the cms pages
         $records = CmsPages::getRssPages($locale);
         foreach ($records as $record) {
             $link = 'http://' . $_SERVER['HTTP_HOST'] . '/cms/' . $record['var'] . '.html';
             self::createEntry($feed, $record['title'], $record['body'], $link);
         }
         // Get all the products
         $records = Products::getAllHighlighted($localeID);
         foreach ($records as $record) {
             $title = $record['ProductsData'][0]['name'];
             $descritption = strip_tags($record['ProductsData'][0]['shortdescription']);
             $inserted_at = !empty($record['inserted_at']) ? strtotime($record['inserted_at']) : null;
             $updated_at = !empty($record['updated_at']) ? strtotime($record['updated_at']) : null;
             $link = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $record['uri'] . '.html';
             self::createEntry($feed, $title, $descritption, $link, $inserted_at, $updated_at);
         }
         /**
          * 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.
          */
         $out = $feed->export('atom');
     } catch (Zend_Feed_Exception $e) {
         die($e->getMessage());
     }
     die($out);
 }
Esempio n. 3
0
 public function feedAction()
 {
     $data = $this->_request->getParams();
     $this->prefix = "Default_";
     $config = $this->config;
     $this->setupCache('default');
     //$this->totpl('theInclude','list');
     if ($data['lib']) {
         $feedtype = $data['type'];
         if (!($out = $this->loadCache('feed_' . $data['lib'] . "_" . $feedtype))) {
             //we have a lib... now get the content for this lib
             $type = $this->getContentTypeByLib($data['lib']);
             //some admins think it is a good thing to add more than one content type for each lib ;S
             if ($type['title']) {
                 $content = $this->getRecent($type['title'], 10);
             } else {
                 foreach ($type as $o => $s) {
                     $content[] = $this->getRecent($s['title'], 5);
                 }
             }
             //get recent items
             if (count($content) > 0) {
                 $feed = new Zend_Feed_Writer_Feed();
                 $feed->setTitle($config->site->frontend_title . " " . $data['lib'] . " feed");
                 $feed->setLink($this->http_location);
                 $feed->setCopyright($this->t($config->site->feed_copyright));
                 $feed->setGenerator($config->site->feed_generator);
                 $feed->setFeedLink($this->http_location . "/" . $data['lib'], 'atom');
                 $feed->setFeedLink($this->http_location . "/" . $data['lib'] . "?type=rss", 'rss');
                 $feed->addAuthor(array('name' => $config->site->feed_author_name, 'email' => $config->site->feed_author_email, 'uri' => $this->http_location));
                 $feed->setImage(array('uri' => $config->site->feed_logo_image));
                 $feed->setDateModified(time());
                 $feed->addHub('http://pubsubhubbub.appspot.com/');
                 //now we need to loop
                 foreach ($content as $k => $v) {
                     if ($v['title']) {
                         $entry = $feed->createEntry();
                         $entry->setTitle($v['title']);
                         $entry->setLink($this->http_location . "/" . $data['lib'] . "/" . $v['slug']);
                         $entry->setDateCreated($v['datestr']);
                         $entry->setDateModified(time());
                         if ($v['content']) {
                             $entry->setDescription(strip_tags(stripslashes(substr($v['content'], 0, 160))));
                         }
                         $feed->addEntry($entry);
                     } else {
                         foreach ($v as $r) {
                             $entry = $feed->createEntry();
                             $entry->setTitle($r['title']);
                             $entry->setLink($this->http_location . "/" . $data['lib'] . "/" . $r['slug']);
                             $entry->setDateCreated($r['datestr']);
                             $entry->setDateModified(time());
                             if ($r['content']) {
                                 $entry->setDescription(strip_tags(stripslashes(substr($r['content'], 0, 160))));
                             }
                             $feed->addEntry($entry);
                         }
                     }
                 }
                 $out = $feed->export($feedtype);
             }
             $this->cacheData($out, 'feed_' . $data['lib'] . "_" . $feedtype);
         }
         header("Content-type: text/xml");
         echo $out;
         die;
     }
 }
Esempio n. 4
0
 public function testAddingHubUrlThrowsExceptionOnInvalidUri()
 {
     $writer = new Zend_Feed_Writer_Feed();
     try {
         $writer->addHub('http://');
         $this->fail();
     } catch (Zend_Feed_Exception $e) {
     }
 }
Esempio n. 5
0
 /**
  * Generate our Feed
  */
 protected function getFeed($type = null)
 {
     # Prepare
     $App = $this->getHelper('App');
     $Identity = $App->getUser();
     # --------------------------
     # Fetch Content
     # Search
     $search = $App->fetchSearch();
     $searchQuery = delve($search, 'query');
     # Prepare Criteria
     $criteria = array('recent' => true, 'fetch' => 'list', 'status' => 'published', 'Identity' => $Identity, 'hydrationMode' => Doctrine::HYDRATE_ARRAY);
     # Criteria: SearchQuery
     if ($searchQuery) {
         $criteria['search'] = $searchQuery;
     }
     # Fetch
     $Contents = $App->fetchRecords('Content', $criteria);
     # --------------------------
     # Generate Feed
     # Pepare Feed
     $feed = array('title' => $App->getConfig('site.title'), 'link' => $App->getBaseUrl(true), 'author' => $App->getConfig('site.author'), 'dateModified' => empty($Content[0]) ? time() : strtotime($Content->updated_at), 'description' => $App->getConfig('site.description', 'News Feed for ' . $App->getConfig('site.title')), 'categories' => prepare_csv_array($App->getConfig('site.keywords')));
     # Create Feed
     $Feed = new Zend_Feed_Writer_Feed();
     $Feed->setTitle($feed['title']);
     $Feed->setLink($feed['link']);
     $Feed->setDateModified($feed['dateModified']);
     $Feed->setDescription($feed['description']);
     $Feed->addAuthor($feed['author']['title'], $feed['author']['email'], $feed['author']['url']);
     $Feed->addHub('http://pubsubhubbub.appspot.com/');
     # Apply Categories
     $categories = array();
     foreach ($feed['categories'] as $tag) {
         $categories[] = array('term' => str_replace(' ', '-', $tag), 'label' => $tag);
     }
     $Feed->addCategories($categories);
     # Content Map
     $contentMap = array('title' => 'title', 'url' => 'link', 'updated_at' => 'dateModified', 'created_at' => 'dateCreated', 'description_rendered' => 'description', 'content_rendered' => 'content');
     # Apply Content
     foreach ($Contents as $Content) {
         # Create Entry
         $Entry = $Feed->createEntry();
         # Prepare Content
         $Content['url'] = $App->getUrl()->content($Content)->full()->toString();
         $Content['updated_at'] = strtotime($Content['updated_at']);
         $Content['created_at'] = strtotime($Content['created_at']);
         # Apply Content
         foreach ($contentMap as $from => $to) {
             $method = 'set' . ucfirst($to);
             $value = delve($Content, $from);
             $Entry->{$method}($value);
         }
         # Apply Author
         if (empty($Content['Author']['website'])) {
             $Content['Author']['website'] = $App->getUrl()->user($Content['Author'])->full()->toString();
         }
         $Entry->addAuthor($Content['Author']['displayname'], $Content['Author']['email'], $Content['Author']['website']);
         # Apply Categories
         $categories = array();
         foreach ($Content['ContentTags'] as $Tag) {
             $categories[] = array('term' => str_replace(' ', '-', $Tag['name']), 'label' => $Tag['name']);
         }
         $Entry->addCategories($categories);
         # Add Entry
         $Feed->addEntry($Entry);
     }
     # --------------------------
     # Done
     # Return Feed
     return $Feed;
 }