/** If the parameter ec3_xml is set, then brutally hijack the page and replace * it with XML calendar data. This is used by XmlHttpRequests from the * active calendar JavaScript. */ function ec3_filter_query_vars_xml() { $components = explode('_', $_GET['ec3_xml']); if (count($components) == 2) { $date = new ec3_Date($components[0], $components[1]); $end = $date->next_month(); $calendar_days = ec3_util_calendar_days($date->month_id(), $end->month_id()); @header('Content-type: text/xml'); echo '<?xml version="1.0" encoding="' . get_settings('blog_charset') . '" standalone="yes"?>'; echo "<calendar><month id='" . $date->month_id() . "'>\n"; foreach ($calendar_days as $day_id => $day) { if ('today' == $day_id) { $dc = explode('_', ec3_strftime(":_%Y_%m_%d")); } else { $dc = explode('_', $day_id); } if (count($dc) == 4) { $date->day_num = $dc[3]; $titles = $day->get_titles(); echo "<day id='{$day_id}' is_event='{$day->is_event}'" . " titles='{$titles}' link='" . $date->day_link() . "'/>\n"; } } echo "</month></calendar>\n"; exit(0); } }
/** Template function. Call this from your template to insert the * Event Calendar. */ function ec3_get_calendar() { if (!ec3_check_installed(__('Event Calendar', 'ec3'))) { return; } global $ec3; // Can't cope with more than one calendar on the same page. Everything has // a unique ID, so it can't be duplicated. // Simple fix for problem: Just ignore all calls after the first. $ec3->call_count++; if ($ec3->call_count > 1) { echo "<!-- You can only have one Event Calendar on each page. -->\n"; return; } echo "<div id='wp-calendar'>\n"; $this_month = new ec3_Date(); // Display navigation panel. if (0 == $ec3->navigation) { ec3_get_calendar_nav($this_month, $ec3->num_months); } // Get entries $end_month = $this_month->plus_months($ec3->num_months); $calendar_days = ec3_util_calendar_days($this_month->month_id(), $end_month->month_id()); // Display months. $thead = ec3_util_thead(); for ($i = 0; $i < $ec3->num_months; $i++) { $next_month = $this_month->next_month(); ec3_get_calendar_month($this_month, $calendar_days, $thead); $this_month = $next_month; } // Display navigation panel. if (1 == $ec3->navigation) { ec3_get_calendar_nav(new ec3_Date(), $ec3->num_months); } echo "</div>\n"; if (!$ec3->disable_popups) { echo "\t<script type='text/javascript' src='" . $ec3->myfiles . "/popup.js'></script>\n"; } }