displayStartDate = $dStartDate; $this->displayEndDate = $dEndDate; $this->month = $m; $this->year = $y; $this->externalArray = array(); $this->eventList = array(); } function getEventList() { $db = new DB_071181(); $currentEvent = array(); $numDays = date('t', mktime(0,0,0,$this->month,1,$this->year)); for($i=1;$i<=$numDays;$i++) { $this->eventList[$i] = array(); } //Main Calendar //for($i=1; $i<=$numDays; $i++) //{ // $d = date('Y-m-d', mktime(0,0,0,$this->month,$i,$this->year)); $results = $db->getDateRange($this->displayStartDate,$this->displayEndDate); //$this->eventList[$i] = array(); foreach($results as $r) { $currentEvent['eID'] = $r->id; $currentEvent['eTitle'] = stripslashes($r->eventTitle); $currentEvent['eDescription'] = stripslashes($r->eventDescription); $currentEvent['eLocation'] = stripslashes($r->eventLocation); $currentEvent['eStartDate'] = stripslashes($r->eventStartDate); $currentEvent['eStartTime'] = stripslashes($r->eventStartTime); $currentEvent['eEndDate'] = stripslashes($r->eventEndDate); $currentEvent['eEndTime'] = stripslashes($r->eventEndTime); $d = split('-', $currentEvent['eStartDate']); $d = $d[2]; array_push($this->eventList[$d], $currentEvent); } //} //External Calendars //for($i=1; $i<=$numDays; $i++) //{ //$d = date('Y-m-d', mktime(0,0,0,$this->month,$i,$this->year)); $results = $db->getExternalCalendarList(); foreach($results as $r) { if($r->externalType=='iCal') { $reader = new iCalReader($r->externalAddress); $meta = $reader->getMeta(); $tz = $meta['TZID']; $events = $reader->getEvents(); $i=-1; if(!is_array($events)) return; foreach($events as $e) { $currentEvent['eID'] = $i; $currentEvent['eTitle'] = $e['SUMMARY']."
".$r->externalName; $currentEvent['eDescription'] = $e['DESCRIPTION']; $currentEvent['eLocation'] = $e['LOCATION']; if($e['DTSTART;TZID='.$tz]) { $eDTSTART = split('T', $e['DTSTART;TZID='.$tz]); $dd = $eDTSTART[0]; $tt = $eDTSTART[1]; $dd = str_split($dd); $currentEvent['eStartDate'] = $dd[0].$dd[1].$dd[2].$dd[3]."-".$dd[4].$dd[5]."-".$dd[6].$dd[7]; $tt = str_split($tt); $currentEvent['eStartTime'] = $tt[0].$tt[1].":".$tt[2].$tt[3].":".$tt[4].$tt[5]; } if($e['DTEND;TZID='.$tz]) { $eDTEND = split('T', $e['DTEND;TZID='.$tz]); $dd = $eDTEND[0]; $tt = $eDTEND[1]; $dd = str_split($dd); $currentEvent['eEndDate'] = $dd[0].$dd[1].$dd[2].$dd[3]."-".$dd[4].$dd[5]."-".$dd[6].$dd[7]; $tt = str_split($tt); $currentEvent['eEndTime'] = $tt[0].$tt[1].":".$tt[2].$tt[3].":".$tt[4].$tt[5]; } if($e['DTSTART;VALUE=DATE']) { $dd = $e['DTSTART;VALUE=DATE']; $dd = str_split($dd); $currentEvent['eStartDate'] = $dd[0].$dd[1].$dd[2].$dd[3]."-".$dd[4].$dd[5]."-".$dd[6].$dd[7]; $currentEvent['eStartTime'] = ''; } if($e['DTEND;VALUE=DATE']) { $dd = $e['DTEND;VALUE=DATE']; $dd = str_split($dd); $currentEvent['eEndDate'] = $dd[0].$dd[1].$dd[2].$dd[3]."-".$dd[4].$dd[5]."-".$dd[6].$dd[7]; $currentEvent['eEndTime'] = ''; } $d = split('-', $currentEvent['eStartDate']); $d = $d[2]; array_push($this->eventList[$d], $currentEvent); $i--; } } } //} } function displayManagementPage() { if( $_GET['action']=='editEvent' ) { echo "
"; $this->displayEditEventForm(); echo "
"; } else if( $_GET['action']=='editExternal' ) { echo "
"; $this->displayEditExternalForm(); echo "
"; } else { echo "
"; echo "\t\t
\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\"\"\n"; echo "\t\t\n"; echo "\t\t
\n"; $this->getEventList(); $this->displayCalendar(); $this->displayAddEventForm(); //$this->displayExternalCalendars(); //$this->displayAddExternalForm(); echo "
"; } } function displayCalendar() { $explodedDate = explode("-", $this->displayStartDate); $month = $explodedDate[1]; $year = $explodedDate[0]; $db = new DB_071181(); $results = $db->getDateRange($this->displayStartDate, $this->displayEndDate); ?>

Events Calendar ()

Today

getDateRange($this->displayStartDate, $this->displayEndDate); $rArray = array(); for($i=1; $i<=31; $i++) { $rArray[$i] = false; } foreach($results as $r) { $eDate = explode("-", $r->eventStartDate); $dayofmonth = date('j', mktime(0,0,0,$eDate[1],$eDate[2],$eDate[0])); $rArray[$dayofmonth] = true; } $firstDay = get_option('start_of_week'); echo $this->printCalendar($year, $month, $rArray, 4, NULL, $firstDay); /* foreach($results as $r) { echo "$r->eventTitle id\">Edit id&eDate=$r->eventDate\">Delete
"; echo "$r->eventLocation
"; echo "$r->eventDate
"; echo "$r->eventStartTime
"; echo "$r->eventEndTime

"; } */ } function printCalendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()) { $first_of_month = gmmktime(0,0,0,$month,1,$year); #remember that mktime will automatically correct if invalid dates are entered # for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998 # this provides a built in "rounding" feature to generate_calendar() $day_names = array(); #generate all the day names according to the current locale for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday $day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month)); $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day $title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names #Begin calendar. Uses a real . See http://diveintomark.org/archives/2002/07/03 @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable if($p) $p = ''.($pl ? ''.$p.'' : $p).' '; if($n) $n = ' '.($nl ? ''.$n.'' : $n).''; $calendar = ''."\n";//. //'\n"; if($day_name_length){ #if the day names should be shown ($day_name_length > 0) #if day_name_length is >3, the full name of the day will be printed foreach($day_names as $d) $calendar .= ''; $calendar .= "\n"; } if($weekday > 0) $calendar .= ''; #initial 'empty' days for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){ if($weekday == 7){ $weekday = 0; #start a new week $calendar .= "\n"; } if($this->eventList[$day]){ $calendar .= '\n"; } else $calendar .= "\n"; } //if($weekday != 7) $calendar .= ''; #remaining "empty" days for($weekday; $weekday<7; $weekday++) { $calendar .= ''; } return $calendar."\n
'.$p.($month_href ? ''.$title.'' : $title).$n."
'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'
 
'.$day.'
'; $d = date("Y-m-d", mktime(0,0,0,$month, $day, $year)); $results = $this->eventList[$day]; foreach($results as $r) { $calendar .= "=0) { $calendar .= "?page=events-calendar.php&action=editEvent&eID=".$r['eID'] ."\""; } else { $calendar .= "#\""; } $calendar .= "onMouseover=\"ddrivetip('"; $calendar .= "Title:".ereg_replace("[\r\n]", " ", stripslashes($r['eTitle']))."
"; $calendar .= "Description:".ereg_replace("[\r\n]", " ", stripslashes($r['eDescription']))."
"; $calendar .= "Location:".ereg_replace("[\r\n]", " ", stripslashes($r['eLocation']))."
"; $calendar .= "Start Time:".$r['eStartDate']; if($r['eStartTime']!='') { $calendar .= ", ".$r['eStartTime']; } $calendar .= "
"; $calendar .= "End Time:".$r['eEndDate']; if($r['eEndTime']!='') { $calendar .= ", ".$r['eEndTime']; } $calendar .= "
"; $displayTitle = str_split(stripslashes($r['eTitle']), 15); $calendar .= "
','white', 175);\" onMouseout=\"hideddrivetip();\">" . $displayTitle[0] ."
"; if($r['eID']>=0) $calendar .= ""; $calendar .= "
"; } $calendar .= "
$day
  
\n"; } function displayAddEventForm() { echo "\t\t\t

Add Event

\n"; echo "\t\t\t
\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t
\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t
\n"; } function displayEditEventForm() { $db = new DB_071181(); $r = $db->getEntry($_GET['eID']); $r = $r[0]; $eStartTime = stripslashes($r->eventStartTime); $eEndTime = stripslashes($r->eventEndTime); $checked = ""; $visibility = ""; if(stripslashes($r->eventStartTime)=="00:00:00" && stripslashes($r->eventEndTime)=="11:59:59") { $eStartTime = ""; $eEndTime = ""; $checked = "checked=\"checked\""; $visibility = "style=\"visibility:hidden;\""; } echo "\t\t\t

