From b3bb2bc2f16b7d93c40804920df8aace543ada47 Mon Sep 17 00:00:00 2001 From: Fanch317 Date: Sat, 18 Apr 2020 17:48:07 +0200 Subject: [PATCH 1/2] [AirBreizhBridge] Add new bridge --- bridges/AirBreizhBridge.php | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 bridges/AirBreizhBridge.php diff --git a/bridges/AirBreizhBridge.php b/bridges/AirBreizhBridge.php new file mode 100644 index 00000000000..7cacd7cac44 --- /dev/null +++ b/bridges/AirBreizhBridge.php @@ -0,0 +1,55 @@ + array( + 'theme' => array( + 'name' => 'Thematique', + 'type' => 'list', + 'defaultValue' => '', + 'values' => array( + 'Tout' => '', + 'Rapport d\'activite' => 'rapport-dactivite', + 'Etude' => 'etudes', + 'Information' => 'information', + 'Autres documents' => 'autres-documents', + 'Plan Régional de Surveillance de la qualité de l’air' => 'prsqa', + 'Transport' => 'transport' + ) + ) + ) + ); + + public function getIcon() { + return 'https://www.airbreizh.asso.fr/voy_content/uploads/2017/11/favicon.png'; + } + + public function collectData(){ + $html = ''; + $html = getSimpleHTMLDOM(static::URI . 'publications/?fwp_publications_thematiques='.$this->getInput('theme')) + or returnClientError('No results for this query.'); + + foreach ($html->find('article') as $article) { + $item = array(); + // Title + $item['title'] = $article->find('h2', 0)->plaintext; + // Author + $item['author'] = 'Air Breizh'; + // Image + $imagelink = $article->find('.card__image', 0)->find('img', 0)->getAttribute('src'); + // Content preview + $item['content'] = ' +
' + . $article->find('.card__text', 0)->plaintext; + // URL + $item['uri'] = $article->find('.publi__buttons',0)->find('a', 0)->getAttribute('href'); + // ID + $item['id'] = $article->find('.publi__buttons',0)->find('a', 0)->getAttribute('href'); + $this->items[] = $item; + } + } +} From 2428caaa7b94e43a34064e37d53b02a66763ca7d Mon Sep 17 00:00:00 2001 From: Fanch317 Date: Sat, 18 Apr 2020 17:58:08 +0200 Subject: [PATCH 2/2] [AirBreizhBridge] Fix lint syntax and tests failures --- bridges/AirBreizhBridge.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bridges/AirBreizhBridge.php b/bridges/AirBreizhBridge.php index 7cacd7cac44..2d852da546a 100644 --- a/bridges/AirBreizhBridge.php +++ b/bridges/AirBreizhBridge.php @@ -10,7 +10,6 @@ class AirBreizhBridge extends BridgeAbstract { 'theme' => array( 'name' => 'Thematique', 'type' => 'list', - 'defaultValue' => '', 'values' => array( 'Tout' => '', 'Rapport d\'activite' => 'rapport-dactivite', @@ -30,7 +29,7 @@ public function getIcon() { public function collectData(){ $html = ''; - $html = getSimpleHTMLDOM(static::URI . 'publications/?fwp_publications_thematiques='.$this->getInput('theme')) + $html = getSimpleHTMLDOM(static::URI . 'publications/?fwp_publications_thematiques=' . $this->getInput('theme')) or returnClientError('No results for this query.'); foreach ($html->find('article') as $article) { @@ -46,9 +45,9 @@ public function collectData(){
' . $article->find('.card__text', 0)->plaintext; // URL - $item['uri'] = $article->find('.publi__buttons',0)->find('a', 0)->getAttribute('href'); + $item['uri'] = $article->find('.publi__buttons', 0)->find('a', 0)->getAttribute('href'); // ID - $item['id'] = $article->find('.publi__buttons',0)->find('a', 0)->getAttribute('href'); + $item['id'] = $article->find('.publi__buttons', 0)->find('a', 0)->getAttribute('href'); $this->items[] = $item; } }