From f3f33cabed3d0a3cee6a417a82702410580bbba0 Mon Sep 17 00:00:00 2001 From: Corentin Garcia Date: Thu, 3 Jan 2019 18:29:29 +0100 Subject: [PATCH] [EliteDangerousGalnetBridge] Add support for others website languages (#992) * [EliteDangerousGalnetBridge] Add support for others website languages * [EliteDangerousGalnetBridge] Fix post title --- bridges/EliteDangerousGalnetBridge.php | 29 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/bridges/EliteDangerousGalnetBridge.php b/bridges/EliteDangerousGalnetBridge.php index d19b360b..dc6077b3 100644 --- a/bridges/EliteDangerousGalnetBridge.php +++ b/bridges/EliteDangerousGalnetBridge.php @@ -6,25 +6,36 @@ class EliteDangerousGalnetBridge extends BridgeAbstract { const URI = 'https://community.elitedangerous.com/galnet/'; const CACHE_TIMEOUT = 7200; // 2h const DESCRIPTION = 'Returns the latest page of news from Galnet'; - - public function getIcon() { - return 'https://community.elitedangerous.com/sites/ -EDSITE_COMM/themes/bootstrap/bootstrap_community/favicon.ico'; - } + const PARAMETERS = array( + array( + 'language' => array( + 'name' => 'Language', + 'type' => 'list', + 'values' => array( + 'English' => 'en', + 'French' => 'fr', + 'German' => 'de' + ), + 'defaultValue' => 'en' + ) + ) + ); public function collectData(){ - $html = getSimpleHTMLDOM(self::URI) + $language = $this->getInput('language'); + $url = 'https://community.elitedangerous.com/'; + $url = $url . $language . '/galnet'; + $html = getSimpleHTMLDOM($url) or returnServerError('Error while downloading the website content'); foreach($html->find('div.article') as $element) { $item = array(); $uri = $element->find('h3 a', 0)->href; - $uri = self::URI . substr($uri, strlen('/galnet/')); + $uri = 'https://community.elitedangerous.com/' . $language . $uri; $item['uri'] = $uri; - $title = $element->find('h3 a', 0)->plaintext; - $item['title'] = substr($title, 1); //remove the space between icon and title + $item['title'] = $element->find('h3 a', 0)->plaintext; $content = $element->find('p', -1)->innertext; $item['content'] = $content;