From 1d588096769c21fb8ebb3cf201bdbab42a3681a6 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 3 Aug 2016 21:12:43 +0200 Subject: [PATCH 1/2] Change nested function MsnMondeExtractContent to 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/MsnMondeBridge.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php index fab3b253..9b0c09d1 100644 --- a/bridges/MsnMondeBridge.php +++ b/bridges/MsnMondeBridge.php @@ -11,14 +11,13 @@ class MsnMondeBridge extends BridgeAbstract{ } + function MsnMondeExtractContent($url, &$item) { + $html2 = $this->file_get_html($url); + $item->content = $html2->find('#content', 0)->find('article', 0)->find('section', 0)->plaintext; + $item->timestamp = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime); + } + public function collectData(array $param){ - - function MsnMondeExtractContent($url, &$item) { - $html2 = $this->file_get_html($url); - $item->content = $html2->find('#content', 0)->find('article', 0)->find('section', 0)->plaintext; - $item->timestamp = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime); - } - $html = $this->file_get_html('http://www.msn.com/fr-fr/actualite/monde') or $this->returnError('Could not request MsnMonde.', 404); $limit = 0; foreach($html->find('.smalla') as $article) { @@ -26,7 +25,7 @@ class MsnMondeBridge extends BridgeAbstract{ $item = new \Item(); $item->title = utf8_decode($article->find('h4', 0)->innertext); $item->uri = "http://www.msn.com" . utf8_decode($article->find('a', 0)->href); - MsnMondeExtractContent($item->uri, $item); + $this->MsnMondeExtractContent($item->uri, $item); $this->items[] = $item; $limit++; } From 924e123ba6069c414864e891576e9d5b417272fb Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 3 Aug 2016 21:14:46 +0200 Subject: [PATCH 2/2] Fix indentation and remove empty lines --- bridges/MsnMondeBridge.php | 50 ++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php index 9b0c09d1..4b0e0eff 100644 --- a/bridges/MsnMondeBridge.php +++ b/bridges/MsnMondeBridge.php @@ -2,13 +2,11 @@ class MsnMondeBridge extends BridgeAbstract{ public function loadMetadatas() { - $this->maintainer = "kranack"; $this->name = "MSN Actu Monde"; $this->uri = "http://www.msn.com/fr-fr/actualite/monde"; $this->description = "Returns the 10 newest posts from MSN Actualités (full text)"; - $this->update = "2015-01-30"; - + $this->update = "2016-08-03"; } function MsnMondeExtractContent($url, &$item) { @@ -17,30 +15,30 @@ class MsnMondeBridge extends BridgeAbstract{ $item->timestamp = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime); } - public function collectData(array $param){ - $html = $this->file_get_html('http://www.msn.com/fr-fr/actualite/monde') or $this->returnError('Could not request MsnMonde.', 404); - $limit = 0; - foreach($html->find('.smalla') as $article) { - if($limit < 10) { - $item = new \Item(); - $item->title = utf8_decode($article->find('h4', 0)->innertext); - $item->uri = "http://www.msn.com" . utf8_decode($article->find('a', 0)->href); - $this->MsnMondeExtractContent($item->uri, $item); - $this->items[] = $item; - $limit++; - } - } - } + public function collectData(array $param){ + $html = $this->file_get_html($this->getURI()) or $this->returnError('Could not request MsnMonde.', 404); + $limit = 0; + foreach($html->find('.smalla') as $article) { + if($limit < 10) { + $item = new \Item(); + $item->title = utf8_decode($article->find('h4', 0)->innertext); + $item->uri = "http://www.msn.com" . utf8_decode($article->find('a', 0)->href); + $this->MsnMondeExtractContent($item->uri, $item); + $this->items[] = $item; + $limit++; + } + } + } - public function getName(){ - return 'MSN Actu Monde'; - } + public function getName(){ + return 'MSN Actu Monde'; + } - public function getURI(){ - return 'http://www.msn.com/fr-fr/actualite/monde'; - } + public function getURI(){ + return 'http://www.msn.com/fr-fr/actualite/monde'; + } - public function getCacheDuration(){ - return 3600; // 1 hour - } + public function getCacheDuration(){ + return 3600; // 1 hour + } }