Exemplo n.º 1
0
 function test()
 {
     if (!CheckPermissions('admin')) {
         return;
     }
     // Load libraries
     $this->load->library('academic_calendar');
     $this->load->library('calendar_backend');
     $this->load->library('calendar_frontend');
     $this->load->library('calendar_source_yorker');
     $this->load->library('calendar_view_days');
     // Set up data sources
     $data = new CalendarData();
     $sources = array();
     $sources[0] = new CalendarSourceYorker();
     $sources[0]->SetRange(strtotime('-2month'), strtotime('1month'));
     // Accumulate data from sources in $data
     foreach ($sources as $source) {
         try {
             $source->FetchEvents($data);
         } catch (Exception $e) {
             $this->messages->AddMessage('error', 'calendar data source failed: ' . $e->getMessage());
         }
     }
     // Display data
     $days = new CalendarViewDays();
     $days->SetCalendarData($data);
     $this->main_frame->SetContent($days);
     // Load view
     $this->main_frame->Load();
 }
 function GetDays(&$sources, $DateRange = NULL, $Filter = NULL, $Format = 'ac:re')
 {
     // Read date range
     $range = $this->date_uri->ReadUri($DateRange, TRUE);
     $now = new Academic_time(time());
     if ($range['valid']) {
         $start = $range['start'];
         $end = $range['end'];
     } else {
         $start = $now->Midnight();
         $end = $start->Adjust('7day');
     }
     $stretch_end = $end->Adjust($this->mDefaultOverlap);
     $sources->SetRange($start->Timestamp(), $stretch_end->Timestamp());
     $this->ReadFilter($sources, $Filter);
     $create_sources = $this->GetCreateSources($sources);
     $calendar_data = new CalendarData();
     $this->messages->AddMessages($sources->FetchEvents($calendar_data));
     // Display data
     $this->load->library('calendar_frontend');
     $this->load->library('calendar_view_days');
     $days = new CalendarViewDays();
     $days->SetCalendarData($calendar_data);
     $days->SetStartEnd($start->Timestamp(), $end->Timestamp());
     $days->SetPaths($this->mPaths);
     $days->SetRangeFormat($Format);
     $days->SetRangeFilter(NULL !== $Filter ? '/' . $Filter : '');
     $days->SetCategories($this->mCategories);
     $days->EnableCreate(isset($this->mPermissions['create']) && $sources->GetSource(0)->IsSupported('create'));
     $data = array('Filters' => $this->GetFilters($sources), 'ViewMode' => $days, 'RangeDescription' => $range['description'], 'Path' => $this->mPaths, 'CreateSources' => $create_sources);
     if ($now->Timestamp() >= $start->Timestamp() && $now->Timestamp() < $end->Timestamp()) {
         $focus = $now->Midnight();
     } else {
         $focus = $start;
     }
     $this->SetupTabs('days', $focus, $Filter);
     return new FramesView('calendar/my_calendar', $data);
 }
 function GetDays(&$sources, $DateRange = NULL, $Filter = NULL, $Format = 'ac:re')
 {
     $CI =& get_instance();
     // Read date range
     $range = $CI->date_uri->ReadUri($DateRange, TRUE);
     $now = new Academic_time(time());
     if ($range['valid']) {
         $start = $range['start'];
         $end = $range['end'];
     } else {
         $start = $now->Midnight();
         $end = $start->Adjust('7day');
     }
     $sources->SetRange($start->Timestamp(), $end->Timestamp());
     $this->ReadFilter($sources, $Filter);
     $calendar_data = new CalendarData();
     $CI->messages->AddMessages($sources->FetchEvents($calendar_data));
     // Display data
     $CI->load->library('calendar_view_days');
     $days = new CalendarViewDays();
     $days->SetCalendarData($calendar_data);
     $days->SetStartEnd($start->Timestamp(), $end->Timestamp());
     $days->SetRangeUrl($this->mRangeUrl, $Format, NULL !== $Filter ? '/' . $Filter : '');
     $days->SetCategories($this->mCategories);
     $data = array('Filters' => $this->GetFilters($sources), 'ViewMode' => $days, 'RangeDescription' => $range['description'], 'ReadOnly' => $this->mReadOnly, 'Path' => $this->mPaths);
     $this->SetupTabs('days', $start, $Filter);
     return new FramesView('calendar/my_calendar', $data);
 }