public function executeSearch() { $feed = new sfAtom1Feed(); $feed->setTitle('Hoydaa Snippets'); $feed->setLink('http://codesnippet.hoydaa.org'); $feed->setAuthorEmail('*****@*****.**'); $feed->setAuthorName('Hoydaa Snippets'); $querystring = $this->getRequestParameter('q'); $query = new sfLuceneCriteria($this->getLuceneInstance()); $query->addDescendingSortBy('createdat'); $query->addSane($querystring); $pager = new sfLucenePager($this->getLuceneInstance()->friendlyFind($query)); $num = $pager->getNbResults(); if ($num > 0) { $pager->setMaxPerPage(10); $pager->setPage(1); foreach ($pager->getResults() as $result) { $item = new sfFeedItem(); $item->setTitle($result->getTitle()); $item->setLink('snippet/show?id=' . $result->getId()); $item->setAuthorName($result->getContributor()); $item->setPubDate(strtotime($result->getCreatedAt())); //$item->setAuthorEmail(($code->getSfGuardUser() ? // $code->getSfGuardUser()->getProfile()->getEmail() : $code->getEmail())); $item->setUniqueId($result->getId()); $item->setDescription($result->getSummary()); $feed->addItem($item); } } $this->feed = $feed; $this->setTemplate('feed'); }
protected function createFeed($posts, $tag) { $feed = new sfAtom1Feed(); $feed->setTitle('Planeta PHP.pl' . (empty($tag) ? '' : ' - tag: ' . $tag)); $feed->setLink('@homepage'); $feed->setFeedUrl(empty($tag) ? '@feed' : '@feeds?tag=' . $tag); $feed->setAuthorEmail('*****@*****.**'); $feed->setAuthorName('Planeta PHP.pl'); foreach ($posts as $post) { $item = new sfFeedItem(); $item->setTitle($post->getTitle()); $item->setLink($post->getLink()); $item->setAuthorName($post->getBlog()->getAuthor()); $item->setPubdate($post->getCreatedAt('U')); $item->setUniqueId($post->getLink()); $item->setContent($post->getContent()); $item->setCategories($post->getTagNames()); $feed->addItem($item); } return $feed; }
/** * Executes index action * */ public function executeShow() { $feed = new sfAtom1Feed(); $feed->setTitle('Flinders University Events'); $feed->setLink('http://www.flinders.edu.au/'); $feed->setAuthorEmail('*****@*****.**'); $feed->setAuthorName('Web Development'); $feedImage = new sfFeedImage(); $feedImage->setFavicon('http://www.flinders.edu.au/favicon.ico'); $feed->setImage($feedImage); $conn = Propel::getConnection(); $query = ' SELECT * FROM %s JOIN %s ON (%s = %s) WHERE %s = true AND %s::date >= now()::date ORDER BY %s ASC '; $query = sprintf($query, EtimePeer::TABLE_NAME, EventPeer::TABLE_NAME, EtimePeer::EVENT_ID, EventPeer::ID, EventPeer::PUBLISHED, EtimePeer::START_DATE, EtimePeer::START_DATE); $stmt = $conn->prepareStatement($query); $resultset = $stmt->executeQuery(ResultSet::FETCHMODE_NUM); $etimes = EtimePeer::populateObjects($resultset); foreach ($etimes as $etime) { $item = new sfFeedItem(); $item->setTitle($etime->getEvent()->getTitle() . ' - ' . $etime->getTitle()); $item->setLink('@show_outside_event?slug=' . $etime->getEvent()->getSlug()); $item->setAuthorName($etime->getEtimePeoples()); $item->setPubdate($etime->getStartDate('U')); $item->setUniqueId($etime->getId()); if ($etime->getDescription()) { $item->setDescription($etime->getDescription()); } else { $item->setDescription($etime->getEvent()->getDescription()); } $feed->addItem($item); } $this->feed = $feed; }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->getContext()->getConfiguration()->loadHelpers(array('Url')); $feed = new sfAtom1Feed(); $feed->setTitle('日本Symfonyユーザー会 コンテンツ更新情報'); $feed->setLink($this->getController()->genUrl('@homepage')); $feed->setAuthorEmail('*****@*****.**'); $feed->setAuthorName('日本Symfonyユーザー会'); $feedImage = new sfFeedImage(); $feedImage->setFavicon(public_path('images/favicon.ico')); $pages = Doctrine_Query::create()->from('Page p')->limit(10)->orderBy('p.last_updated desc')->execute(); foreach ($pages as $page) { $item = new sfFeedItem(); $item->setTitle($page->getTitle()); $item->setLink(url_for_page($page->getPath())); $item->setPubdate($page->getDateTimeObject('last_updated')->format('U')); $item->setDescription(strip_tags($page->getContentRendered())); $item->setContent($page->getContentRendered()); $feed->addItem($item); } $this->feed = $feed; }
public function executeNoticiesCulturalsLastPosts() { $this->IDS = 1; $feed = new sfAtom1Feed(); $feed->setTitle('NotÃcies Culturals de Girona'); $feed->setLink('http://www.casadecultura.org/noticiesculturals'); $feed->setAuthorEmail('*****@*****.**'); $feed->setAuthorName('Giroscopi || Casa de Cultura de Girona'); $feedImage = new sfFeedImage(); $feedImage->setFavicon('http://www.casadecultura.cat/images/blogs/Dissenys/noticies_culturals/blog_02.png'); $feed->setImage($feedImage); $C = new Criteria(); $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->IDS); $C->add(AppBlogsEntriesPeer::PAGE_ID, 1); $C->addDescendingOrderByColumn(AppBlogsEntriesPeer::ID); $Q = AppBlogsEntriesPeer::doSelect($C); $WEBROOTURL = OptionsPeer::getString('SF_WEBROOTURL', $this->IDS); foreach ($Q as $post) { $item = new sfFeedItem(); $item->setTitle($post->getTitle()); $item->setLink($WEBROOTURL . 'noticiesculturals?NOTICIA_ID=' . $post->getId()); $item->setAuthorName('Giroscopi'); $item->setAuthorEmail('*****@*****.**'); $IMG = $post->getImages(); if (!$IMG) { $url = ""; } else { $url = '<img width="100px" src="' . $WEBROOTURL . 'images/blogs/' . $IMG[0]->getUrl() . '">'; } $url_web = $WEBROOTURL . 'noticiesculturals?NOTICIA_ID=' . $post->getId(); $item->setUniqueId($url_web); $TEXT = "\t\r\n\t \t\t <table border=\"0\"><tr><td>{$url}</td><td>\t \t\t \r\n\t\t <h1>{$post->getTitle()}</h1><br />\r\n\t\t <h2>{$post->getSubtitle1()}</h2><br />\r\n\t\t <h3>{$post->getSubtitle2()}</h3><br />\r\n\t\t <a href=\"{$post->getUrl()}\">Web</a><br />\r\n\t\t <a href=\"{$url_web}\">NotÃcia original</a>\r\n\t\t </td></tr></table>\t \r\n\t "; $item->setContent($TEXT); $feed->addItem($item); } $this->feed = $feed; $this->setLayout('blank'); $this->setTemplate('RSS'); }
define('SF_APP', 'frontend'); include dirname(__FILE__) . '/../../../../test/bootstrap/functional.php'; $b = new sfTestBrowser(); $b->initialize(); $feedParams = array('title' => 'foo', 'link' => 'http://foobar', 'description' => 'foobar baz', 'language' => 'fr', 'authorName' => 'francois', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://bar.baz', 'subtitle' => 'hey, foo, this is bar', 'categories' => array('foo', 'bar'), 'feedUrl' => 'http://www.example.com', 'encoding' => 'UTF-16'); $enclosureParams = array('url' => 'foo.com', 'length' => '1234', 'mimeType' => 'foobarmimetype'); $enclosure = new sfFeedEnclosure(); $enclosure->initialize($enclosureParams); $itemParams = array('title' => 'fooitem', 'link' => 'http://www.example.com/item1', 'description' => 'foobar baz item', 'content' => 'this is foo bar baz', 'authorName' => 'francois item', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://bar.baz.item', 'categories' => array('fooitem', 'baritem'), 'pubDate' => '12345', 'comments' => 'gee', 'uniqueId' => '98765', 'enclosure' => $enclosure, 'categories' => array('fooitem', 'baritem')); $item2Params = array('title' => 'foobaritem', 'pubDate' => '123456', 'link' => 'http://www.example.com'); $image_params = array('title' => 'symfony project', 'link' => 'http://www.symfony-project.org', 'favicon' => 'http://www.symfony-project.org/favicon.ico', 'image' => 'http://www.symfony-project.org/images/symfony_logo.gif', 'faviconX' => '16', 'faviconY' => '16', 'imageX' => '176', 'imageY' => '37'); $feed = new sfAtom1Feed(); $feed->initialize($feedParams); $feedItem = new sfFeedItem(); $feedItem->initialize($itemParams); $feed->addItem($feedItem); $feedItem2 = new sfFeedItem(); $feedItem2->initialize($item2Params); $feed->addItem($feedItem2); $feedImage = new sfFeedImage(); $feedImage->initialize($image_params); $feed->setImage($feedImage); $t = new lime_test(57, new lime_output_color()); $t->diag('toXML() - generated feed'); $feedString = $feed->toXml(); $feedXml = simplexml_load_string($feedString); $namespaces = $feedXml->getNamespaces(); $t->ok(in_array('http://www.w3.org/2005/Atom', $namespaces), '<feed> is declared with the proper Atom namespace'); $attributes = $feedXml->attributes('http://www.w3.org/XML/1998/namespace'); preg_match('/^<\\?xml\\s*version="1\\.0"\\s*encoding="(.*?)".*?\\?>$/mi', $feedString, $matches); $t->is($matches[1], $feed->getEncoding(), 'The encoding is set with the proper feed encoding');