protected function buildFeed($parsedFeed, $url, $getFavicon, $modified, $etag, $location) { $feed = new Feed(); $link = $parsedFeed->getSiteUrl(); if (!$link) { $link = $location; } // unescape content because angularjs helps against XSS $title = strip_tags($this->decodeTwice($parsedFeed->getTitle())); $feed->setTitle($title); $feed->setUrl($url); // the url used to add the feed $feed->setLocation($location); // the url where the feed was found $feed->setLink($link); // <link> attribute in the feed $feed->setLastModified($modified); $feed->setEtag($etag); $feed->setAdded($this->time->getTime()); if ($getFavicon) { $faviconFetcher = $this->faviconFactory->build(); $favicon = $faviconFetcher->find($feed->getLink()); $feed->setFaviconLink($favicon); } return $feed; }
private function createFeed($hasFavicon = false) { $this->expectFeed('getTitle', $this->feedTitle); $this->expectFeed('getSiteUrl', $this->feedLink); $feed = new Feed(); $feed->setTitle('&its a title'); $feed->setUrl($this->url); $feed->setLink($this->feedLink); $feed->setAdded($this->time); $feed->setLastModified($this->modified); $feed->setEtag($this->etag); $feed->setLocation($this->location); if ($hasFavicon) { $this->faviconFactory->expects($this->once())->method('build')->will($this->returnValue($this->faviconFetcher)); $this->faviconFetcher->expects($this->once())->method('find')->with($this->equalTo($this->feedLink))->will($this->returnValue($this->webFavicon)); $feed->setFaviconLink($this->webFavicon); } return $feed; }
private function createFeed($feed) { $newFeed = new Feed(); $newFeed->setUserId($this->userId); $newFeed->setFolderId($feed['folderId']); $newFeed->setTitle($feed['title']); $newFeed->setUrl($feed['url']); $newFeed->setLocation($feed['location']); $newFeed->setFaviconLink($feed['faviconLink']); $newFeed->setAdded($feed['added']); $newFeed->setLink($feed['link']); $newFeed->setPreventUpdate($feed['preventUpdate']); $newFeed->setDeletedAt($feed['deletedAt']); $newFeed->setArticlesPerUpdate($feed['articlesPerUpdate']); $newFeed->setLastModified($feed['lastModified']); $newFeed->setEtag($feed['etag']); return $this->feedMapper->insert($newFeed); }
public function testFetchMapItemsGetFavicon() { $this->expectCore('get_title', $this->feedTitle); $this->expectCore('get_permalink', $this->feedLink, 2); $feed = new Feed(); $feed->setTitle('&its a title'); $feed->setUrl($this->url); $feed->setLink($this->feedLink); $feed->setAdded($this->time); $feed->setFaviconLink($this->webFavicon); $this->core->expects($this->once())->method('init')->will($this->returnValue(true)); $this->faviconFetcher->expects($this->once())->method('fetch')->will($this->returnValue($this->webFavicon)); $item = $this->createItem(false, true); $this->expectCore('get_items', array($this->item)); $result = $this->fetcher->fetch($this->url); $this->assertEquals(array($feed, array($item)), $result); }
protected function buildFeed($simplePieFeed, $url, $getFavicon) { $feed = new Feed(); // unescape content because angularjs helps against XSS $title = strip_tags($this->decodeTwice($simplePieFeed->get_title())); // if there is no title use the url if (!$title) { $title = $url; } $feed->setTitle($title); $feed->setUrl($url); $link = $simplePieFeed->get_permalink(); if (!$link) { $link = $url; } $feed->setLink($link); $feed->setAdded($this->time->getTime()); if ($getFavicon) { // use the favicon from the page first since most feeds use a weird image $favicon = $this->faviconFetcher->fetch($feed->getLink()); if (!$favicon) { $favicon = $simplePieFeed->get_image_url(); } $feed->setFaviconLink($favicon); } return $feed; }