From c061057861330214dc0d95d2332152ad27958c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sat, 27 Aug 2016 12:43:53 +0200 Subject: [PATCH] [GoogleSearchBridge] remove useless checks and useless member $request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit still broken though Signed-off-by: Pierre Mazière --- bridges/GoogleSearchBridge.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bridges/GoogleSearchBridge.php b/bridges/GoogleSearchBridge.php index 5585cea2..c2512bf0 100644 --- a/bridges/GoogleSearchBridge.php +++ b/bridges/GoogleSearchBridge.php @@ -9,8 +9,6 @@ */ class GoogleSearchBridge extends BridgeAbstract{ - private $request; - public function loadMetadatas() { $this->maintainer = "sebsauvage"; @@ -19,7 +17,10 @@ class GoogleSearchBridge extends BridgeAbstract{ $this->description = "Returns most recent results from Google search."; $this->parameters[] = array( - 'q'=>array('name'=>"keyword") + 'q'=>array( + 'name'=>"keyword", + 'required'=>true + ) ); } @@ -29,13 +30,7 @@ class GoogleSearchBridge extends BridgeAbstract{ $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['q']['value'])) { /* keyword search mode */ - $this->request = $param['q']['value']; - $html = $this->getSimpleHTMLDOM('https://www.google.com/search?q=' . urlencode($this->request) . '&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnServerError('No results for this query.'); - } - else{ - $this->returnClientError('You must specify a keyword (?q=...).'); - } + $html = $this->getSimpleHTMLDOM('https://www.google.com/search?q=' . urlencode($param['q']['value']) . '&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnServerError('No results for this query.'); $emIsRes = $html->find('div[id=ires]',0); if( !is_null($emIsRes) ){ @@ -55,7 +50,8 @@ class GoogleSearchBridge extends BridgeAbstract{ } public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') .'Google search'; + $param=$this->parameters[$this->queriedContext]; + return $param['q']['value'] .' - Google search'; } public function getCacheDuration(){