From 792578aefbbfe8a804b4f09801722035d907ccb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sat, 27 Aug 2016 20:16:22 +0200 Subject: [PATCH] [WikipediaBridge] remove useless code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/WikipediaBridge.php | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/bridges/WikipediaBridge.php b/bridges/WikipediaBridge.php index 55394f7..d12f6ed 100644 --- a/bridges/WikipediaBridge.php +++ b/bridges/WikipediaBridge.php @@ -51,7 +51,6 @@ class WikipediaBridge extends BridgeAbstract{ public function getName(){ $params=$this->parameters[$this->queriedContext]; - $subject = WIKIPEDIA_SUBJECT_TFA; switch($params['subject']['value']){ case 'tfa': $subject = WIKIPEDIA_SUBJECT_TFA; @@ -80,16 +79,7 @@ class WikipediaBridge extends BridgeAbstract{ public function collectData(){ $params=$this->parameters[$this->queriedContext]; - if(!isset($params['language']['value'])) - $this->returnClientError('You must specify a valid language via \'&language=\'!'); - if(!$this->CheckLanguageCode(strtolower($params['language']['value']))) - $this->returnClientError('The language code you provided (\'' . $params['language']['value'] . '\') is not supported!'); - - if(!isset($params['subject']['value'])) - $this->returnClientError('You must specify a valid subject via \'&subject=\'!'); - - $subject = WIKIPEDIA_SUBJECT_TFA; switch($params['subject']['value']){ case 'tfa': $subject = WIKIPEDIA_SUBJECT_TFA; @@ -102,9 +92,7 @@ class WikipediaBridge extends BridgeAbstract{ break; } - $fullArticle = false; - if(isset($params['fullarticle']['value'])) - $fullArticle = $params['fullarticle']['value']; + $fullArticle = $params['fullarticle']['value']; // This will automatically send us to the correct main page in any language (try it!) $html = $this->getSimpleHTMLDOM($this->getURI() . '/wiki'); @@ -128,20 +116,6 @@ class WikipediaBridge extends BridgeAbstract{ $this->$function($html, $subject, $fullArticle); } - /** - * Returns true if the language code is part of the parameters list - */ - private function CheckLanguageCode($languageCode){ - $languages = $this->parameters[0]['language']['values']; - - $language_names = array(); - - foreach($languages as $name=>$value) - $language_names[] = $value; - - return in_array($languageCode, $language_names); - } - /** * Replaces all relative URIs with absolute ones * @param $element A simplehtmldom element