Chris@76
|
1 <?php
|
Chris@76
|
2 /**
|
Chris@76
|
3 * Simple Machines Forum (SMF)
|
Chris@76
|
4 *
|
Chris@76
|
5 * @package SMF
|
Chris@76
|
6 * @author Simple Machines
|
Chris@76
|
7 * @copyright 2011 Simple Machines
|
Chris@76
|
8 * @license http://www.simplemachines.org/about/smf/license.php BSD
|
Chris@76
|
9 *
|
Chris@76
|
10 * @version 2.0
|
Chris@76
|
11 */
|
Chris@76
|
12
|
Chris@76
|
13 // Editing or adding holidays.
|
Chris@76
|
14 function template_edit_holiday()
|
Chris@76
|
15 {
|
Chris@76
|
16 global $context, $settings, $options, $scripturl, $txt, $modSettings;
|
Chris@76
|
17
|
Chris@76
|
18 // Start with javascript for getting the calendar dates right.
|
Chris@76
|
19 echo '
|
Chris@76
|
20 <script type="text/javascript"><!-- // --><![CDATA[
|
Chris@76
|
21 var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
Chris@76
|
22
|
Chris@76
|
23 function generateDays()
|
Chris@76
|
24 {
|
Chris@76
|
25 var days = 0, selected = 0;
|
Chris@76
|
26 var dayElement = document.getElementById("day"), yearElement = document.getElementById("year"), monthElement = document.getElementById("month");
|
Chris@76
|
27
|
Chris@76
|
28 monthLength[1] = 28;
|
Chris@76
|
29 if (yearElement.options[yearElement.selectedIndex].value % 4 == 0)
|
Chris@76
|
30 monthLength[1] = 29;
|
Chris@76
|
31
|
Chris@76
|
32 selected = dayElement.selectedIndex;
|
Chris@76
|
33 while (dayElement.options.length)
|
Chris@76
|
34 dayElement.options[0] = null;
|
Chris@76
|
35
|
Chris@76
|
36 days = monthLength[monthElement.value - 1];
|
Chris@76
|
37
|
Chris@76
|
38 for (i = 1; i <= days; i++)
|
Chris@76
|
39 dayElement.options[dayElement.length] = new Option(i, i);
|
Chris@76
|
40
|
Chris@76
|
41 if (selected < days)
|
Chris@76
|
42 dayElement.selectedIndex = selected;
|
Chris@76
|
43 }
|
Chris@76
|
44 // ]]></script>';
|
Chris@76
|
45
|
Chris@76
|
46 // Show a form for all the holiday information.
|
Chris@76
|
47 echo '
|
Chris@76
|
48 <div id="admincenter">
|
Chris@76
|
49 <form action="', $scripturl, '?action=admin;area=managecalendar;sa=editholiday" method="post" accept-charset="', $context['character_set'], '">
|
Chris@76
|
50 <div class="cat_bar">
|
Chris@76
|
51 <h3 class="catbg">', $context['page_title'], '</h3>
|
Chris@76
|
52 </div>
|
Chris@76
|
53 <div class="windowbg">
|
Chris@76
|
54 <span class="topslice"><span></span></span>
|
Chris@76
|
55 <div class="content">
|
Chris@76
|
56 <dl class="settings">
|
Chris@76
|
57 <dt class="small_caption">
|
Chris@76
|
58 <strong>', $txt['holidays_title_label'], ':</strong>
|
Chris@76
|
59 </dt>
|
Chris@76
|
60 <dd class="small_caption">
|
Chris@76
|
61 <input type="text" name="title" value="', $context['holiday']['title'], '" size="55" maxlength="60" />
|
Chris@76
|
62 </dd>
|
Chris@76
|
63 <dt class="small_caption">
|
Chris@76
|
64 <strong>', $txt['calendar_year'], '</strong>
|
Chris@76
|
65 </dt>
|
Chris@76
|
66 <dd class="small_caption">
|
Chris@76
|
67 <select name="year" id="year" onchange="generateDays();">
|
Chris@76
|
68 <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected="selected"' : '', '>', $txt['every_year'], '</option>';
|
Chris@76
|
69 // Show a list of all the years we allow...
|
Chris@76
|
70 for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
|
Chris@76
|
71 echo '
|
Chris@76
|
72 <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected="selected"' : '', '>', $year, '</option>';
|
Chris@76
|
73
|
Chris@76
|
74 echo '
|
Chris@76
|
75 </select>
|
Chris@76
|
76 ', $txt['calendar_month'], '
|
Chris@76
|
77 <select name="month" id="month" onchange="generateDays();">';
|
Chris@76
|
78
|
Chris@76
|
79 // There are 12 months per year - ensure that they all get listed.
|
Chris@76
|
80 for ($month = 1; $month <= 12; $month++)
|
Chris@76
|
81 echo '
|
Chris@76
|
82 <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '</option>';
|
Chris@76
|
83
|
Chris@76
|
84 echo '
|
Chris@76
|
85 </select>
|
Chris@76
|
86 ', $txt['calendar_day'], '
|
Chris@76
|
87 <select name="day" id="day" onchange="generateDays();">';
|
Chris@76
|
88
|
Chris@76
|
89 // This prints out all the days in the current month - this changes dynamically as we switch months.
|
Chris@76
|
90 for ($day = 1; $day <= $context['holiday']['last_day']; $day++)
|
Chris@76
|
91 echo '
|
Chris@76
|
92 <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected="selected"' : '', '>', $day, '</option>';
|
Chris@76
|
93
|
Chris@76
|
94 echo '
|
Chris@76
|
95 </select>
|
Chris@76
|
96 </dd>
|
Chris@76
|
97 </dl>';
|
Chris@76
|
98
|
Chris@76
|
99 if ($context['is_new'])
|
Chris@76
|
100 echo '
|
Chris@76
|
101 <input type="submit" value="', $txt['holidays_button_add'], '" class="button_submit" />';
|
Chris@76
|
102 else
|
Chris@76
|
103 echo '
|
Chris@76
|
104 <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button_submit" />
|
Chris@76
|
105 <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button_submit" />
|
Chris@76
|
106 <input type="hidden" name="holiday" value="', $context['holiday']['id'], '" />';
|
Chris@76
|
107 echo '
|
Chris@76
|
108 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
|
Chris@76
|
109 </div>
|
Chris@76
|
110 <span class="botslice"><span></span></span>
|
Chris@76
|
111 </div>
|
Chris@76
|
112 </form>
|
Chris@76
|
113 </div>
|
Chris@76
|
114 <br class="clear" />';
|
Chris@76
|
115 }
|
Chris@76
|
116
|
Chris@76
|
117 ?> |