annotate forum/Themes/default/Calendar.template.php @ 77:b31c38a09c41 website

Add justification text in registration
author Chris Cannam
date Sun, 07 Jul 2013 11:57:22 +0200
parents e3e11437ecea
children
rev   line source
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 // The main calendar - January, for example.
Chris@76 14 function template_main()
Chris@76 15 {
Chris@76 16 global $context, $settings, $options, $txt, $scripturl, $modSettings;
Chris@76 17
Chris@76 18 echo '
Chris@76 19 <div id="calendar">
Chris@76 20 <div id="month_grid">
Chris@76 21 ', template_show_month_grid('prev'), '
Chris@76 22 ', template_show_month_grid('current'), '
Chris@76 23 ', template_show_month_grid('next'), '
Chris@76 24 </div>
Chris@76 25 <div id="main_grid" style="', $context['browser']['is_ie'] && !$context['browser']['is_ie8'] ? 'float: ' . ($context['right_to_left'] ? 'right; padding-right' : 'left; padding-left') . ': 20px;' : 'margin-' . ($context['right_to_left'] ? 'right' : 'left') . ': 220px; ', '">
Chris@76 26 ', $context['view_week'] ? template_show_week_grid('main') : template_show_month_grid('main');
Chris@76 27
Chris@76 28 // Build the calendar button array.
Chris@76 29 $calendar_buttons = array(
Chris@76 30 'post_event' => array('test' => 'can_post', 'text' => 'calendar_post_event', 'image' => 'calendarpe.gif', 'lang' => true, 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']),
Chris@76 31 );
Chris@76 32
Chris@76 33 template_button_strip($calendar_buttons, 'right');
Chris@76 34
Chris@76 35 // Show some controls to allow easy calendar navigation.
Chris@76 36 echo '
Chris@76 37 <form id="calendar_navigation" action="', $scripturl, '?action=calendar" method="post" accept-charset="', $context['character_set'], '">
Chris@76 38 <select name="month">';
Chris@76 39
Chris@76 40 // Show a select box with all the months.
Chris@76 41 foreach ($txt['months'] as $number => $month)
Chris@76 42 echo '
Chris@76 43 <option value="', $number, '"', $number == $context['current_month'] ? ' selected="selected"' : '', '>', $month, '</option>';
Chris@76 44 echo '
Chris@76 45 </select>
Chris@76 46 <select name="year">';
Chris@76 47
Chris@76 48 // Show a link for every year.....
Chris@76 49 for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
Chris@76 50 echo '
Chris@76 51 <option value="', $year, '"', $year == $context['current_year'] ? ' selected="selected"' : '', '>', $year, '</option>';
Chris@76 52 echo '
Chris@76 53 </select>
Chris@76 54 <input type="submit" class="button_submit" value="', $txt['view'], '" />';
Chris@76 55
Chris@76 56 echo '
Chris@76 57 </form>
Chris@76 58 <br class="clear" />
Chris@76 59 </div>
Chris@76 60 </div>';
Chris@76 61 }
Chris@76 62
Chris@76 63 // Template for posting a calendar event.
Chris@76 64 function template_event_post()
Chris@76 65 {
Chris@76 66 global $context, $settings, $options, $txt, $scripturl, $modSettings;
Chris@76 67
Chris@76 68 // Start the javascript for drop down boxes...
Chris@76 69 echo '
Chris@76 70 <script type="text/javascript"><!-- // --><![CDATA[
Chris@76 71 var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Chris@76 72
Chris@76 73 function generateDays()
Chris@76 74 {
Chris@76 75 var days = 0, selected = 0;
Chris@76 76 var dayElement = document.getElementById("day"), yearElement = document.getElementById("year"), monthElement = document.getElementById("month");
Chris@76 77
Chris@76 78 monthLength[1] = 28;
Chris@76 79 if (yearElement.options[yearElement.selectedIndex].value % 4 == 0)
Chris@76 80 monthLength[1] = 29;
Chris@76 81
Chris@76 82 selected = dayElement.selectedIndex;
Chris@76 83 while (dayElement.options.length)
Chris@76 84 dayElement.options[0] = null;
Chris@76 85
Chris@76 86 days = monthLength[monthElement.value - 1];
Chris@76 87
Chris@76 88 for (i = 1; i <= days; i++)
Chris@76 89 dayElement.options[dayElement.length] = new Option(i, i);
Chris@76 90
Chris@76 91 if (selected < days)
Chris@76 92 dayElement.selectedIndex = selected;
Chris@76 93 }
Chris@76 94
Chris@76 95 function toggleLinked(form)
Chris@76 96 {
Chris@76 97 form.board.disabled = !form.link_to_board.checked;
Chris@76 98 }
Chris@76 99 // ]]></script>
Chris@76 100
Chris@76 101 <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;">';
Chris@76 102
Chris@76 103 if (!empty($context['event']['new']))
Chris@76 104 echo '
Chris@76 105 <input type="hidden" name="eventid" value="', $context['event']['eventid'], '" />';
Chris@76 106
Chris@76 107 // Start the main table.
Chris@76 108 echo '
Chris@76 109 <div id="post_event">
Chris@76 110 <div class="cat_bar">
Chris@76 111 <h3 class="catbg">
Chris@76 112 ', $context['page_title'], '
Chris@76 113 </h3>
Chris@76 114 </div>';
Chris@76 115
Chris@76 116 if (!empty($context['post_error']['messages']))
Chris@76 117 {
Chris@76 118 echo '
Chris@76 119 <div class="errorbox">
Chris@76 120 <dl class="event_error">
Chris@76 121 <dt>
Chris@76 122 ', $context['error_type'] == 'serious' ? '<strong>' . $txt['error_while_submitting'] . '</strong>' : '', '
Chris@76 123 </dt>
Chris@76 124 <dt class="error">
Chris@76 125 ', implode('<br />', $context['post_error']['messages']), '
Chris@76 126 </dt>
Chris@76 127 </dl>
Chris@76 128 </div>';
Chris@76 129 }
Chris@76 130
Chris@76 131 echo '
Chris@76 132 <div class="windowbg">
Chris@76 133 <span class="upperframe"><span></span></span>
Chris@76 134 <div class="roundframe">
Chris@76 135 <fieldset id="event_main">
Chris@76 136 <legend><span', isset($context['post_error']['no_event']) ? ' class="error"' : '', '>', $txt['calendar_event_title'], '</span></legend>
Chris@76 137 <input type="text" name="evtitle" maxlength="255" size="70" value="', $context['event']['title'], '" class="input_text" />
Chris@76 138 <div class="smalltext">
Chris@76 139 <input type="hidden" name="calendar" value="1" />', $txt['calendar_year'], '
Chris@76 140 <select name="year" id="year" onchange="generateDays();">';
Chris@76 141
Chris@76 142 // Show a list of all the years we allow...
Chris@76 143 for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
Chris@76 144 echo '
Chris@76 145 <option value="', $year, '"', $year == $context['event']['year'] ? ' selected="selected"' : '', '>', $year, '&nbsp;</option>';
Chris@76 146
Chris@76 147 echo '
Chris@76 148 </select>
Chris@76 149 ', $txt['calendar_month'], '
Chris@76 150 <select name="month" id="month" onchange="generateDays();">';
Chris@76 151
Chris@76 152 // There are 12 months per year - ensure that they all get listed.
Chris@76 153 for ($month = 1; $month <= 12; $month++)
Chris@76 154 echo '
Chris@76 155 <option value="', $month, '"', $month == $context['event']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '&nbsp;</option>';
Chris@76 156
Chris@76 157 echo '
Chris@76 158 </select>
Chris@76 159 ', $txt['calendar_day'], '
Chris@76 160 <select name="day" id="day">';
Chris@76 161
Chris@76 162 // This prints out all the days in the current month - this changes dynamically as we switch months.
Chris@76 163 for ($day = 1; $day <= $context['event']['last_day']; $day++)
Chris@76 164 echo '
Chris@76 165 <option value="', $day, '"', $day == $context['event']['day'] ? ' selected="selected"' : '', '>', $day, '&nbsp;</option>';
Chris@76 166
Chris@76 167 echo '
Chris@76 168 </select>
Chris@76 169 </div>
Chris@76 170 </fieldset>';
Chris@76 171
Chris@76 172 if (!empty($modSettings['cal_allowspan']) || $context['event']['new'])
Chris@76 173 echo '
Chris@76 174 <fieldset id="event_options">
Chris@76 175 <legend>', $txt['calendar_event_options'], '</legend>
Chris@76 176 <div class="event_options smalltext">
Chris@76 177 <ul class="event_options">';
Chris@76 178
Chris@76 179 // If events can span more than one day then allow the user to select how long it should last.
Chris@76 180 if (!empty($modSettings['cal_allowspan']))
Chris@76 181 {
Chris@76 182 echo '
Chris@76 183 <li>
Chris@76 184 ', $txt['calendar_numb_days'], '
Chris@76 185 <select name="span">';
Chris@76 186
Chris@76 187 for ($days = 1; $days <= $modSettings['cal_maxspan']; $days++)
Chris@76 188 echo '
Chris@76 189 <option value="', $days, '"', $context['event']['span'] == $days ? ' selected="selected"' : '', '>', $days, '&nbsp;</option>';
Chris@76 190
Chris@76 191 echo '
Chris@76 192 </select>
Chris@76 193 </li>';
Chris@76 194 }
Chris@76 195
Chris@76 196 // If this is a new event let the user specify which board they want the linked post to be put into.
Chris@76 197 if ($context['event']['new'])
Chris@76 198 {
Chris@76 199 echo '
Chris@76 200 <li>
Chris@76 201 ', $txt['calendar_link_event'], '
Chris@76 202 <input type="checkbox" style="vertical-align: middle;" class="input_check" name="link_to_board" checked="checked" onclick="toggleLinked(this.form);" />
Chris@76 203 </li>
Chris@76 204 <li>
Chris@76 205 ', $txt['calendar_post_in'], '
Chris@76 206 <select id="board" name="board" onchange="this.form.submit();">';
Chris@76 207 foreach ($context['event']['categories'] as $category)
Chris@76 208 {
Chris@76 209 echo '
Chris@76 210 <optgroup label="', $category['name'], '">';
Chris@76 211 foreach ($category['boards'] as $board)
Chris@76 212 echo '
Chris@76 213 <option value="', $board['id'], '"', $board['selected'] ? ' selected="selected"' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
Chris@76 214 echo '
Chris@76 215 </optgroup>';
Chris@76 216 }
Chris@76 217 echo '
Chris@76 218 </select>
Chris@76 219 </li>';
Chris@76 220 }
Chris@76 221
Chris@76 222 if (!empty($modSettings['cal_allowspan']) || $context['event']['new'])
Chris@76 223 echo '
Chris@76 224 </ul>
Chris@76 225 </div>
Chris@76 226 </fieldset>';
Chris@76 227
Chris@76 228 echo '
Chris@76 229 <div class="righttext">
Chris@76 230 <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit" />';
Chris@76 231 // Delete button?
Chris@76 232 if (empty($context['event']['new']))
Chris@76 233 echo '
Chris@76 234 <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" onclick="return confirm(\'', $txt['calendar_confirm_delete'], '\');" class="button_submit" />';
Chris@76 235
Chris@76 236 echo '
Chris@76 237 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
Chris@76 238 <input type="hidden" name="eventid" value="', $context['event']['eventid'], '" />
Chris@76 239 </div>
Chris@76 240 </div>
Chris@76 241 <span class="lowerframe"><span></span></span>
Chris@76 242 </div>
Chris@76 243 </div>
Chris@76 244 </form>
Chris@76 245 <br class="clear" />';
Chris@76 246 }
Chris@76 247
Chris@76 248 // Display a monthly calendar grid.
Chris@76 249 function template_show_month_grid($grid_name)
Chris@76 250 {
Chris@76 251 global $context, $settings, $options, $txt, $scripturl, $modSettings, $smcFunc;
Chris@76 252
Chris@76 253 if (!isset($context['calendar_grid_' . $grid_name]))
Chris@76 254 return false;
Chris@76 255
Chris@76 256 $calendar_data = &$context['calendar_grid_' . $grid_name];
Chris@76 257 $colspan = !empty($calendar_data['show_week_links']) ? 8 : 7;
Chris@76 258
Chris@76 259 if (empty($calendar_data['disable_title']))
Chris@76 260 {
Chris@76 261 echo '
Chris@76 262 <div class="cat_bar">
Chris@76 263 <h3 class="catbg centertext" style="font-size: ', $calendar_data['size'] == 'large' ? 'large' : 'small', ';">';
Chris@76 264
Chris@76 265 if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'])
Chris@76 266 echo '
Chris@76 267 <span class="floatleft"><a href="', $calendar_data['previous_calendar']['href'], '">&#171;</a></span>';
Chris@76 268
Chris@76 269 if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'])
Chris@76 270 echo '
Chris@76 271 <span class="floatright"><a href="', $calendar_data['next_calendar']['href'], '">&#187;</a></span>';
Chris@76 272
Chris@76 273 if ($calendar_data['show_next_prev'])
Chris@76 274 echo '
Chris@76 275 ', $txt['months_titles'][$calendar_data['current_month']], ' ', $calendar_data['current_year'];
Chris@76 276 else
Chris@76 277 echo '
Chris@76 278 <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>';
Chris@76 279
Chris@76 280 echo '
Chris@76 281 </h3>
Chris@76 282 </div>';
Chris@76 283 }
Chris@76 284
Chris@76 285 echo '
Chris@76 286 <table cellspacing="1" class="calendar_table">';
Chris@76 287
Chris@76 288 // Show each day of the week.
Chris@76 289 if (empty($calendar_data['disable_day_titles']))
Chris@76 290 {
Chris@76 291 echo '
Chris@76 292 <tr class="titlebg2">';
Chris@76 293
Chris@76 294 if (!empty($calendar_data['show_week_links']))
Chris@76 295 echo '
Chris@76 296 <th>&nbsp;</th>';
Chris@76 297
Chris@76 298 foreach ($calendar_data['week_days'] as $day)
Chris@76 299 {
Chris@76 300 echo '
Chris@76 301 <th class="days" scope="col" ', $calendar_data['size'] == 'small' ? 'style="font-size: x-small;"' : '', '>', !empty($calendar_data['short_day_titles']) ? ($smcFunc['substr']($txt['days'][$day], 0, 1)) : $txt['days'][$day], '</th>';
Chris@76 302 }
Chris@76 303 echo '
Chris@76 304 </tr>';
Chris@76 305 }
Chris@76 306
Chris@76 307 /* Each week in weeks contains the following:
Chris@76 308 days (a list of days), number (week # in the year.) */
Chris@76 309 foreach ($calendar_data['weeks'] as $week)
Chris@76 310 {
Chris@76 311 echo '
Chris@76 312 <tr>';
Chris@76 313
Chris@76 314 if (!empty($calendar_data['show_week_links']))
Chris@76 315 echo '
Chris@76 316 <td class="windowbg2 weeks">
Chris@76 317 <a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '">&#187;</a>
Chris@76 318 </td>';
Chris@76 319
Chris@76 320 /* Every day has the following:
Chris@76 321 day (# in month), is_today (is this day *today*?), is_first_day (first day of the week?),
Chris@76 322 holidays, events, birthdays. (last three are lists.) */
Chris@76 323 foreach ($week['days'] as $day)
Chris@76 324 {
Chris@76 325 // If this is today, make it a different color and show a border.
Chris@76 326 echo '
Chris@76 327 <td style="height: ', $calendar_data['size'] == 'small' ? '20' : '100', 'px; padding: 2px;', $calendar_data['size'] == 'small' ? 'font-size: x-small;' : '', '" class="', $day['is_today'] ? 'calendar_today' : 'windowbg', ' days">';
Chris@76 328
Chris@76 329 // Skip it if it should be blank - it's not a day if it has no number.
Chris@76 330 if (!empty($day['day']))
Chris@76 331 {
Chris@76 332 // Should the day number be a link?
Chris@76 333 if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
Chris@76 334 echo '
Chris@76 335 <a href="', $scripturl, '?action=calendar;sa=post;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $day['day'], '</a>';
Chris@76 336 else
Chris@76 337 echo '
Chris@76 338 ', $day['day'];
Chris@76 339
Chris@76 340 // Is this the first day of the week? (and are we showing week numbers?)
Chris@76 341 if ($day['is_first_day'] && $calendar_data['size'] != 'small')
Chris@76 342 echo '<span class="smalltext"> - <a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '">', $txt['calendar_week'], ' ', $week['number'], '</a></span>';
Chris@76 343
Chris@76 344 // Are there any holidays?
Chris@76 345 if (!empty($day['holidays']))
Chris@76 346 echo '
Chris@76 347 <div class="smalltext holiday">', $txt['calendar_prompt'], ' ', implode(', ', $day['holidays']), '</div>';
Chris@76 348
Chris@76 349 // Show any birthdays...
Chris@76 350 if (!empty($day['birthdays']))
Chris@76 351 {
Chris@76 352 echo '
Chris@76 353 <div class="smalltext">
Chris@76 354 <span class="birthday">', $txt['birthdays'], '</span>';
Chris@76 355
Chris@76 356 /* Each of the birthdays has:
Chris@76 357 id, name (person), age (if they have one set?), and is_last. (last in list?) */
Chris@76 358 $use_js_hide = empty($context['show_all_birthdays']) && count($day['birthdays']) > 15;
Chris@76 359 $count = 0;
Chris@76 360 foreach ($day['birthdays'] as $member)
Chris@76 361 {
Chris@76 362 echo '
Chris@76 363 <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide)? '' : ', ';
Chris@76 364
Chris@76 365 // Stop at ten?
Chris@76 366 if ($count == 10 && $use_js_hide)
Chris@76 367 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;">, ';
Chris@76 368
Chris@76 369 $count++;
Chris@76 370 }
Chris@76 371 if ($use_js_hide)
Chris@76 372 echo '
Chris@76 373 </span>';
Chris@76 374
Chris@76 375 echo '
Chris@76 376 </div>';
Chris@76 377 }
Chris@76 378
Chris@76 379 // Any special posted events?
Chris@76 380 if (!empty($day['events']))
Chris@76 381 {
Chris@76 382 echo '
Chris@76 383 <div class="smalltext">
Chris@76 384 <span class="event">', $txt['events'], '</span>';
Chris@76 385
Chris@76 386 /* The events are made up of:
Chris@76 387 title, href, is_last, can_edit (are they allowed to?), and modify_href. */
Chris@76 388 foreach ($day['events'] as $event)
Chris@76 389 {
Chris@76 390 // If they can edit the event, show a star they can click on....
Chris@76 391 if ($event['can_edit'])
Chris@76 392 echo '
Chris@76 393 <a class="modify_event" href="', $event['modify_href'], '"><img src="' . $settings['images_url'] . '/icons/modify_small.gif" alt="*" /></a>';
Chris@76 394
Chris@76 395 echo '
Chris@76 396 ', $event['link'], $event['is_last'] ? '' : ', ';
Chris@76 397 }
Chris@76 398
Chris@76 399 echo '
Chris@76 400 </div>';
Chris@76 401 }
Chris@76 402 }
Chris@76 403
Chris@76 404 echo '
Chris@76 405 </td>';
Chris@76 406 }
Chris@76 407
Chris@76 408 echo '
Chris@76 409 </tr>';
Chris@76 410 }
Chris@76 411
Chris@76 412 echo '
Chris@76 413 </table>';
Chris@76 414 }
Chris@76 415
Chris@76 416 // Or show a weekly one?
Chris@76 417 function template_show_week_grid($grid_name)
Chris@76 418 {
Chris@76 419 global $context, $settings, $options, $txt, $scripturl, $modSettings;
Chris@76 420
Chris@76 421 if (!isset($context['calendar_grid_' . $grid_name]))
Chris@76 422 return false;
Chris@76 423
Chris@76 424 $calendar_data = &$context['calendar_grid_' . $grid_name];
Chris@76 425
Chris@76 426 // Loop through each month (At least one) and print out each day.
Chris@76 427 foreach ($calendar_data['months'] as $month_data)
Chris@76 428 {
Chris@76 429 echo '
Chris@76 430 <div class="cat_bar">
Chris@76 431 <h3 class="catbg weekly">';
Chris@76 432
Chris@76 433 if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && empty($done_title))
Chris@76 434 echo '
Chris@76 435 <span class="floatleft"><a href="', $calendar_data['previous_week']['href'], '">&#171;</a></span>';
Chris@76 436
Chris@76 437 if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && empty($done_title))
Chris@76 438 echo '
Chris@76 439 <span class="floatright"><a href="', $calendar_data['next_week']['href'], '">&#187;</a></span>';
Chris@76 440
Chris@76 441 echo '
Chris@76 442 <a href="', $scripturl, '?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']) : '', '
Chris@76 443 </h3>
Chris@76 444 </div>';
Chris@76 445
Chris@76 446 $done_title = true;
Chris@76 447
Chris@76 448 echo '
Chris@76 449 <table width="100%" class="calendar_table weeklist" cellspacing="1" cellpadding="0">';
Chris@76 450
Chris@76 451 foreach ($month_data['days'] as $day)
Chris@76 452 {
Chris@76 453 echo '
Chris@76 454 <tr>
Chris@76 455 <td colspan="2">
Chris@76 456 <div class="title_bar">
Chris@76 457 <h4 class="titlebg">', $txt['days'][$day['day_of_week']], '</h4>
Chris@76 458 </div>
Chris@76 459 </td>
Chris@76 460 </tr>
Chris@76 461 <tr>
Chris@76 462 <td class="windowbg">';
Chris@76 463
Chris@76 464 // Should the day number be a link?
Chris@76 465 if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
Chris@76 466 echo '
Chris@76 467 <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'], '">', $day['day'], '</a>';
Chris@76 468 else
Chris@76 469 echo '
Chris@76 470 ', $day['day'];
Chris@76 471
Chris@76 472 echo '
Chris@76 473 </td>
Chris@76 474 <td class="', $day['is_today'] ? 'calendar_today' : 'windowbg2', ' weekdays">';
Chris@76 475
Chris@76 476 // Are there any holidays?
Chris@76 477 if (!empty($day['holidays']))
Chris@76 478 echo '
Chris@76 479 <div class="smalltext holiday">', $txt['calendar_prompt'], ' ', implode(', ', $day['holidays']), '</div>';
Chris@76 480
Chris@76 481 // Show any birthdays...
Chris@76 482 if (!empty($day['birthdays']))
Chris@76 483 {
Chris@76 484 echo '
Chris@76 485 <div class="smalltext">
Chris@76 486 <span class="birthday">', $txt['birthdays'], '</span>';
Chris@76 487
Chris@76 488 /* Each of the birthdays has:
Chris@76 489 id, name (person), age (if they have one set?), and is_last. (last in list?) */
Chris@76 490 foreach ($day['birthdays'] as $member)
Chris@76 491 echo '
Chris@76 492 <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', ';
Chris@76 493 echo '
Chris@76 494 </div>';
Chris@76 495 }
Chris@76 496
Chris@76 497 // Any special posted events?
Chris@76 498 if (!empty($day['events']))
Chris@76 499 {
Chris@76 500 echo '
Chris@76 501 <div class="smalltext">
Chris@76 502 <span class="event">', $txt['events'], '</span>';
Chris@76 503
Chris@76 504 /* The events are made up of:
Chris@76 505 title, href, is_last, can_edit (are they allowed to?), and modify_href. */
Chris@76 506 foreach ($day['events'] as $event)
Chris@76 507 {
Chris@76 508 // If they can edit the event, show a star they can click on....
Chris@76 509 if ($event['can_edit'])
Chris@76 510 echo '
Chris@76 511 <a href="', $event['modify_href'], '"><img src="' . $settings['images_url'] . '/icons/modify_small.gif" alt="*" /></a> ';
Chris@76 512
Chris@76 513 echo '
Chris@76 514 ', $event['link'], $event['is_last'] ? '' : ', ';
Chris@76 515 }
Chris@76 516
Chris@76 517 echo '
Chris@76 518 </div>';
Chris@76 519 }
Chris@76 520
Chris@76 521 echo '
Chris@76 522 </td>
Chris@76 523 </tr>';
Chris@76 524 }
Chris@76 525
Chris@76 526 echo '
Chris@76 527 </table>';
Chris@76 528 }
Chris@76 529 }
Chris@76 530
Chris@76 531 function template_bcd()
Chris@76 532 {
Chris@76 533 global $context, $scripturl;
Chris@76 534
Chris@76 535 echo '
Chris@76 536 <table cellpadding="0" cellspacing="1" align="center">
Chris@76 537 <caption class="titlebg">BCD Clock</caption>
Chris@76 538 <tr class="windowbg">';
Chris@76 539
Chris@76 540 $alt = false;
Chris@76 541 foreach ($context['clockicons'] as $t => $v)
Chris@76 542 {
Chris@76 543 echo '
Chris@76 544 <td style="padding-', $alt ? 'right' : 'left', ': 1.5em;" valign="bottom">';
Chris@76 545
Chris@76 546 foreach ($v as $i)
Chris@76 547 echo '
Chris@76 548 <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" /><br />';
Chris@76 549
Chris@76 550 echo '
Chris@76 551 </td>';
Chris@76 552
Chris@76 553 $alt = !$alt;
Chris@76 554 }
Chris@76 555
Chris@76 556 echo '
Chris@76 557 </tr>
Chris@76 558 </table>
Chris@76 559 <p align="center"><a href="', $scripturl, '?action=clock;rb">Are you hardcore?</a></p>
Chris@76 560
Chris@76 561 <script type="text/javascript"><!-- // --><![CDATA[
Chris@76 562 var icons = new Object();';
Chris@76 563
Chris@76 564 foreach ($context['clockicons'] as $t => $v)
Chris@76 565 {
Chris@76 566 foreach ($v as $i)
Chris@76 567 echo '
Chris@76 568 icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
Chris@76 569 }
Chris@76 570
Chris@76 571 echo '
Chris@76 572 function update()
Chris@76 573 {
Chris@76 574 // Get the current time
Chris@76 575 var time = new Date();
Chris@76 576 var hour = time.getHours();
Chris@76 577 var min = time.getMinutes();
Chris@76 578 var sec = time.getSeconds();
Chris@76 579
Chris@76 580 // Break it up into individual digits
Chris@76 581 var h1 = parseInt(hour / 10);
Chris@76 582 var h2 = hour % 10;
Chris@76 583 var m1 = parseInt(min / 10);
Chris@76 584 var m2 = min % 10;
Chris@76 585 var s1 = parseInt(sec / 10);
Chris@76 586 var s2 = sec % 10;
Chris@76 587
Chris@76 588 // For each digit figure out which ones to turn off and which ones to turn on
Chris@76 589 var turnon = new Array();';
Chris@76 590
Chris@76 591 foreach ($context['clockicons'] as $t => $v)
Chris@76 592 {
Chris@76 593 foreach ($v as $i)
Chris@76 594 echo '
Chris@76 595 if (', $t, ' >= ', $i, ')
Chris@76 596 {
Chris@76 597 turnon.push("', $t, '_', $i, '");
Chris@76 598 ', $t, ' -= ', $i, ';
Chris@76 599 }';
Chris@76 600 }
Chris@76 601
Chris@76 602 echo '
Chris@76 603 for (var i in icons)
Chris@76 604 if (!in_array(i, turnon))
Chris@76 605 icons[i].src = "', $context['offimg'], '";
Chris@76 606 else
Chris@76 607 icons[i].src = "', $context['onimg'], '";
Chris@76 608
Chris@76 609 window.setTimeout("update();", 500);
Chris@76 610 }
Chris@76 611 // Checks for variable in theArray.
Chris@76 612 function in_array(variable, theArray)
Chris@76 613 {
Chris@76 614 for (var i = 0; i < theArray.length; i++)
Chris@76 615 {
Chris@76 616 if (theArray[i] == variable)
Chris@76 617 return true;
Chris@76 618 }
Chris@76 619 return false;
Chris@76 620 }
Chris@76 621
Chris@76 622 update();
Chris@76 623 // ]]></script>';
Chris@76 624 }
Chris@76 625
Chris@76 626 function template_hms()
Chris@76 627 {
Chris@76 628 global $context, $scripturl;
Chris@76 629
Chris@76 630 echo '
Chris@76 631 <table cellpadding="0" cellspacing="1" align="center">
Chris@76 632 <caption class="titlebg">Binary Clock</caption>';
Chris@76 633 $alt = false;
Chris@76 634 foreach ($context['clockicons'] as $t => $v)
Chris@76 635 {
Chris@76 636 echo '
Chris@76 637 <tr class="', $alt ? 'windowbg2' : 'windowbg', '">
Chris@76 638 <td align="right">';
Chris@76 639 foreach ($v as $i)
Chris@76 640 echo '
Chris@76 641 <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" />';
Chris@76 642 echo '
Chris@76 643 </td>';
Chris@76 644 $alt = !$alt;
Chris@76 645 }
Chris@76 646
Chris@76 647 echo '
Chris@76 648 </tr>
Chris@76 649 <tr class="', $alt ? 'windowbg2' : 'windowbg', '"><td colspan="6" align="center"><a href="', $scripturl, '?action=clock">Too tough for you?</a></td></tr>
Chris@76 650 </table>';
Chris@76 651
Chris@76 652 echo '
Chris@76 653 <script type="text/javascript"><!-- // --><![CDATA[
Chris@76 654 var icons = new Object();';
Chris@76 655
Chris@76 656 foreach ($context['clockicons'] as $t => $v)
Chris@76 657 {
Chris@76 658 foreach ($v as $i)
Chris@76 659 echo '
Chris@76 660 icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
Chris@76 661 }
Chris@76 662
Chris@76 663 echo '
Chris@76 664 function update()
Chris@76 665 {
Chris@76 666 // Get the current time
Chris@76 667 var time = new Date();
Chris@76 668 var h = time.getHours();
Chris@76 669 var m = time.getMinutes();
Chris@76 670 var s = time.getSeconds();
Chris@76 671
Chris@76 672 // For each digit figure out which ones to turn off and which ones to turn on
Chris@76 673 var turnon = new Array();';
Chris@76 674
Chris@76 675 foreach ($context['clockicons'] as $t => $v)
Chris@76 676 {
Chris@76 677 foreach ($v as $i)
Chris@76 678 echo '
Chris@76 679 if (', $t, ' >= ', $i, ')
Chris@76 680 {
Chris@76 681 turnon.push("', $t, '_', $i, '");
Chris@76 682 ', $t, ' -= ', $i, ';
Chris@76 683 }';
Chris@76 684 }
Chris@76 685
Chris@76 686 echo '
Chris@76 687 for (var i in icons)
Chris@76 688 if (!in_array(i, turnon))
Chris@76 689 icons[i].src = "', $context['offimg'], '";
Chris@76 690 else
Chris@76 691 icons[i].src = "', $context['onimg'], '";
Chris@76 692
Chris@76 693 window.setTimeout("update();", 500);
Chris@76 694 }
Chris@76 695 // Checks for variable in theArray.
Chris@76 696 function in_array(variable, theArray)
Chris@76 697 {
Chris@76 698 for (var i = 0; i < theArray.length; i++)
Chris@76 699 {
Chris@76 700 if (theArray[i] == variable)
Chris@76 701 return true;
Chris@76 702 }
Chris@76 703 return false;
Chris@76 704 }
Chris@76 705
Chris@76 706 update();
Chris@76 707 // ]]></script>';
Chris@76 708 }
Chris@76 709
Chris@76 710 function template_omfg()
Chris@76 711 {
Chris@76 712 global $context, $scripturl;
Chris@76 713
Chris@76 714 echo '
Chris@76 715 <table cellpadding="0" cellspacing="1" align="center">
Chris@76 716 <caption class="titlebg">OMFG Binary Clock</caption>';
Chris@76 717 $alt = false;
Chris@76 718 foreach ($context['clockicons'] as $t => $v)
Chris@76 719 {
Chris@76 720 echo '
Chris@76 721 <tr class="', $alt ? 'windowbg2' : 'windowbg', '">
Chris@76 722 <td align="right">';
Chris@76 723 foreach ($v as $i)
Chris@76 724 echo '
Chris@76 725 <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" />';
Chris@76 726 echo '
Chris@76 727 </td>';
Chris@76 728 $alt = !$alt;
Chris@76 729 }
Chris@76 730
Chris@76 731 echo '
Chris@76 732 </tr>
Chris@76 733 </table>';
Chris@76 734
Chris@76 735 echo '
Chris@76 736 <script type="text/javascript"><!-- // --><![CDATA[
Chris@76 737 var icons = new Object();';
Chris@76 738
Chris@76 739 foreach ($context['clockicons'] as $t => $v)
Chris@76 740 {
Chris@76 741 foreach ($v as $i)
Chris@76 742 echo '
Chris@76 743 icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
Chris@76 744 }
Chris@76 745
Chris@76 746 echo '
Chris@76 747 function update()
Chris@76 748 {
Chris@76 749 // Get the current time
Chris@76 750 var time = new Date();
Chris@76 751 var month = time.getMonth() + 1;
Chris@76 752 var day = time.getDate();
Chris@76 753 var year = time.getFullYear();
Chris@76 754 year = year % 100;
Chris@76 755 var hour = time.getHours();
Chris@76 756 var min = time.getMinutes();
Chris@76 757 var sec = time.getSeconds();
Chris@76 758
Chris@76 759 // For each digit figure out which ones to turn off and which ones to turn on
Chris@76 760 var turnon = new Array();';
Chris@76 761
Chris@76 762 foreach ($context['clockicons'] as $t => $v)
Chris@76 763 {
Chris@76 764 foreach ($v as $i)
Chris@76 765 echo '
Chris@76 766 if (', $t, ' >= ', $i, ')
Chris@76 767 {
Chris@76 768 turnon.push("', $t, '_', $i, '");
Chris@76 769 ', $t, ' -= ', $i, ';
Chris@76 770 }';
Chris@76 771 }
Chris@76 772
Chris@76 773 echo '
Chris@76 774 for (var i in icons)
Chris@76 775 if (!in_array(i, turnon))
Chris@76 776 icons[i].src = "', $context['offimg'], '";
Chris@76 777 else
Chris@76 778 icons[i].src = "', $context['onimg'], '";
Chris@76 779
Chris@76 780 window.setTimeout("update();", 500);
Chris@76 781 }
Chris@76 782 // Checks for variable in theArray.
Chris@76 783 function in_array(variable, theArray)
Chris@76 784 {
Chris@76 785 for (var i = 0; i < theArray.length; i++)
Chris@76 786 {
Chris@76 787 if (theArray[i] == variable)
Chris@76 788 return true;
Chris@76 789 }
Chris@76 790 return false;
Chris@76 791 }
Chris@76 792
Chris@76 793 update();
Chris@76 794 // ]]></script>';
Chris@76 795 }
Chris@76 796
Chris@76 797 function template_thetime()
Chris@76 798 {
Chris@76 799 global $context, $scripturl;
Chris@76 800
Chris@76 801 echo '
Chris@76 802 <table cellpadding="0" cellspacing="0" border="1" align="center">
Chris@76 803 <caption>The time you requested</caption>';
Chris@76 804 $alt = false;
Chris@76 805 foreach ($context['clockicons'] as $t => $v)
Chris@76 806 {
Chris@76 807 echo '
Chris@76 808 <tr class="', $alt ? 'windowbg2' : 'windowbg', '">
Chris@76 809 <td align="right">';
Chris@76 810 foreach ($v as $i)
Chris@76 811 echo '
Chris@76 812 <img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" />';
Chris@76 813 echo '
Chris@76 814 </td>';
Chris@76 815 $alt = !$alt;
Chris@76 816 }
Chris@76 817
Chris@76 818 echo '
Chris@76 819 </tr>
Chris@76 820 </table>';
Chris@76 821
Chris@76 822 }
Chris@76 823
Chris@76 824 ?>