-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterms.php
46 lines (38 loc) · 1.14 KB
/
terms.php
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
<?php
/** A list of all terms */
$TERMS = array(
202310 => 'Spring 2023',
202280 => 'Fall 2022',
2022533 => 'Summer 2022 - Full Third Term',
2022531 => 'Summer 2022 - First Session',
2022532 => 'Summer 2022 - Second Session',
202210 => 'Spring 2022',
202180 => 'Fall 2021',
2021533 => 'Summer 2021 - Full Third Term',
2021531 => 'Summer 2021 - First Session',
2021532 => 'Summer 2021 - Second Session',
202110 => 'Spring 2021',
202080 => 'Fall 2020',
);
/** The default term */
$DEFAULT_TERM = $TERMS[202080];
/** Retrieves the text representation of the term name like 'Fall 2023' */
function getTerm(int $term)
{
global $TERMS, $DEFAULT_TERM;
if (isset($TERMS[$term])) {
return $TERMS[$term];
} else {
return $DEFAULT_TERM;
}
}
/** Renders a list of options for a select dropdown based on the array of terms above */
function renderTermOptions(string $activeTerm = null)
{
global $TERMS;
foreach ($TERMS as $key => $value) {
?>
<option value="<?= $key; ?>" <?= isset($activeTerm) && $activeTerm == $key ? "selected" : "" ?>><?= $value ?></option>
<?php
}
}