$prev = increment_month($time, -1); $next = increment_month($time, 1); $prev_month = date('n', $prev); $prev_yr = date('Y', $prev); $next_month = date('n', $next); $next_yr = date('Y', $next); // expensive way to see if there are past/future events $nav_links = Array(); $prev_events = AcademicCalendar::get_events($prev_month, $prev_yr); if (count($prev_events) > 0) { $prev_title = date('F Y', $prev); $prev_url = academicURL($prev_yr, $prev_month); $nav_links[] = "<a href=\"$prev_url\">< $prev_title</a>"; } $next_events = AcademicCalendar::get_events($next_month, $next_yr); if (count($next_events) > 0) { $next_title = date('F Y', $next); $next_url = academicURL($next_yr, $next_month); $nav_links[] = "<a href=\"$next_url\">$next_title ></a>"; } require "$page->branch/academic.html"; $page->output(); ?>
public static function get_term_data() { $month = (int) date('m'); AcademicCalendar::init(); return array( "year" => date('y'), "season" => AcademicCalendar::get_term(), //"season" => ($month <= 7) ? 'sp' : 'fa' ); }
public static function is_running_today($routeName, $time=NULL, $strict=FALSE) { if ($time === NULL) $time = time(); $routeInfo = self::get_route_info($routeName); if (!$routeInfo) return FALSE; if (array_key_exists('excludeHolidays', $routeInfo)) { if (AcademicCalendar::is_holiday($time)) if ($strict || AcademicCalendar::is_holiday($time + 86400)) return FALSE; } // for year-round shuttles if (count($routeInfo['dates']) == 0) return TRUE; // shuttles with limite date ranges foreach ($routeInfo['dates'] as $dateRange) { // allow them to view times up to 1 day from now if ($dateRange->contains_point($time) || (!$strict && $dateRange->contains_point($time + 86400))) return TRUE; } return FALSE; }
public static function get_term($time=NULL) { if ($time === NULL) $time = time(); if (self::$terms === NULL) { // if we're in the second half of the year, use next year's calendar $year = (date('n', $time) < 7) ? date('Y', $time) : date('Y', $time) + 1; // start with crude lower-bound guesses for ranges $fall_start = mktime(0, 0, 0, 8, 15, $year-1); $iap_start = mktime(0, 0, 0, 1, 1, $year); $spring_start = mktime(0, 0, 0, 2, 1, $year); $summer_start = mktime(0, 0, 0, 6, 1, $year); $summer_end = mktime(0, 0, 0, 8, 15, $year); self::$terms = Array( 'fa' => new TimeRange($fall_start, $iap_start), 'ia' => new TimeRange($iap_start, $spring_start), 'sp' => new TimeRange($spring_start, $summer_start), 'su' => new TimeRange($summer_start, $summer_end), ); if (array_key_exists($year, self::$icals)) { $ical = self::$icals[$year]; $events = $ical->search_by_title("first day of"); foreach ($events as $event) { $event_start = increment_day($event->get_start(), -1); foreach (self::$terms as $term => $range) { if ($range->contains_point($event_start)) { self::$terms[$term]->set_start($event_start); switch ($term) { case 'ia': self::$terms['fa']->set_end($event_start); break; case 'sp': self::$terms['ia']->set_end($event_start); break; case 'su': self::$terms['sp']->set_end($event_start); break; } // switch break; } // if } // foreach term } // foreach event } // done creating terms } foreach (self::$terms as $term => $range) { if ($range->contains_point($time)) { return $term; break; } } return NULL; }
public function addAcademicCalendarRelatedByParent(AcademicCalendar $l) { $this->collAcademicCalendarsRelatedByParent[] = $l; $l->setAcademicCalendarRelatedByParent($this); }
$religious = array(); } */ $year = $_REQUEST['year']; if (!$year) { $year = date('Y', time()); } $next = $year + 1; $prev = $year - 1; $holidays = AcademicCalendar::get_holidays($year); $nav_links = array(); if ($_REQUEST['page'] == 'religious') { require "{$page->branch}/religious_text.html"; //$has_next = isset($religious_days[$next]); //$has_prev = isset($religious_days[$prev]); } else { // we should save this data as session variables if we don't // want to calculate 3 sets of dates for each page load $prev_holidays = AcademicCalendar::get_holidays($prev); if (count($prev_holidays) > 0) { $prev_url = holidaysURL($prev); $nav_links[] = "<a href=\"{$prev_url}\">< {$prev}</a>"; } $next_holidays = AcademicCalendar::get_holidays($next); if (count($next_holidays) > 0) { $next_url = holidaysURL($next); $nav_links[] = "<a href=\"{$next_url}\">{$next} ></a>"; } require "{$page->branch}/holidays.html"; } $page->output();
public function addAcademicCalendar(AcademicCalendar $l) { $this->collAcademicCalendars[] = $l; $l->setCurriculum($this); }
public function addAcademicCalendar(AcademicCalendar $l) { $this->collAcademicCalendars[] = $l; $l->setClassGroup($this); }
} $data[] = $catData; } break; case 'holidays': case 'academic': // TODO: see whether any of this code can be consolidated with // mobi-web/calendar/academic.php and mobi-web/calendar/holidays.php require_once LIBDIR . "AcademicCalendar.php"; $month = isset($_REQUEST['month']) ? $_REQUEST['month'] : date('n'); $year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date('Y'); if ($_REQUEST['command'] == 'holidays') { $events = AcademicCalendar::get_holidays($year); } else { $events = AcademicCalendar::get_events($month, $year); } foreach ($events as $event) { /* $event_dict = Array(); // we'll give the event a random unique ID since there's nothing // useful we can do with it on the backend $event_dict['id'] = crc32($event->get_uid()) >> 1; // 32 bit unsigned before shift $event_dict['title'] = $event->get_summary(); $event_dict['start'] = $event->get_start(); $event_dict['end'] = $event->get_end(); // location and description are always blank but just for completeness... if ($location = $event->get_location()) { $event_dict['location'] = $location; }