%%s
',
$date -> format ("d"),
getLocalizedShortDayName (
intval ($date -> format ("N"))
)
);
// Fetch events for the specified date
$events = getEventsForDate ($ical, $date);
// Skip empty days
if (count ($events) == 0) return "";
// Iterate over each event and add an event entry to the HTML
foreach ($events as $event) {
$dtstart = $ical -> iCalDateToDateTime($event -> dtstart_array[3]);
$dtend = $ical -> iCalDateToDateTime($event -> dtend_array[3]);
$today_end = clone $date; $today_end -> modify("+1 day");
$time_separator = " - ";
$time_prefix = "";
$time_start = $dtstart -> format('H:i');
$time_end = $dtend -> format('H:i');
// When start date is in past, don't display start time
if ($dtstart < $date) {
$time_start = "";
$time_separator = "Bis ";
}
// When end date is in future, don't display end time
if ($dtend > $today_end) {
$time_end = "";
$time_separator = "";
$time_prefix = "Ab ";
}
// Assemble time display string
$time_str = "{$time_prefix}{$time_start}{$time_separator}{$time_end}";
// Check if event is all day
if ($time_start == "00:00" && $time_end == "00:00") {
$time_str = "Ganztägig";
}
// Check if event is multi day
if ($time_start == "" && $time_end == "") {
$time_str = "Mehrtägig";
}
// Check if multi day event without start times
if ($time_start . $time_end == "00:00") {
$time_str = "Mehrtägig";
}
$html = sprintf (
$html,
sprintf (
'
%s
%s
%%s',
$event -> summary,
$time_str
),
);
}
$html = sprintf ($html, '');
return $html;
}
/**
* Return HTML with flow header for specific date
*
* @param DateTime $date DateTime object
*
* @return string Returns HTML with flow header
* @return false False on failure
*/
function generateFlowHeader ($date) {
if ($date == null) return false;
return sprintf (
'',
getLocalizedMonthName (intval ($date -> format ("m")))
);
}
/**
* Return HTML for the flow body
*
* @param ICal $ical ICal object
* @param DateTime $date DateTime object
* @param int $days Days to display
*
* @return string Returns HTML with the entire flow data
* @return false False on failure
*/
function generateFlowData ($ical, $date, $days) {
if ($ical == null || $date == null) return false;
$html = generateFlowHeader ($date) . "\n%s";
$end_date = clone $date; $end_date -> modify ("+{$days} days");
while ($date <= $end_date) {
if ($date -> format ("d") == "01") $html = sprintf (
$html,
generateFlowHeader ($date) . "\n%s"
);
$html = sprintf (
$html,
generateFlowEntryForDay($ical, $date) . "%s"
);
$date -> modify ("+1 day");
}
$html = sprintf ($html, "");
return $html;
}
/**
* Echoes the entire HTML for the flow body
*/
function echoFlowBody () {
global $ical;
echo generateFlowData (
$ical,
getRequestedStartDate(),
getRequestedDisplayedDays()
);
}