[ParuVenduImmobilierBridge] code simplification

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-29 20:23:36 +02:00
parent 41dfc57103
commit 0b4854ccbf

View file

@ -25,30 +25,8 @@ class ParuVenduImmoBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$html = ''; $html = $this->getSimpleHTMLDOM($this->getURI())
$num = 20; or $this->returnServerError('Could not request paruvendu.');
$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.');
foreach($html->find('div.annonce a') as $element) { 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(){ public function getName(){
$request=''; $request='';
if($this->getInput('minarea') && $minarea=$this->getInput('minarea');
!empty($this->getInput('minarea')) if(!empty($minarea)){
){ $request .= ' '.$minarea.' m2';
$request .= ' '.$this->getInput('minarea').' m2';
} }
if($this->getInput('lo') && $location=$this->getInput('lo');
!empty($this->getInput('lo'))){ if(!empty($location)){
$request .= ' In: '.$this->getInput('lo'); $request .= ' In: '.$location;
} }
return 'Paru Vendu Immobilier'.$request; return 'Paru Vendu Immobilier'.$request;
} }