|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Simple Machines Forum (SMF) |
|
4
|
|
|
* |
|
5
|
|
|
* @package SMF |
|
6
|
|
|
* @author Simple Machines http://www.simplemachines.org |
|
7
|
|
|
* @copyright 2016 Simple Machines and individual contributors |
|
8
|
|
|
* @license http://www.simplemachines.org/about/smf/license.php BSD |
|
9
|
|
|
* |
|
10
|
|
|
* @version 2.1 Beta 3 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Our main calendar template, which encapsulates weeks and months. |
|
15
|
|
|
*/ |
|
16
|
|
|
function template_main() |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
global $context; |
|
19
|
|
|
|
|
20
|
|
|
// The main calendar wrapper. |
|
21
|
|
|
echo '<div id="calendar">'; |
|
22
|
|
|
|
|
23
|
|
|
// Show the mini-blocks if they're enabled. |
|
24
|
|
|
if (empty($context['blocks_disabled'])) |
|
25
|
|
|
{ |
|
26
|
|
|
echo ' |
|
27
|
|
|
<div id="month_grid"> |
|
28
|
|
|
', template_show_month_grid('prev', true), ' |
|
29
|
|
|
', template_show_month_grid('current', true), ' |
|
30
|
|
|
', template_show_month_grid('next', true), ' |
|
31
|
|
|
</div> |
|
32
|
|
|
'; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
// Are we viewing a specific week or a specific month? |
|
36
|
|
|
if (isset($_GET['viewweek'])) |
|
37
|
|
|
{ |
|
38
|
|
|
echo ' |
|
39
|
|
|
<div id="main_grid"> |
|
40
|
|
|
', template_show_week_grid('main'), ' |
|
41
|
|
|
</div> |
|
42
|
|
|
'; |
|
43
|
|
|
} |
|
44
|
|
|
else |
|
45
|
|
|
{ |
|
46
|
|
|
echo ' |
|
47
|
|
|
<div id="main_grid"> |
|
48
|
|
|
', template_show_month_grid('main'), ' |
|
49
|
|
|
</div> |
|
50
|
|
|
'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// Close our wrapper. |
|
54
|
|
|
echo ' |
|
55
|
|
|
</div>'; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Display a monthly calendar grid. |
|
60
|
|
|
* |
|
61
|
|
|
* @param string $grid_name The grid name |
|
62
|
|
|
* @param bool $is_mini Is this a mini grid? |
|
63
|
|
|
* @return void|bool Returns false if the grid doesn't exist. |
|
64
|
|
|
*/ |
|
65
|
|
|
function template_show_month_grid($grid_name, $is_mini = false) |
|
66
|
|
|
{ |
|
67
|
|
|
global $context, $settings, $txt, $scripturl, $modSettings; |
|
68
|
|
|
|
|
69
|
|
|
// If the grid doesn't exist, no point in proceeding. |
|
70
|
|
|
if (!isset($context['calendar_grid_' . $grid_name])) |
|
71
|
|
|
return false; |
|
72
|
|
|
|
|
73
|
|
|
// A handy little pointer variable. |
|
74
|
|
|
$calendar_data = &$context['calendar_grid_' . $grid_name]; |
|
75
|
|
|
|
|
76
|
|
|
// Some conditions for whether or not we should show the week links *here*. |
|
77
|
|
|
if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
78
|
|
|
$show_week_links = true; |
|
79
|
|
|
else |
|
80
|
|
|
$show_week_links = false; |
|
81
|
|
|
|
|
82
|
|
|
// Assuming that we've not disabled it, show the title block! |
|
83
|
|
|
if (empty($calendar_data['disable_title'])) |
|
84
|
|
|
{ |
|
85
|
|
|
echo ' |
|
86
|
|
|
<div class="cat_bar"> |
|
87
|
|
|
<h3 class="catbg centertext largetext">'; |
|
88
|
|
|
|
|
89
|
|
|
// Previous Link: If we're showing prev / next and it's not a mini-calendar. |
|
90
|
|
|
if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
91
|
|
|
{ |
|
92
|
|
|
echo ' |
|
93
|
|
|
<span class="floatleft"> |
|
94
|
|
|
<a href="', $calendar_data['previous_calendar']['href'], '">«</a> |
|
95
|
|
|
</span> |
|
96
|
|
|
'; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
// Next Link: if we're showing prev / next and it's not a mini-calendar. |
|
100
|
|
View Code Duplication |
if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
|
|
|
|
|
101
|
|
|
{ |
|
102
|
|
|
echo ' |
|
103
|
|
|
<span class="floatright"> |
|
104
|
|
|
<a href="', $calendar_data['next_calendar']['href'], '">»</a> |
|
105
|
|
|
</span> |
|
106
|
|
|
'; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
// Arguably the most exciting part, the title! |
|
110
|
|
|
echo '<a href="', $scripturl, '?action=calendar;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], '">', $txt['months_titles'][$calendar_data['current_month']], ' ', $calendar_data['current_year'], '</a>'; |
|
111
|
|
|
|
|
112
|
|
|
echo ' |
|
113
|
|
|
</h3> |
|
114
|
|
|
</div> |
|
115
|
|
|
'; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
// Finally, the main calendar table. |
|
119
|
|
|
echo '<table class="calendar_table">'; |
|
120
|
|
|
|
|
121
|
|
|
// Show each day of the week. |
|
122
|
|
|
if (empty($calendar_data['disable_day_titles'])) |
|
123
|
|
|
{ |
|
124
|
|
|
echo '<tr>'; |
|
125
|
|
|
|
|
126
|
|
|
// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
|
127
|
|
|
if ($show_week_links === true) |
|
128
|
|
|
echo '<th> </th>'; |
|
129
|
|
|
|
|
130
|
|
|
// Now, loop through each actual day of the week. |
|
131
|
|
|
foreach ($calendar_data['week_days'] as $day) |
|
132
|
|
|
{ |
|
133
|
|
|
echo '<th class="days" scope="col">', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '</th>'; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
echo '</tr>'; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
// Our looping begins on a per-week basis. |
|
140
|
|
|
foreach ($calendar_data['weeks'] as $week) |
|
141
|
|
|
{ |
|
142
|
|
|
|
|
143
|
|
|
// Some useful looping variables. |
|
144
|
|
|
$current_month_started = false; |
|
145
|
|
|
$count = 1; |
|
146
|
|
|
$final_count = 1; |
|
147
|
|
|
|
|
148
|
|
|
echo '<tr class="days_wrapper">'; |
|
149
|
|
|
|
|
150
|
|
|
// This is where we add the actual week link, if enabled on this location. |
|
151
|
|
|
if ($show_week_links === true) |
|
152
|
|
|
{ |
|
153
|
|
|
echo ' |
|
154
|
|
|
<td class="windowbg2 weeks"> |
|
155
|
|
|
<a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '" title="', $txt['calendar_view_week'], '">»</a> |
|
156
|
|
|
</td> |
|
157
|
|
|
'; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
// Now loop through each day in the week we're on. |
|
161
|
|
|
foreach ($week['days'] as $day) |
|
162
|
|
|
{ |
|
163
|
|
|
// What classes should each day inherit? Day is default. |
|
164
|
|
|
$classes = array('days'); |
|
165
|
|
|
if (!empty($day['day'])) |
|
166
|
|
|
{ |
|
167
|
|
|
|
|
168
|
|
|
// Default Classes (either compact or comfortable and either calendar_today or windowbg). |
|
169
|
|
|
$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
|
170
|
|
|
$classes[] = !empty($day['is_today']) ? 'calendar_today' : 'windowbg'; |
|
171
|
|
|
|
|
172
|
|
|
// Additional classes are given for events, holidays, and birthdays. |
|
173
|
|
View Code Duplication |
if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
|
|
|
|
|
|
174
|
|
|
{ |
|
175
|
|
|
if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1,3))) |
|
176
|
|
|
$classes[] = 'events'; |
|
177
|
|
|
elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2,3))) |
|
178
|
|
|
$classes[] = 'events'; |
|
179
|
|
|
} |
|
180
|
|
View Code Duplication |
if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
|
|
|
|
|
|
181
|
|
|
{ |
|
182
|
|
|
if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1,3))) |
|
183
|
|
|
$classes[] = 'holidays'; |
|
184
|
|
|
elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2,3))) |
|
185
|
|
|
$classes[] = 'holidays'; |
|
186
|
|
|
} |
|
187
|
|
View Code Duplication |
if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
|
|
|
|
|
|
188
|
|
|
{ |
|
189
|
|
|
if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1,3))) |
|
190
|
|
|
$classes[] = 'birthdays'; |
|
191
|
|
|
elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2,3))) |
|
192
|
|
|
$classes[] = 'birthdays'; |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
else |
|
196
|
|
|
// Default Classes (either compact or comfortable and disabled). |
|
197
|
|
|
$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
|
198
|
|
|
$classes[] = 'disabled'; |
|
199
|
|
|
|
|
200
|
|
|
// Now, implode the classes for each day. |
|
201
|
|
|
echo '<td class="', implode(' ', $classes), '">'; |
|
202
|
|
|
|
|
203
|
|
|
// If it's within this current month, go ahead and begin. |
|
204
|
|
|
if (!empty($day['day'])) |
|
205
|
|
|
{ |
|
206
|
|
|
|
|
207
|
|
|
// If it's the first day of this month and not a mini-calendar, we'll add the month title - whether short or full. |
|
208
|
|
|
$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
|
209
|
|
|
|
|
210
|
|
|
// The actual day number - be it a link, or just plain old text! |
|
211
|
|
|
if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
212
|
|
|
echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
213
|
|
|
else |
|
214
|
|
|
echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
215
|
|
|
|
|
216
|
|
|
// A lot of stuff, we're not showing on mini-calendars to conserve space. |
|
217
|
|
|
if ($is_mini === false) |
|
218
|
|
|
{ |
|
219
|
|
|
// Holidays are always fun, let's show them! |
|
220
|
|
|
if (!empty($day['holidays'])) |
|
221
|
|
|
echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
222
|
|
|
|
|
223
|
|
|
// Happy Birthday Dear, Member! |
|
224
|
|
|
if (!empty($day['birthdays'])) |
|
225
|
|
|
{ |
|
226
|
|
|
echo ' |
|
227
|
|
|
<div class="smalltext"> |
|
228
|
|
|
<span class="birthday">', $txt['birthdays'], '</span> '; |
|
229
|
|
|
|
|
230
|
|
|
/* Each of the birthdays has: |
|
231
|
|
|
id, name (person), age (if they have one set?), and is_last. (last in list?) */ |
|
232
|
|
|
$use_js_hide = empty($context['show_all_birthdays']) && count($day['birthdays']) > 15; |
|
233
|
|
|
$birthday_count = 0; |
|
234
|
|
|
foreach ($day['birthdays'] as $member) |
|
235
|
|
|
{ |
|
236
|
|
|
echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
|
237
|
|
|
|
|
238
|
|
|
// 9...10! Let's stop there. |
|
239
|
|
|
if ($birthday_count == 10 && $use_js_hide) |
|
240
|
|
|
// !!TODO - Inline CSS and JavaScript should be moved. |
|
241
|
|
|
echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
|
242
|
|
|
|
|
243
|
|
|
++$birthday_count; |
|
244
|
|
|
} |
|
245
|
|
|
if ($use_js_hide) |
|
246
|
|
|
echo '</span>'; |
|
247
|
|
|
|
|
248
|
|
|
echo '</div>'; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
// Any special posted events? |
|
252
|
|
|
if (!empty($day['events'])) |
|
253
|
|
|
{ |
|
254
|
|
|
// Sort events by start time (all day events will be listed first) |
|
255
|
|
View Code Duplication |
uasort($day['events'], function ($a, $b) { |
|
|
|
|
|
|
256
|
|
|
if ($a['start_timestamp'] == $b['start_timestamp']) |
|
257
|
|
|
return 0; |
|
258
|
|
|
return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
259
|
|
|
}); |
|
260
|
|
|
|
|
261
|
|
|
echo ' |
|
262
|
|
|
<div class="smalltext lefttext"> |
|
263
|
|
|
<span class="event">', $txt['events'], '</span><br>'; |
|
264
|
|
|
|
|
265
|
|
|
/* The events are made up of: |
|
266
|
|
|
title, href, is_last, can_edit (are they allowed to?), and modify_href. */ |
|
267
|
|
|
foreach ($day['events'] as $event) |
|
268
|
|
|
{ |
|
269
|
|
|
$event_icons_needed = ($event['can_edit'] || $event['can_export']) ? true : false; |
|
270
|
|
|
|
|
271
|
|
|
echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
|
272
|
|
|
|
|
273
|
|
|
if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
274
|
|
|
echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
275
|
|
|
elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
276
|
|
|
echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
277
|
|
|
elseif (!empty($event['allday'])) |
|
278
|
|
|
echo $txt['calendar_allday']; |
|
279
|
|
|
|
|
280
|
|
|
echo '</span>'; |
|
281
|
|
|
|
|
282
|
|
View Code Duplication |
if (!empty($event['location'])) |
|
|
|
|
|
|
283
|
|
|
echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
284
|
|
|
|
|
285
|
|
|
if ($event['can_edit'] || $event['can_export']) |
|
286
|
|
|
{ |
|
287
|
|
|
echo ' <span class="modify_event_links">'; |
|
288
|
|
|
|
|
289
|
|
|
// If they can edit the event, show an icon they can click on.... |
|
290
|
|
|
if ($event['can_edit']) |
|
291
|
|
|
{ |
|
292
|
|
|
echo ' |
|
293
|
|
|
<a class="modify_event" href="', $event['modify_href'], '"> |
|
294
|
|
|
<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
|
295
|
|
|
</a>'; |
|
296
|
|
|
} |
|
297
|
|
|
// Exporting! |
|
298
|
|
|
if ($event['can_export']) |
|
299
|
|
|
{ |
|
300
|
|
|
echo ' |
|
301
|
|
|
<a class="modify_event" href="', $event['export_href'], '"> |
|
302
|
|
|
<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
|
303
|
|
|
</a>'; |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
echo '</span><br class="clear">'; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
echo '</div>'; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
echo '</div>'; |
|
313
|
|
|
} |
|
314
|
|
|
} |
|
315
|
|
|
$current_month_started = $count; |
|
316
|
|
|
} |
|
317
|
|
|
// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
|
318
|
|
|
elseif ($is_mini === false) |
|
319
|
|
|
{ |
|
320
|
|
|
if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
321
|
|
|
echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- + 1, '</a>'; |
|
322
|
|
|
elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
323
|
|
|
echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
// Close this day and increase var count. |
|
327
|
|
|
echo '</td>'; |
|
328
|
|
|
++$count; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
echo '</tr>'; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
// Quick Month Navigation + Post Event Link on Main Grids! |
|
335
|
|
|
if ($is_mini === false) |
|
336
|
|
|
template_calendar_base($show_week_links === true ? 8 : 7); |
|
337
|
|
|
|
|
338
|
|
|
// The end of our main table. |
|
339
|
|
|
echo '</table>'; |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* Shows a weekly grid |
|
344
|
|
|
* |
|
345
|
|
|
* @param string $grid_name The name of the grid |
|
346
|
|
|
* @return void|bool Returns false if the grid doesn't exist |
|
347
|
|
|
*/ |
|
348
|
|
|
function template_show_week_grid($grid_name) |
|
349
|
|
|
{ |
|
350
|
|
|
global $context, $settings, $txt, $scripturl, $modSettings; |
|
351
|
|
|
|
|
352
|
|
|
// We might have no reason to proceed, if the variable isn't there. |
|
353
|
|
|
if (!isset($context['calendar_grid_' . $grid_name])) |
|
354
|
|
|
return false; |
|
355
|
|
|
|
|
356
|
|
|
// Handy pointer. |
|
357
|
|
|
$calendar_data = &$context['calendar_grid_' . $grid_name]; |
|
358
|
|
|
|
|
359
|
|
|
// At the very least, we have one month. Possibly two, though. |
|
360
|
|
|
$iteration = 1; |
|
361
|
|
|
$num_months = count($calendar_data['months']); |
|
362
|
|
|
foreach ($calendar_data['months'] as $month_data) |
|
363
|
|
|
{ |
|
364
|
|
|
// For our first iteration, we'll add a nice header! |
|
365
|
|
|
if ($iteration == 1) |
|
366
|
|
|
{ |
|
367
|
|
|
echo ' |
|
368
|
|
|
<div class="cat_bar"> |
|
369
|
|
|
<h3 class="catbg centertext largetext">'; |
|
370
|
|
|
// Previous Week Link... |
|
371
|
|
View Code Duplication |
if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
|
|
|
|
|
372
|
|
|
{ |
|
373
|
|
|
echo ' |
|
374
|
|
|
<span class="floatleft"> |
|
375
|
|
|
<a href="', $calendar_data['previous_week']['href'], '">«</a> |
|
376
|
|
|
</span> |
|
377
|
|
|
'; |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
// Next Week Link... |
|
381
|
|
View Code Duplication |
if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
|
|
|
|
|
382
|
|
|
{ |
|
383
|
|
|
echo ' |
|
384
|
|
|
<span class="floatright"> |
|
385
|
|
|
<a href="', $calendar_data['next_week']['href'], '">»</a> |
|
386
|
|
|
</span>'; |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
// The Month Title + Week Number... |
|
390
|
|
|
if (!empty($calendar_data['week_title'])) |
|
391
|
|
|
echo $calendar_data['week_title']; |
|
392
|
|
|
|
|
393
|
|
|
echo ' |
|
394
|
|
|
</h3> |
|
395
|
|
|
</div>'; |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
// Our actual month... |
|
399
|
|
|
echo ' |
|
400
|
|
|
<div class="week_month_title"> |
|
401
|
|
|
<a href="', $scripturl, '?action=calendar;month=', $month_data['current_month'], '"> |
|
402
|
|
|
', $txt['months_titles'][$month_data['current_month']], ' |
|
403
|
|
|
</a> |
|
404
|
|
|
</div>'; |
|
405
|
|
|
|
|
406
|
|
|
// The main table grid for $this week. |
|
407
|
|
|
echo ' |
|
408
|
|
|
<table class="table_grid calendar_week"> |
|
409
|
|
|
<tr> |
|
410
|
|
|
<th class="days" scope="col">', $txt['calendar_day'], '</th> |
|
411
|
|
|
<th class="days" scope="col">', $txt['events'], '</th> |
|
412
|
|
|
<th class="days" scope="col">', $txt['calendar_prompt'], '</th> |
|
413
|
|
|
<th class="days" scope="col">', $txt['birthdays'], '</th> |
|
414
|
|
|
</tr>'; |
|
415
|
|
|
// Each day of the week. |
|
416
|
|
|
foreach ($month_data['days'] as $day) |
|
417
|
|
|
{ |
|
418
|
|
|
// How should we be highlighted or otherwise not...? |
|
419
|
|
|
$classes = array('days'); |
|
420
|
|
|
$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
|
421
|
|
|
$classes[] = !empty($day['is_today']) ? 'calendar_today' : 'windowbg'; |
|
422
|
|
|
|
|
423
|
|
|
echo ' |
|
424
|
|
|
<tr class="days_wrapper"> |
|
425
|
|
|
<td class="', implode(' ', $classes), ' act_day">'; |
|
426
|
|
|
// Should the day number be a link? |
|
427
|
|
|
if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
428
|
|
|
echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
429
|
|
|
else |
|
430
|
|
|
echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
431
|
|
|
|
|
432
|
|
|
echo '</td> |
|
433
|
|
|
<td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">'; |
|
434
|
|
|
// Show any events... |
|
435
|
|
|
if (!empty($day['events'])) |
|
436
|
|
|
{ |
|
437
|
|
|
// Sort events by start time (all day events will be listed first) |
|
438
|
|
View Code Duplication |
uasort($day['events'], function ($a, $b) { |
|
|
|
|
|
|
439
|
|
|
if ($a['start_timestamp'] == $b['start_timestamp']) |
|
440
|
|
|
return 0; |
|
441
|
|
|
return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
442
|
|
|
}); |
|
443
|
|
|
|
|
444
|
|
|
foreach ($day['events'] as $event) |
|
445
|
|
|
{ |
|
446
|
|
|
echo '<div class="event_wrapper">'; |
|
447
|
|
|
|
|
448
|
|
|
$event_icons_needed = ($event['can_edit'] || $event['can_export']) ? true : false; |
|
449
|
|
|
|
|
450
|
|
|
echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
|
451
|
|
|
|
|
452
|
|
|
if (!empty($event['start_time_local'])) |
|
453
|
|
|
echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
454
|
|
|
else |
|
455
|
|
|
echo $txt['calendar_allday']; |
|
456
|
|
|
|
|
457
|
|
|
echo '</span>'; |
|
458
|
|
|
|
|
459
|
|
View Code Duplication |
if (!empty($event['location'])) |
|
|
|
|
|
|
460
|
|
|
echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
461
|
|
|
|
|
462
|
|
|
if (!empty($event_icons_needed)) |
|
463
|
|
|
{ |
|
464
|
|
|
echo ' <span class="modify_event_links">'; |
|
465
|
|
|
|
|
466
|
|
|
// If they can edit the event, show a star they can click on.... |
|
467
|
|
View Code Duplication |
if (!empty($event['can_edit'])) |
|
|
|
|
|
|
468
|
|
|
{ |
|
469
|
|
|
echo ' |
|
470
|
|
|
<a class="modify_event" href="', $event['modify_href'], '"> |
|
471
|
|
|
<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
|
472
|
|
|
</a>'; |
|
473
|
|
|
} |
|
474
|
|
|
// Can we export? Sweet. |
|
475
|
|
View Code Duplication |
if (!empty($event['can_export'])) |
|
|
|
|
|
|
476
|
|
|
{ |
|
477
|
|
|
echo ' |
|
478
|
|
|
<a class="modify_event" href="', $event['export_href'], '"> |
|
479
|
|
|
<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
|
480
|
|
|
</a>'; |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
echo '</span><br class="clear">'; |
|
484
|
|
|
} |
|
485
|
|
|
|
|
486
|
|
|
echo ' |
|
487
|
|
|
</div>'; |
|
488
|
|
|
} |
|
489
|
|
|
if (!empty($context['can_post'])) |
|
490
|
|
|
{ |
|
491
|
|
|
echo ' |
|
492
|
|
|
<div class="week_add_event"> |
|
493
|
|
|
<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a> |
|
494
|
|
|
</div> |
|
495
|
|
|
<br class="clear">'; |
|
496
|
|
|
} |
|
497
|
|
|
} |
|
498
|
|
View Code Duplication |
else |
|
|
|
|
|
|
499
|
|
|
{ |
|
500
|
|
|
if (!empty($context['can_post'])) |
|
501
|
|
|
{ |
|
502
|
|
|
echo ' |
|
503
|
|
|
<div class="week_add_event"> |
|
504
|
|
|
<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a> |
|
505
|
|
|
</div>'; |
|
506
|
|
|
} |
|
507
|
|
|
} |
|
508
|
|
|
echo '</td> |
|
509
|
|
|
<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
|
510
|
|
|
// Show any holidays! |
|
511
|
|
|
if (!empty($day['holidays'])) |
|
512
|
|
|
echo implode('<br>', $day['holidays']); |
|
513
|
|
|
|
|
514
|
|
|
echo '</td> |
|
515
|
|
|
<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">'; |
|
516
|
|
|
// Show any birthdays... |
|
517
|
|
|
if (!empty($day['birthdays'])) |
|
518
|
|
|
{ |
|
519
|
|
View Code Duplication |
foreach ($day['birthdays'] as $member) |
|
|
|
|
|
|
520
|
|
|
{ |
|
521
|
|
|
echo ' |
|
522
|
|
|
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], '</a> |
|
523
|
|
|
', isset($member['age']) ? ' (' . $member['age'] . ')' : '', ' |
|
524
|
|
|
', $member['is_last'] ? '' : '<br>'; |
|
525
|
|
|
} |
|
526
|
|
|
} |
|
527
|
|
|
echo '</td> |
|
528
|
|
|
</tr>'; |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
// We'll show the lower column after our last month is shown. |
|
532
|
|
|
if ($iteration == $num_months) |
|
533
|
|
|
template_calendar_base(4); |
|
534
|
|
|
|
|
535
|
|
|
// Increase iteration for loop counting. |
|
536
|
|
|
++$iteration; |
|
537
|
|
|
|
|
538
|
|
|
echo ' |
|
539
|
|
|
</table>'; |
|
540
|
|
|
} |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
/** |
|
544
|
|
|
* Calendar Grid Base |
|
545
|
|
|
* |
|
546
|
|
|
* This function is ONLY designed for use |
|
547
|
|
|
* within an existing table element. |
|
548
|
|
|
* |
|
549
|
|
|
* @param int $col_span How many columns to span |
|
550
|
|
|
*/ |
|
551
|
|
|
function template_calendar_base($col_span = 1) |
|
552
|
|
|
{ |
|
553
|
|
|
global $context, $scripturl, $txt; |
|
554
|
|
|
echo ' |
|
555
|
|
|
<tr> |
|
556
|
|
|
<td class="calendar_base" colspan="', $col_span, '"> |
|
557
|
|
|
', template_button_strip($context['calendar_buttons'], 'right'), ' |
|
558
|
|
|
<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
|
559
|
|
|
<select name="month" id="input_month">'; |
|
560
|
|
|
|
|
561
|
|
|
// Show a select box with all the months. |
|
562
|
|
|
foreach ($txt['months_short'] as $number => $month) |
|
563
|
|
|
{ |
|
564
|
|
|
echo ' |
|
565
|
|
|
<option value="', $number, '"', $number == $context['current_month'] ? ' selected' : '', '>', $month, '</option>'; |
|
566
|
|
|
} |
|
567
|
|
|
|
|
568
|
|
|
echo ' |
|
569
|
|
|
</select> |
|
570
|
|
|
<select name="year">'; |
|
571
|
|
|
|
|
572
|
|
|
// Show a link for every year..... |
|
573
|
|
|
for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) |
|
574
|
|
|
{ |
|
575
|
|
|
echo '<option value="', $year, '"', $year == $context['current_year'] ? ' selected' : '', '>', $year, '</option>'; |
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
echo '</select> |
|
579
|
|
|
<input type="submit" class="button_submit" id="view_button" value="', $txt['view'], '"> |
|
580
|
|
|
</form> |
|
581
|
|
|
</td> |
|
582
|
|
|
</tr>'; |
|
583
|
|
|
} |
|
584
|
|
|
|
|
585
|
|
|
/** |
|
586
|
|
|
* Template for posting a calendar event. |
|
587
|
|
|
*/ |
|
588
|
|
|
function template_event_post() |
|
589
|
|
|
{ |
|
590
|
|
|
global $context, $txt, $scripturl, $modSettings; |
|
591
|
|
|
|
|
592
|
|
|
echo ' |
|
593
|
|
|
<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">'; |
|
594
|
|
|
|
|
595
|
|
|
if (!empty($context['event']['new'])) |
|
596
|
|
|
echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
597
|
|
|
|
|
598
|
|
|
// Start the main table. |
|
599
|
|
|
echo ' |
|
600
|
|
|
<div id="post_event"> |
|
601
|
|
|
<div class="cat_bar"> |
|
602
|
|
|
<h3 class="catbg"> |
|
603
|
|
|
', $context['page_title'], ' |
|
604
|
|
|
</h3> |
|
605
|
|
|
</div>'; |
|
606
|
|
|
|
|
607
|
|
|
if (!empty($context['post_error']['messages'])) |
|
608
|
|
|
{ |
|
609
|
|
|
echo ' |
|
610
|
|
|
<div class="errorbox"> |
|
611
|
|
|
<dl class="event_error"> |
|
612
|
|
|
<dt> |
|
613
|
|
|
', $context['error_type'] == 'serious' ? '<strong>' . $txt['error_while_submitting'] . '</strong>' : '', ' |
|
614
|
|
|
</dt> |
|
615
|
|
|
<dt class="error"> |
|
616
|
|
|
', implode('<br>', $context['post_error']['messages']), ' |
|
617
|
|
|
</dt> |
|
618
|
|
|
</dl> |
|
619
|
|
|
</div>'; |
|
620
|
|
|
} |
|
621
|
|
|
|
|
622
|
|
|
echo ' |
|
623
|
|
|
<div class="roundframe"> |
|
624
|
|
|
<fieldset id="event_main"> |
|
625
|
|
|
<legend><span', isset($context['post_error']['no_event']) ? ' class="error"' : '', '>', $txt['calendar_event_title'], '</span></legend> |
|
626
|
|
|
<input type="hidden" name="calendar" value="1"> |
|
627
|
|
|
<div class="event_options_left" id="event_title"> |
|
628
|
|
|
<div> |
|
629
|
|
|
<input type="text" id="evtitle" name="evtitle" maxlength="255" size="55" value="', $context['event']['title'], '" tabindex="', $context['tabindex']++, '" class="input_text"> |
|
630
|
|
|
</div> |
|
631
|
|
|
</div>'; |
|
632
|
|
|
|
|
633
|
|
|
// If this is a new event let the user specify which board they want the linked post to be put into. |
|
634
|
|
|
if ($context['event']['new'] && !empty($context['event']['categories'])) |
|
635
|
|
|
{ |
|
636
|
|
|
echo ' |
|
637
|
|
|
<div class="event_options_right" id="event_board"> |
|
638
|
|
|
<div> |
|
639
|
|
|
<span class="label">', $txt['calendar_post_in'], '</span> |
|
640
|
|
|
<input type="checkbox" style="vertical-align: middle;" class="input_check" name="link_to_board"', (!empty($context['event']['board']) ? ' checked' : ''), ' onclick="toggleLinked(this.form);"> |
|
641
|
|
|
<select name="board"', empty($context['event']['board']) ? ' disabled' : '' , '>'; |
|
642
|
|
View Code Duplication |
foreach ($context['event']['categories'] as $category) |
|
|
|
|
|
|
643
|
|
|
{ |
|
644
|
|
|
echo ' |
|
645
|
|
|
<optgroup label="', $category['name'], '">'; |
|
646
|
|
|
foreach ($category['boards'] as $board) |
|
647
|
|
|
echo ' |
|
648
|
|
|
<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
|
649
|
|
|
echo ' |
|
650
|
|
|
</optgroup>'; |
|
651
|
|
|
} |
|
652
|
|
|
echo ' |
|
653
|
|
|
</select> |
|
654
|
|
|
</div> |
|
655
|
|
|
</div>'; |
|
656
|
|
|
} |
|
657
|
|
|
|
|
658
|
|
|
// Note to theme writers: The JavaScripts expect the input fields for the start and end dates & times to be contained in a wrapper element with the id "event_time_input" |
|
659
|
|
|
echo ' |
|
660
|
|
|
</fieldset> |
|
661
|
|
|
<fieldset id="event_options"> |
|
662
|
|
|
<legend>', $txt['calendar_event_options'], '</legend> |
|
663
|
|
|
<div class="event_options_left" id="event_time_input"> |
|
664
|
|
|
<div> |
|
665
|
|
|
<span class="label">', $txt['start'], '</span> |
|
666
|
|
|
<input type="text" name="start_date" id="start_date" maxlength="10" value="', $context['event']['start_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input start" data-type="date"> |
|
667
|
|
|
<input type="text" name="start_time" id="start_time" maxlength="11" value="', $context['event']['start_time_local'], '" tabindex="', $context['tabindex']++, '" class="input_text time_input start" data-type="time"', !empty($context['event']['allday']) ? ' disabled' : '', '> |
|
668
|
|
|
</div> |
|
669
|
|
|
<div> |
|
670
|
|
|
<span class="label">', $txt['end'], '</span> |
|
671
|
|
|
<input type="text" name="end_date" id="end_date" maxlength="10" value="', $context['event']['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date"', $modSettings['cal_maxspan'] == 1 ? ' disabled' : '', '> |
|
672
|
|
|
<input type="text" name="end_time" id="end_time" maxlength="11" value="', $context['event']['end_time_local'], '" tabindex="', $context['tabindex']++, '" class="input_text time_input end" data-type="time"', !empty($context['event']['allday']) ? ' disabled' : '', '> |
|
673
|
|
|
</div> |
|
674
|
|
|
</div> |
|
675
|
|
|
<div class="event_options_right" id="event_time_options"> |
|
676
|
|
|
<div id="event_allday"> |
|
677
|
|
|
<label for="allday"><span class="label">', $txt['calendar_allday'], '</span></label> |
|
678
|
|
|
<input type="checkbox" name="allday" id="allday"', !empty($context['event']['allday']) ? ' checked' : '', ' tabindex="', $context['tabindex']++, '"> |
|
679
|
|
|
</div> |
|
680
|
|
|
<div id="event_timezone"> |
|
681
|
|
|
<span class="label">', $txt['calendar_timezone'], '</span> |
|
682
|
|
|
<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
|
683
|
|
|
|
|
684
|
|
View Code Duplication |
foreach ($context['all_timezones'] as $tz => $tzname) |
|
|
|
|
|
|
685
|
|
|
echo ' |
|
686
|
|
|
<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
|
687
|
|
|
|
|
688
|
|
|
echo ' |
|
689
|
|
|
</select> |
|
690
|
|
|
</div> |
|
691
|
|
|
</div> |
|
692
|
|
|
<div> |
|
693
|
|
|
<span class="label">', $txt['location'], '</span> |
|
694
|
|
|
<input type="text" name="event_location" id="event_location" maxlength="255" value="', !empty($context['event']['location']) ? $context['event']['location'] : '', '" tabindex="', $context['tabindex']++, '" class="input_text"> |
|
695
|
|
|
</div> |
|
696
|
|
|
</fieldset>'; |
|
697
|
|
|
|
|
698
|
|
|
echo ' |
|
699
|
|
|
<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">'; |
|
700
|
|
|
// Delete button? |
|
701
|
|
|
if (empty($context['event']['new'])) |
|
702
|
|
|
echo ' |
|
703
|
|
|
<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">'; |
|
704
|
|
|
|
|
705
|
|
|
echo ' |
|
706
|
|
|
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
|
707
|
|
|
<input type="hidden" name="eventid" value="', $context['event']['eventid'], '"> |
|
708
|
|
|
|
|
709
|
|
|
</div> |
|
710
|
|
|
</div> |
|
711
|
|
|
</form>'; |
|
712
|
|
|
} |
|
713
|
|
|
|
|
714
|
|
View Code Duplication |
function template_bcd() |
|
|
|
|
|
|
715
|
|
|
{ |
|
716
|
|
|
global $context, $scripturl; |
|
717
|
|
|
$alt = false; |
|
718
|
|
|
echo ' |
|
719
|
|
|
<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;"> |
|
720
|
|
|
<tr> |
|
721
|
|
|
<th class="windowbg2" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;" colspan="6">BCD Clock</th> |
|
722
|
|
|
</tr> |
|
723
|
|
|
<tr class="windowbg">'; |
|
724
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
725
|
|
|
{ |
|
726
|
|
|
echo '<td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">'; |
|
727
|
|
|
foreach ($v as $i) |
|
728
|
|
|
{ |
|
729
|
|
|
echo '<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>'; |
|
730
|
|
|
} |
|
731
|
|
|
echo '</td>'; |
|
732
|
|
|
$alt = !$alt; |
|
733
|
|
|
} |
|
734
|
|
|
echo '</tr> |
|
735
|
|
|
<tr class="', $alt ? 'windowbg2' : 'windowbg', '" style="border-top: 1px solid #ccc; text-align: center;"> |
|
736
|
|
|
<td colspan="6"> |
|
737
|
|
|
<a href="', $scripturl, '?action=clock;rb">Are you hardcore?</a> |
|
738
|
|
|
</td> |
|
739
|
|
|
</tr> |
|
740
|
|
|
</table> |
|
741
|
|
|
|
|
742
|
|
|
<script> |
|
743
|
|
|
var icons = new Object();'; |
|
744
|
|
|
|
|
745
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
746
|
|
|
{ |
|
747
|
|
|
foreach ($v as $i) |
|
748
|
|
|
echo ' |
|
749
|
|
|
icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
echo ' |
|
753
|
|
|
function update() |
|
754
|
|
|
{ |
|
755
|
|
|
// Get the current time |
|
756
|
|
|
var time = new Date(); |
|
757
|
|
|
var hour = time.getHours(); |
|
758
|
|
|
var min = time.getMinutes(); |
|
759
|
|
|
var sec = time.getSeconds(); |
|
760
|
|
|
|
|
761
|
|
|
// Break it up into individual digits |
|
762
|
|
|
var h1 = parseInt(hour / 10); |
|
763
|
|
|
var h2 = hour % 10; |
|
764
|
|
|
var m1 = parseInt(min / 10); |
|
765
|
|
|
var m2 = min % 10; |
|
766
|
|
|
var s1 = parseInt(sec / 10); |
|
767
|
|
|
var s2 = sec % 10; |
|
768
|
|
|
|
|
769
|
|
|
// For each digit figure out which ones to turn off and which ones to turn on |
|
770
|
|
|
var turnon = new Array();'; |
|
771
|
|
|
|
|
772
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
773
|
|
|
{ |
|
774
|
|
|
foreach ($v as $i) |
|
775
|
|
|
echo ' |
|
776
|
|
|
if (', $t, ' >= ', $i, ') |
|
777
|
|
|
{ |
|
778
|
|
|
turnon.push("', $t, '_', $i, '"); |
|
779
|
|
|
', $t, ' -= ', $i, '; |
|
780
|
|
|
}'; |
|
781
|
|
|
} |
|
782
|
|
|
|
|
783
|
|
|
echo ' |
|
784
|
|
|
for (var i in icons) |
|
785
|
|
|
if (!in_array(i, turnon)) |
|
786
|
|
|
icons[i].src = "', $context['offimg'], '"; |
|
787
|
|
|
else |
|
788
|
|
|
icons[i].src = "', $context['onimg'], '"; |
|
789
|
|
|
|
|
790
|
|
|
window.setTimeout("update();", 500); |
|
791
|
|
|
} |
|
792
|
|
|
// Checks for variable in theArray. |
|
793
|
|
|
function in_array(variable, theArray) |
|
794
|
|
|
{ |
|
795
|
|
|
for (var i = 0; i < theArray.length; i++) |
|
796
|
|
|
{ |
|
797
|
|
|
if (theArray[i] == variable) |
|
798
|
|
|
return true; |
|
799
|
|
|
} |
|
800
|
|
|
return false; |
|
801
|
|
|
} |
|
802
|
|
|
|
|
803
|
|
|
update(); |
|
804
|
|
|
</script>'; |
|
805
|
|
|
} |
|
806
|
|
|
|
|
807
|
|
View Code Duplication |
function template_hms() |
|
|
|
|
|
|
808
|
|
|
{ |
|
809
|
|
|
global $context, $scripturl; |
|
810
|
|
|
$alt = false; |
|
811
|
|
|
echo ' |
|
812
|
|
|
<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;"> |
|
813
|
|
|
<tr> |
|
814
|
|
|
<th class="windowbg2" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;">Binary Clock</th> |
|
815
|
|
|
</tr>'; |
|
816
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
817
|
|
|
{ |
|
818
|
|
|
echo ' |
|
819
|
|
|
<tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
|
820
|
|
|
<td>'; |
|
821
|
|
|
foreach ($v as $i) |
|
822
|
|
|
{ |
|
823
|
|
|
echo '<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
|
824
|
|
|
} |
|
825
|
|
|
echo '</td> |
|
826
|
|
|
</tr> |
|
827
|
|
|
'; |
|
828
|
|
|
$alt = !$alt; |
|
829
|
|
|
} |
|
830
|
|
|
echo '</tr> |
|
831
|
|
|
<tr class="', $alt ? 'windowbg2' : 'windowbg', '" style="border-top: 1px solid #ccc; text-align: center;"> |
|
832
|
|
|
<td> |
|
833
|
|
|
<a href="', $scripturl, '?action=clock">Too tough for you?</a> |
|
834
|
|
|
</td> |
|
835
|
|
|
</tr> |
|
836
|
|
|
</table>'; |
|
837
|
|
|
|
|
838
|
|
|
echo ' |
|
839
|
|
|
<script> |
|
840
|
|
|
var icons = new Object();'; |
|
841
|
|
|
|
|
842
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
843
|
|
|
{ |
|
844
|
|
|
foreach ($v as $i) |
|
845
|
|
|
echo ' |
|
846
|
|
|
icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
|
847
|
|
|
} |
|
848
|
|
|
|
|
849
|
|
|
echo ' |
|
850
|
|
|
function update() |
|
851
|
|
|
{ |
|
852
|
|
|
// Get the current time |
|
853
|
|
|
var time = new Date(); |
|
854
|
|
|
var h = time.getHours(); |
|
855
|
|
|
var m = time.getMinutes(); |
|
856
|
|
|
var s = time.getSeconds(); |
|
857
|
|
|
|
|
858
|
|
|
// For each digit figure out which ones to turn off and which ones to turn on |
|
859
|
|
|
var turnon = new Array();'; |
|
860
|
|
|
|
|
861
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
862
|
|
|
{ |
|
863
|
|
|
foreach ($v as $i) |
|
864
|
|
|
echo ' |
|
865
|
|
|
if (', $t, ' >= ', $i, ') |
|
866
|
|
|
{ |
|
867
|
|
|
turnon.push("', $t, '_', $i, '"); |
|
868
|
|
|
', $t, ' -= ', $i, '; |
|
869
|
|
|
}'; |
|
870
|
|
|
} |
|
871
|
|
|
|
|
872
|
|
|
echo ' |
|
873
|
|
|
for (var i in icons) |
|
874
|
|
|
if (!in_array(i, turnon)) |
|
875
|
|
|
icons[i].src = "', $context['offimg'], '"; |
|
876
|
|
|
else |
|
877
|
|
|
icons[i].src = "', $context['onimg'], '"; |
|
878
|
|
|
|
|
879
|
|
|
window.setTimeout("update();", 500); |
|
880
|
|
|
} |
|
881
|
|
|
// Checks for variable in theArray. |
|
882
|
|
|
function in_array(variable, theArray) |
|
883
|
|
|
{ |
|
884
|
|
|
for (var i = 0; i < theArray.length; i++) |
|
885
|
|
|
{ |
|
886
|
|
|
if (theArray[i] == variable) |
|
887
|
|
|
return true; |
|
888
|
|
|
} |
|
889
|
|
|
return false; |
|
890
|
|
|
} |
|
891
|
|
|
|
|
892
|
|
|
update(); |
|
893
|
|
|
</script>'; |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
function template_omfg() |
|
897
|
|
|
{ |
|
898
|
|
|
global $context; |
|
899
|
|
|
$alt = false; |
|
900
|
|
|
echo ' |
|
901
|
|
|
<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;"> |
|
902
|
|
|
<tr> |
|
903
|
|
|
<th class="windowbg2" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;">OMFG Binary Clock</th> |
|
904
|
|
|
</tr>'; |
|
905
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
906
|
|
|
{ |
|
907
|
|
|
echo ' |
|
908
|
|
|
<tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
|
909
|
|
|
<td>'; |
|
910
|
|
|
foreach ($v as $i) |
|
911
|
|
|
{ |
|
912
|
|
|
echo '<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
|
913
|
|
|
} |
|
914
|
|
|
echo '</td> |
|
915
|
|
|
</tr> |
|
916
|
|
|
'; |
|
917
|
|
|
$alt = !$alt; |
|
918
|
|
|
} |
|
919
|
|
|
echo '</tr> |
|
920
|
|
|
</table>'; |
|
921
|
|
|
|
|
922
|
|
|
echo ' |
|
923
|
|
|
<script> |
|
924
|
|
|
var icons = new Object();'; |
|
925
|
|
|
|
|
926
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
927
|
|
|
{ |
|
928
|
|
|
foreach ($v as $i) |
|
929
|
|
|
echo ' |
|
930
|
|
|
icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
|
931
|
|
|
} |
|
932
|
|
|
|
|
933
|
|
|
echo ' |
|
934
|
|
|
function update() |
|
935
|
|
|
{ |
|
936
|
|
|
// Get the current time |
|
937
|
|
|
var time = new Date(); |
|
938
|
|
|
var month = time.getMonth() + 1; |
|
939
|
|
|
var day = time.getDate(); |
|
940
|
|
|
var year = time.getFullYear(); |
|
941
|
|
|
year = year % 100; |
|
942
|
|
|
var hour = time.getHours(); |
|
943
|
|
|
var min = time.getMinutes(); |
|
944
|
|
|
var sec = time.getSeconds(); |
|
945
|
|
|
|
|
946
|
|
|
// For each digit figure out which ones to turn off and which ones to turn on |
|
947
|
|
|
var turnon = new Array();'; |
|
948
|
|
|
|
|
949
|
|
|
foreach ($context['clockicons'] as $t => $v) |
|
950
|
|
|
{ |
|
951
|
|
|
foreach ($v as $i) |
|
952
|
|
|
echo ' |
|
953
|
|
|
if (', $t, ' >= ', $i, ') |
|
954
|
|
|
{ |
|
955
|
|
|
turnon.push("', $t, '_', $i, '"); |
|
956
|
|
|
', $t, ' -= ', $i, '; |
|
957
|
|
|
}'; |
|
958
|
|
|
} |
|
959
|
|
|
|
|
960
|
|
|
echo ' |
|
961
|
|
|
for (var i in icons) |
|
962
|
|
|
if (!in_array(i, turnon)) |
|
963
|
|
|
icons[i].src = "', $context['offimg'], '"; |
|
964
|
|
|
else |
|
965
|
|
|
icons[i].src = "', $context['onimg'], '"; |
|
966
|
|
|
|
|
967
|
|
|
window.setTimeout("update();", 500); |
|
968
|
|
|
} |
|
969
|
|
|
// Checks for variable in theArray. |
|
970
|
|
|
function in_array(variable, theArray) |
|
971
|
|
|
{ |
|
972
|
|
|
for (var i = 0; i < theArray.length; i++) |
|
973
|
|
|
{ |
|
974
|
|
|
if (theArray[i] == variable) |
|
975
|
|
|
return true; |
|
976
|
|
|
} |
|
977
|
|
|
return false; |
|
978
|
|
|
} |
|
979
|
|
|
|
|
980
|
|
|
update(); |
|
981
|
|
|
</script>'; |
|
982
|
|
|
} |
|
983
|
|
|
|
|
984
|
|
|
function template_thetime() |
|
985
|
|
|
{ |
|
986
|
|
|
global $context; |
|
987
|
|
|
$alt = false; |
|
988
|
|
|
echo ' |
|
989
|
|
|
<table class="table_grid" style="margin: 0 auto 0 auto; border: 1px solid #ccc;"> |
|
990
|
|
|
<tr> |
|
991
|
|
|
<th class="windowbg2" style="font-weight: bold; text-align: center; border-bottom: 1px solid #ccc;">The time you requested</th> |
|
992
|
|
|
</tr>'; |
|
993
|
|
|
foreach ($context['clockicons'] as $v) |
|
994
|
|
|
{ |
|
995
|
|
|
echo ' |
|
996
|
|
|
<tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
|
997
|
|
|
<td>'; |
|
998
|
|
|
foreach ($v as $i) |
|
999
|
|
|
{ |
|
1000
|
|
|
echo '<img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" style="padding: 2px;">'; |
|
1001
|
|
|
} |
|
1002
|
|
|
echo '</td> |
|
1003
|
|
|
</tr> |
|
1004
|
|
|
'; |
|
1005
|
|
|
$alt = !$alt; |
|
1006
|
|
|
} |
|
1007
|
|
|
echo ' |
|
1008
|
|
|
</table>'; |
|
1009
|
|
|
} |
|
1010
|
|
|
|
|
1011
|
|
|
?> |
|
|
|
|
|
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignoreannotation.See also the PhpDoc documentation for @ignore.