34 include_once(
'Services/Calendar/classes/class.ilDate.php');
35 include_once(
'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php');
36 include_once(
'Services/Calendar/classes/class.ilCalendarUserSettings.php');
37 include_once(
'Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
66 $this->seed = $seed_date;
72 $this->tabs_gui = $ilTabs;
77 $this->timezone = $ilUser->getTimeZone();
90 $this->ctrl->saveParameter($this,
'seed');
93 $next_class = $ilCtrl->getNextClass();
96 case 'ilcalendarappointmentgui':
97 $this->ctrl->setReturn($this,
'');
98 $this->tabs_gui->setSubTabActive(
$_SESSION[
'cal_last_tab']);
103 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
105 $this->ctrl->forwardCommand($app);
109 $time = microtime(
true);
110 $cmd = $this->ctrl->getCmd(
"show");
112 $tpl->setContent($this->tpl->get());
113 #echo "Zeit: ".(microtime(true) - $time);
133 if($this->user_settings->getDayStart())
136 $morning_aggr = ($this->user_settings->getDayStart()-1)*60+(60-$raster);
142 $evening_aggr = $this->user_settings->getDayEnd()*60;
145 $this->tpl =
new ilTemplate(
'tpl.week_view.html',
true,
true,
'Services/Calendar');
147 include_once(
'./Services/YUI/classes/class.ilYuiUtil.php');
153 $this->tpl->setVariable(
'NAVIGATION',$navigation->getHTML());
155 if(isset(
$_GET[
"bkid"]))
157 $user_id =
$_GET[
"bkid"];
158 $disable_empty =
true;
161 elseif($ilUser->getId() == ANONYMOUS_USER_ID)
163 $user_id = $ilUser->getId();
164 $disable_empty =
false;
169 $user_id = $ilUser->getId();
170 $disable_empty =
false;
173 include_once(
'Services/Calendar/classes/class.ilCalendarSchedule.php');
175 $this->scheduler->addSubitemCalendars(
true);
176 $this->scheduler->calculate();
180 $all_fullday = array();
183 $daily_apps = $this->scheduler->getByDay($date,$this->timezone);
184 $hours = $this->
parseHourInfo($daily_apps,$date,$counter,$hours,
189 $this->weekdays[] = $date;
191 $num_apps[$date->get(
IL_CAL_DATE)] = count($daily_apps);
193 $all_fullday[] = $daily_apps;
199 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
207 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$date->get(
IL_CAL_DATE));
208 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$date->get(
IL_CAL_DATE));
209 $this->ctrl->setParameterByClass(
'ilcalendardaygui',
'seed',$date->get(
IL_CAL_DATE));
213 if ($settings->getEnableGroupMilestones())
215 $this->tpl->setCurrentBlock(
"new_ms");
217 $this->tpl->setVariable(
'H_NEW_MS_ALT', $this->lng->txt(
'cal_new_ms'));
218 $this->tpl->setVariable(
'NEW_MS_LINK', $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'addMilestone'));
219 $this->tpl->parseCurrentBlock();
223 $this->tpl->setCurrentBlock(
"new_app");
224 $this->tpl->setVariable(
'NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
225 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
227 $this->tpl->setVariable(
'NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
228 $this->tpl->parseCurrentBlock();
234 if(!$disable_empty || $num_apps[$date->get(
IL_CAL_DATE)] > 0)
236 $link = $this->ctrl->getLinkTargetByClass(
'ilcalendardaygui',
'');
237 $this->ctrl->clearParametersByClass(
'ilcalendardaygui');
239 $this->tpl->setCurrentBlock(
"day_view1_link");
240 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
241 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
242 $this->tpl->parseCurrentBlock();
244 $this->tpl->setCurrentBlock(
"day_view2_link");
245 $this->tpl->setVariable(
'DAYNAME',$dayname);
246 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
247 $this->tpl->parseCurrentBlock();
251 $this->tpl->setCurrentBlock(
"day_view1_no_link");
252 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
253 $this->tpl->parseCurrentBlock();
255 $this->tpl->setCurrentBlock(
"day_view2_no_link");
256 $this->tpl->setVariable(
'DAYNAME',$dayname);
257 $this->tpl->parseCurrentBlock();
260 $this->tpl->setCurrentBlock(
'day_header_row');
261 $this->tpl->setVariable(
'DAY_COLSPAN',max($colspans[$counter],1));
262 $this->tpl->parseCurrentBlock();
269 foreach($all_fullday as $daily_apps)
271 foreach($daily_apps as $event)
273 if($event[
'fullday'])
278 $this->tpl->setCurrentBlock(
'f_day_row');
279 $this->tpl->setVariable(
'COLSPAN',max($colspans[$counter],1));
280 $this->tpl->parseCurrentBlock();
283 $this->tpl->setCurrentBlock(
'fullday_apps');
284 $this->tpl->setVariable(
'TXT_F_DAY', $lng->txt(
"cal_all_day"));
285 $this->tpl->parseCurrentBlock();
287 $new_link_counter = 0;
288 foreach($hours as $num_hour => $hours_per_day)
291 foreach($hours_per_day as $num_day => $hour)
295 if(!($num_hour%60) || ($num_hour == $morning_aggr && $morning_aggr) ||
296 ($num_hour == $evening_aggr && $evening_aggr))
301 if(($num_hour == $morning_aggr && $morning_aggr) ||
302 ($num_hour == $evening_aggr && $evening_aggr))
304 $this->tpl->setVariable(
'TIME_ROWSPAN', 1);
309 $this->tpl->setVariable(
'TIME_ROWSPAN', 60/$raster);
312 $this->tpl->setCurrentBlock(
'time_txt');
314 $this->tpl->setVariable(
'TIME',$hour[
'txt']);
315 $this->tpl->parseCurrentBlock();
319 foreach($hour[
'apps_start'] as $app)
325 if ($ilUser->prefs[
"screen_reader_optimization"])
327 $this->tpl->setCurrentBlock(
'scrd_day_cell');
328 $this->tpl->setVariable(
'TD_CLASS',
'calstd');
329 $this->tpl->parseCurrentBlock();
333 #echo "NUMDAY: ".$num_day;
334 #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
335 $num_apps = $hour[
'apps_num'];
336 $colspan = max($colspans[$num_day],1);
340 if(!$hour[
'apps_num'] && !$ilUser->prefs[
"screen_reader_optimization"] && !$no_add)
342 $this->tpl->setCurrentBlock(
'new_app_link');
343 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$this->weekdays[$num_day]->
get(
IL_CAL_DATE));
344 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$this->seed->get(
IL_CAL_DATE));
345 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour',floor($num_hour/60));
346 $this->tpl->setVariable(
'DAY_NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
347 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
350 $this->tpl->setVariable(
'DAY_NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
351 $this->tpl->setVariable(
'DAY_NEW_ID',++$new_link_counter);
352 $this->tpl->parseCurrentBlock();
355 for($i = $colspan;$i > $hour[
'apps_num'];$i--)
357 if ($ilUser->prefs[
"screen_reader_optimization"])
361 $this->tpl->setCurrentBlock(
'day_cell');
365 if($num_hour%60 == 60-$raster ||
366 ($num_hour == $morning_aggr && $morning_aggr) ||
367 ($num_hour == $evening_aggr && $evening_aggr))
369 $empty_border =
' calempty_border';
372 if($i == ($hour[
'apps_num'] + 1))
374 $this->tpl->setVariable(
'TD_CLASS',
'calempty calrightborder'.$empty_border);
375 #$this->tpl->setVariable('TD_STYLE',$add_style);
379 $this->tpl->setVariable(
'TD_CLASS',
'calempty'.$empty_border);
380 #$this->tpl->setVariable('TD_STYLE',$add_style);
383 if(!$hour[
'apps_num'])
385 $this->tpl->setVariable(
'DAY_ID',$new_link_counter);
387 $this->tpl->setVariable(
'TD_ROWSPAN',1);
388 $this->tpl->parseCurrentBlock();
392 $this->tpl->touchBlock(
'time_row');
395 $this->tpl->setVariable(
"TXT_TIME", $lng->txt(
"time"));
407 $this->tpl->setCurrentBlock(
'panel_code');
408 $this->tpl->setVariable(
'NUM',$this->num_appointments);
409 $this->tpl->parseCurrentBlock();
412 if ($a_app[
'event']->isMilestone())
414 $this->tpl->setCurrentBlock(
'fullday_ms_icon');
415 $this->tpl->setVariable(
'ALT_FD_MS', $this->lng->txt(
"cal_milestone"));
417 $this->tpl->parseCurrentBlock();
420 $this->tpl->setCurrentBlock(
'fullday_app');
422 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
424 $this->tpl->setVariable(
'F_DAY_ID',$this->num_appointments);
426 $compl = ($a_app[
'event']->isMilestone() && $a_app[
'event']->getCompletion() > 0)
427 ?
" (".$a_app[
'event']->getCompletion().
"%)"
430 $this->tpl->setVariable(
'F_APP_TITLE',$a_app[
'event']->getPresentationTitle().$compl);
432 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
433 $this->tpl->setVariable(
'F_APP_BGCOLOR',$color);
436 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
437 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
438 $this->tpl->setVariable(
'F_APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
440 $this->tpl->parseCurrentBlock();
442 $this->num_appointments++;
455 $this->tpl->setCurrentBlock(
'panel_code');
456 $this->tpl->setVariable(
'NUM',$this->num_appointments);
457 $this->tpl->parseCurrentBlock();
459 if (!$ilUser->prefs[
"screen_reader_optimization"])
461 $this->tpl->setCurrentBLock(
'not_empty');
465 $this->tpl->setCurrentBLock(
'scrd_not_empty');
468 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
471 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
472 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
473 $this->tpl->setVariable(
'APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
475 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
476 $style =
'background-color: '.$color.
';';
477 $style .= (
'color:'.ilCalendarUtil::calculateFontColor($color));
481 if($a_app[
'event']->isFullDay())
483 $title = $a_app[
'event']->getPresentationTitle();
487 switch($this->user_settings->getTimeFormat())
490 $title = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'H:i',$this->timezone);
494 $title = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'h:ia',$this->timezone);
498 if ($ilUser->prefs[
"screen_reader_optimization"])
500 switch($this->user_settings->getTimeFormat())
503 $title.=
"-".$a_app[
'event']->getEnd()->get(
IL_CAL_FKT_DATE,
'H:i',$this->timezone);
507 $title.=
"-".$a_app[
'event']->getEnd()->get(
IL_CAL_FKT_DATE,
'h:ia',$this->timezone);
512 $title .= (
' '.$a_app[
'event']->getPresentationTitle());
513 $td_style .= $a_app[
'event']->getPresentationStyle();
516 $this->tpl->setVariable(
'APP_TITLE',$title);
517 $this->tpl->setVariable(
'LINK_NUM',$this->num_appointments);
519 $this->tpl->setVariable(
'LINK_STYLE',$style);
522 if (!$ilUser->prefs[
"screen_reader_optimization"])
525 $this->tpl->parseCurrentBlock();
527 $this->tpl->setCurrentBlock(
'day_cell');
529 $this->tpl->setVariable(
'DAY_CELL_NUM',$this->num_appointments);
530 $this->tpl->setVariable(
'TD_ROWSPAN',$a_app[
'rowspan']);
531 $this->tpl->setVariable(
'TD_STYLE',$td_style);
532 $this->tpl->setVariable(
'TD_CLASS',
'calevent');
534 $this->tpl->parseCurrentBlock();
539 $this->tpl->setVariable(
'DIV_STYLE',$style);
540 $this->tpl->parseCurrentBlock();
543 $this->num_appointments++;
556 $morning_aggr, $evening_aggr, $raster)
560 for($i = $morning_aggr;$i <= $evening_aggr;$i+=$raster)
562 $hours[$i][$num_day][
'apps_start'] = array();
563 $hours[$i][$num_day][
'apps_num'] = 0;
564 switch($this->user_settings->getTimeFormat())
567 if ($morning_aggr > 0 && $i == $morning_aggr)
569 $hours[$i][$num_day][
'txt'] = sprintf(
'%02d:00',0).
"-".
570 sprintf(
'%02d:00',ceil(($i+1)/60));
574 $hours[$i][$num_day][
'txt'].= sprintf(
'%02d:%02d',floor($i/60),$i%60);
576 if ($evening_aggr < 23*60 && $i == $evening_aggr)
578 $hours[$i][$num_day][
'txt'].=
"-".sprintf(
'%02d:00',23);
583 if ($morning_aggr > 0 && $i == $morning_aggr)
585 $hours[$i][$num_day][
'txt'] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
587 $hours[$i][$num_day][
'txt'].= date(
'h a',mktime(floor($i/60),$i%60,0,1,1,2000));
588 if ($evening_aggr < 23 && $i == $evening_aggr)
590 $hours[$i][$num_day][
'txt'].=
"-".date(
'h a',mktime(23,0,0,1,1,2000));
599 foreach($daily_apps as $app)
607 if($app[
'start_info'][
'mday'] != $date_info[
'mday'])
613 $start = $app[
'start_info'][
'hours']*60+$app[
'start_info'][
'minutes'];
616 if($app[
'end_info'][
'mday'] != $date_info[
'mday'])
620 elseif($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours'])
622 $end = $start+$raster;
627 $end = $app[
'end_info'][
'hours']*60+$app[
'end_info'][
'minutes'];
631 if ($ilUser->prefs[
"screen_reader_optimization"])
633 $end = $start+$raster;
636 if ($start < $morning_aggr)
638 $start = $morning_aggr;
640 if ($end <= $morning_aggr)
642 $end = $morning_aggr+$raster;
644 if ($start > $evening_aggr)
646 $start = $evening_aggr;
648 if ($end > $evening_aggr+$raster)
650 $end = $evening_aggr+$raster;
654 $end = $start+$raster;
658 $start = floor($start/$raster)*$raster;
659 $end = ceil($end/$raster)*$raster;
662 for($i = $start;$i < $end;$i+=$raster)
666 if (!$ilUser->prefs[
"screen_reader_optimization"])
668 $app[
'rowspan'] = ceil(($end - $start)/$raster);
674 $hours[$i][$num_day][
'apps_start'][] = $app;
677 $hours[$i][$num_day][
'apps_num']++;
694 foreach($hours as $hour_num => $hours_per_day)
696 foreach($hours_per_day as $num_day => $hour)
698 $colspans[$num_day] = max($colspans[$num_day],$hour[
'apps_num']);
701 if ($ilUser->prefs[
"screen_reader_optimization"])
703 $colspans[$num_day] = 1;