[LeBonCoinBridge] code simplification

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-29 12:42:34 +02:00
parent 953faabb1a
commit 0668f79704

View file

@ -3,7 +3,7 @@ class LeBonCoinBridge extends BridgeAbstract{
public $maintainer = "16mhz"; public $maintainer = "16mhz";
public $name = "LeBonCoin"; public $name = "LeBonCoin";
public $uri = "http://www.leboncoin.fr"; public $uri = "http://www.leboncoin.fr/";
public $description = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword ."; public $description = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword .";
public $parameters = array( array( public $parameters = array( array(
@ -44,6 +44,7 @@ class LeBonCoinBridge extends BridgeAbstract{
'name'=>'Catégorie', 'name'=>'Catégorie',
'type'=>'list', 'type'=>'list',
'values'=>array( 'values'=>array(
'TOUS'=>'',
'EMPLOI'=>'_emploi_', 'EMPLOI'=>'_emploi_',
'VEHICULES'=>array( 'VEHICULES'=>array(
'Tous'=>'_vehicules_', 'Tous'=>'_vehicules_',
@ -136,14 +137,16 @@ class LeBonCoinBridge extends BridgeAbstract{
public function collectData(){ public function collectData(){
$html = ''; $category=$this->getInput('c');
if (empty($this->getInput('c'))) { if (empty($category)){
$link = 'http://www.leboncoin.fr/annonces/offres/' . $this->getInput('r') . '/?f=a&th=1&q=' . urlencode($this->getInput('k')); $category='annonces';
} }
else {
$link = 'http://www.leboncoin.fr/' . $this->getInput('c') . '/offres/' . $this->getInput('r') . '/?f=a&th=1&q=' . urlencode($this->getInput('k')); $html = $this->getSimpleHTMLDOM(
} $this->uri.$category.'/offres/' . $this->getInput('r') . '/?'
$html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request LeBonCoin.'); .'f=a&th=1&'
.'q=' . urlencode($this->getInput('k'))
) or $this->returnServerError('Could not request LeBonCoin.');
$list = $html->find('.tabsContent', 0); $list = $html->find('.tabsContent', 0);
if($list === NULL) { if($list === NULL) {