displayStartDate = $dStartDate; $this->displayEndDate = $dEndDate; $this->mmonth = $m; $this->yyear = $y; $this->externalArray = array(); $this->eventList = array(); } function getEventList() { $db = new DB_071181(); $currentEvent = array(); $numDays = date('t', mktime(0,0,0,$this->mmonth,1,$this->yyear)); 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->mmonth,$i,$this->yyear)); $results = $db->getDateRange($this->displayStartDate,$this->displayEndDate); //$this->eventList[$i] = array(); foreach($results as $r) { $currentEvent['eID'] = $r->id; $currentEvent['eTitle'] = addslashes($r->eventTitle); $currentEvent['eDescription'] = addslashes($r->eventDescription); $currentEvent['eLocation'] = addslashes($r->eventLocation); $currentEvent['eStartDate'] = addslashes($r->eventStartDate); $currentEvent['eStartTime'] = addslashes($r->eventStartTime); $currentEvent['eEndDate'] = addslashes($r->eventEndDate); $currentEvent['eEndTime'] = addslashes($r->eventEndTime); $currentEvent['accessLevel'] = $r->accessLevel; $d = split('-', $currentEvent['eStartDate']); $d = (int)$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->mmonth,$i,$this->yyear)); $results = $db->getExternalCalendarList(); foreach($results as $r) { if($r->externalType=='iCal') { /////if (!file_exists(ICS_CACHE)) { ///// mkdir(ICS_CACHE,0755) or die ("Cannot write Cache Directory for ".ICS_CACHE."."); /////} $startDateArray = split('-',$this->displayStartDate); $endDateArray = split('-',$this->displayEndDate); $now=strtotime($this->displayStartDate); $then=strtotime($this->displayEndDate); $now_arr=getdate($now); //$now=strtotime($now_arr['month']." 1, ".$$now_arr['year']); //$url=EVENTSCALENDARPATH.'basic.ics'; $url=trim($r->externalAddress); $icsobject = new ICS_FiletoArray($url); ICS_ParseParse($icsobject,$now,$then,$eventlist,$sortlist); array_multisort($sortlist, SORT_ASC, $eventlist); $j=-1; foreach ($eventlist as $event){ if (strtotime($event['DTSTART'])>=$now&&strtotime($event['DTSTART'])<=$then){ $currentEvent['eID'] = $j; $currentEvent['eTitle'] = addslashes(addslashes($event['SUMMARY']."
".$r->externalName)); $currentEvent['eDescription'] = addslashes(addslashes($event['DESCRIPTION'])); $currentEvent['eLocation'] = addslashes(addslashes($event['LOCATION'])); $currentEvent['eStartDate'] = addslashes(addslashes(strftime("%Y-%m-%d",strtotime($event['DTSTART'])))); $currentEvent['eStartTime'] = addslashes(addslashes(strftime("%H:%M:%S",strtotime($event['DTSTART'])))); $currentEvent['eEndDate'] = addslashes(addslashes(strftime("%Y-%m-%d",strtotime($event['DTEND'])))); $currentEvent['eEndTime'] = addslashes(addslashes(strftime("%H:%M:%S",strtotime($event['DTEND'])))); $d = split('-', $currentEvent['eStartDate']); $d = (int)$d[2]; array_push($this->eventList[$d], $currentEvent); $j--; } } } //} } } function displayManagementPage() { if( $_GET['action']=='editEvent' ) { echo "
"; $this->displayEditEventForm(); echo "
"; } else if( $_GET['action']=='editExternal' ) { echo "
"; $this->displayEditExternalForm(); echo "
"; } else { $this->getEventList(); $this->displayCalendar(); $this->displayAddEventForm(); $this->displayExternalCalendars(); $this->displayAddExternalForm(); echo ""; } } function displayCalendar() { $explodedDate = explode("-", $this->displayStartDate); $mmonth = $explodedDate[1]; $yyear = $explodedDate[0]; $db = new DB_071181(); $results = $db->getDateRange($this->displayStartDate, $this->displayEndDate); ?>

