예제 #1
0
 /**
  * @return array(Todays events view, Todo view).
  */
 private function _GetMiniCalendars()
 {
     $this->load->library('academic_calendar');
     $this->load->library('calendar_backend');
     $this->load->library('calendar_source_my_calendar');
     $this->load->library('calendar_frontend');
     $this->load->library('calendar_view_upcoming');
     $this->load->library('calendar_view_todo_list');
     $now = new Academic_time(time());
     $start = $now;
     $end = $now->Midnight()->Adjust('+2day');
     $sources = new CalendarSourceMyCalendar();
     // lets be explicit just in case:
     $sources->EnableGroup('owned');
     $sources->EnableGroup('subscribed');
     $sources->EnableGroup('private');
     $sources->EnableGroup('active');
     $sources->DisableGroup('inactive');
     $sources->SetRange($start->Timestamp(), $end->Timestamp());
     $sources->SetTodoRange(time(), time());
     $calendar_data = new CalendarData();
     $this->messages->AddMessages($calendar_data->FetchEventsFromSources($sources));
     // Display data
     $this->load->library('calendar_view_days');
     $EventsView = new CalendarViewUpcoming();
     $EventsView->SetMiniMode();
     $EventsView->SetCalendarData($calendar_data);
     //$EventsView->SetStartEnd($start->Timestamp(), $end->Timestamp());
     $TodoView = NULL;
     // 		$TodoView = new CalendarViewTodoList();
     // 		$TodoView->SetCalendarData($calendar_data);
     return array($EventsView, $TodoView);
 }
 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);
 }
 function GetWeeks(&$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->BackToMonday();
         $end = $start->Adjust('4weeks');
     }
     $sources->SetRange($start->Timestamp(), $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_weeks');
     $weeks = new CalendarViewWeeks();
     $weeks->SetCalendarData($calendar_data);
     $weeks->SetStartEnd($start->Timestamp(), $end->Timestamp());
     $weeks->SetPaths($this->mPaths);
     $weeks->SetRangeFormat($Format);
     $weeks->SetRangeFilter(NULL !== $Filter ? '/' . $Filter : '');
     $weeks->SetCategories($this->mCategories);
     $data = array('Filters' => $this->GetFilters($sources), 'ViewMode' => $weeks, '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('weeks', $focus, $Filter);
     return new FramesView('calendar/my_calendar', $data);
 }
    protected function _Load()
    {
        $value = $this->value;
        if (null === $value) {
            $value = Academic_time::NewToday();
        } else {
            $value = new Academic_time($value);
        }
        ?>
<div	class="input_date_display"<?php 
        ?>
	onclick="<?php 
        echo xml_escape('return input_date_click("' . $this->name . '");');
        ?>
"<?php 
        ?>
	><?php 
        if ($this->date) {
            ?>
<span class="day" id="<?php 
            echo $this->id . '__day';
            ?>
"><?php 
            echo $value->Format('l');
            ?>
</span> <?php 
            ?>
week <span class="week" id="<?php 
            echo $this->id . '__wk';
            ?>
"><?php 
            echo $value->AcademicWeek();
            ?>
</span> <?php 
            ?>
of <span class="term" id="<?php 
            echo $this->id . '__term';
            ?>
"><?php 
            echo ucfirst($value->AcademicTermNameUnique());
            echo ' ' . $value->StartOfTerm()->Year();
            ?>
</span> <?php 
        }
        if ($this->time) {
            ?>
at <span class="hour" id="<?php 
            echo $this->id . '__hr';
            ?>
"><?php 
            echo $value->Hour();
            ?>
</span><?php 
            ?>
:<span class="minute" id="<?php 
            echo $this->id . '__min';
            ?>
"><?php 
            echo $value->Minute();
            ?>
</span> <?php 
        }
        ?>
</div><?php 
        $days = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
        ?>
<div	class="input_date_selector"<?php 
        ?>
	id="<?php 
        echo $this->id . '__selector';
        ?>
"<?php 
        ?>
	><?php 
        // Init script
        ?>
<script type="text/javascript"><?php 
        echo xml_escape('onLoadFunctions.push(function() {' . 'input_date_init(' . js_literalise($this->name) . ');' . '});', false);
        ?>
</script><?php 
        ?>
<div><?php 
        // Day of the week
        ?>
<select	id="<?php 
        echo $this->id . '__day_select';
        ?>
"<?php 
        ?>
	name="<?php 
        echo $this->name . '[day]';
        ?>
"<?php 
        ?>
	onchange="<?php 
        echo xml_escape('return input_date_day_changed("' . $this->name . '");');
        ?>
"<?php 
        ?>
><?php 
        foreach ($days as $val => $day) {
            ?>
<option value="<?php 
            echo $val;
            ?>
"<?php 
            if ($val == $value->DayOfWeek(1)) {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            echo $day;
            ?>
</option><?php 
        }
        ?>
</select><?php 
        // Week of the term
        ?>
<span>week</span><?php 
        ?>
<select	id="<?php 
        echo $this->id . '__wk_select';
        ?>
"<?php 
        ?>
	name="<?php 
        echo $this->name . '[wk]';
        ?>
"<?php 
        ?>
	onchange="<?php 
        echo xml_escape('return input_date_day_changed("' . $this->name . '");');
        ?>
"<?php 
        ?>
><?php 
        $weeks = $value->AcademicTermWeeks();
        for ($wk = 1; $wk <= $weeks; ++$wk) {
            ?>
<option value="<?php 
            echo $wk;
            ?>
"<?php 
            if ($wk == $value->AcademicWeek()) {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            echo $wk;
            ?>
</option><?php 
        }
        ?>
</select><?php 
        // Term
        ?>
<span>of</span><?php 
        ?>
<select	id="<?php 
        echo $this->id . '__term_select';
        ?>
"<?php 
        ?>
	name="<?php 
        echo $this->name . '[term]';
        ?>
"<?php 
        ?>
	onchange="<?php 
        echo xml_escape('return input_date_term_changed("' . $this->name . '");');
        ?>
"<?php 
        ?>
><?php 
        $sel_year = $value->AcademicYear();
        $sel_term = $value->AcademicTerm();
        $year = $sel_year;
        $term = 0;
        ?>
<option value="earlier">(more)</option><?php 
        for ($i = 0; $i < 6; ++$i) {
            $cur = new Academic_time(Academic_time::StartOfAcademicTerm($year, $term));
            ?>
<option value="<?php 
            echo "{$year}-{$term}";
            ?>
"<?php 
            if ($term == $sel_term && $year == $sel_year) {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            echo xml_escape(ucfirst($cur->AcademicTermNameUnique()) . ' ' . $cur->Year());
            ?>
</option><?php 
            ++$term;
            if ($term == 6) {
                $term = 0;
                ++$year;
            }
        }
        ?>
<option value="later">(more)</option><?php 
        ?>
</select><?php 
        // Time of day
        if ($this->time) {
            ?>
<span>at</span><?php 
            ?>
<select	id="<?php 
            echo $this->id . '__hr_select';
            ?>
"<?php 
            ?>
	name="<?php 
            echo $this->name . '[hr]';
            ?>
"<?php 
            ?>
	onchange="<?php 
            echo xml_escape('return input_date_time_changed("' . $this->name . '");');
            ?>
"<?php 
            ?>
><?php 
            for ($hr = 0; $hr < 24; ++$hr) {
                ?>
<option value="<?php 
                echo $hr;
                ?>
"<?php 
                if ($hr == $value->Hour()) {
                    ?>
 selected="selected"<?php 
                }
                ?>
><?php 
                echo sprintf('%02d', $hr);
                ?>
</option><?php 
            }
            ?>
</select><?php 
            ?>
<span>:</span><?php 
            ?>
<select	id="<?php 
            echo $this->id . '__min_select';
            ?>
"<?php 
            ?>
	name="<?php 
            echo $this->name . '[min]';
            ?>
"<?php 
            ?>
	onchange="<?php 
            echo xml_escape('return input_date_time_changed("' . $this->name . '");');
            ?>
"<?php 
            ?>
><?php 
            $minute = $value->Minute();
            $minute_interval = 5;
            for ($min = 0; $min < 60; $min += $minute_interval) {
                ?>
<option value="<?php 
                echo $min;
                ?>
"<?php 
                if ($min <= $minute && $min + $minute_interval > $minute) {
                    ?>
 selected="selected"<?php 
                }
                ?>
><?php 
                echo sprintf('%02d', $min);
                ?>
</option><?php 
            }
            ?>
</select><?php 
        }
        // Close button
        ?>
<input	type="button" value="x"<?php 
        ?>
	onclick="<?php 
        echo xml_escape('return input_selector_click("' . $this->name . '__selector");');
        ?>
"<?php 
        ?>
	/><?php 
        ?>
</div><?php 
        ?>
<div><?php 
        ?>
<table class="recur-cal cal-text"><?php 
        // Days along the top
        ?>
<tr><?php 
        ?>
<th /><?php 
        foreach ($days as $day) {
            ?>
<th><?php 
            echo xml_escape($day);
            ?>
</th><?php 
        }
        ?>
</tr><?php 
        $cur = $value->MondayWeek1OfTerm();
        $sel = $value->Midnight()->Timestamp();
        $today = Academic_time::NewToday()->Timestamp();
        $last_month = 0;
        $term = $cur->AcademicTerm();
        for ($wk = 1; $cur->AcademicTerm() == $term; ++$wk) {
            ?>
<tr id="<?php 
            echo $this->id . '__wk_' . $wk;
            ?>
"><?php 
            ?>
<th><?php 
            echo $wk;
            ?>
</th><?php 
            for ($dy = 0; $dy < 7; ++$dy) {
                $month = $cur->Month();
                $ts = $cur->Timestamp();
                $classes = array();
                if ($ts < $today) {
                    $classes[] = "pa";
                }
                if ($month % 2 == 0) {
                    $classes[] = "ev";
                }
                if ($ts == $today) {
                    $classes[] = "tod";
                }
                if ($ts == $sel) {
                    $classes[] = "sel";
                }
                if ($dy >= 5) {
                    $classes[] = "we";
                }
                ?>
<td	class="<?php 
                echo join(' ', $classes);
                ?>
"<?php 
                ?>
	id="<?php 
                echo $this->id . '__' . $cur->AcademicWeek() . '_' . $cur->Format('D');
                ?>
"<?php 
                ?>
	onclick="<?php 
                echo xml_escape('return input_date_change(' . js_literalise($this->name) . ',' . js_literalise($wk) . ',' . js_literalise($dy) . ');');
                ?>
"<?php 
                ?>
	><?php 
                if ($month != $last_month) {
                    echo xml_escape($cur->Format('M')) . '&nbsp;';
                    $last_month = $month;
                }
                echo xml_escape($cur->Format('j'));
                ?>
</td><?php 
                $cur = $cur->Adjust('+1day');
            }
            ?>
</tr><?php 
        }
        ?>
</table><?php 
        ?>
</div><?php 
        ?>
</div><?php 
    }