1
0
Fork 0
forked from blallo/rss-bridge

Change all nested functions to member functions

This fixes error "Using $this when not in object context"

Nested functions are not part of the object and therefore don't have
access to the object instance $this!
This commit is contained in:
logmanoriginal 2016-08-03 20:11:25 +02:00
parent 6ff73d47bb
commit 2a02023c8a

View file

@ -7,12 +7,10 @@ class LeJournalDuGeekBridge extends BridgeAbstract{
$this->name = "journaldugeek.com (FR)"; $this->name = "journaldugeek.com (FR)";
$this->uri = "http://www.journaldugeek.com/"; $this->uri = "http://www.journaldugeek.com/";
$this->description = "Returns the 5 newest posts from LeJournalDuGeek (full text)."; $this->description = "Returns the 5 newest posts from LeJournalDuGeek (full text).";
$this->update = "2014-07-14"; $this->update = "2016-08-03";
} }
public function collectData(array $param){
function LeJournalDuGeekStripCDATA($string) { function LeJournalDuGeekStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string); $string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string); $string = str_replace(']]>', '', $string);
@ -38,16 +36,17 @@ class LeJournalDuGeekBridge extends BridgeAbstract{
return $text; return $text;
} }
public function collectData(array $param){
$rssFeed = $this->file_get_html('http://www.journaldugeek.com/rss') or $this->returnError('Could not request http://www.journaldugeek.com/rss', 404); $rssFeed = $this->file_get_html('http://www.journaldugeek.com/rss') or $this->returnError('Could not request http://www.journaldugeek.com/rss', 404);
$limit = 0; $limit = 0;
foreach($rssFeed->find('item') as $element) { foreach($rssFeed->find('item') as $element) {
if($limit < 5) { if($limit < 5) {
$item = new \Item(); $item = new \Item();
$item->title = LeJournalDuGeekStripCDATA($element->find('title', 0)->innertext); $item->title = $this->LeJournalDuGeekStripCDATA($element->find('title', 0)->innertext);
$item->uri = LeJournalDuGeekStripCDATA($element->find('guid', 0)->plaintext); $item->uri = $this->LeJournalDuGeekStripCDATA($element->find('guid', 0)->plaintext);
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$item->content = LeJournalDuGeekExtractContent($item->uri); $item->content = $this->LeJournalDuGeekExtractContent($item->uri);
$this->items[] = $item; $this->items[] = $item;
$limit++; $limit++;
} }