From 0b4854ccbfacd24c09b1519e99dd36556632d4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Mon, 29 Aug 2016 20:23:36 +0200 Subject: [PATCH] [ParuVenduImmobilierBridge] code simplification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/ParuVenduImmoBridge.php | 62 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index d3c38460..9f1cfd42 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -25,30 +25,8 @@ class ParuVenduImmoBridge extends BridgeAbstract public function collectData() { - $html = ''; - $num = 20; - $appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1'; - $maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; - $link = $this->uri.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison; - - if ($this->getInput('minarea')) { - $link .= '&sur0='.urlencode($this->getInput('minarea')); - } - - if ($this->getInput('maxprice')) { - $link .= '&px1='.urlencode($this->getInput('maxprice')); - } - - if ($this->getInput('pa')) { - $link .= '&pa='.urlencode($this->getInput('pa')); - } - - if ($this->getInput('lo')) { - $link .= '&lo='.urlencode($this->getInput('lo')); - } - - $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request paruvendu.'); - + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('Could not request paruvendu.'); foreach($html->find('div.annonce a') as $element) { @@ -79,16 +57,38 @@ class ParuVenduImmoBridge extends BridgeAbstract } } + public function getURI(){ + $appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1'; + $maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; + $link = $this->uri.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison; + + if ($this->getInput('minarea')) { + $link .= '&sur0='.urlencode($this->getInput('minarea')); + } + + if ($this->getInput('maxprice')) { + $link .= '&px1='.urlencode($this->getInput('maxprice')); + } + + if ($this->getInput('pa')) { + $link .= '&pa='.urlencode($this->getInput('pa')); + } + + if ($this->getInput('lo')) { + $link .= '&lo='.urlencode($this->getInput('lo')); + } + return $link; + } + public function getName(){ $request=''; - if($this->getInput('minarea') && - !empty($this->getInput('minarea')) - ){ - $request .= ' '.$this->getInput('minarea').' m2'; + $minarea=$this->getInput('minarea'); + if(!empty($minarea)){ + $request .= ' '.$minarea.' m2'; } - if($this->getInput('lo') && - !empty($this->getInput('lo'))){ - $request .= ' In: '.$this->getInput('lo'); + $location=$this->getInput('lo'); + if(!empty($location)){ + $request .= ' In: '.$location; } return 'Paru Vendu Immobilier'.$request; }