|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package ElkArte Forum |
|
5
|
|
|
* @copyright ElkArte Forum contributors |
|
6
|
|
|
* @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file) |
|
7
|
|
|
* |
|
8
|
|
|
* This file contains code covered by: |
|
9
|
|
|
* copyright: 2011 Simple Machines (http://www.simplemachines.org) |
|
10
|
|
|
* |
|
11
|
|
|
* @version 2.0 dev |
|
12
|
|
|
* |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
use ElkArte\Helper\Util; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The main calendar - January, for example. |
|
19
|
|
|
*/ |
|
20
|
|
|
function template_show_calendar() |
|
21
|
|
|
{ |
|
22
|
|
|
global $context, $txt; |
|
23
|
|
|
|
|
24
|
|
|
echo ' |
|
25
|
|
|
<div id="calendar"> |
|
26
|
|
|
<div id="month_grid"> |
|
27
|
|
|
', template_show_month_grid('prev'), ' |
|
|
|
|
|
|
28
|
|
|
', template_show_month_grid('current'), ' |
|
|
|
|
|
|
29
|
|
|
', template_show_month_grid('next'), ' |
|
|
|
|
|
|
30
|
|
|
</div> |
|
31
|
|
|
<div id="main_grid"> |
|
32
|
|
|
', $context['view_week'] ? template_show_week_grid('main') : template_show_month_grid('main'); |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
// Show some controls to allow easy calendar navigation. |
|
35
|
|
|
echo ' |
|
36
|
|
|
<form id="calendar_navigation" action="', getUrl('action', ['action' => 'calendar']), '" method="post" accept-charset="UTF-8">'; |
|
37
|
|
|
|
|
38
|
|
|
template_button_strip($context['calendar_buttons'], 'floatright'); |
|
39
|
|
|
|
|
40
|
|
|
echo ' |
|
41
|
|
|
<select name="month">'; |
|
42
|
|
|
|
|
43
|
|
|
// Show a select box with all the months. |
|
44
|
|
|
foreach ($txt['months'] as $number => $month) |
|
45
|
|
|
{ |
|
46
|
|
|
echo ' |
|
47
|
|
|
<option value="', $number, '"', $number == $context['current_month'] ? ' selected="selected"' : '', '>', $month, '</option>'; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
echo ' |
|
51
|
|
|
</select> |
|
52
|
|
|
<select name="year">'; |
|
53
|
|
|
|
|
54
|
|
|
// Show a link for every year..... |
|
55
|
|
|
for ($year = $context['cal_minyear']; $year <= $context['cal_maxyear']; $year++) |
|
56
|
|
|
{ |
|
57
|
|
|
echo ' |
|
58
|
|
|
<option value="', $year, '"', $year == $context['current_year'] ? ' selected="selected"' : '', '>', $year, '</option>'; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
echo ' |
|
62
|
|
|
</select> |
|
63
|
|
|
<input type="submit" value="', $txt['view'], '" /> |
|
64
|
|
|
</form> |
|
65
|
|
|
</div> |
|
66
|
|
|
</div>'; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Template for posting a calendar event. |
|
71
|
|
|
*/ |
|
72
|
|
|
function template_unlinked_event_post() |
|
73
|
|
|
{ |
|
74
|
|
|
global $context, $txt, $modSettings; |
|
75
|
|
|
|
|
76
|
|
|
// Start the javascript for drop down boxes... |
|
77
|
|
|
echo ' |
|
78
|
|
|
<form action="', getUrl('action', ['action' => 'calendar', 'sa' => 'post']), '" method="post" name="postevent" accept-charset="UTF-8" onsubmit="submitonce(this);elk_saveEntities(\'postevent\', [\'evtitle\']);">'; |
|
79
|
|
|
|
|
80
|
|
|
if (!empty($context['event']['new'])) |
|
81
|
|
|
{ |
|
82
|
|
|
echo ' |
|
83
|
|
|
<input type="hidden" name="eventid" value="', $context['event']['eventid'], '" />'; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
// Start the main table. |
|
87
|
|
|
echo ' |
|
88
|
|
|
<div id="post_event"> |
|
89
|
|
|
<h2 class="category_header">', $context['page_title'], '</h2>'; |
|
90
|
|
|
|
|
91
|
|
|
if (!empty($context['post_error']['messages'])) |
|
92
|
|
|
{ |
|
93
|
|
|
echo ' |
|
94
|
|
|
<div class="errorbox"> |
|
95
|
|
|
<dl class="event_error"> |
|
96
|
|
|
<dt> |
|
97
|
|
|
', $context['error_type'] == 'serious' ? '<strong>' . $txt['error_while_submitting'] . '</strong>' : '', ' |
|
98
|
|
|
</dt> |
|
99
|
|
|
<dt class="error"> |
|
100
|
|
|
', implode('<br />', $context['post_error']['messages']), ' |
|
101
|
|
|
</dt> |
|
102
|
|
|
</dl> |
|
103
|
|
|
</div>'; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
echo ' |
|
107
|
|
|
<div id="event_main" class="well"> |
|
108
|
|
|
<label for="evtitle"', isset($context['post_error']['no_event']) ? ' class="error"' : '', ' id="caption_evtitle">', $txt['calendar_event_title'], '</label> |
|
109
|
|
|
<input type="text" id="evtitle" name="evtitle" maxlength="255" size="55" value="', $context['event']['title'], '" tabindex="', $context['tabindex']++, '" class="input_text" /> |
|
110
|
|
|
<div id="datepicker"> |
|
111
|
|
|
<input type="hidden" name="calendar" value="1" /><label for="year">', $txt['calendar_year'], '</label> |
|
112
|
|
|
<select name="year" id="year" tabindex="', $context['tabindex']++, '" onchange="generateDays();">'; |
|
113
|
|
|
|
|
114
|
|
|
// Show a list of all the years we allow... |
|
115
|
|
|
for ($year = $context['cal_minyear']; $year <= $context['cal_maxyear']; $year++) |
|
116
|
|
|
{ |
|
117
|
|
|
echo ' |
|
118
|
|
|
<option value="', $year, '"', $year == $context['event']['year'] ? ' selected="selected"' : '', '>', $year, '</option>'; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
echo ' |
|
122
|
|
|
</select> |
|
123
|
|
|
<label for="month">', $txt['calendar_month'], '</label> |
|
124
|
|
|
<select name="month" id="month" onchange="generateDays();">'; |
|
125
|
|
|
|
|
126
|
|
|
// There are 12 months per year - ensure that they all get listed. |
|
127
|
|
|
for ($month = 1; $month <= 12; $month++) |
|
128
|
|
|
{ |
|
129
|
|
|
echo ' |
|
130
|
|
|
<option value="', $month, '"', $month == $context['event']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '</option>'; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
echo ' |
|
134
|
|
|
</select> |
|
135
|
|
|
<label for="day">', $txt['calendar_day'], '</label> |
|
136
|
|
|
<select name="day" id="day">'; |
|
137
|
|
|
|
|
138
|
|
|
// This prints out all the days in the current month - this changes dynamically as we switch months. |
|
139
|
|
|
for ($day = 1; $day <= $context['event']['last_day']; $day++) |
|
140
|
|
|
{ |
|
141
|
|
|
echo ' |
|
142
|
|
|
<option value="', $day, '"', $day == $context['event']['day'] ? ' selected="selected"' : '', '>', $day, '</option>'; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
echo ' |
|
146
|
|
|
</select> |
|
147
|
|
|
</div>'; |
|
148
|
|
|
|
|
149
|
|
|
if (!empty($modSettings['cal_allowspan']) || $context['event']['new']) |
|
150
|
|
|
{ |
|
151
|
|
|
echo ' |
|
152
|
|
|
<ul class="event_options">'; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
// If events can span more than one day then allow the user to select how long it should last. |
|
156
|
|
|
if (!empty($modSettings['cal_allowspan'])) |
|
157
|
|
|
{ |
|
158
|
|
|
echo ' |
|
159
|
|
|
<li> |
|
160
|
|
|
<label for="span">', $txt['calendar_numb_days'], '</label> |
|
161
|
|
|
<select id="span" name="span">'; |
|
162
|
|
|
|
|
163
|
|
|
for ($days = 1; $days <= $modSettings['cal_maxspan']; $days++) |
|
164
|
|
|
{ |
|
165
|
|
|
echo ' |
|
166
|
|
|
<option value="', $days, '"', $context['event']['span'] == $days ? ' selected="selected"' : '', '>', $days, '</option>'; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
echo ' |
|
170
|
|
|
</select> |
|
171
|
|
|
</li>'; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
// If this is a new event let the user specify which board they want the linked post to be put into. |
|
175
|
|
|
if ($context['event']['new']) |
|
176
|
|
|
{ |
|
177
|
|
|
echo ' |
|
178
|
|
|
<li> |
|
179
|
|
|
<label for="link_to_board">', $txt['calendar_link_event'], '</label> |
|
180
|
|
|
<input type="checkbox" id="link_to_board" name="link_to_board" checked="checked" onclick="toggleLinked(this.form);" /> |
|
181
|
|
|
</li> |
|
182
|
|
|
<li> |
|
183
|
|
|
', template_select_boards('board', $txt['calendar_post_in'], 'onchange="this.form.submit();"'), ' |
|
184
|
|
|
</li>'; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
if (!empty($modSettings['cal_allowspan']) || $context['event']['new']) |
|
188
|
|
|
{ |
|
189
|
|
|
echo ' |
|
190
|
|
|
</ul>'; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
echo ' |
|
194
|
|
|
<div class="submitbutton"> |
|
195
|
|
|
<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" />'; |
|
196
|
|
|
|
|
197
|
|
|
// Delete button? |
|
198
|
|
|
if (empty($context['event']['new'])) |
|
199
|
|
|
{ |
|
200
|
|
|
echo ' |
|
201
|
|
|
<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" onclick="return confirm(\'', $txt['calendar_confirm_delete'], '\');" />'; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
echo ' |
|
205
|
|
|
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
|
206
|
|
|
<input type="hidden" name="eventid" value="', $context['event']['eventid'], '" /> |
|
207
|
|
|
</div> |
|
208
|
|
|
</div> |
|
209
|
|
|
</div> |
|
210
|
|
|
</form>'; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* Display a monthly calendar grid. |
|
215
|
|
|
* |
|
216
|
|
|
* @param string $grid_name |
|
217
|
|
|
*/ |
|
218
|
|
|
function template_show_month_grid($grid_name) |
|
219
|
|
|
{ |
|
220
|
|
|
global $context, $txt, $modSettings; |
|
221
|
|
|
|
|
222
|
|
|
if (!isset($context['calendar_grid_' . $grid_name])) |
|
223
|
|
|
{ |
|
224
|
|
|
return false; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
$calendar_data = &$context['calendar_grid_' . $grid_name]; |
|
228
|
|
|
|
|
229
|
|
|
if (empty($calendar_data['disable_title'])) |
|
230
|
|
|
{ |
|
231
|
|
|
echo ' |
|
232
|
|
|
<h2 class="category_header">'; |
|
233
|
|
|
|
|
234
|
|
|
if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev']) |
|
235
|
|
|
{ |
|
236
|
|
|
echo ' |
|
237
|
|
|
<a href="', $calendar_data['previous_calendar']['href'], '" class="previous_month"> |
|
238
|
|
|
<i class="icon icon-lg i-chevron-circle-left"></i> |
|
239
|
|
|
</a>'; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev']) |
|
243
|
|
|
{ |
|
244
|
|
|
echo ' |
|
245
|
|
|
<a href="', $calendar_data['next_calendar']['href'], '" class="next_month"> |
|
246
|
|
|
<i class="icon icon-lg i-chevron-circle-right"></i> |
|
247
|
|
|
</a>'; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
if ($calendar_data['show_next_prev']) |
|
251
|
|
|
{ |
|
252
|
|
|
echo ' |
|
253
|
|
|
', $txt['months_titles'][$calendar_data['current_month']], ' ', $calendar_data['current_year']; |
|
254
|
|
|
} |
|
255
|
|
|
else |
|
256
|
|
|
{ |
|
257
|
|
|
echo ' |
|
258
|
|
|
<a href="', getUrl('action', ['action' => 'calendar', 'year' => $calendar_data['current_year'], 'month' => $calendar_data['current_month']]), '"> |
|
259
|
|
|
<i class="icon icon-small i-calendar"></i> ', $txt['months_titles'][$calendar_data['current_month']], ' ', $calendar_data['current_year'], ' |
|
260
|
|
|
</a>'; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
echo ' |
|
264
|
|
|
</h2>'; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
// Show the sidebar months |
|
268
|
|
|
echo ' |
|
269
|
|
|
<table class="calendar_table">'; |
|
270
|
|
|
|
|
271
|
|
|
// Show each day of the week. |
|
272
|
|
|
if (empty($calendar_data['disable_day_titles'])) |
|
273
|
|
|
{ |
|
274
|
|
|
echo ' |
|
275
|
|
|
<tr class="table_head">'; |
|
276
|
|
|
|
|
277
|
|
|
if (!empty($calendar_data['show_week_links'])) |
|
278
|
|
|
{ |
|
279
|
|
|
echo ' |
|
280
|
|
|
<th> </th>'; |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
foreach ($calendar_data['week_days'] as $day) |
|
284
|
|
|
{ |
|
285
|
|
|
echo ' |
|
286
|
|
|
<th scope="col" class="days">', empty($calendar_data['short_day_titles']) ? ($txt['days'][$day]) : Util::substr($txt['days'][$day], 0, 1), '</th>'; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
echo ' |
|
290
|
|
|
</tr>'; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
// Each week in weeks contains the following: |
|
294
|
|
|
// days (a list of days), number (week # in the year.) |
|
295
|
|
|
foreach ($calendar_data['weeks'] as $week) |
|
296
|
|
|
{ |
|
297
|
|
|
echo ' |
|
298
|
|
|
<tr>'; |
|
299
|
|
|
|
|
300
|
|
|
if (!empty($calendar_data['show_week_links'])) |
|
301
|
|
|
{ |
|
302
|
|
|
echo ' |
|
303
|
|
|
<td class="weeks"> |
|
304
|
|
|
<a href="', getUrl('action', ['action' => 'calendar', 'year' => $calendar_data['current_year'], 'month' => $calendar_data['current_month'], 'day' => $week['days'][0]['day'], 'viewweek']), '"> |
|
305
|
|
|
<i class="icon i-eye-plus"></i> |
|
306
|
|
|
</a> |
|
307
|
|
|
</td>'; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
// Every day has the following: |
|
311
|
|
|
// day (# in month), is_today (is this day *today*?), is_first_day (first day of the week?), |
|
312
|
|
|
// holidays, events, birthdays. (last three are lists.) |
|
313
|
|
|
foreach ($week['days'] as $day) |
|
314
|
|
|
{ |
|
315
|
|
|
// If this is today, make it a different color and show a border. |
|
316
|
|
|
echo ' |
|
317
|
|
|
<td class="', $day['is_today'] ? 'calendar_today' : '', ' days">'; |
|
318
|
|
|
|
|
319
|
|
|
// Skip it if it should be blank - it's not a day if it has no number. |
|
320
|
|
|
if (!empty($day['day'])) |
|
321
|
|
|
{ |
|
322
|
|
|
// Should the day number be a link? |
|
323
|
|
|
if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
324
|
|
|
{ |
|
325
|
|
|
echo ' |
|
326
|
|
|
<a href="', getUrl('action', ['action' => 'calendar', 'sa' => 'post', 'year' => $calendar_data['current_year'], 'month' => $calendar_data['current_month'], 'day' => $day['day'], '{session_data}']), '">', $day['day'], '</a>'; |
|
327
|
|
|
} |
|
328
|
|
|
else |
|
329
|
|
|
{ |
|
330
|
|
|
echo ' |
|
331
|
|
|
', $day['day']; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
// Is this the first day of the week? (and are we showing week numbers?) |
|
335
|
|
|
if ($day['is_first_day'] && $calendar_data['size'] != 'small') |
|
336
|
|
|
{ |
|
337
|
|
|
echo ' - <a href="', getUrl('action', ['action' => 'calendar', 'year' => $calendar_data['current_year'], 'month' => $calendar_data['current_month'], 'day' => $day['day'], 'viewweek']), '">', $txt['calendar_week'], ' ', $week['number'], '</a>'; |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
// Are there any holidays? |
|
341
|
|
|
if (!empty($day['holidays'])) |
|
342
|
|
|
{ |
|
343
|
|
|
echo ' |
|
344
|
|
|
<div class="holiday">', $txt['calendar_prompt'], ' ', implode(', ', $day['holidays']), '</div>'; |
|
345
|
|
|
} |
|
346
|
|
|
|
|
347
|
|
|
// Show any birthdays... |
|
348
|
|
|
if (!empty($day['birthdays'])) |
|
349
|
|
|
{ |
|
350
|
|
|
echo ' |
|
351
|
|
|
<div> |
|
352
|
|
|
<span class="birthday">', $txt['birthdays'], '</span>'; |
|
353
|
|
|
|
|
354
|
|
|
// Each of the birthdays has: |
|
355
|
|
|
// id, name (person), age (if they have one set?), and is_last. (last in list?) |
|
356
|
|
|
$use_js_hide = empty($context['show_all_birthdays']) && count($day['birthdays']) > 10; |
|
357
|
|
|
$count = 0; |
|
358
|
|
|
foreach ($day['birthdays'] as $member) |
|
359
|
|
|
{ |
|
360
|
|
|
echo ' |
|
361
|
|
|
<a href="', getUrl('profile', ['action' => 'profile', 'u' => $member['id'], 'name' => $member['name']]), '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
|
362
|
|
|
|
|
363
|
|
|
// Stop at ten? |
|
364
|
|
|
if ($count === 10 && $use_js_hide) |
|
365
|
|
|
{ |
|
366
|
|
|
echo ' |
|
367
|
|
|
<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br /> |
|
368
|
|
|
<a href="', getUrl('action', ['action' => 'calendar', 'year' => $calendar_data['current_year'], 'month' => $calendar_data['current_month'], 'showbd']), '" onclick="document.getElementById(\'bdhide_', $day['day'], "').style.display = 'block'; document.getElementById('bdhidelink_", $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a> |
|
369
|
|
|
</span> |
|
370
|
|
|
<span id="bdhide_', $day['day'], '" class="hide">, '; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
$count++; |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
if ($use_js_hide) |
|
377
|
|
|
{ |
|
378
|
|
|
echo ' |
|
379
|
|
|
</span>'; |
|
380
|
|
|
} |
|
381
|
|
|
|
|
382
|
|
|
echo ' |
|
383
|
|
|
</div>'; |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
// Any special posted events? |
|
387
|
|
|
if (!empty($day['events'])) |
|
388
|
|
|
{ |
|
389
|
|
|
echo ' |
|
390
|
|
|
<div class="lefttext"> |
|
391
|
|
|
<span class="event">', $txt['events'], '</span><br />'; |
|
392
|
|
|
|
|
393
|
|
|
// The events are made up of: |
|
394
|
|
|
// title, href, is_last, can_edit (are they allowed to?), and modify_href. |
|
395
|
|
|
foreach ($day['events'] as $event) |
|
396
|
|
|
{ |
|
397
|
|
|
// If they can edit the event, show an icon they can click on.... |
|
398
|
|
|
if ($event['can_edit']) |
|
399
|
|
|
{ |
|
400
|
|
|
echo ' |
|
401
|
|
|
<a class="modify_event" href="', $event['modify_href'], '"> |
|
402
|
|
|
<i class="icon i-modify" title="' . $txt['modify'] . '"></i> |
|
403
|
|
|
</a>'; |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
if ($event['can_export']) |
|
407
|
|
|
{ |
|
408
|
|
|
echo ' |
|
409
|
|
|
<a class="modify_event" href="', $event['export_href'], '"> |
|
410
|
|
|
<i class="icon i-download" title="' . $txt['save'] . '"></i> |
|
411
|
|
|
</a>'; |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
echo ' |
|
415
|
|
|
', $event['link'], $event['is_last'] ? '' : '<br />'; |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
echo ' |
|
419
|
|
|
</div>'; |
|
420
|
|
|
} |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
echo ' |
|
424
|
|
|
</td>'; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
echo ' |
|
428
|
|
|
</tr>'; |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
echo ' |
|
432
|
|
|
</table>'; |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* Or show a weekly one? |
|
437
|
|
|
* |
|
438
|
|
|
* @param string $grid_name |
|
439
|
|
|
*/ |
|
440
|
|
|
function template_show_week_grid($grid_name) |
|
441
|
|
|
{ |
|
442
|
|
|
global $context, $txt, $modSettings; |
|
443
|
|
|
|
|
444
|
|
|
if (!isset($context['calendar_grid_' . $grid_name])) |
|
445
|
|
|
{ |
|
446
|
|
|
return false; |
|
447
|
|
|
} |
|
448
|
|
|
|
|
449
|
|
|
$calendar_data = &$context['calendar_grid_' . $grid_name]; |
|
450
|
|
|
$done_title = false; |
|
451
|
|
|
|
|
452
|
|
|
// Loop through each month (At least one) and print out each day. |
|
453
|
|
|
foreach ($calendar_data['months'] as $month_data) |
|
454
|
|
|
{ |
|
455
|
|
|
echo ' |
|
456
|
|
|
<h2 class="category_header">'; |
|
457
|
|
|
|
|
458
|
|
|
if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && empty($done_title)) |
|
459
|
|
|
{ |
|
460
|
|
|
echo ' |
|
461
|
|
|
<span class="previous_month"> |
|
462
|
|
|
<a href="', $calendar_data['previous_week']['href'], '"> |
|
463
|
|
|
<i class="icon icon-lg i-chevron-circle-left"></i> |
|
464
|
|
|
</a> |
|
465
|
|
|
</span>'; |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && empty($done_title)) |
|
469
|
|
|
{ |
|
470
|
|
|
echo ' |
|
471
|
|
|
<span class="next_month"> |
|
472
|
|
|
<a href="', $calendar_data['next_week']['href'], '"> |
|
473
|
|
|
<i class="icon icon-lg i-chevron-circle-right"></i> |
|
474
|
|
|
</a> |
|
475
|
|
|
</span>'; |
|
476
|
|
|
} |
|
477
|
|
|
|
|
478
|
|
|
echo ' |
|
479
|
|
|
<a href="', getUrl('action', ['action' => 'calendar', 'month' => $month_data['current_month'], 'year' => $month_data['current_year']]), '">', $txt['months_titles'][$month_data['current_month']], ' ', $month_data['current_year'], '</a>', empty($done_title) && !empty($calendar_data['week_number']) ? (' - ' . $txt['calendar_week'] . ' ' . $calendar_data['week_number']) : '', ' |
|
480
|
|
|
</h2>'; |
|
481
|
|
|
|
|
482
|
|
|
$done_title = true; |
|
483
|
|
|
|
|
484
|
|
|
echo ' |
|
485
|
|
|
<ul class="weeklist">'; |
|
486
|
|
|
|
|
487
|
|
|
foreach ($month_data['days'] as $day) |
|
488
|
|
|
{ |
|
489
|
|
|
echo ' |
|
490
|
|
|
<li> |
|
491
|
|
|
<h4>'; |
|
492
|
|
|
|
|
493
|
|
|
// Should the day number be a link? |
|
494
|
|
|
if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
495
|
|
|
{ |
|
496
|
|
|
echo ' |
|
497
|
|
|
<a href="', getUrl('action', ['action' => 'calendar', 'sa' => 'post', 'month' => $month_data['current_month'], 'year' => $month_data['current_year'], 'day' => $day['day'], '{session_data}']), '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
498
|
|
|
} |
|
499
|
|
|
else |
|
500
|
|
|
{ |
|
501
|
|
|
echo ' |
|
502
|
|
|
', $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
echo ' |
|
506
|
|
|
</h4> |
|
507
|
|
|
<div class="', $day['is_today'] ? 'calendar_today' : '', ' weekdays">'; |
|
508
|
|
|
|
|
509
|
|
|
// Are there any holidays? |
|
510
|
|
|
if (!empty($day['holidays'])) |
|
511
|
|
|
{ |
|
512
|
|
|
echo ' |
|
513
|
|
|
<div class="smalltext holiday">', $txt['calendar_prompt'], ' ', implode(', ', $day['holidays']), '</div>'; |
|
514
|
|
|
} |
|
515
|
|
|
|
|
516
|
|
|
// Show any birthdays... |
|
517
|
|
|
if (!empty($day['birthdays'])) |
|
518
|
|
|
{ |
|
519
|
|
|
echo ' |
|
520
|
|
|
<div class="smalltext"> |
|
521
|
|
|
<span class="birthday">', $txt['birthdays'], '</span>'; |
|
522
|
|
|
|
|
523
|
|
|
// Each of the birthdays has: |
|
524
|
|
|
// id, name (person), age (if they have one set?), and is_last. (last in list?) |
|
525
|
|
|
foreach ($day['birthdays'] as $member) |
|
526
|
|
|
{ |
|
527
|
|
|
echo ' |
|
528
|
|
|
<a href="', getUrl('profile', ['action' => 'profile', 'u' => $member['id'], 'name' => $member['name']]), '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
echo ' |
|
532
|
|
|
</div>'; |
|
533
|
|
|
} |
|
534
|
|
|
|
|
535
|
|
|
// Any special posted events? |
|
536
|
|
|
if (!empty($day['events'])) |
|
537
|
|
|
{ |
|
538
|
|
|
echo ' |
|
539
|
|
|
<div class="smalltext"> |
|
540
|
|
|
<span class="event">', $txt['events'], '</span>'; |
|
541
|
|
|
|
|
542
|
|
|
// The events are made up of: |
|
543
|
|
|
// title, href, is_last, can_edit (are they allowed to?), and modify_href. |
|
544
|
|
|
foreach ($day['events'] as $event) |
|
545
|
|
|
{ |
|
546
|
|
|
// If they can edit the event, show a star they can click on.... |
|
547
|
|
|
if ($event['can_edit']) |
|
548
|
|
|
{ |
|
549
|
|
|
echo ' |
|
550
|
|
|
<a href="', $event['modify_href'], '"> |
|
551
|
|
|
<i class="icon i-modify" title="' . $txt['modify'] . '"></i> |
|
552
|
|
|
</a> '; |
|
553
|
|
|
} |
|
554
|
|
|
|
|
555
|
|
|
echo ' |
|
556
|
|
|
', $event['link'], $event['is_last'] ? '' : ', '; |
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
|
|
echo ' |
|
560
|
|
|
</div>'; |
|
561
|
|
|
} |
|
562
|
|
|
|
|
563
|
|
|
echo ' |
|
564
|
|
|
</div> |
|
565
|
|
|
</li>'; |
|
566
|
|
|
} |
|
567
|
|
|
|
|
568
|
|
|
echo ' |
|
569
|
|
|
</ul>'; |
|
570
|
|
|
} |
|
571
|
|
|
} |
|
572
|
|
|
|