feat: introduce event carousel and ICS integration for homepage
Added an event carousel to the homepage to display upcoming events dynamically. Integrated ICS parsing to fetch and format calendar data for future events. Enhanced layout and responsiveness with scroll functionality and improved styling.
This commit is contained in:
@@ -1,50 +1,5 @@
|
||||
<?php
|
||||
|
||||
// URL der öffentlichen ICS-Datei
|
||||
define(
|
||||
'CAL_URL',
|
||||
'https://calendar.google.com/calendar/ical/jv1bq94un3ivoa8ka0rk9ngq4k%40group.calendar.google.com/public/basic.ics',
|
||||
);
|
||||
|
||||
// ICS-Datei laden
|
||||
$ics = @file_get_contents(CAL_URL);
|
||||
if ( ! $ics) {
|
||||
echo '<div class="text-red-600">Kalender konnte nicht geladen werden.</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Termine parsen
|
||||
function parse_ics($ics)
|
||||
{
|
||||
$lines = explode("\n", $ics);
|
||||
$events = [];
|
||||
$event = [];
|
||||
$inEvent = false;
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if ($line === 'BEGIN:VEVENT') {
|
||||
$inEvent = true;
|
||||
$event = [];
|
||||
} elseif ($line === 'END:VEVENT') {
|
||||
$inEvent = false;
|
||||
$events[] = $event;
|
||||
} elseif ($inEvent) {
|
||||
// Property kann Parameter enthalten, z.B. DTSTART;TZID=Europe/Berlin:20240701T19000000
|
||||
$parts = explode(':', $line, 2);
|
||||
if (count($parts) === 2) {
|
||||
$key = $parts[0];
|
||||
$val = $parts[1];
|
||||
// Nur den eigentlichen Property-Namen extrahieren
|
||||
$key = strtoupper(preg_replace('/;.+$/', '', $key));
|
||||
$event[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
function format_ics_date($date)
|
||||
{
|
||||
// Unterstützt sowohl ganztägige als auch Zeitangaben
|
||||
@@ -59,7 +14,8 @@ function format_ics_date($date)
|
||||
}
|
||||
}
|
||||
|
||||
$events = parse_ics($ics);
|
||||
$events = collection('termine');
|
||||
|
||||
// Nur Events mit DTSTART berücksichtigen
|
||||
$events = array_filter($events, function ($event) {
|
||||
return isset($event['DTSTART']) && ! empty($event['DTSTART']);
|
||||
@@ -135,6 +91,7 @@ if ($filter_jahr && $filter_monat) {
|
||||
$filtered_events = $future_events;
|
||||
}
|
||||
?>
|
||||
|
||||
<section class="py-24 bg-sf_grau-50">
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 flex flex-col md:flex-row gap-8">
|
||||
<!-- Sidebar -->
|
||||
|
||||
Reference in New Issue
Block a user