Athletics | 5th & 6th Girls and Boys Basketball |
###DESCRIPTION###";
// What happens if there's nothing to display
$event_error=" There are no items to display. ";
// The separate date header is here
$event_dateheader="###DATE### ";
$GroupByDate=true;
// Change the above to 'false' if you don't want to group this by dates.
// ...and how many you want to display (leave at 999 for everything)
$items_to_show=200;
$use_cache=false;
// ...figure beginning and ending dates for current season
$date_to_start="";
$date_to_end="";
// $todayDate = date("Y-m-d");// current date
$todayDate = date("Y-m-d");
$month = date("m",strtotime($todayDate));
//Set dates for football season
if ($month > "5" and $month < "13") {
$date_to_start=date(Y)."-07-01";
$date_to_end=date(Y)+"1"."-06-01";
}
else
{ $date_to_start=date(Y)-"1"."-07-02";
$date_to_end=date(Y)."-06-01";
}
// And finally, change this to 'true' to see lots of fancy debug code
$debug_mode=false;
//
//End of configuration block
/////////
if ($debug_mode) {error_reporting (E_ALL); ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL); echo "Debug mode is on. Hello there. Your server thinks the time is ".date(DATE_RFC822)." ";}
// Form the XML address.
$calendar_xml_address = str_replace("/basic","/full?singleevents=true&max-results=".$items_to_show."&orderby=starttime&sortorder=a&start-min=".$date_to_start."&start-max=".$date_to_end,$calendarfeed); //This goes and gets future events in your feed.
if ($debug_mode) {
echo "We're going to go and grab this feed. ";}
$xml = simplexml_load_file($calendar_xml_address);
if ($debug_mode) {echo " Successfully got the GCal feed. ";}
$items_shown=0;
$old_date="";
$xml->asXML();
foreach ($xml->entry as $entry){
$ns_gd = $entry->children('http://schemas.google.com/g/2005');
//Do some niceness to the description
//Make any URLs used in the description clickable
// $description = preg_replace('"\b(http://\S+)"', '$1', $entry->content);
// Add target to urls
$description = str_replace('a href', 'a target=_blank href', $entry->content);
// Make email addresses in the description clickable
$description = preg_replace("`([-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6})`i","\\1", $description);
// Replaice semicolon with line break
$description = preg_replace("'; '", " ", $description);
if ($debug_mode) { echo "Here's the next item's start time... GCal says ".$ns_gd->when->attributes()->startTime." PHP says ".date("g.ia -Z",strtotime($ns_gd->when->attributes()->startTime))." "; }
if ($debug_mode) { echo "Here's the next item's end time... GCal says ".$ns_gd->when->attributes()->endTime." PHP says ".date("g.ia -Z",strtotime($ns_gd->when->attributes()->endTime))." "; }
// These are the dates we'll display
$gCalDate = date($dateformat, strtotime($ns_gd->when->attributes()->startTime));
$gCalDateStart = date($dateformat, strtotime($ns_gd->when->attributes()->startTime));
$gCalDateEnd = date($dateformat, strtotime($ns_gd->when->attributes()->endTime));
$gCalStartTime = date($timeformat, strtotime($ns_gd->when->attributes()->startTime));
$gCalEndTime = date($timeformat, strtotime($ns_gd->when->attributes()->endTime));
if ($debug_mode) {
echo "gCalDate: ".$gCalDate." ";
echo "gCalDateStart: ".$gCalDateStart." ";
echo "gCalDateEnd: ".$gCalDateEnd." ";
echo "gCalStartTime: ".$gCalStartTime." ";
echo "gCalEndTime: ".$gCalEndTime." ";
echo "strtotime gCalDate".strtotime($gCalDate)." ";
echo "time".time()." ";
echo "time less day".(time() - 84600)." ";
}
// Now, let's run it through some str_replaces, and store it with the date for easy sorting later
$temp_event=$event_display;
$temp_dateheader=$event_dateheader;
$temp_event=str_replace("###TITLE###",$entry->title,$temp_event);
$temp_event=str_replace("###DESCRIPTION###",$description,$temp_event);
if ($gCalDateStart!=$gCalDateEnd) {
//This starts and ends on a different date, so show the dates
if ($gCalStartTime=$gCalEndTime) {
$temp_event=str_replace("###DATESTART###","",$temp_event);
$temp_event=str_replace("###DATEEND###","",$temp_event);
}
$temp_event=str_replace("###DATESTART###",$gCalDateStart,$temp_event);
$temp_event=str_replace("###DATEEND###",$gCalDateEnd,$temp_event);
} else {
$temp_event=str_replace("###DATESTART###",'',$temp_event);
$temp_event=str_replace("###DATEEND###",'',$temp_event);
}
$temp_event=str_replace("###DATE###",$gCalDate,$temp_event);
$temp_dateheader=str_replace("###DATE###",$gCalDate,$temp_dateheader);
if ($gCalStartTime!=$gCalEndTime) {
$temp_event=str_replace("###FROM###"," | ".$gCalStartTime,$temp_event);
$temp_event=str_replace("###UNTIL###",$gCalEndTime,$temp_event);
}
else {
$temp_event=str_replace("###FROM###","",$temp_event);
$temp_event=str_replace("###UNTIL###","",$temp_event);
}
$temp_event=str_replace("###WHERE###",$ns_gd->where->attributes()->valueString,$temp_event);
$temp_event=str_replace("###LINK###",$entry->link->attributes()->href,$temp_event);
$temp_event=str_replace("###MAPLINK###","http://maps.google.com/?q=".urlencode($ns_gd->where->attributes()->valueString),$temp_event);
// Accept and translate HTML
$temp_event=str_replace("<","<",$temp_event);
$temp_event=str_replace(">",">",$temp_event);
$temp_event=str_replace(""","\"",$temp_event);
if (($items_to_show>0 AND $items_shown<$items_to_show)) {
if ($GroupByDate) {
if ($gCalDate!=$old_date) {
echo $temp_dateheader; $old_date=$gCalDate;
}
}
echo $temp_event."";
$items_shown++;
}
}
if (!$items_shown) { echo $event_error; }
?>
|