'; // Show the mini-blocks if they're enabled. if (empty($context['blocks_disabled'])) echo '
', template_show_month_grid('prev', true), ' ', template_show_month_grid('current', true), ' ', template_show_month_grid('next', true), '
'; // What view are we showing? if ($context['calendar_view'] == 'viewlist') echo '
', template_show_upcoming_list('main'), '
'; elseif ($context['calendar_view'] == 'viewweek') echo '
', template_show_week_grid('main'), '
'; else echo '
', template_show_month_grid('main'), '
'; // Close our wrapper. echo ' '; } /** * Display a list of upcoming events, birthdays, and holidays. * * @param string $grid_name The grid name * @return void|bool Returns false if the grid doesn't exist. */ function template_show_upcoming_list($grid_name) { global $context, $scripturl, $txt; // Bail out if we have nothing to work with if (!isset($context['calendar_grid_' . $grid_name])) return false; // Protect programmer sanity $calendar_data = &$context['calendar_grid_' . $grid_name]; // Do we want a title? if (empty($calendar_data['disable_title'])) echo '

', $txt['calendar_upcoming'], '

'; // Give the user some controls to work with template_calendar_top($calendar_data); // Output something just so people know it's not broken if (empty($calendar_data['events']) && empty($calendar_data['birthdays']) && empty($calendar_data['holidays'])) echo '
', $txt['calendar_empty'], '
'; // First, list any events if (!empty($calendar_data['events'])) { echo '

', str_replace(':', '', $txt['events']), '

'; } // Next, list any birthdays if (!empty($calendar_data['birthdays'])) { echo '

', str_replace(':', '', $txt['birthdays']), '

'; foreach ($calendar_data['birthdays'] as $date) { echo '

', $date['date_local'], ': '; unset($date['date_local']); $birthdays = array(); foreach ($date as $member) $birthdays[] = '' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . ''; echo implode(', ', $birthdays); echo '

'; } echo '
'; } // Finally, list any holidays if (!empty($calendar_data['holidays'])) { echo '

', str_replace(':', '', $txt['calendar_prompt']), '

'; $holidays = array(); foreach ($calendar_data['holidays'] as $date) { $date_local = $date['date_local']; unset($date['date_local']); foreach ($date as $holiday) $holidays[] = $holiday . ' (' . $date_local . ')'; } echo implode(', ', $holidays); echo '

'; } } /** * Display a monthly calendar grid. * * @param string $grid_name The grid name * @param bool $is_mini Is this a mini grid? * @return void|bool Returns false if the grid doesn't exist. */ function template_show_month_grid($grid_name, $is_mini = false) { global $context, $txt, $scripturl, $modSettings; // If the grid doesn't exist, no point in proceeding. if (!isset($context['calendar_grid_' . $grid_name])) return false; // A handy little pointer variable. $calendar_data = &$context['calendar_grid_' . $grid_name]; // Some conditions for whether or not we should show the week links *here*. 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))) $show_week_links = true; else $show_week_links = false; // Assuming that we've not disabled it, show the title block! if (empty($calendar_data['disable_title'])) { echo '

'; // Previous Link: If we're showing prev / next and it's not a mini-calendar. if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) echo ' « '; // Next Link: if we're showing prev / next and it's not a mini-calendar. if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) echo ' » '; // Arguably the most exciting part, the title! echo ' ', $txt['months_titles'][$calendar_data['current_month']], ' ', $calendar_data['current_year'], '

'; } // Show the controls on main grids if ($is_mini === false) template_calendar_top($calendar_data); // Finally, the main calendar table. echo ' '; // Show each day of the week. if (empty($calendar_data['disable_day_titles'])) { echo ' '; // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! if ($show_week_links === true) echo ' '; // Now, loop through each actual day of the week. foreach ($calendar_data['week_days'] as $day) echo ' '; echo ' '; } // Our looping begins on a per-week basis. foreach ($calendar_data['weeks'] as $week) { // Some useful looping variables. $current_month_started = false; $count = 1; $final_count = 1; echo ' '; // This is where we add the actual week link, if enabled on this location. if ($show_week_links === true) echo ' '; // Now loop through each day in the week we're on. foreach ($week['days'] as $day) { // What classes should each day inherit? Day is default. $classes = array('days'); if (!empty($day['day'])) { $classes[] = !empty($day['is_today']) ? 'calendar_today' : 'windowbg'; // Additional classes are given for events, holidays, and birthdays. foreach (array('events', 'holidays', 'birthdays') as $event_type) if (!empty($day[$event_type])) $classes[] = $event_type; } else { $classes[] = 'disabled'; } // Now, implode the classes for each day. echo ' '; ++$count; } echo ' '; } // The end of our main table. echo '
', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '
» '; // If it's within this current month, go ahead and begin. if (!empty($day['day'])) { // If it's the first day of this month and not a mini-calendar, we'll add the month title - whether short or full. $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']] . ' ') : ''; // The actual day number - be it a link, or just plain old text! if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) echo ' ', $title_prefix, $day['day'], ''; elseif ($is_mini) echo ' ', $title_prefix, $day['day'], ''; else echo ' ', $title_prefix, $day['day'], ''; // A lot of stuff, we're not showing on mini-calendars to conserve space. if ($is_mini === false) { // Holidays are always fun, let's show them! if (!empty($day['holidays'])) echo '
', $txt['calendar_prompt'], ' ', implode(', ', $day['holidays']), '
'; // Happy Birthday Dear Member! if (!empty($day['birthdays'])) { echo '
', $txt['birthdays'], ' '; /* Each of the birthdays has: id, name (person), age (if they have one set?), and is_last. (last in list?) */ $use_js_hide = empty($context['show_all_birthdays']) && count($day['birthdays']) > 15; $birthday_count = 0; foreach ($day['birthdays'] as $member) { echo '', $member['name'], '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; // 9...10! Let's stop there. if ($birthday_count == 10 && $use_js_hide) // !!TODO - Inline CSS and JavaScript should be moved. echo '...
(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')
'; echo '
'; } // Any special posted events? if (!empty($day['events'])) { // Sort events by start time (all day events will be listed first) uasort( $day['events'], function($a, $b) { if ($a['start_timestamp'] == $b['start_timestamp']) return 0; return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; } ); echo '
', $txt['events'], '
'; /* The events are made up of: title, href, is_last, can_edit (are they allowed to?), and modify_href. */ foreach ($day['events'] as $event) { $event_icons_needed = ($event['can_edit'] || $event['can_export']) ? true : false; echo '
', $event['link'], '
'; if (!empty($event['start_time_local']) && $event['starts_today'] == true) echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); elseif (!empty($event['allday'])) echo $txt['calendar_allday']; echo ' '; if (!empty($event['location'])) echo '
' . $event['location'] . ''; if ($event['can_edit'] || $event['can_export']) { echo ' '; // If they can edit the event, show an icon they can click on.... if ($event['can_edit']) echo ' '; // Exporting! if ($event['can_export']) echo ' '; echo '
'; } echo '
'; } echo '
'; } } $current_month_started = $count; } // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! elseif ($is_mini === false) { if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) echo '', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, ''; elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) echo '', $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++, ''; } // Close this day and increase var count. echo '
'; } /** * Shows a weekly grid * * @param string $grid_name The name of the grid * @return void|bool Returns false if the grid doesn't exist */ function template_show_week_grid($grid_name) { global $context, $txt, $scripturl, $modSettings; // We might have no reason to proceed, if the variable isn't there. if (!isset($context['calendar_grid_' . $grid_name])) return false; // Handy pointer. $calendar_data = &$context['calendar_grid_' . $grid_name]; // At the very least, we have one month. Possibly two, though. $iteration = 1; foreach ($calendar_data['months'] as $month_data) { // For our first iteration, we'll add a nice header! if ($iteration == 1) { echo '

'; // Previous Week Link... if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) echo ' « '; // Next Week Link... if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) echo ' » '; // "Week beginning " if (!empty($calendar_data['week_title'])) echo $calendar_data['week_title']; echo '

'; // Show the controls template_calendar_top($calendar_data); } // Our actual month... echo '
', $txt['months_titles'][$month_data['current_month']], '
'; // The main table grid for $this week. echo ' '; if (!empty($calendar_data['show_events'])) echo ' '; if (!empty($calendar_data['show_holidays'])) echo ' '; if (!empty($calendar_data['show_birthdays'])) echo ' '; echo ' '; // Each day of the week. foreach ($month_data['days'] as $day) { // How should we be highlighted or otherwise not...? $classes = array('days'); $classes[] = !empty($day['is_today']) ? 'calendar_today' : 'windowbg'; echo ' '; if (!empty($calendar_data['show_events'])) { echo ' '; } if (!empty($calendar_data['show_holidays'])) { echo ' '; } if (!empty($calendar_data['show_birthdays'])) { echo ' '; } echo ' '; } // Increase iteration for loop counting. ++$iteration; echo '
', $txt['calendar_day'], '', $txt['events'], '', $txt['calendar_prompt'], '', $txt['birthdays'], '
'; // Should the day number be a link? if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) echo ' ', $txt['days'][$day['day_of_week']], ' - ', $day['day'], ''; else echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; echo ' '; // Show any events... if (!empty($day['events'])) { // Sort events by start time (all day events will be listed first) uasort( $day['events'], function($a, $b) { if ($a['start_timestamp'] == $b['start_timestamp']) return 0; return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; } ); foreach ($day['events'] as $event) { echo '
'; $event_icons_needed = ($event['can_edit'] || $event['can_export']) ? true : false; echo $event['link'], '
'; if (!empty($event['start_time_local'])) echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; else echo $txt['calendar_allday']; echo ' '; if (!empty($event['location'])) echo '
' . $event['location'] . ''; if (!empty($event_icons_needed)) { echo ' '; // If they can edit the event, show a star they can click on.... if (!empty($event['can_edit'])) echo ' '; // Can we export? Sweet. if (!empty($event['can_export'])) echo ' '; echo '
'; } echo '
'; } if (!empty($context['can_post'])) { echo '
'; } } else { if (!empty($context['can_post'])) echo ' '; } echo '
'; // Show any holidays! if (!empty($day['holidays'])) echo implode('
', $day['holidays']); echo '
'; // Show any birthdays... if (!empty($day['birthdays'])) { foreach ($day['birthdays'] as $member) echo ' ', $member['name'], ' ', isset($member['age']) ? ' (' . $member['age'] . ')' : '', ' ', $member['is_last'] ? '' : '
'; } echo '
'; } } /** * Calendar controls under the title * * Creates the view selector (list, month, week), the date selector (either a * select menu or a date range chooser, depending on the circumstances), and the * "Post Event" button. * * @param array $calendar_data The data for the calendar grid that this is for */ function template_calendar_top($calendar_data) { global $context, $scripturl, $txt; echo '
', $txt['calendar_list'], ' ', $txt['calendar_month'], ' ', $txt['calendar_week'], '
', template_button_strip($context['calendar_buttons'], 'right'); echo '
'; if (!empty($calendar_data['end_date'])) echo ' ', strtolower($txt['to']), ' '; echo '
'; } /** * Template for posting a calendar event. */ function template_event_post() { global $context, $txt, $scripturl, $modSettings; echo '
'; if (!empty($context['event']['new'])) echo ' '; // Start the main table. echo '

', $context['page_title'], '

'; if (!empty($context['post_error']['messages'])) echo '
', $context['error_type'] == 'serious' ? '' . $txt['error_while_submitting'] . '' : '', '
', implode('
', $context['post_error']['messages']), '
'; echo '
', $txt['calendar_event_title'], '
'; // If this is a new event let the user specify which board they want the linked post to be put into. if ($context['event']['new'] && !empty($context['event']['categories'])) { echo '
', $txt['calendar_post_in'], '
'; } // Note to theme writers: The JavaScript expects the input fields for the start and end dates & times to be contained in a wrapper element with the id "event_time_input" echo '
', $txt['calendar_event_options'], '
', $txt['start'], '
', $txt['end'], '
', $txt['calendar_timezone'], '
', $txt['location'], '
'; echo ' '; // Delete button? if (empty($context['event']['new'])) echo ' '; echo '
'; } /** * Displays a clock */ function template_bcd() { global $context, $scripturl; $alt = false; echo ' '; foreach ($context['clockicons'] as $t => $v) { echo ' '; $alt = !$alt; } echo '
BCD Clock
'; foreach ($v as $i) echo '
'; echo '
Are you hardcore?
'; } /** * Displays the hours, minutes and seconds for our clock */ function template_hms() { global $context, $scripturl; $alt = false; echo ' '; foreach ($context['clockicons'] as $t => $v) { echo ' '; $alt = !$alt; } echo '
Binary Clock
'; foreach ($v as $i) echo ' '; echo '
Too tough for you?
'; echo ' '; } /** * Displays a binary clock */ function template_omfg() { global $context; $alt = false; echo ' '; foreach ($context['clockicons'] as $t => $v) { echo ' '; $alt = !$alt; } echo '
OMFG Binary Clock
'; foreach ($v as $i) echo ' '; echo '
'; } /** * Displays the time */ function template_thetime() { global $context; $alt = false; echo ' '; foreach ($context['clockicons'] as $v) { echo ' '; $alt = !$alt; } echo '
The time you requested
'; foreach ($v as $i) echo ' '; echo '
'; } ?>