diff --git a/bridges/DRKBlutspendeBridge.php b/bridges/DRKBlutspendeBridge.php new file mode 100644 index 00000000..15075898 --- /dev/null +++ b/bridges/DRKBlutspendeBridge.php @@ -0,0 +1,107 @@ + [ + 'term' => [ + 'name' => 'PLZ / Ort', + 'required' => true, + 'exampleValue' => '12555', + ], + 'radius' => [ + 'name' => 'Umkreis in km', + 'type' => 'number', + 'exampleValue' => 10, + ], + 'limit_days' => [ + 'name' => 'Limit von Tagen', + 'title' => 'Nur Termine innerhalb der nächsten x Tagen', + 'type' => 'number', + 'exampleValue' => 28, + ], + 'limit_items' => [ + 'name' => 'Limit von Terminen', + 'title' => 'Nicht mehr als x Termine', + 'type' => 'number', + 'required' => true, + 'defaultValue' => 20, + ] + ] + ]; + + public function collectData() + { + $limitItems = intval($this->getInput('limit_items')); + $this->collectExpandableDatas(self::buildAppointmentsURI(), $limitItems); + } + + protected function parseItem(array $item) + { + $html = getSimpleHTMLDOM($item['uri']); + + $detailsElement = $html->find('.details', 0); + + $dateElement = $detailsElement->find('.datum', 0); + $dateLines = self::explodeLines($dateElement->plaintext); + + $addressElement = $detailsElement->find('.adresse', 0); + $addressLines = self::explodeLines($addressElement->plaintext); + + $infoElement = $detailsElement->find('.angebote > h4 + p', 0); + $info = $infoElement ? $infoElement->innertext : ''; + + $imageElements = $detailsElement->find('.fotos img'); + + $item['title'] = $dateLines[0] . ' ' . $dateLines[1] . ' ' . $addressLines[0] . ' - ' . $addressLines[1]; + + $item['content'] = <<{$dateLines[0]} {$dateLines[1]}
+{$addressElement->innertext}
+{$info}
+ HTML; + + foreach ($imageElements as $imageElement) { + $src = $imageElement->getAttribute('src'); + $item['content'] .= <<