/
ManageCalendar.template.php
115 lines (99 loc) · 3.93 KB
/
ManageCalendar.template.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
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
<?php
/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines
* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
*/
// Editing or adding holidays.
function template_edit_holiday()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
// Start with javascript for getting the calendar dates right.
echo '
<script type="text/javascript"><!-- // --><![CDATA[
var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function generateDays()
{
var days = 0, selected = 0;
var dayElement = document.getElementById("day"), yearElement = document.getElementById("year"), monthElement = document.getElementById("month");
monthLength[1] = 28;
if (yearElement.options[yearElement.selectedIndex].value % 4 == 0)
monthLength[1] = 29;
selected = dayElement.selectedIndex;
while (dayElement.options.length)
dayElement.options[0] = null;
days = monthLength[monthElement.value - 1];
for (i = 1; i <= days; i++)
dayElement.options[dayElement.length] = new Option(i, i);
if (selected < days)
dayElement.selectedIndex = selected;
}
// ]]></script>';
// Show a form for all the holiday information.
echo '
<div id="admincenter">
<form action="', $scripturl, '?action=admin;area=managecalendar;sa=editholiday" method="post" accept-charset="', $context['character_set'], '">
<div class="cat_bar">
<h3 class="catbg">', $context['page_title'], '</h3>
</div>
<div class="windowbg">
<div class="content">
<dl class="settings">
<dt class="small_caption">
<strong>', $txt['holidays_title_label'], ':</strong>
</dt>
<dd class="small_caption">
<input type="text" name="title" value="', $context['holiday']['title'], '" size="55" maxlength="60">
</dd>
<dt class="small_caption">
<strong>', $txt['calendar_year'], '</strong>
</dt>
<dd class="small_caption">
<select name="year" id="year" onchange="generateDays();">
<option value="0000"', $context['holiday']['year'] == '0000' ? ' selected="selected"' : '', '>', $txt['every_year'], '</option>';
// Show a list of all the years we allow...
for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
echo '
<option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected="selected"' : '', '>', $year, '</option>';
echo '
</select>
', $txt['calendar_month'], '
<select name="month" id="month" onchange="generateDays();">';
// There are 12 months per year - ensure that they all get listed.
for ($month = 1; $month <= 12; $month++)
echo '
<option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '</option>';
echo '
</select>
', $txt['calendar_day'], '
<select name="day" id="day" onchange="generateDays();">';
// This prints out all the days in the current month - this changes dynamically as we switch months.
for ($day = 1; $day <= $context['holiday']['last_day']; $day++)
echo '
<option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected="selected"' : '', '>', $day, '</option>';
echo '
</select>
</dd>
</dl>';
if ($context['is_new'])
echo '
<input type="submit" value="', $txt['holidays_button_add'], '" class="button_submit">';
else
echo '
<input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button_submit">
<input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button_submit">
<input type="hidden" name="holiday" value="', $context['holiday']['id'], '">';
echo '
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
</div>
</div>
</form>
</div>
<br class="clear">';
}
?>