From 1262cc982ce4242b7bfcf14865d312381ddfe0bb Mon Sep 17 00:00:00 2001 From: hleskien <34342248+hleskien@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:12:38 +0100 Subject: [PATCH] added new bridges (#3920) * added new bridges * lint --------- Co-authored-by: Dag --- .../BundesverbandFuerFreieKammernBridge.php | 28 ++++++ bridges/DeutscherAeroClubBridge.php | 28 ++++++ bridges/EDDHPiRepsBridge.php | 85 +++++++++++++++++++ bridges/EDDHPresseschauBridge.php | 42 +++++++++ bridges/FliegermagazinBridge.php | 22 +++++ bridges/LogicMastersBridge.php | 26 ++++++ bridges/LuftfahrtBundesAmtBridge.php | 41 +++++++++ bridges/LuftsportSHBridge.php | 26 ++++++ 8 files changed, 298 insertions(+) create mode 100644 bridges/BundesverbandFuerFreieKammernBridge.php create mode 100644 bridges/DeutscherAeroClubBridge.php create mode 100644 bridges/EDDHPiRepsBridge.php create mode 100644 bridges/EDDHPresseschauBridge.php create mode 100644 bridges/FliegermagazinBridge.php create mode 100644 bridges/LogicMastersBridge.php create mode 100644 bridges/LuftfahrtBundesAmtBridge.php create mode 100644 bridges/LuftsportSHBridge.php diff --git a/bridges/BundesverbandFuerFreieKammernBridge.php b/bridges/BundesverbandFuerFreieKammernBridge.php new file mode 100644 index 00000000..147f2d47 --- /dev/null +++ b/bridges/BundesverbandFuerFreieKammernBridge.php @@ -0,0 +1,28 @@ +setTime(0, 0, 0); + return $dti->getTimestamp(); + } +} diff --git a/bridges/DeutscherAeroClubBridge.php b/bridges/DeutscherAeroClubBridge.php new file mode 100644 index 00000000..de98798d --- /dev/null +++ b/bridges/DeutscherAeroClubBridge.php @@ -0,0 +1,28 @@ +setTime(0, 0, 0); + return $dti->getTimestamp(); + } +} + diff --git a/bridges/EDDHPiRepsBridge.php b/bridges/EDDHPiRepsBridge.php new file mode 100644 index 00000000..7d5e6a0b --- /dev/null +++ b/bridges/EDDHPiRepsBridge.php @@ -0,0 +1,85 @@ +find('table table table td') as $itemnode) { + $texts = $this->extractTexts($itemnode->find('text, br')); + $timestamp = $itemnode->find('.su_dat', 0)->innertext(); + $uri = $itemnode->find('.pir_hd a', 0)->href; + $this->items[] = [ + 'timestamp' => $this->formatItemTimestamp($timestamp), + 'title' => $this->formatItemTitle($texts), + 'uri' => $this->formatItemUri($uri), + 'author' => $this->formatItemAuthor($texts), + 'content' => $this->formatItemContent($texts) + ]; + } + } + + public function getIcon() + { + return 'https://eddh.de/favicon.ico'; + } + + private function extractTexts($nodes) + { + $texts = []; + $i = 0; + foreach ($nodes as $node) { + $text = trim($node->outertext()); + if ($node->tag == 'br') { + $texts[$i++] = "\n"; + } elseif (($node->tag == 'text') && ($text != '')) { + $text = iconv('Windows-1252', 'UTF-8', $text); + $text = str_replace(' ', '', $text); + $texts[$i++] = $text; + } + } + return $texts; + } + + protected function formatItemAuthor($texts) + { + $pos = array_search('Name:', $texts); + return $texts[$pos + 1]; + } + + protected function formatItemContent($texts) + { + $pos1 = array_search('Bemerkungen:', $texts); + $pos2 = array_search('Bewertung:', $texts); + $content = ''; + for ($i = $pos1 + 1; $i < $pos2; $i++) { + $content .= $texts[$i]; + } + return trim($content); + } + + protected function formatItemTitle($texts) + { + $texts[5] = ltrim($texts[5], '('); + return implode(' ', [$texts[1], $texts[2], $texts[3], $texts[5]]); + } + + protected function formatItemTimestamp($value) + { + $value = str_replace('Eintrag vom', '', $value); + $value = trim($value); + return strtotime($value); + } + + protected function formatItemUri($value) + { + return 'https://eddh.de/info/' . $value; + } +} diff --git a/bridges/EDDHPresseschauBridge.php b/bridges/EDDHPresseschauBridge.php new file mode 100644 index 00000000..93585684 --- /dev/null +++ b/bridges/EDDHPresseschauBridge.php @@ -0,0 +1,42 @@ +setTime(0, 0, 0); + return $dti->getTimestamp(); + } +} diff --git a/bridges/FliegermagazinBridge.php b/bridges/FliegermagazinBridge.php new file mode 100644 index 00000000..84804e99 --- /dev/null +++ b/bridges/FliegermagazinBridge.php @@ -0,0 +1,22 @@ +parse($value); + } +} \ No newline at end of file diff --git a/bridges/LuftfahrtBundesAmtBridge.php b/bridges/LuftfahrtBundesAmtBridge.php new file mode 100644 index 00000000..2b0384a2 --- /dev/null +++ b/bridges/LuftfahrtBundesAmtBridge.php @@ -0,0 +1,41 @@ +setTime(0, 0, 0); + return $dti->getTimestamp(); + } + + // remove jsession part + protected function formatItemUri($value) + { + $parts = explode(';', $value); + return $parts[0]; + } +} + diff --git a/bridges/LuftsportSHBridge.php b/bridges/LuftsportSHBridge.php new file mode 100644 index 00000000..66914c61 --- /dev/null +++ b/bridges/LuftsportSHBridge.php @@ -0,0 +1,26 @@ +getTimestamp(); + } +}