/** * Filters all {event*} tags * @param $content Content to filter * @param $evt Event Object (optional) * @return String Filtered content */ function filterContent($content, $evt = NULL) { // Match all tags, but make sure that no escaped {} are selected! preg_match_all('/[^\\\\]?(\\{event[s]?_(.+?[^\\\\])\\})/is', $content, $matches, PREG_SET_ORDER); foreach ($matches as $k => $m) { $matches[$k][0] = $m[1]; $matches[$k][1] = $m[2]; unset($matches[$k][2]); } if (count($matches) == 0) { return $content; } // Get Page url if any $page_id = intval(get_option('fse_page')); if (!empty($page_id)) { $page_url = get_permalink($page_id); if (!empty($page_url)) { if (strpos($page_url, '?') === false) { $page_url .= '?event='; } else { $page_url .= '&event='; } } } $showenddate = get_option('fse_show_enddate') == true ? true : false; $hideifallday = get_option('fse_allday_hide_time') == true ? true : false; if (!empty($evt)) { // We just create an event object, if it does no exist, all var are empty! } elseif (isset($_GET['event'])) { $evt = new fsEvent(intval($_GET['event']), 'publish'); } else { // Load an empty event, to get all attributes in the correct format $evt = new fsEvent(-1); } // Calculate duration $start = floor($evt->tsfrom / 60); $end = floor($evt->tsto / 60); $diff = $end - $start; if ($evt->allday == true) { $dur_days = floor($diff / 1440) + 1; // Add 1 day } else { $dur_days = floor($diff / 1440); $diff -= $dur_days * 1440; $dur_hours = floor($diff / 60); $diff -= $dur_hours * 60; $dur_minutes = $diff; } foreach ($matches as $m) { //$token = explode(';', $m[1]); $token = array(); $qopen = false; $esc = false; $temp = ''; // Covert URL Encodings $m[1] = html_entity_decode($m[1]); $m[1] = str_replace(array('”', '″', '“'), array('"', '"', '"'), $m[1]); /*$m[1] = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $m[1]); $m[1] = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $m[1]);*/ for ($i = 0; $i < strlen($m[1]); $i++) { if ($m[1][$i] == '"' && $esc == false) { $qopen = !$qopen; $esc = false; $temp .= '"'; } elseif ($m[1][$i] == "\\") { // Maybe already escaped, just add it as well if ($esc == true) { $temp .= '\\'; // Make 2! $esc = false; } else { $esc = true; } } elseif ($m[1][$i] == ';' && $qopen == false) { $token[] = trim($temp); $temp = ''; $esc = false; } else { $temp .= $m[1][$i]; $esc = false; } } if (!empty($temp)) { $token[] = $temp; } $opts = array(); $opts_orig = array(); if (count($token) > 1) { for ($i = 1; $i < count($token); $i++) { list($opt_orig, $val) = explode('=', $token[$i], 2); $val = trim($val); $opt_orig = trim($opt_orig); $opt = strtolower($opt_orig); // Remove " " preg_match('/^"(.*)"$/s', $val, $matches); if (count($matches) > 0) { $val = $matches[1]; } $opts[$opt] = $val; $opts_orig[$opt_orig] = $val; } } $tag = strtolower(trim($token[0])); // Reset! $rep = ''; switch ($tag) { case 'id': if (isset($opts['id'])) { unset($evt); $evt = new fsEvent(intval($opts['id']), 'publish'); $rep = ''; } else { $rep = $evt->eventid; } break; case 'subject': if (empty($evt->subject)) { $rep = __('Event not found'); } else { $rep = $evt->subject; } break; case 'location': $rep = $evt->location; break; case 'description': $rep = $evt->getDescription(); break; case 'author': $rep = $evt->author_t; break; case 'publisher': $rep = $evt->publishauthor_t; break; case 'authorid': $rep = $evt->author; break; case 'publisherid': $rep = $evt->publishauthor; break; case 'startdate': if (!empty($evt->tsfrom)) { if (isset($opts['fmt'])) { $rep = $evt->getStart($opts['fmt'], 2); } else { $rep = $evt->getStart('', 2); } } else { $rep = ''; } break; case 'enddate': if (!empty($evt->tsto)) { if (isset($opts['alwaysshowenddate'])) { $l_sed = $opts['alwaysshowenddate'] == true ? true : false; } else { $l_sed = $showenddate; } // Do not display if date AND time is the same if ($l_sed == false && (fsCalendar::date('d', $evt->tsto) == fsCalendar::date('d', $evt->tsfrom) && fsCalendar::date('m', $evt->tsto) == fsCalendar::date('m', $evt->tsfrom) && fsCalendar::date('Y', $evt->tsto) == fsCalendar::date('Y', $evt->tsfrom))) { $rep = ''; } else { if (isset($opts['before'])) { $rep = $opts['before']; } else { $rep = ''; } if (isset($opts['fmt'])) { $rep .= $evt->getEnd($opts['fmt'], 2); } else { $rep .= $evt->getEnd('', 2); } } } else { $rep = ''; } break; case 'starttime': if (!empty($evt->tsfrom)) { if (isset($opts['hideifallday'])) { $l_hide = $opts['hideifallday'] == true ? true : false; } else { $l_hide = $hideifallday; } if ($evt->allday == true && $l_hide == true) { $rep = ''; } else { // Do not display if date AND time is the same if (isset($opts['fmt'])) { $rep = $evt->getStart($opts['fmt'], 3); } else { $rep = $evt->getStart('', 3); } } } else { $rep = ''; } break; case 'endtime': if (!empty($evt->tsto)) { if (isset($opts['hideifallday'])) { $l_hide = $opts['hideifallday'] == true ? true : false; } else { $l_hide = $hideifallday; } // Do not display if date AND time is the same if (isset($opts['alwaysshowenddate'])) { $l_sed = $opts['alwaysshowenddate'] == true ? true : false; } else { $l_sed = $showenddate; } if ($evt->allday == true && $l_hide == true || $l_sed == false && $evt->tsfrom == $evt->tsto) { $rep = ''; } else { if (isset($opts['before'])) { $rep = $opts['before']; } else { $rep = ''; } if (isset($opts['fmt'])) { $rep .= $evt->getEnd($opts['fmt'], 3); } else { $rep .= $evt->getEnd('', 3); } } } else { $rep = ''; } break; case 'duration': $t = $opts['type']; $a = $opts['suffix']; $e = isset($opts['empty']) ? $opts['empty'] : 0; if (in_array($t, array('d', 'h', 'm'))) { if ($evt->allday == true) { if ($t == 'd') { $rep = $dur_days . $a; } else { $rep = ''; } } else { switch ($t) { case 'd': $rep = $dur_days; break; case 'h': $rep = $dur_hours; break; case 'm': $rep = $dur_minutes; break; } if (empty($rep) && $e != 1) { $rep = ''; } else { $rep .= $a; } } } else { $rep = ''; } break; case 'allday': if ($evt->allday == true && isset($opts['text'])) { $rep = $opts['text']; } else { $rep = ''; } break; case 'publishdate': if (!empty($evt->publishdate)) { if (isset($opts['fmt'])) { $rep = fsCalendar::date_i18n($opts['fmt'], $evt->publishdate); } else { $rep = fsCalendar::date_i18n('d.m.Y', $evt->publishdate); } } else { $rep = ''; } break; case 'publishtime': if (!empty($evt->publishdate)) { if (isset($opts['fmt'])) { $rep = fsCalendar::date_i18n($opts['fmt'], $evt->publishdate); } else { $rep = fsCalendar::date_i18n('H:i', $evt->publishdate); } } else { $rep = ''; } break; case 'categories': $excl = array(); if (isset($opts['exclude'])) { $excl = explode(',', $opts['exclude']); } if (isset($opts['sep'])) { $sep = $opts['sep']; } else { $sep = ', '; } $rep = ''; $first = true; foreach ($evt->categories_t as $k => $c) { if (!in_array($k, $excl)) { if ($first == true) { $first = false; } else { if ($sep != 'list') { $rep .= $sep; } } if ($sep == 'list') { $rep .= '<li>' . $c . '</li>'; } else { $rep .= $c; } } } if ($sep == 'list') { $rep = '<ul class="eventcategories">' . $rep . '</ul>'; } break; case 'url': if ($opts['linktopost'] == true && !empty($evt->postid)) { $rep = get_permalink($evt->postid); } elseif (!empty($page_url) && !empty($evt->eventid)) { $rep = $page_url . $evt->eventid; } else { $rep = ''; } break; case 'print': $opts['echo'] = false; // No echo! $rep = $this->printEvents($opts); break; case 'printlist': $opts['echo'] = false; // No echo! $rep = $this->printEventsList($opts); break; case 'calendar': $uniqueId = substr(uniqid('fscal-'), 0, 12); $rep = '<div id="' . $uniqueId . '"></div>'; $rep .= "<script type=\"text/javascript\">jQuery(document).ready(function() {jQuery('#{$uniqueId}').fullCalendar({"; // Convert hierarchical options if (is_array($opts_orig)) { foreach ($opts_orig as $key => $val) { $keys = explode('->', $key); // Process from the last to the second for ($i = count($keys) - 1; $i > 0; $i--) { $tmp[trim($keys[$i])] = $val; $val = $tmp; } if (trim($keys[0]) != $key) { unset($opts_orig[$key]); } $opts_orig[trim($keys[0])] = $val; } } // First day of week if (!isset($opts_orig['firstDay'])) { if (get_option('fse_ws_wp') == true) { $weekstart = get_option('start_of_week'); } else { $weekstart = get_option('fse_ws'); } $rep .= "firstDay: {$weekstart},"; } // Date formats if (!isset($opts_orig['timeFormat'])) { $fmt = $this->convertDateFmt(get_option('time_format')); $rep .= "timeFormat: \"{$fmt}\","; } // Translation of month and day names if (!isset($opts_orig['monthNames'])) { $rep .= 'monthNames: ["' . implode('","', $GLOBALS['month']) . '"],'; } if (!isset($opts_orig['monthNamesShort'])) { $rep .= 'monthNamesShort: ["' . implode('","', $GLOBALS['month_abbrev']) . '"],'; } if (!isset($opts_orig['dayNames'])) { $rep .= 'dayNames: ["' . implode('","', $GLOBALS['weekday']) . '"],'; } if (!isset($opts_orig['dayNamesShort'])) { $rep .= 'dayNamesShort: ["' . implode('","', $GLOBALS['weekday_abbrev']) . '"],'; } if (!isset($opts_orig['titleFormat'])) { $rep .= 'titleFormat: {' . 'month: "' . addslashes($this->convertDateFmt(get_option('fse_fc_tit_month_fmt'))) . '",' . 'week: "' . addslashes($this->convertDateFmt(get_option('fse_fc_tit_week_fmt'))) . '",' . 'day: "' . addslashes($this->convertDateFmt(get_option('fse_fc_tit_day_fmt'))) . '"' . '},'; } if (!isset($opts_orig['columnFormat'])) { $rep .= 'columnFormat: {' . "month: '" . addslashes($this->convertDateFmt(get_option('fse_fc_col_month_fmt'))) . "'," . "week: '" . addslashes($this->convertDateFmt(get_option('fse_fc_col_week_fmt'))) . "'," . "day: '" . addslashes($this->convertDateFmt(get_option('fse_fc_col_day_fmt'))) . "'" . '},'; } // Button Texts if (!isset($opts_orig['buttonText'])) { $rep .= 'buttonText: {' . "prev: '" . __(' ◄ ', self::$plugin_textdom) . "'," . "next: '" . __(' ► ', self::$plugin_textdom) . "'," . "prevYear: '" . __(' << ', self::$plugin_textdom) . "'," . "nextYear: '" . __(' >> ', self::$plugin_textdom) . "'," . "today: '" . __('today', self::$plugin_textdom) . "'," . "month: '" . __('month', self::$plugin_textdom) . "'," . "week: '" . __('week', self::$plugin_textdom) . "'," . "day: '" . __('day', self::$plugin_textdom) . "'},"; } //Add all original options if (is_array($opts_orig)) { foreach ($opts_orig as $key => $val) { $rep .= $this->filterContentProcessCalOpts($key, $val); } } // Link Click $postlink = isset($opts_orig['linktopost']) && $opts_orig['linktopost'] == true; if ($postlink || isset($page_url)) { $rep .= "eventClick: function(calEvent, jsEvent, view) {"; if ($postlink) { $rep .= "if (calEvent.post_url != '') { document.location.href=calEvent.post_url; return; }"; } if (!empty($page_url)) { $rep .= "document.location.href='{$page_url}'+calEvent.id;"; } $rep .= "},"; } $rep .= "events: function(start, end, callback) {\n\t\t\t\t\t \tjQuery.post(\n\t\t\t\t\t \t\tWPCalendar.ajaxUrl,\n\t\t\t\t\t \t\t{\n\t\t\t\t\t \t\t\taction: 'wpcal-getevents',\n\t\t\t\t\t start: Math.round(start.getTime() / 1000),\n\t\t\t\t\t end: Math.round(end.getTime() / 1000)" . (isset($opts['include']) ? ",include:'" . $opts['include'] . "'" : '') . (isset($opts['exclude']) ? ",exclude:'" . $opts['exclude'] . "'" : '') . (isset($opts['categories']) ? ",categories:'" . $opts['categories'] . "'" : '') . (isset($opts['state']) ? ",state:'" . $opts['state'] . "'" : '') . (isset($opts['author']) ? ",author:'" . $opts['author'] . "'" : '') . "},\n\t\t\t\t\t \t\tfunction(events) {\n\t\t\t\t\t \t\t\tvar evt = eval(events);\n\t\t\t\t\t \t\t\tcallback(evt);\n\t\t\t\t\t \t\t}\n\t\t\t\t\t \t);\n\t\t\t\t\t },"; if ($rep[strlen($rep) - 1] == ',') { $rep = substr($rep, 0, strlen($rep) - 1); } $rep .= '})});'; $rep .= '</script>'; break; } $content = preg_replace('/' . preg_quote($m[0], '/') . '/', str_replace('$', '\\$', $rep), $content, 1); } return $content; }
?> "><?php _e('View', fsCalendar::$plugin_textdom); ?> </a> </span> </div> </td> <td> <?php echo '<a href="' . $bl . '&event_author=' . esc_attr($e->author) . '">' . esc_attr($e->author_t) . '</a>'; ?> </td> <td> <?php $df = $e->getStart('', 2); $dt = $e->getEnd('', 2); echo $df; if ($dt != $df) { echo '<br />' . $dt; } ?> </td> <td> <?php if ($e->allday == true) { _e('All day event', fsCalendar::$plugin_textdom); } else { echo $e->getStart('', 3) . '<br />' . $e->getEnd('', 3); } ?>