From 0631e9d835abe62f367083ea705f1bdd69605956 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 2 Aug 2016 15:31:55 +0200 Subject: [PATCH] Make ExtractContent 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! --- bridges/DauphineLibereBridge.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bridges/DauphineLibereBridge.php b/bridges/DauphineLibereBridge.php index f33c21c..27f84d7 100644 --- a/bridges/DauphineLibereBridge.php +++ b/bridges/DauphineLibereBridge.php @@ -7,7 +7,7 @@ class DauphineLibereBridge extends BridgeAbstract{ $this->name = "DauphineLibereBridge Bridge"; $this->uri = "http://www.ledauphine.com/"; $this->description = "Returns the newest articles."; - $this->update = "05/11/2015"; + $this->update = "2016-08-02"; $this->parameters[] = @@ -82,16 +82,15 @@ class DauphineLibereBridge extends BridgeAbstract{ ]'; } - - public function collectData(array $param){ - - function ExtractContent($url) { $html2 = $this->file_get_html($url); $text = $html2->find('div.column', 0)->innertext; $text = preg_replace('@]*?>.*?@si', '', $text); return $text; } + + public function collectData(array $param){ + if (isset($param['u'])) { /* user timeline mode */ $this->request = $param['u']; $html = $this->file_get_html('http://www.ledauphine.com/'.$this->request.'/rss') or $this->returnError('Could not request DauphineLibere.', 404); @@ -107,7 +106,7 @@ class DauphineLibereBridge extends BridgeAbstract{ $item->title = $element->find('title', 0)->innertext; $item->uri = $element->find('guid', 0)->plaintext; $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); - $item->content = ExtractContent($item->uri); + $item->content = $this->ExtractContent($item->uri); $this->items[] = $item; $limit++; }