Edit Event

\n"; echo "\t\t\t
\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t
eventTitle)."\" />
".stripslashes($r->eventDescription)."
eventLocation)."\" />
eventStartDate)."\"/>
eventEndDate)."\"/>
\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "id\" />"; echo "\t\t\t
\n"; } function displayExternalCalendars() { $db = new DB_071181(); $results = $db->getExternalCalendarList(); echo "

External Calendars

\n"; echo "\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\n"; echo "\t\n"; echo "\t\n"; $i=0; foreach($results as $r) { if($i % 2 == 0) $class = "alternate"; else $class = ""; echo "\t\tid . "\" class=\"" . $class . "\">\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\n"; $i++; } echo "\t\n"; echo "
IDTypeNameAddressAction
" . $r->id . "" . $r->externalType . "" . $r->externalName . "" . $r->externalAddress . "id\">Editid . "\">Delete
\n\n
"; } function displayAddExternalForm() { echo "\t\t\t
\n"; echo "\t\t\tCurrently only iCal (non-repeating events) is supported but I hope to add more soon.
\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t
\n"; echo "\t\t\t\t\t\tmonth\" />\n"; echo "\t\t\t\t\t\tyear\" />\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t
\n"; } function displayEditExternalForm() { global $month, $year; $db = new DB_071181(); $r = $db->getExternalCalendar($_GET['id']); $r = $r[0]; echo "\t\t\t
\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t
externalName\" />
externalAddress\" />
\n"; echo "\t\t\t\t\t\tid\" />\n"; echo "\t\t\t\t\t\tmonth\" />\n"; echo "\t\t\t\t\t\tyear\" />\n"; echo "\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t\t\t\n"; echo "\t\t\t\t

\n"; echo "\t\t\t
\n"; } function displayWidgetControl() { $options = get_option('widgetEventsCalendar'); if ( !is_array($options) ){ $options = array(); $options['title'] = 'Events Calendar'; $options['dayOfWeekLength'] = '3'; } if ( $_POST['eventscalendar-submit'] ) { $options['title'] = strip_tags(stripslashes($_POST['eventscalendar-title'])); $options['dayOfWeekLength'] = strip_tags(stripslashes($_POST['eventscalendar-dayOfWeekLength'])); update_option('widgetEventsCalendar', $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); $dayOfWeekLength = htmlspecialchars($options['dayOfWeekLength'], ENT_QUOTES); $one = 'no'; $two = 'no'; $three = 'no'; $four = 'no'; if($options['dayOfWeekLength']=='1') $one = "checked=\"yes\""; if($options['dayOfWeekLength']=='2') $two = "checked=\"yes\""; if($options['dayOfWeekLength']=='3') $three = "checked=\"yes\""; if($options['dayOfWeekLength']=='4') $four = "checked=\"yes\""; echo '

'; echo '

'; echo ''; } } endif; ?>