Ejemplo n.º 1
1
 public function executeFeed(sfWebRequest $request)
 {
     $vanity = $request->getParameter('id');
     $s = $request->getParameter('s', 0);
     $culture = $this->getUser()->getCulture();
     $c = new Criteria();
     $c->add(PropuestaPeer::VANITY, $vanity);
     $entity = PropuestaPeer::doSelectOne($c);
     $this->forward404Unless($entity);
     if ($entity->getCulture() != $culture) {
         $this->redirect("@homepage");
     }
     $filter = array();
     $filter['type_id'] = Propuesta::NUM_ENTITY;
     $filter['entity_id'] = $entity->getId();
     $reviews = SfReviewManager::getReviews($filter);
     $title = sfContext::getInstance()->getI18N()->__('%1% en Voota.es', array('%1%' => $entity));
     $description = sfContext::getInstance()->getI18N()->__('Opiniones sobre %1%, %2% votos a favor y %3% votos en contra', array('%1%' => $entity, '%2%' => $entity->getSumu(), '%3%' => $entity->getSumd()));
     $feed = new sfRssFeed();
     $feed->setTitle($title);
     $feed->setLanguage($culture);
     $feed->setSubtitle($description);
     $feed->setDescription($description);
     $feed->setLink('propuesta/show?id=' . $entity->getVanity());
     $domainExt = $culture == 'ca' ? "cat" : $culture;
     $feed->setAuthorName("Voota.{$domainExt}");
     $feedImage = new sfFeedImage();
     $feedImage->setLink('propuesta/show?id=' . $entity->getVanity());
     $feedImage->setImage(S3Voota::getImagesUrl() . '/' . $entity->getImagePath() . '/cc_' . $entity->getImagen());
     $feedImage->setTitle($entity);
     $feed->setImage($feedImage);
     foreach ($reviews as $review) {
         $item = new sfFeedItem();
         $item->setTitle(sfContext::getInstance()->getI18N()->__('%1%, voota %2%.', array('%1%' => $review->getSfGuardUser(), '%2%' => $review->getValue() == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'))));
         $item->setLink('sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($review));
         $item->setAuthorName($review->getSfGuardUser());
         $item->setPubdate($review->getCreatedAt('U'));
         $item->setUniqueId($review->getId());
         $avatar = S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $review->getSfGuardUser()->getProfile()->getImagen();
         $text = $culture == $review->getCulture() || !$review->getCulture() ? $review->getText() : '';
         $img = $review->getSfGuardUser()->getProfile()->getImagen() ? "<img src=\"{$avatar}\" alt =\"" . $review->getSfGuardUser() . "\" /> " : "";
         $content = "{$text}";
         $item->setDescription($content);
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Ejemplo n.º 2
0
 /**
  * Создать ленту
  *
  * @param array $rows
  * @param array $parameters
  *
  * @return sfFeed
  */
 private function buildFeed(array $rows, array $parameters)
 {
     // default parameters
     $parameters = array_merge(sfConfig::get('app_feeds_default_parameters', array()), $parameters);
     $feed = sfFeed::newInstance($parameters['feed_type']);
     $feed->setTitle($parameters['title']);
     $feed->setLink($parameters['link']);
     $feed->setAuthorName($parameters['author_name']);
     if (isset($parameters['author_email'])) {
         $feed->setAuthorEmail($parameters['author_email']);
     }
     foreach ($rows as $row) {
         $item = new sfFeedItem();
         $item->setTitle($row['title']);
         $item->setAuthorName($row['author_name']);
         if (isset($parameters['permalink_url'])) {
             $item->setLink(sprintf('@%s?%s=%s', $parameters['permalink_url'], $parameters['permalink_param_name'], $row[$parameters['permalink_param_column']]));
         }
         if (isset($row['author_email'])) {
             $item->setAuthorEmail($row['author_email']);
         }
         $item->setPubdate(strtotime($row['created_at']) - date('Z', strtotime($row['created_at'])));
         $item->setUniqueId($row['id']);
         $item->setDescription($row['description']);
         $feed->addItem($item);
     }
     $this->feed = $feed;
     $this->getContext()->getResponse()->setContentType($feed->getContentType());
     $this->setTemplate('feed');
 }
Ejemplo n.º 3
0
 /**
  *
  * @param array $historyEntries Many objects of History class
  * @return sfRss201Feed
  */
 public function getFeed($historyEntries)
 {
     $this->createFeed();
     $i = 0;
     foreach ($historyEntries as $historyEntry) {
         $user = $historyEntry->getUser();
         $content = (string) $historyEntry;
         $item = new sfFeedItem();
         $item->initialize(array('title' => strip_tags($content), 'link' => 'http://' . RaykuCommon::getCurrentHttpDomain(), 'pubDate' => strtotime($historyEntry->getCreatedAt()), 'description' => $content));
         $this->feed->addItem($item);
     }
     return $this->feed;
 }
Ejemplo n.º 4
0
 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');
 }
Ejemplo n.º 5
0
 public function executeFeed($request)
 {
     // Firstly, fetch the articles we will put in the feed
     $articles = Doctrine_Query::create()->from('Article a')->withI18n()->where('aTranslation.is_active = ?', true)->orderBy('aTranslation.created_at DESC')->limit(20)->execute();
     // Then create a sfRssFeed instance and configure it
     $this->feed = new sfRssFeed();
     $this->feed->setTitle('Últimos artículos');
     $this->feed->setAuthorName('Casa Taller Pedro Pablo Oliva');
     // here we use £link to get blog page absolute url.
     // this is the prefered way to get a page url.
     $blogUrl = $this->getHelper()->link('article/list')->getAbsoluteHref();
     $this->feed->setLink($blogUrl);
     // Add each article to the feed
     foreach ($articles as $article) {
         $item = new sfFeedItem();
         $item->setTitle($article->title);
         // use link helper to get the article page url
         $item->setLink($this->getHelper()->link($article)->getAbsoluteHref());
         $item->setAuthorName($article->Author);
         $item->setUniqueId($article->title . ' (' . $article->id . ')');
         $dateObject = new DateTime($article->createdAt);
         $item->setPubdate($dateObject->format('U'));
         $item->setDescription($this->getHelper()->media($article->Image)->size(300, 200) . $this->getService('markdown')->toHtml($article->body));
         $this->feed->addItem($item);
     }
     // disable the layout
     $this->setLayout(false);
 }
 /**
  * Sets the feed item parameters, based on an associative array
  *
  * @param array an associative array
  *
  * @return sfFeedItem the current sfFeedItem object
  */
 public function initialize($item_array)
 {
     parent::initialize($item_array);
     $this->setLongitude(isset($item_array['longitude']) ? $item_array['longitude'] : '');
     $this->setLatitude(isset($item_array['latitude']) ? $item_array['latitude'] : '');
     return $this;
 }
 /**
  * Sets the feed item parameters, based on an associative array
  *
  * @param array an associative array
  *
  * @return sfFeedItem the current sfFeedItem object
  */
 public function initialize($item_array)
 {
     parent::initialize($item_array);
     $this->setDctermsAbstract(isset($item_array['dcterms_abstract']) ? $item_array['dcterms_abstract'] : '');
     $this->setPermalink(isset($item_array['permalink']) ? $item_array['permalink'] : '');
     $this->setDcIdentifier(isset($item_array['dc_identifier']) ? $item_array['dc_identifier'] : '');
     $this->setDcPublisher(isset($item_array['dc_publisher']) ? $item_array['dc_publisher'] : '');
     $this->setLocations(isset($item_array['locations']) ? $item_array['locations'] : '');
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
 /**
  * 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;
 }
Ejemplo n.º 10
0
 public function executeRecent(sfWebRequest $request)
 {
     $feed = $this->getFeed($request->getParameter('format'));
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PluginPeer::CREATED_AT);
     $c->setLimit(20);
     $plugins = PluginPeer::doSelect($c);
     foreach ((array) $plugins as $plugin) {
         $item = new sfFeedItem();
         $item->setTitle($plugin->getTitle());
         $item->setLink('@plugin?slug=' . $plugin->getSlug());
         $item->setAuthorName($plugin->getAuthor()->getFullName());
         $item->setPubdate($plugin->getCreatedAt('U'));
         $item->setUniqueId($plugin->getSlug());
         $item->setContent($plugin->getDescription());
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Ejemplo n.º 11
0
 public function executeRss(dmWebRequest $request)
 {
     $records = dmDb::query('Plugin p')->leftJoin('p.CreatedBy user')->where('p.is_active = ?', true)->orderBy('p.position ASC')->limit(20)->fetchRecords();
     $this->preloadPages($records);
     $feed = new sfRssFeed();
     $feed->setTitle('Diem Project Plugins');
     $feed->setLink('http://diem-project.org/plugins');
     $feed->setAuthorName('Thibault Duplessis');
     foreach ($records as $record) {
         $item = new sfFeedItem();
         $item->setTitle($record->name);
         $item->setLink($this->getHelper()->link($record)->getAbsoluteHref());
         $item->setAuthorName($record->CreatedBy);
         $item->setPubdate($record->getDateTimeObject('created_at')->format('U'));
         $item->setUniqueId($record->name . ' (' . $record->id . ')');
         $item->setDescription($this->getService('markdown')->toHtml($record->text));
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Ejemplo n.º 12
0
 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');
 }
Ejemplo n.º 13
0
 /**
  * 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 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;
 }
Ejemplo n.º 15
0
 public function addItemFromArray($item_array)
 {
     $item = new sfFeedItem();
     $item->setTitle(isset($item_array['title']) ? $item_array['title'] : '');
     $item->setLink(isset($item_array['link']) ? $item_array['link'] : '');
     $item->setDescription(isset($item_array['description']) ? $item_array['description'] : '');
     $item->setAuthorEmail(isset($item_array['authorEmail']) ? $item_array['authorEmail'] : '');
     $item->setAuthorName(isset($item_array['authorName']) ? $item_array['authorName'] : '');
     $item->setAuthorLink(isset($item_array['authorLink']) ? $item_array['authorLink'] : '');
     $item->setPubdate(isset($item_array['pubdate']) ? $item_array['pubdate'] : '');
     $item->setComments(isset($item_array['comments']) ? $item_array['comments'] : '');
     $item->setUniqueId(isset($item_array['uniqueId']) ? $item_array['uniqueId'] : '');
     $item->setEnclosure(isset($item_array['enclosure']) ? $item_array['enclosure'] : '');
     $item->setCategories(isset($item_array['categories']) ? $item_array['categories'] : '');
     $this->items[] = $item;
 }
Ejemplo n.º 16
0
define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../../../..'));
define('SF_APP', 'frontend');
include dirname(__FILE__) . '/../../../../test/bootstrap/functional.php';
$b = new sfTestBrowser();
$b->initialize();
$t = new lime_test(15, new lime_output_color());
$enclosureParams = array('url' => 'foo.com', 'length' => '1234', 'mimeType' => 'foobarmimetype');
$enclosure = new sfFeedEnclosure();
$enclosure->initialize($enclosureParams);
$item_params = array('title' => 'foo', 'link' => 'http://www.example.com', 'description' => 'foobar baz', 'content' => 'hey, do you foo, bar?', 'authorName' => 'francois', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://francois.toto.com', 'pubDate' => '12345', 'comments' => 'this is foo bar baz', 'uniqueId' => 'hello world', 'enclosure' => $enclosure, 'categories' => array('foo', 'bar'));
$item = new sfFeedItem();
$t->isa_ok($item->initialize($item_params), 'sfFeedItem', 'initialize() returns the current feed item object');
$t->is($item->getTitle(), $item_params['title'], 'getTitle() gets the item title');
$t->is($item->getLink(), $item_params['link'], 'getLink() gets the item link');
$t->is($item->getDescription(), $item_params['description'], 'getDescription() gets the item description');
$t->is($item->getContent(), $item_params['content'], 'getContent() gets the item content');
$t->is($item->getAuthorName(), $item_params['authorName'], 'getAuthorName() gets the item author name');
$t->is($item->getAuthorEmail(), $item_params['authorEmail'], 'getAuthorEmail() gets the item author email');
$t->is($item->getAuthorLink(), $item_params['authorLink'], 'getAuthorLink() gets the item author link');
$t->is($item->getPubDate(), $item_params['pubDate'], 'getPubDate() gets the item publication date');
$t->is($item->getComments(), $item_params['comments'], 'getComments() gets the item comments');
$t->is($item->getUniqueId(), $item_params['uniqueId'], 'getUniqueId() gets the item unique id');
$t->is($item->getEnclosure(), $item_params['enclosure'], 'getEnclosure() gets the item enclosure');
$t->is($item->getCategories(), $item_params['categories'], 'getCategories() gets the item categories');
$item_params = array('title' => 'foo', 'link' => 'http://www.example.com', 'content' => 'hey, do you <strong>foo</strong>, my dear bar?');
$item = new sfFeedItem();
$item->initialize($item_params);
$t->is($item->getDescription(), strip_tags($item_params['content']), 'getDescription() gets the stripped item content when no description is defined');
sfConfig::set('app_feed_item_max_length', 5);
$t->is($item->getDescription(), 'hey, [...]', 'getDescription() gets the stripped item content truncated to a maximaum size when no description is defined');
Ejemplo n.º 17
0
$t->isnt($generatedItem->getAuthorLink(), $feedItem->getAuthorLink(), 'The author link property cannot be set from a RSS feed');
$t->is($generatedItem->getPubDate(), $feedItem->getPubdate(), 'The publication date property is properly set');
$t->is($generatedItem->getComments(), $feedItem->getComments(), 'The comments property is properly set');
$t->is($generatedItem->getUniqueId(), $feedItem->getUniqueId(), 'The unique id property is properly set');
$t->is($generatedItem->getEnclosure()->__toString(), $feedItem->getEnclosure()->__toString(), 'The enclosure property is properly set');
$t->is($generatedItem->getCategories(), $feedItem->getCategories(), 'The categories property is properly set');
$generatedItem = $items[1];
$t->is($generatedItem->getAuthorEmail(), $feedItem2->getAuthorEmail(), 'The author email property is properly set, even if there is no email address');
$t->diag('RSS 0.91');
$feed = new sfRssFeed();
$feed->setVersion('0.91');
$feed->initialize($feedParams);
$feedItem = new sfFeedItem();
$feedItem->initialize($itemParams);
$feed->addItem($feedItem);
$feedItem2 = new sfFeedItem();
$feedItem2->initialize($item2Params);
$feed->addItem($feedItem2);
$feedString = $feed->asXml();
$generatedFeed = new sfRssFeed();
$generatedFeed->fromXml($feedString);
$t->isnt($generatedFeed->getCategories(), $feed->getCategories(), '<category> doesn\'t exist in a RSS0.91 feed');
$items = $generatedFeed->getItems();
$generatedItem = $items[0];
$t->isnt($generatedItem->getAuthorEmail(), $feedItem->getAuthorEmail(), '<item><author> doesn\'t exist in a RSS0.91 feed');
$t->isnt($generatedItem->getAuthorName(), $feedItem->getAuthorName(), '<item><author> doesn\'t exist in a RSS0.91 feed');
$t->isnt($generatedItem->getPubDate(), $feedItem->getPubdate(), '<item><pubDate> doesn\'t exist in a RSS0.91 feed');
$t->isnt($generatedItem->getComments(), $feedItem->getComments(), '<item><comments> doesn\'t exist in a RSS0.91 feed');
$t->isnt($generatedItem->getUniqueId(), $feedItem->getUniqueId(), '<item><guid> doesn\'t exist in a RSS0.91 feed');
$t->is($generatedItem->getEnclosure(), '', '<item><enclosure> doesn\'t exist in a RSS0.91 feed');
$t->isnt($generatedItem->getCategories(), $feedItem->getCategories(), '<item><category> doesn\'t exist in a RSS0.91 feed');
Ejemplo n.º 18
0
 /**
  * Populates a feed with items based on objects.
  * Inspects the available methods of the objects to populate items properties.
  *
  * @param array an array of objects
  * @param string A route name for building the URIs to the items
  * @param array An associative array of options
  *
  * @return sfFeed the current sfFeed object
  */
 public static function convertObjectsToItems($objects, $options = array())
 {
     $items = array();
     foreach ($objects as $object) {
         $item = new sfFeedItem();
         // For each item property, check if an object method is provided,
         // and if not, guess it. Here is what it does for the link property
         if (isset($options['methods']['link'])) {
             if ($options['methods']['link']) {
                 $item->setLink(call_user_func(array($object, $options['methods']['link'])));
             } else {
                 $item->setLink('');
             }
         } else {
             $routeName = isset($options['routeName']) ? $options['routeName'] : '';
             $fallbackUrl = isset($options['fallbackUrl']) ? $options['fallbackUrl'] : '';
             $item->setLink(self::getItemFeedLink($object, $routeName, $fallbackUrl));
         }
         // For the other properties, it can be automated
         // Not as readable but definitely more concise
         $details = array('title', 'description', 'content', 'authorEmail', 'authorName', 'authorLink', 'pubdate', 'comments', 'uniqueId', 'enclosure', 'categories');
         foreach ($details as $detail) {
             $itemMethod = 'set' . ucfirst($detail);
             if (isset($options['methods'][$detail])) {
                 if ($options['methods'][$detail]) {
                     if (is_array($options['methods'][$detail])) {
                         call_user_func(array($item, $itemMethod), call_user_func_array(array($object, $options['methods'][$detail][0]), $options['methods'][$detail][1]));
                     } else {
                         call_user_func(array($item, $itemMethod), call_user_func(array($object, $options['methods'][$detail])));
                     }
                 } else {
                     call_user_func(array($item, $itemMethod), '');
                 }
             } else {
                 call_user_func(array($item, $itemMethod), call_user_func(array('sfFeedPeer', 'getItemFeed' . ucfirst($detail)), $object));
             }
         }
         $items[] = $item;
     }
     return $items;
 }
Ejemplo n.º 19
0
 public function executeFeed(sfWebRequest $request)
 {
     $vanity = $request->getParameter('username');
     $this->f = $request->getParameter('f');
     $culture = $this->getUser()->getCulture();
     $c = new Criteria();
     $c->add(SfGuardUserProfilePeer::VANITY, $vanity, Criteria::EQUAL);
     $userProfile = SfGuardUserProfilePeer::doSelectOne($c);
     $this->forward404Unless($userProfile);
     $this->user = $userProfile->getsfGuardUser();
     if (!$this->user->getIsActive() && is_numeric($userProfile->getFacebookUid())) {
         $user = SfGuardUserPeer::retrieveByPK($userProfile->getFacebookUid());
         $this->forward404Unless($user);
         $this->redirect('perfil/show?username='******'%1% en Voota.es', array('%1%' => $this->user));
     $descripcion = SfVoUtil::cutToLength($userProfile->getPresentacion(), 155, '...', true);
     $description = $descripcion ? $descripcion : sfContext::getInstance()->getI18N()->__('Votos y opiniones de %1% sobre políticos y partidos de España', array('%1%' => trim($this->user) ? $this->user : $this->user->getProfile()->getVanity()));
     $feed = new sfRssFeed();
     $feed->setTitle($title);
     $feed->setLanguage($culture);
     $feed->setSubtitle($description);
     $feed->setDescription($description);
     $feed->setLink('perfil/show?username='******'ca' ? "cat" : $culture;
     $feed->setAuthorName("Voota.{$domainExt}");
     $feedImage = new sfFeedImage();
     $feedImage->setLink('perfil/show?username='******'/usuarios/cc_' . $this->user->getProfile()->getImagen());
     $feedImage->setTitle($this->user);
     $feed->setImage($feedImage);
     foreach ($reviews as $review) {
         $item = new sfFeedItem();
         $entityText = "";
         if (!$review->getSfReviewType()) {
             $tmpReview = $review->getSfReviewRelatedBySfReviewId();
             $entityText = sfContext::getInstance()->getI18N()->__('Otra opinión sobre') . ' ';
         } else {
             $tmpReview = $review;
         }
         $sfReviewType = SfReviewTypePeer::retrieveByPk($tmpReview->getSfReviewTypeId());
         $peer = $sfReviewType->getModel() . 'Peer';
         $entity = $peer::retrieveByPk($tmpReview->getEntityId());
         $entityText .= $entity;
         $item->setTitle(sfContext::getInstance()->getI18N()->__('%1%, voota %2%.', array('%1%' => $entityText, '%2%' => $review->getValue() == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'))));
         $item->setLink('sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($review));
         $item->setAuthorName($review->getSfGuardUser());
         $item->setPubdate($review->getCreatedAt('U'));
         $item->setUniqueId($review->getId());
         $avatar = S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $review->getSfGuardUser()->getProfile()->getImagen();
         $text = $culture == $review->getCulture() || !$review->getCulture() ? $review->getText() : '';
         $img = $review->getSfGuardUser()->getProfile()->getImagen() ? "<img src=\"{$avatar}\" alt =\"" . $review->getSfGuardUser() . "\" /> " : "";
         $content = "{$text}";
         $item->setDescription($content);
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Ejemplo n.º 20
0
 protected function feedItemToArray(sfFeedItem $item)
 {
     return array('title' => $item->getTitle(), 'link' => $item->getLink(), 'content' => $item->getDescription() ? $item->getDescription() : $item->getContent(), 'pub_date' => $item->getPubDate(), 'author_name' => $item->getAuthorName(), 'author_link' => $item->getAuthorLink(), 'author_email' => $item->getAuthorEmail());
 }
Ejemplo n.º 21
0
 private static function addToFeed($feed, $reports)
 {
     foreach ($reports as $report) {
         $item = new sfFeedItem();
         $item->setTitle($report->getTitle());
         $item->setLink('report/show?id=' . $report->getFriendlyUrl());
         if ($report->getsfGuardUser()) {
             $item->setAuthorName($report->getsfGuardUser()->getProfile()->getFirstname() . ' ' . $report->getsfGuardUser()->getProfile()->getLastname());
             $item->setAuthorEmail($report->getsfGuardUser()->getProfile()->getEmail());
         }
         $item->setPubdate($report->getCreatedAt('U'));
         $item->setUniqueId($report->getFriendlyUrl());
         $titles = array();
         foreach ($report->getReportQuerys() as $report_query) {
             $titles[] = $report_query->getTitle();
         }
         //print_r($titles);
         $item->setDescription(($report->getDescription() ? $report->getDescription() . " " : "") . 'Queries: ' . implode(', ', $titles));
         $feed->addItem($item);
     }
 }
Ejemplo n.º 22
0
 public function executeFeed(sfWebRequest $request)
 {
     $this->page = $request->getParameter("page", "1");
     $this->entityId = $request->getParameter("entityId", false);
     $this->value = $request->getParameter("value", false);
     $this->sfReviewType = $request->getParameter("type_id", false);
     $this->text = $request->getParameter("t", false);
     $this->entity = false;
     $this->filter = false;
     $culture = $this->getUser()->getCulture();
     $filter = array();
     //$filter['culture'] = $culture;
     if ($this->sfReviewType) {
         $filter['type_id'] = $this->sfReviewType;
     }
     if ($this->text) {
         $filter['textFilter'] = 'text';
     }
     $reviewsPager = SfReviewManager::getReviews($filter);
     $str = '';
     switch ($this->sfReviewType) {
         case 1:
             $str = sfContext::getInstance()->getI18N()->__("políticos");
             break;
         case 2:
             $str = sfContext::getInstance()->getI18N()->__("partidos");
             break;
         case 3:
             $str = sfContext::getInstance()->getI18N()->__("propuestas");
             break;
         case "null":
             $str = sfContext::getInstance()->getI18N()->__("respuestas a otros comentarios");
             break;
     }
     $title = sfContext::getInstance()->getI18N()->__("Últimas opiniones%1% en Voota.", array('%1%' => $str ? " " . sfContext::getInstance()->getI18N()->__("sobre") . " {$str}" : ""));
     $reviews = $reviewsPager->getResults();
     $description = ($reviews[0]->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo') : (trim($reviews[0]->getSfGuardUser()) ? $reviews[0]->getSfGuardUser() : $reviews[0]->getSfGuardUser()->getProfile())) . " (" . ago(strtotime($reviews[0]->getModifiedAt() ? $reviews[0]->getModifiedAt() : $reviews[0]->getCreatedAt())) . "), " . ($reviews[1]->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo') : (trim($reviews[1]->getSfGuardUser()) ? $reviews[1]->getSfGuardUser() : $reviews[1]->getSfGuardUser()->getProfile())) . " (" . ago(strtotime($reviews[1]->getModifiedAt() ? $reviews[1]->getModifiedAt() : $reviews[1]->getCreatedAt())) . "), " . ($reviews[2]->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo') : (trim($reviews[2]->getSfGuardUser()) ? $reviews[2]->getSfGuardUser() : $reviews[2]->getSfGuardUser()->getProfile())) . " (" . ago(strtotime($reviews[2]->getModifiedAt() ? $reviews[2]->getModifiedAt() : $reviews[2]->getCreatedAt())) . "), " . "...";
     $feed = new sfRssFeed();
     $feed->setTitle($title);
     $feed->setLanguage($culture);
     $feed->setSubtitle($description);
     $feed->setDescription($description);
     $params = "";
     if ($this->sfReviewType) {
         $params .= ($params ? '&' : '?') . 'type_id=' . $this->sfReviewType;
     }
     if ($this->text) {
         $params .= ($params ? '&' : '?') . 't=' . $this->text;
     }
     $feed->setLink("sfReviewFront/feed{$params}");
     $domainExt = $culture == 'ca' ? "cat" : $culture;
     $feed->setAuthorName("Voota.{$domainExt}");
     foreach ($reviews as $review) {
         $item = new sfFeedItem();
         $entityText = "";
         if (!$review->getSfReviewType()) {
             $tmpReview = $review->getSfReviewRelatedBySfReviewId();
             $entityText = sfContext::getInstance()->getI18N()->__('otra opinión sobre') . ' ';
         } else {
             $tmpReview = $review;
         }
         $sfReviewType = SfReviewTypePeer::retrieveByPk($tmpReview->getSfReviewTypeId());
         $peer = $sfReviewType->getModel() . 'Peer';
         $entity = $peer::retrieveByPk($tmpReview->getEntityId());
         $entityText .= $entity;
         $item->setTitle(sfContext::getInstance()->getI18N()->__('%1%, voota %2% de %3%.', array('%1%' => $review->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo') : $review->getSfGuardUser(), '%2%' => $review->getValue() == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%3%' => $entityText)));
         $item->setLink('sfReviewFront/show?id=' . SfVoUtil::reviewPermalink($review));
         if (!$review->getAnonymous()) {
             $item->setAuthorName($review->getSfGuardUser());
         }
         $item->setPubdate($review->getCreatedAt('U'));
         $item->setUniqueId($review->getId());
         if (!$review->getAnonymous()) {
             $avatar = S3Voota::getImagesUrl() . '/usuarios/cc_s_' . $review->getSfGuardUser()->getProfile()->getImagen();
         }
         $text = $culture == $review->getCulture() || !$review->getCulture() ? $review->getText() : '';
         if (!$review->getAnonymous()) {
             $img = $review->getSfGuardUser()->getProfile()->getImagen() ? "<img src=\"{$avatar}\" alt =\"" . $review->getSfGuardUser() . "\" /> " : "";
         }
         $content = "{$text}";
         $item->setDescription($content);
         $feed->addItem($item);
     }
     $this->feed = $feed;
 }
Ejemplo n.º 23
0
    $t->pass('addItem() accepts sfFeedItem objects');
} catch (Exception $e) {
    $t->fail('addItem() accepts sfFeedItem objects');
}
$t->is(count($feed->getItems()), 1, 'addItem() adds an item to the feed');
$feed->setItems();
$t->is(count($feed->getItems()), 0, 'setItems() with no arguments reinitializes the feed items');
$feed->addItems(array(new sfFeedItem(), new sfFeedItem(), new sfFeedItem()));
$t->is(count($feed->getItems()), 3, 'addItems() adds several items at once');
$feed->setItems();
try {
    $feed->addItemFromArray(array());
    $t->pass('addItemFromArray() accepts an array');
} catch (Exception $e) {
    $t->fail('addItemFromArray() accepts an array');
}
$t->is(count($feed->getItems()), 1, 'addItemFromArray() adds an item to the feed');
$feed_params = array('title' => 'foo', 'link' => 'bar', 'description' => 'foobar baz', 'language' => 'fr', 'authorName' => 'francois', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://francois.toto.com', 'subtitle' => 'this is foo bar', 'categories' => array('foo', 'bar'), 'feedUrl' => 'http://www.example.com', 'encoding' => 'UTF-16');
$feed = new sfFeed();
$feed->initialize($feed_params);
$item1_params = array('title' => 'foo', 'pubDate' => '1');
$item1 = new sfFeedItem();
$item1->initialize($item1_params);
$item2_params = array('title' => 'bar', 'pubDate' => '3');
$item2 = new sfFeedItem();
$item2->initialize($item2_params);
$item3_params = array('title' => 'baz', 'pubDate' => '2');
$item3 = new sfFeedItem();
$item3->initialize($item3_params);
$feed->addItems(array($item1, $item2, $item3));
$t->is($feed->getLatestPostDate(), '3', 'getLatestPostDate() returns the latest post date of all feed items');
Ejemplo n.º 24
0
 private function setPosts(&$feed, $posts)
 {
     foreach ($posts as $post) {
         $item = new sfFeedItem();
         $item->setTitle(__('Пост №') . $post->getId());
         $item->setLink('post/show?id=' . $post->getId());
         $item->setAuthorName($post->getUser()->getUsername());
         $item->setPubdate(strtotime($post->getCreatedAt()));
         $item->setUniqueId($post->getId());
         $item->setDescription($this->getPartial('post/post_rss', array('post' => $post)));
         $feed->addItem($item);
     }
 }