forked from blallo/rss-bridge
Merge pull request #335 from LogMANOriginal/CastorusBridge
[Castorus] Allow filter via ZIP code or city name
This commit is contained in:
commit
67e2698211
1 changed files with 38 additions and 0 deletions
|
@ -6,6 +6,30 @@ class CastorusBridge extends BridgeAbstract {
|
||||||
$this->uri = $this->getURI();
|
$this->uri = $this->getURI();
|
||||||
$this->description = "Returns the latest changes";
|
$this->description = "Returns the latest changes";
|
||||||
$this->update = "2016-08-05";
|
$this->update = "2016-08-05";
|
||||||
|
|
||||||
|
$this->parameters["Get latest changes"] = '[]';
|
||||||
|
$this->parameters["Get latest changes via ZIP code"] =
|
||||||
|
'[
|
||||||
|
{
|
||||||
|
"name": "ZIP code",
|
||||||
|
"identifier" : "zip",
|
||||||
|
"type" : "text",
|
||||||
|
"required" : "true",
|
||||||
|
"exampleValue" : "74910, 74",
|
||||||
|
"title" : "Insert ZIP code (complete or partial)"
|
||||||
|
}
|
||||||
|
]';
|
||||||
|
$this->parameters["Get latest changes via city name"] =
|
||||||
|
'[
|
||||||
|
{
|
||||||
|
"name": "City name",
|
||||||
|
"identifier" : "city",
|
||||||
|
"type" : "text",
|
||||||
|
"required" : "true",
|
||||||
|
"exampleValue" : "Seyssel, Seys",
|
||||||
|
"title" : "Insert city name (complete or partial)"
|
||||||
|
}
|
||||||
|
]';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extracts the tile from an actitiy
|
// Extracts the tile from an actitiy
|
||||||
|
@ -55,6 +79,12 @@ class CastorusBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(array $params){
|
public function collectData(array $params){
|
||||||
|
if(isset($params['zip']))
|
||||||
|
$zip_filter = trim($params['zip']);
|
||||||
|
|
||||||
|
if(isset($params['city']))
|
||||||
|
$city_filter = trim($params['city']);
|
||||||
|
|
||||||
$html = $this->file_get_html($this->getURI());
|
$html = $this->file_get_html($this->getURI());
|
||||||
|
|
||||||
if(!$html)
|
if(!$html)
|
||||||
|
@ -74,6 +104,14 @@ class CastorusBridge extends BridgeAbstract {
|
||||||
$item->content = '<a href="' . $item->uri . '">' . $item->title . '</a><br><p>'
|
$item->content = '<a href="' . $item->uri . '">' . $item->title . '</a><br><p>'
|
||||||
. $this->ExtractActivityPrice($activity) . '</p>';
|
. $this->ExtractActivityPrice($activity) . '</p>';
|
||||||
|
|
||||||
|
if(isset($zip_filter) && !(substr($item->title, 0, strlen($zip_filter)) === $zip_filter)){
|
||||||
|
continue; // Skip this item
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($city_filter) && !(substr($item->title, strpos($item->title, ' ') + 1, strlen($city_filter)) === $city_filter)){
|
||||||
|
continue; // Skip this item
|
||||||
|
}
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue