diff --git a/bridges/TicketioBridge.php b/bridges/TicketioBridge.php new file mode 100644 index 00000000000..ed52f6c8687 --- /dev/null +++ b/bridges/TicketioBridge.php @@ -0,0 +1,63 @@ + [ + 'name' => 'Link to Ticketpage', + 'required' => true, + 'exampleValue' => 'https://gotogotec.ticket.io' + ] + ] + ]; + + public function collectData() { + $html = getSimpleHTMLDOM($this->getInput('Link')); + + if (!$html) { + returnServerError('Could not retrieve website content.'); + } + + // Find all event rows + $eventRows = $html->find('tr.container'); + + foreach ($eventRows as $eventRow) { + // Get the event name + $eventName = $eventRow->find('a.a-eventlink', 0)->plaintext; + + // Reduce eventName length if too long + if(strlen($eventName) > 35) { + $eventName = substr($eventName,0,35); + } + + // Find the list item containing the date + $dateElement = $eventRow->find('ul.fa-ul li span', 1); // Second inside the list item + + // Check if the date element is found + if ($dateElement) { + $eventDate = $dateElement->plaintext; + } else { + $eventDate = 'Date not found'; + } + + // Build title out of Name and Date + $eventTitle = $eventName . ' - ' . $eventDate; + + // Link to the event page + $eventLink = $this->getInput('Link') . $eventRow->find('a.a-eventlink', 0)->href; + + // Create a feed item with the title and link + $item = []; + $item['title'] = $eventTitle; + $item['uri'] = $eventLink; + $item['content'] = "

More details

"; + + $this->items[] = $item; + } + } +}