Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PanneauPocket bridge #3825

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions bridges/PanneauPocketBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class PanneauPocketBridge extends BridgeAbstract
'name' => 'Choisir une ville',
'type' => 'list',
'values' => self::CITIES,
],
'cityName' => [
'name' => 'Ville',
],
'cityId' => [
'name' => 'Identifiant',
]
]
];
Expand Down Expand Up @@ -113,8 +119,14 @@ class PanneauPocketBridge extends BridgeAbstract

public function collectData()
{
$matchedCity = array_search($this->getInput('cities'), self::CITIES);
$city = strtolower($this->getInput('cities') . '-' . $matchedCity);
$cityId = $this->getInput('cityId');
if ($cityId != null) {
$cityName = $this->getInput('cityName');
$city = strtolower($cityId . '-' . $cityName);
} else {
$matchedCity = array_search($this->getInput('cities'), self::CITIES);
$city = strtolower($this->getInput('cities') . '-' . $matchedCity);
}
$url = sprintf('https://app.panneaupocket.com/ville/%s', urlencode($city));

$html = getSimpleHTMLDOM($url);
Expand All @@ -136,6 +148,18 @@ public function collectData()
}
}

public function detectParameters($url)
{
$params = [];
$regex = '/\/ville\/(\d+)-([a-z0-9-]+)/';
if (preg_match($regex, $url, $matches)) {
$params['cityId'] = $matches[1];
$params['cityName'] = $matches[2];
return $params;
}
return null;
}

/**
* Produce self::CITIES array
*/
Expand Down