From 5fb27b2aa6e99d2616a04d8e55d627709d0ed826 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 2 Aug 2016 14:41:54 +0200 Subject: [PATCH] Make CommonDreamsExtractContent 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! --- bridges/CommonDreamsBridge.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bridges/CommonDreamsBridge.php b/bridges/CommonDreamsBridge.php index 6f55b63..6eaca6a 100644 --- a/bridges/CommonDreamsBridge.php +++ b/bridges/CommonDreamsBridge.php @@ -7,10 +7,18 @@ class CommonDreamsBridge extends BridgeAbstract{ $this->name = "CommonDreams Bridge"; $this->uri = "http://www.commondreams.org/"; $this->description = "Returns the newest articles."; - $this->update = "2015-04-03"; + $this->update = "2016-08-02"; } + function CommonDreamsExtractContent($url) { + $html3 = $this->file_get_html($url); + $text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext; + $html3->clear(); + unset ($html3); + return $text; + } + public function collectData(array $param){ function CommonDreamsUrl($string) { @@ -18,14 +26,6 @@ class CommonDreamsBridge extends BridgeAbstract{ $string = $html2[2] . "/node/" . $html2[0]; return $string; } - - function CommonDreamsExtractContent($url) { - $html3 = $this->file_get_html($url); - $text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext; - $html3->clear(); - unset ($html3); - return $text; - } $html = $this->file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404); $limit = 0; @@ -35,7 +35,7 @@ class CommonDreamsBridge extends BridgeAbstract{ $item->title = $element->find('title', 0)->innertext; $item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext); $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); - $item->content = CommonDreamsExtractContent($item->uri); + $item->content = $this->CommonDreamsExtractContent($item->uri); $this->items[] = $item; $limit++; }