function placePageCalendar($content) { // Get the options... $icsOptions = $this->getAdminOptions(); // SET LOCALE FOR EVERY PAGE/EVENT if (!empty($icsOptions['date_language'])) { $fixed_locales = preg_replace('/ +/', '', $icsOptions['date_language']); $locales = explode(',', $fixed_locales); if (!setlocale(LC_ALL, $locales)) { //return "Locale Error"; exit; } } // Only do this if this is a page and it has the appropriate custom field if (is_page()) { $savedLimit = $icsOptions['event_limit']; $savedDefault = $icsOptions['ics_file_default']; if (isset($_GET['ics-perm'])) { $icsArray = unserialize($icsOptions['ics_files']); $output = '<a style="float:right;" href="' . preg_replace('/ics-perm=([^&?]*)(&|\\?)?/i', '', $_SERVER['REQUEST_URI']) . '">' . __('Return to Calendar', 'WPICSImporter') . '</a>' . '<br style="clear:both;" />'; return $output . ICalEvents::display_one_event($icsArray, $_GET['ics-perm']); } if (preg_match('/\\[' . $this->showEvents . '=?([0-9]*)?( +cal=)?([0-9,]{1,})?\\]/i', $content, $args)) { define('ICAL_EVENTS_CACHE_TTL', $icsOptions['cache_time']); preg_match_all('/\\[' . $this->showEvents . '=?([0-9]*)?( +cal=)?([0-9,]{1,})?\\]/i', $content, $args); foreach ($args[1] as $k => $arg) { $more = ''; if (!empty($arg)) { $icsOptions['event_limit'] = $arg; $more .= '=' . $arg; } else { $icsOptions['event_limit'] = $savedLimit; } if (!empty($args[3][$k])) { $icsOptions['ics_file_default'] = $args[3][$k]; $more .= ' +cal=' . $args[3][$k]; } else { $icsOptions['ics_file_default'] = $savedDefault; } if ($icsOptions['use_custom_format'] == 'true') { $eventsContent = ICalEvents::custom_display_events($icsOptions); } else { if ($icsOptions['gmt_start_now'] == 'true') { $gmt_start = time(); $gmt_end = NULL; if ($icsOptions['limit_type'] == 'days') { $gmt_end = time() + (int) $icsOptions['event_limit'] * 24 * 3600; $icsOptions['event_limit'] = 0; } } else { if ($icsOptions['gmt_start'] != '') { $gmt_start = strtotime($icsOptions['gmt_start'], time()); } if ($icsOptions['gmt_end'] != '') { $gmt_end = strtotime($icsOptions['gmt_end'], time()); } } $icsArray = unserialize($icsOptions['ics_files']); if ($icsOptions['ics_file_default'] == 'combine') { $icsFile = $icsArray; } elseif (strstr($icsOptions['ics_file_default'], ',')) { $cals = explode(',', $icsOptions['ics_file_default']); foreach ($cals as $calid) { $icsFile[] = $icsArray[trim($calid)]; } } elseif (!empty($icsArray[$icsOptions['ics_file_default']])) { $icsFile = $icsArray[$icsOptions['ics_file_default']]; } else { $icsFile = array_shift($icsArray); } $eventsContent = ICalEvents::display_events($icsFile, $gmt_start, $gmt_end, $icsOptions['event_limit']); } $content = preg_replace('/\\[' . $this->showEvents . $more . '\\]/i', $eventsContent, $content); } } if (preg_match('/\\[' . $this->showCalendar . '( +cal=)?([0-9,]{1,})?\\]/i', $content)) { $cssAdd = '<style type="text/css" media="screen">@import "' . (empty($icsOptions['cal_css_file']) ? ICSCALENDAR_URLPATH . 'library/ics-calendar.css' : $icsOptions['cal_css_file']) . '";</style>' . "\n"; $eventid = ''; if (!empty($_GET['icsevent'])) { $eventid = $_GET['icsevent']; } if (!empty($_GET['icsdate'])) { $eventdate = $_GET['icsdate']; } $icsArray = unserialize($icsOptions['ics_files']); preg_match_all('/\\[' . $this->showCalendar . '( +cal=)?([0-9,]{1,})?\\]/i', $content, $finds); foreach ($finds[2] as $find) { if (!empty($find)) { $icsOptions['ics_file_default'] = $find; $more = ' +cal=' . $find; } else { $icsOptions['ics_file_default'] = $savedDefault; $more = ''; } $calDisplay = $cssAdd . icsCalDisplay::initCalendar($icsOptions, $eventid, $eventdate); $content = preg_replace('/\\[' . $this->showCalendar . $more . '\\]/i', $calDisplay, $content); } } } return $content; }