function custom_display_events($options, $return_count = false) { if (!isset($options['events_page'])) { $options['events_page'] = 1; } if ($options['gmt_start_now'] == 'true') { $gmt_start = time(); $gmt_end = NULL; if ($options['limit_type'] == 'days') { $gmt_end = time() + (int) $options['event_limit'] * 24 * 3600 * (int) $options['events_page']; $options['event_limit'] = 0; } } else { if ($options['gmt_start'] != '') { $gmt_start = strtotime($options['gmt_start'], time()); } if ($options['gmt_end'] != '') { $gmt_end = strtotime($options['gmt_end'], time()); } } $icsArray = unserialize($options['ics_files']); if ($options['ics_file_default'] == 'combine') { $icsFile = $icsArray; } elseif (strstr($options['ics_file_default'], ',')) { $cals = explode(',', $options['ics_file_default']); foreach ($cals as $calid) { $icsFile[] = $icsArray[trim($calid)]; } } elseif (!empty($icsArray[$options['ics_file_default']])) { $icsFile = $icsArray[$options['ics_file_default']]; } else { $icsFile = array_shift($icsArray); } $events = ICalEvents::get_events($icsFile, $gmt_start, $gmt_end, $options['event_limit'] * (int) $options['events_page']); if (!is_array($events)) { return $events; } if (count($events) > $options['event_limit']) { $event_offset = $options['event_limit'] * ($options['events_page'] - 1); $events = array_slice($events, $event_offset); } $final_output = ''; foreach ($events as $event) { //$final_output .= '<div>'; $output = stripslashes($options['custom_format']); $save_date_format = $options['date_format']; if (date('Y', $event['StartTime']) != date('Y') && $options['date_format_add_year'] == '1') { if ($options['date_function'] == 'date') { $options['date_format'] .= ', Y'; } else { $options['date_format'] .= ', %Y'; } } if (ICalEvents::is_all_day($event['StartTime'], $event['EndTime']) || isset($options['hide_time']) && $options['hide_time'] == 'true') { $formated_date = ICalEvents::fdate($options['date_format'], $event['StartTime']); $output = str_replace('%start-time%', '', $output); $output = str_replace('%end-time%', '', $output); $output = str_replace('%end-date%', '', $output); } else { $formated_date = ICalEvents::format_date_range($event['StartTime'], $event['EndTime'], $event['Untimed'], $options['date_format'], $options['time_format']); } $output = str_replace('%date-time%', $formated_date, $output); if ($event['Untimed']) { $output = str_replace('%start-time%', '', $output); $output = str_replace('%end-time%', '', $output); } else { $formatted_time = ICalEvents::fdate($options['time_format'], $event['StartTime']); $output = str_replace('%start-time%', $formatted_time, $output); $formatted_time = ICalEvents::fdate($options['time_format'], $event['EndTime']); $output = str_replace('%end-time%', $formatted_time, $output); } $formatted_date = ICalEvents::fdate($options['date_format'], $event['StartTime']); $output = str_replace('%start-date%', $formatted_date, $output); if (ICalEvents::is_same_day($event['StartTime'], $event['EndTime'])) { $output = str_replace('%end-date%', '', $output); } else { $formatted_date = ICalEvents::fdate($options['date_format'], $event['EndTime']); $output = str_replace('%end-date%', $formatted_date, $output); } if ($event['Summary']) { $event_title = $event['Summary']; } else { $event_title = 'Untitled Event'; } $output = str_replace('%event-title%', $event_title, $output); if ($event['Description']) { $event_description = $event['Description']; } else { $event_description = ''; } $output = str_replace('%description%', $event_description, $output); if ($event['Location']) { $event_location = $event['Location']; } else { $event_location = ''; } $output = str_replace('%location%', $event_location, $output); if ($event['UID']) { //$output .= '<!-- ' . htmlentities($event['UID']) . ' -->'; } $final_output .= str_replace(array("\r\n", "\n", "\r"), ' ', $output) . ''; //$final_output .= eregi_replace("[\r\n]","",$output);// . '</div>'; $options['date_format'] = $save_date_format; } if ($return_count == true) { return array('output' => $final_output, 'count' => count($events)); } else { return $final_output; } }
function eventBoxArray($array, $options, $uid) { $aEvents = array(); foreach ($array as $event) { $eventUID = 'ics_' . md5($event['UID'] . time()); $eventContent = '<div class="ics-calendar-event-box" id="' . $eventUID . $uid . '">'; $eventContent .= __('Event:', 'WPICSImporter') . ' <strong>' . $event['Summary'] . '</strong><br />'; if (ICalEvents::is_all_day($event['StartTime'], $event['EndTime']) || isset($options['hide_time']) && $options['hide_time'] == 'true') { $formated_date = date($options['date_format'], $event['StartTime']); } else { $formated_date = ICalEvents::format_date_range($event['StartTime'], $event['EndTime'], $event['Untimed'], $options['date_format'], $options['time_format']); } $eventContent .= __('When:', 'WPICSImporter') . ' ' . $formated_date . '<br />'; if ($event['Description'] != '') { $calContent .= __('Description:', 'WPICSImporter') . ' ' . $event['Description']; } $eventContent .= '</div>'; $eventContent .= '<div class="ics-calendar-event" icstag="' . $eventUID . $uid . '">'; $eventContent .= $event['Summary']; $eventContent .= '</div>'; $aEvents[] = $eventContent; } return $aEvents; }