function sp_calendarInformation($parameters, $id, $return_parameters = false)
{
    global $scripturl, $modSettings, $txt;
    $block_parameters = array('events' => 'check', 'future' => 'int', 'birthdays' => 'check', 'holidays' => 'check');
    if ($return_parameters) {
        return $block_parameters;
    }
    $show_event = !empty($parameters['events']);
    $event_future = !empty($parameters['future']) ? (int) $parameters['future'] : 0;
    $event_future = abs($event_future);
    $show_birthday = !empty($parameters['birthdays']);
    $show_holiday = !empty($parameters['holidays']);
    $show_titles = false;
    if (!$show_event && !$show_birthday && !$show_holiday) {
        echo '
								', $txt['sp_calendar_noEventsFound'];
        return;
    }
    $now = forum_time();
    $today_date = date("Y-m-d", $now);
    $calendar_array = array('todayEvents' => array(), 'futureEvents' => array(), 'todayBirthdays' => array(), 'todayHolidays' => array());
    if ($show_event) {
        if (!empty($event_future)) {
            $event_future_date = date("Y-m-d", $now + $event_future * 86400);
        } else {
            $event_future_date = $today_date;
        }
        $events = sp_loadCalendarData('getEvents', $today_date, $event_future_date);
        ksort($events);
        $displayed = array();
        foreach ($events as $day => $day_events) {
            foreach ($day_events as $event_key => $event) {
                if (in_array($event['id'], $displayed)) {
                    unset($events[$day][$event_key]);
                } else {
                    $displayed[] = $event['id'];
                }
            }
        }
        if (!empty($events[$today_date])) {
            $calendar_array['todayEvents'] = $events[$today_date];
            unset($events[$today_date]);
        }
        if (!empty($events)) {
            ksort($events);
            $calendar_array['futureEvents'] = $events;
        }
    }
    if ($show_birthday) {
        $calendar_array['todayBirthdays'] = current(sp_loadCalendarData('getBirthdays', $today_date));
        $show_titles = !empty($show_event) || !empty($show_holiday);
    }
    if ($show_holiday) {
        $calendar_array['todayHolidays'] = current(sp_loadCalendarData('getHolidays', $today_date));
        $show_titles = !empty($show_event) || !empty($show_birthday);
    }
    if (empty($calendar_array['todayEvents']) && empty($calendar_array['futureEvents']) && empty($calendar_array['todayBirthdays']) && empty($calendar_array['todayHolidays'])) {
        echo '
								', $txt['sp_calendar_noEventsFound'];
        return;
    } else {
        echo '
								<ul class="sp_list">';
        if (!empty($calendar_array['todayHolidays'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_holidays'], '</strong></li>';
            }
            foreach ($calendar_array['todayHolidays'] as $key => $holiday) {
                echo '
									<li>', sp_embed_image('holiday'), ' ', $holiday, '</li>';
            }
        }
        if (!empty($calendar_array['todayBirthdays'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_birthdays'], '</strong></li>';
            }
            foreach ($calendar_array['todayBirthdays'] as $member) {
                echo '
									<li>', sp_embed_image('birthday'), ' <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a></li>';
            }
        }
        if (!empty($calendar_array['todayEvents'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_events'], '</strong></li>';
            }
            foreach ($calendar_array['todayEvents'] as $event) {
                echo '
									<li>', sp_embed_image('event'), ' ', $event['link'], !$show_titles ? ' - ' . timeformat(forum_time(), '%d %b') : '', '</li>';
            }
        }
        if (!empty($calendar_array['futureEvents'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_upcomingEvents'], '</strong></li>';
            }
            foreach ($calendar_array['futureEvents'] as $startdate => $events) {
                list($year, $month, $day) = explode('-', $startdate);
                $currentDay = $day . ' ' . $txt['months_short'][(int) $month];
                foreach ($events as $event) {
                    echo '
									<li>', sp_embed_image('event'), ' ', $event['link'], ' - ', $currentDay, '</li>';
                }
            }
        }
        echo '
								</ul>';
    }
}
/**
 * Calendar Info Block, Displays basic calendar ... birthdays, events and holidays.
 *
 * @param mixed[] $parameters
 *		'events' => show events
 *		'future' => how many months out to look for items
 *		'birthdays' => show birthdays
 *		'holidays' => show holidays
 * @param int $id - not used in this block
 * @param boolean $return_parameters if true returns the configuration options for the block
 */
function sp_calendarInformation($parameters, $id, $return_parameters = false)
{
    global $scripturl, $txt;
    $block_parameters = array('events' => 'check', 'future' => 'int', 'birthdays' => 'check', 'holidays' => 'check');
    if ($return_parameters) {
        return $block_parameters;
    }
    $show_event = !empty($parameters['events']);
    $event_future = !empty($parameters['future']) ? (int) $parameters['future'] : 0;
    $event_future = abs($event_future);
    $show_birthday = !empty($parameters['birthdays']);
    $show_holiday = !empty($parameters['holidays']);
    $show_titles = false;
    // If they are not showing anything, not much to do !
    if (!$show_event && !$show_birthday && !$show_holiday) {
        echo '
								', $txt['sp_calendar_noEventsFound'];
        return;
    }
    $now = forum_time();
    $today_date = date("Y-m-d", $now);
    $calendar_array = array('todayEvents' => array(), 'futureEvents' => array(), 'todayBirthdays' => array(), 'todayHolidays' => array());
    // Load calendar events
    if ($show_event) {
        // Just today's events or looking forward a few days?
        if (!empty($event_future)) {
            $event_future_date = date("Y-m-d", $now + $event_future * 86400);
        } else {
            $event_future_date = $today_date;
        }
        // Load them in
        $events = sp_loadCalendarData('getEvents', $today_date, $event_future_date);
        ksort($events);
        $displayed = array();
        foreach ($events as $day => $day_events) {
            foreach ($day_events as $event_key => $event) {
                if (in_array($event['id'], $displayed)) {
                    unset($events[$day][$event_key]);
                } else {
                    $displayed[] = $event['id'];
                }
            }
        }
        if (!empty($events[$today_date])) {
            $calendar_array['todayEvents'] = $events[$today_date];
            unset($events[$today_date]);
        }
        if (!empty($events)) {
            ksort($events);
            $calendar_array['futureEvents'] = $events;
        }
    }
    // Load in today's birthdays
    if ($show_birthday) {
        $calendar_array['todayBirthdays'] = current(sp_loadCalendarData('getBirthdays', $today_date));
        $show_titles = !empty($show_event) || !empty($show_holiday);
    }
    // Load in any holidays
    if ($show_holiday) {
        $calendar_array['todayHolidays'] = current(sp_loadCalendarData('getHolidays', $today_date));
        $show_titles = !empty($show_event) || !empty($show_birthday);
    }
    // Done collecting information, show what we found
    if (empty($calendar_array['todayEvents']) && empty($calendar_array['futureEvents']) && empty($calendar_array['todayBirthdays']) && empty($calendar_array['todayHolidays'])) {
        echo '
								', $txt['sp_calendar_noEventsFound'];
        return;
    } else {
        echo '
								<ul class="sp_list">';
        if (!empty($calendar_array['todayHolidays'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_holidays'], '</strong></li>';
            }
            foreach ($calendar_array['todayHolidays'] as $key => $holiday) {
                echo '
									<li ', sp_embed_class('holiday'), '>', $holiday, '</li>';
            }
        }
        if (!empty($calendar_array['todayBirthdays'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_birthdays'], '</strong></li>';
            }
            foreach ($calendar_array['todayBirthdays'] as $member) {
                echo '
									<li ', sp_embed_class('birthday'), '><a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a></li>';
            }
        }
        if (!empty($calendar_array['todayEvents'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_events'], '</strong></li>';
            }
            foreach ($calendar_array['todayEvents'] as $event) {
                echo '
									<li ', sp_embed_class('event'), '>', $event['link'], !$show_titles ? ' - ' . standardTime(forum_time(), '%d %b') : '', '</li>';
            }
        }
        if (!empty($calendar_array['futureEvents'])) {
            if ($show_titles) {
                echo '
									<li><strong>', $txt['sp_calendar_upcomingEvents'], '</strong></li>';
            }
            foreach ($calendar_array['futureEvents'] as $startdate => $events) {
                foreach ($events as $event) {
                    echo '
									<li ', sp_embed_class('event'), '>', $event['link'], ' - ', timeformat(strtotime($startdate), '%d %b'), '</li>';
                }
            }
        }
        echo '
								</ul>';
    }
}