()

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($yyear, $mmonth, $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($yyear, $mmonth, $days = array(), $day_name_length = 3, $mmonth_href = NULL, $first_day = 0, $pn = array()) { $first_of_month = gmmktime(0,0,0,$mmonth,1,$yyear); #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($mmonth, $yyear, $mmonth_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month)); $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day $title = htmlentities(ucfirst($mmonth_name)).' '.$yyear; #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.($mmonth_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,$mmonth, $day, $yyear)); $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','events-calendar') . ":".ereg_replace("[\r\n]", " ", stripslashes($r['eTitle']))."
"; $calendar .= "" . __('Description','events-calendar') . ":".ereg_replace("[\r\n]", " ", stripslashes($r['eDescription']))."
"; $calendar .= "" . __('Location','events-calendar') . ":".ereg_replace("[\r\n]", " ", stripslashes($r['eLocation']))."
"; $calendar .= "" . __('Start Time','events-calendar') . ":".$r['eStartDate']; if($r['eStartTime']!='') { $calendar .= ", ".$r['eStartTime']; } $calendar .= "
"; $calendar .= "" . __('End Time','events-calendar') . ":".$r['eEndDate']; if($r['eEndTime']!='') { $calendar .= ", ".$r['eEndTime']; } $calendar .= "
"; if($r['accessLevel'] == 'public') $accessLevel = 'Public'; if($r['accessLevel'] == 'level_10') $accessLevel = 'Administrator'; if($r['accessLevel'] == 'level_7') $accessLevel = 'Editor'; if($r['accessLevel'] == 'level_2') $accessLevel = 'Author'; if($r['accessLevel'] == 'level_1') $accessLevel = 'Contributor'; if($r['accessLevel'] == 'level_0') $accessLevel = 'Subscriber'; $calendar .= "" . __('Visibility Level', 'events-calendar') . ":".$accessLevel; $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 "

" . __('Add Event','events-calendar') . "

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

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

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

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

\n"; echo "
\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)=="00:00:00") { $eStartTime = ""; $eEndTime = ""; $checked = "checked=\"checked\""; $visibility = "style=\"visibility:hidden;\""; } echo "

" . __('Edit Event','events-calendar') . "

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

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

\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
eventTitle)."\" />
eventLocation)."\" />
eventStartDate)."\"/>
eventEndDate)."\"/>
\n"; echo "
\n"; echo " \n"; echo "

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

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

" . __('External Calendars','events-calendar') . "

\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $i=0; foreach($results as $r) { if($i % 2 == 0) $class = "alternate"; else $class = ""; echo " id . "\" class=\"" . $class . "\">\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $i++; } echo " \n"; echo "
ID" . __('Type','events-calendar') . "" . __('Name','events-calendar') . "" . __('Address','events-calendar') . "" . __('Action','events-calendar') . "
" . $r->id . "" . $r->externalType . "" . $r->externalName . "" . $r->externalAddress . "id\">" . __('Edit','events-calendar') . "id . "\">" . __('Delete','events-calendar') . "
\n\n
"; } function displayAddExternalForm() { echo "
\n"; echo " Currently only iCal is supported but I hope to add more soon.
\n"; echo "

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

\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " mmonth\" />\n"; echo " yyear\" />\n"; echo " \n"; echo "

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

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

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

\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
externalName\" />
externalAddress\" />
\n"; echo " id\" />\n"; echo " mmonth\" />\n"; echo " yyear\" />\n"; echo " \n"; echo "

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

\n"; echo "
\n"; } function displayWidgetControl() { $options = get_option('widgetEventsCalendar'); if ( !is_array($options) ){ $options = array(); $options['title'] = 'Events Calendar'; $options['dayOfWeekLength'] = '3'; $options['accessLevel'] = 'level_10'; $options['fontSize'] = 10; } if ( $_POST['eventscalendar']['submit'] ) { unset($_POST['eventscalendar']['submit']); foreach ( $_POST['eventscalendar'] as $key => $option ) { $options[$key] = strip_tags(stripslashes($option)); } update_option('widgetEventsCalendar', $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); $dayOfWeekLength = htmlspecialchars($options['dayOfWeekLength'], ENT_QUOTES); $fontSize = htmlspecialchars($options['fontSize'], 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 '

'; ?>

' . __("Formatting Options","events-calendar") . '
(same as PHP date function)

'; echo '

'; echo '

'; echo ''; ?>