format('Y'); $month_n = (int)$today->format('n'); $end_year = ($month_n == 12) ? $year + 1 : $year; $default_start = $today->format('Y-m-d'); $default_end = $end_year . '-12-31'; $start_date = isset($_GET['start']) && $_GET['start'] !== '' ? trim($_GET['start']) : $default_start; $end_date = isset($_GET['end']) && $_GET['end'] !== '' ? trim($_GET['end']) : $default_end; if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $start_date)) $start_date = $default_start; if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $end_date)) $end_date = $default_end; /* --------------------------------------------------------------- Calendar month for calendar view --------------------------------------------------------------- */ $cal_month_raw = isset($_GET['month']) ? trim($_GET['month']) : $today->format('Y-m'); if (!preg_match('/^\d{4}-\d{2}$/', $cal_month_raw)) { $cal_month_raw = $today->format('Y-m'); } $cal_month = $cal_month_raw; $cal_dt = new DateTime($cal_month . '-01'); $prev_dt = clone $cal_dt; $prev_dt->modify('-1 month'); $next_dt = clone $cal_dt; $next_dt->modify('+1 month'); $prev_month = $prev_dt->format('Y-m'); $next_month = $next_dt->format('Y-m'); /* --------------------------------------------------------------- Series filter --------------------------------------------------------------- */ if (isset($_GET['series'])) { $filter_series = (int)$_GET['series']; } elseif (!isset($_GET['start']) && !isset($_GET['month'])) { $filter_series = $default_sid; // first visit: default to Theory/Experimental } else { $filter_series = 0; } /* --------------------------------------------------------------- Fetch seminars --------------------------------------------------------------- */ if ($view === 'calendar') { $range_start = $cal_month . '-01'; $range_end = $cal_dt->format('Y-m-t'); } else { $range_start = $start_date; $range_end = $end_date; } if ($filter_series > 0) { $stmt = $db->prepare( "SELECT s.*, ss.name AS series_name FROM seminars s LEFT JOIN seminar_series ss ON ss.id = s.series_id WHERE s.seminar_date >= ? AND s.seminar_date <= ? AND s.series_id = ? AND s.visible = 1 ORDER BY s.seminar_date ASC" ); $stmt->execute(array($range_start, $range_end, $filter_series)); } else { $stmt = $db->prepare( "SELECT s.*, ss.name AS series_name FROM seminars s LEFT JOIN seminar_series ss ON ss.id = s.series_id WHERE s.seminar_date >= ? AND s.seminar_date <= ? AND s.visible = 1 ORDER BY s.seminar_date ASC" ); $stmt->execute(array($range_start, $range_end)); } $seminars = $stmt->fetchAll(); // Index by day-of-month for calendar view $by_day = array(); if ($view === 'calendar') { foreach ($seminars as $s) { $day = (int)(new DateTime($s['seminar_date']))->format('j'); $by_day[$day][] = $s; } } /* --------------------------------------------------------------- ICS link (preserves series filter) --------------------------------------------------------------- */ $ics_url = '/seminars/seminars.ics.php' . ($filter_series > 0 ? '?series=' . $filter_series : ''); $extra_head = ''; page_start('Seminar Calendar', $extra_head); page_heading('Seminar Calendar', 'All scheduled visitor talks. Click a name to view the schedule.'); ?>
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| '; $cell++; } // Day cells for ($day = 1; $day <= $days_in_month; $day++) { if ($cell > 0 && $cell % 7 === 0) echo ' | ||||||
| ';
echo ' ';
if ($is_today) {
echo '' . $day . '';
} else {
echo $day;
}
echo ' ';
if (isset($by_day[$day])) {
foreach ($by_day[$day] as $s) {
$status = seminar_status($s);
$ev_class = ($status === 'finalized') ? 'cal-event ev-finalized' : 'cal-event';
echo '';
if ($status === 'finalized') {
echo ''
. h($s['speaker_name']) . '';
} else {
echo ''
. h($s['speaker_name']) . '';
}
if (!empty($s['seminar_start_time'])) {
echo ' ';
}
}
echo '' . format_time($s['seminar_start_time']) . ' ';
}
echo ' | ';
$cell++;
}
// Trailing empty cells
while ($cell % 7 !== 0) {
echo ''; $cell++; } echo ' |
No visits scheduled between and .
Showing visit between and .
📅 Subscribe to this calendar — right-click the link and copy the URL, then use “Subscribe to calendar” in Apple Calendar, Google Calendar, or Outlook to keep it updated automatically. Or click the link to do a one-time import.