forked from fsi-tue/eei
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
127 lines (111 loc) · 4.86 KB
/
index.php
File metadata and controls
127 lines (111 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
require_once 'config.php';
require_once 'utils.php';
require_once 'event_type.php';
require_once 'i18n/i18n.php';
global $i18n, $CONFIG_TERM, $FILE_REVISION, $events;
// Load environment variables from the .env file
loadEnv('.env');
// Ensure the eei-registration folder exists
createEeiRegistrationFolder();
?>
<!DOCTYPE html>
<html lang="<?= $i18n->getLanguage() ?>">
<?php
require_once 'head.php';
?>
<body>
<!-- Icons courtesy of fontawesome.com under CC BY 4.0 License -->
<!-- BBQ-Grill icon by Smashicons from flaticon.com -->
<main>
<div class="container">
<span class="sub-title"><?= $CONFIG_TERM ?></span>
<h1 class="title">ERSTI-PROGRAMM</h1>
</div>
<div class="container">
<div class="language-switcher">
<label for="lang-selection" style="display: none;">Language</label> <!-- Hidden label for accessibility -->
<select id="lang-selection" aria-label="Select language">
<option value="de" <?= $i18n->getLanguage() === 'de' ? 'selected' : '' ?>>🇩🇪 Deutsch</option>
<option value="en" <?= $i18n->getLanguage() === 'en' ? 'selected' : '' ?>>🇬🇧 English</option>
</select>
</div>
</div>
<div class="container">
<?php
// Sort events by activity status and date
$sorted_events = $events;
usort($sorted_events, function (Event $a, Event $b) {
// Keep future events before past events
if ($a->isPast() && !$b->isPast()) {
return 1; // Past events appear after active ones
} elseif (!$a->isPast() && $b->isPast()) {
return -1;
}
// If both are past or both are future, sort by date
return $a->getEventStartUTS() - $b->getEventStartUTS();
});
// Render the sorted events
foreach ($sorted_events as $event) {
?>
<a href="event.php?e=<?= $event->link ?>&lang=<?= $i18n->getLanguage() ?>" class="event-link">
<div class="event-row <?= $event->isPast() ? 'past' : '' ?> <?= $event->eventIsTakingPlace() ? 'today' : '' ?>">
<div class="event-pill event-date-pill<?=$event->isMultiDayEvent() ? " event-pill-multiline" : "" ?>">
<?= $event->getEventDateString(['compact' => true, 'no_time' => true]) ?>
</div>
<div class="event-pill event-info-pill">
<span class="event-name"><?= htmlspecialchars($event->name) ?></span>
<?php
// Render icon using a span and the class from $event->icon ?>
<?php
if (!empty($event->icon)): ?>
<span class="event-icon icon <?= htmlspecialchars($event->icon) ?>"></span>
<?php
endif; ?>
</div>
</div>
</a>
<?php
} ?>
</div>
<br>
<div class="footnotes">
<p><?= $i18n['index_savedDataDisclaimer'] ?></p>
<br>
<!-- Using a container with row direction for buttons -->
<div class="container">
<div class="row">
<input id="btn-clr" type="submit" value="<?= $i18n['delete'] ?>"
onclick="if(confirm('<?= addslashes($i18n['index_confirmDelete']) ?>')) { localStorage.clear(); alert('<?= addslashes($i18n['index_deletedData']) ?>'); }">
<input class="link" id="calendar-subscription-button" type="button" value="<?=$i18n['calendar_subscribe']?>">
<a href="https://github.com/fsi-tue/eei">
<!-- Removed inner div, styling applied directly to link -->
<span class="link"> <!-- Use span or div if needed, styled by .link -->
Source Code auf GitHub
</span>
</a>
</div>
</div>
</div>
<!-- Hidden Modal for Calendar Subscription -->
<div id="calendar-subscription-modal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<label for="calendar-link"><?=$i18n['calendar_subscribe_text']?><br>
<input type="text" id="calendar-link" name="calendar-link" value="https://eei.fsi.uni-tuebingen.de/calendar.php?allevents" readonly>
</label>
</div>
</div>
</main>
<script>
// Language change handler
document.getElementById('lang-selection').addEventListener('change', function () {
// Construct URL without query string first
let baseUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
// Add the new language parameter
location.href = `${baseUrl}?lang=${this.value}`;
});
</script>
<script src="js/calendarModal.js"></script>
</body>
</html>