1
0
Fork 0
forked from blallo/rss-bridge

Make CADExtractContent a member function

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-02 13:25:49 +02:00
parent a84f11aed8
commit 1e33b7c2ec

View file

@ -7,20 +7,9 @@ class CADBridge extends BridgeAbstract{
$this->name = "CAD Bridge"; $this->name = "CAD Bridge";
$this->uri = "http://www.cad-comic.com/"; $this->uri = "http://www.cad-comic.com/";
$this->description = "Returns the newest articles."; $this->description = "Returns the newest articles.";
$this->update = "2015-04-03"; $this->update = "2016-08-02";
} }
public function collectData(array $param){
function CADUrl($string) {
$html2 = explode("\"", $string);
$string = $html2[1];
if (substr($string,0,4) != 'http')
return 'notanurl';
return $string;
}
function CADExtractContent($url) { function CADExtractContent($url) {
$html3 = $this->file_get_html($url); $html3 = $this->file_get_html($url);
$htmlpart = explode("/", $url); $htmlpart = explode("/", $url);
@ -36,6 +25,18 @@ class CADBridge extends BridgeAbstract{
return '<img src="'.$img.'"/>'; return '<img src="'.$img.'"/>';
} }
public function collectData(array $param){
function CADUrl($string) {
$html2 = explode("\"", $string);
$string = $html2[1];
if (substr($string,0,4) != 'http')
return 'notanurl';
return $string;
}
$html = $this->file_get_html('http://cdn2.cad-comic.com/rss.xml') or $this->returnError('Could not request CAD.', 404); $html = $this->file_get_html('http://cdn2.cad-comic.com/rss.xml') or $this->returnError('Could not request CAD.', 404);
$limit = 0; $limit = 0;
foreach($html->find('item') as $element) { foreach($html->find('item') as $element) {
@ -45,7 +46,7 @@ class CADBridge extends BridgeAbstract{
$item->uri = CADUrl($element->find('description', 0)->innertext); $item->uri = CADUrl($element->find('description', 0)->innertext);
if ($item->uri != 'notanurl') { if ($item->uri != 'notanurl') {
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$item->content = CADExtractContent($item->uri); $item->content = $this->CADExtractContent($item->uri);
$this->items[] = $item; $this->items[] = $item;
$limit++; $limit++;
} }