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');
202 include_once
"Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
209 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$date->get(
IL_CAL_DATE));
210 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$date->get(
IL_CAL_DATE));
211 $this->ctrl->setParameterByClass(
'ilcalendardaygui',
'seed',$date->get(
IL_CAL_DATE));
215 $new_app_url = $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add');
217 if ($settings->getEnableGroupMilestones())
219 $new_ms_url = $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'addMilestone');
221 $this->tpl->setCurrentBlock(
"new_ms");
222 $this->tpl->setVariable(
'DD_ID', $date->get(
IL_CAL_UNIX));
224 $this->tpl->setVariable(
'URL_DD_NEW_APP', $new_app_url);
225 $this->tpl->setVariable(
'TXT_DD_NEW_APP', $this->lng->txt(
'cal_new_app'));
226 $this->tpl->setVariable(
'URL_DD_NEW_MS', $new_ms_url);
227 $this->tpl->setVariable(
'TXT_DD_NEW_MS', $this->lng->txt(
'cal_new_ms'));
228 $this->tpl->parseCurrentBlock();
232 $this->tpl->setCurrentBlock(
"new_app");
233 $this->tpl->setVariable(
'NEW_APP_LINK',$new_app_url);
236 $this->tpl->parseCurrentBlock();
239 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
245 if(!$disable_empty || $num_apps[$date->get(
IL_CAL_DATE)] > 0)
247 $link = $this->ctrl->getLinkTargetByClass(
'ilcalendardaygui',
'');
248 $this->ctrl->clearParametersByClass(
'ilcalendardaygui');
250 $this->tpl->setCurrentBlock(
"day_view1_link");
251 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
252 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
253 $this->tpl->parseCurrentBlock();
255 $this->tpl->setCurrentBlock(
"day_view2_link");
256 $this->tpl->setVariable(
'DAYNAME',$dayname);
257 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
258 $this->tpl->parseCurrentBlock();
262 $this->tpl->setCurrentBlock(
"day_view1_no_link");
263 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
264 $this->tpl->parseCurrentBlock();
266 $this->tpl->setCurrentBlock(
"day_view2_no_link");
267 $this->tpl->setVariable(
'DAYNAME',$dayname);
268 $this->tpl->parseCurrentBlock();
271 $this->tpl->setCurrentBlock(
'day_header_row');
272 $this->tpl->setVariable(
'DAY_COLSPAN',max($colspans[$counter],1));
273 $this->tpl->parseCurrentBlock();
280 foreach($all_fullday as $daily_apps)
282 foreach($daily_apps as $event)
284 if($event[
'fullday'])
289 $this->tpl->setCurrentBlock(
'f_day_row');
290 $this->tpl->setVariable(
'COLSPAN',max($colspans[$counter],1));
291 $this->tpl->parseCurrentBlock();
294 $this->tpl->setCurrentBlock(
'fullday_apps');
295 $this->tpl->setVariable(
'TXT_F_DAY', $lng->txt(
"cal_all_day"));
296 $this->tpl->parseCurrentBlock();
298 $new_link_counter = 0;
299 foreach($hours as $num_hour => $hours_per_day)
302 foreach($hours_per_day as $num_day => $hour)
306 if(!($num_hour%60) || ($num_hour == $morning_aggr && $morning_aggr) ||
307 ($num_hour == $evening_aggr && $evening_aggr))
312 if(($num_hour == $morning_aggr && $morning_aggr) ||
313 ($num_hour == $evening_aggr && $evening_aggr))
315 $this->tpl->setVariable(
'TIME_ROWSPAN', 1);
320 $this->tpl->setVariable(
'TIME_ROWSPAN', 60/$raster);
323 $this->tpl->setCurrentBlock(
'time_txt');
325 $this->tpl->setVariable(
'TIME',$hour[
'txt']);
326 $this->tpl->parseCurrentBlock();
330 foreach($hour[
'apps_start'] as $app)
336 if ($ilUser->prefs[
"screen_reader_optimization"])
338 $this->tpl->setCurrentBlock(
'scrd_day_cell');
339 $this->tpl->setVariable(
'TD_CLASS',
'calstd');
340 $this->tpl->parseCurrentBlock();
344 #echo "NUMDAY: ".$num_day;
345 #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
346 $num_apps = $hour[
'apps_num'];
347 $colspan = max($colspans[$num_day],1);
351 if(!$hour[
'apps_num'] && !$ilUser->prefs[
"screen_reader_optimization"] && !$no_add)
353 $this->tpl->setCurrentBlock(
'new_app_link');
354 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$this->weekdays[$num_day]->
get(
IL_CAL_DATE));
355 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$this->seed->get(
IL_CAL_DATE));
356 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour',floor($num_hour/60));
357 $this->tpl->setVariable(
'DAY_NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
358 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
361 $this->tpl->setVariable(
'DAY_NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
362 $this->tpl->setVariable(
'DAY_NEW_ID',++$new_link_counter);
363 $this->tpl->parseCurrentBlock();
366 for($i = $colspan;$i > $hour[
'apps_num'];$i--)
368 if ($ilUser->prefs[
"screen_reader_optimization"])
372 $this->tpl->setCurrentBlock(
'day_cell');
376 if($num_hour%60 == 60-$raster ||
377 ($num_hour == $morning_aggr && $morning_aggr) ||
378 ($num_hour == $evening_aggr && $evening_aggr))
380 $empty_border =
' calempty_border';
383 if($i == ($hour[
'apps_num'] + 1))
385 $this->tpl->setVariable(
'TD_CLASS',
'calempty calrightborder'.$empty_border);
386 #$this->tpl->setVariable('TD_STYLE',$add_style);
390 $this->tpl->setVariable(
'TD_CLASS',
'calempty'.$empty_border);
391 #$this->tpl->setVariable('TD_STYLE',$add_style);
394 if(!$hour[
'apps_num'])
396 $this->tpl->setVariable(
'DAY_ID',$new_link_counter);
398 $this->tpl->setVariable(
'TD_ROWSPAN',1);
399 $this->tpl->parseCurrentBlock();
403 $this->tpl->touchBlock(
'time_row');
406 $this->tpl->setVariable(
"TXT_TIME", $lng->txt(
"time"));
418 $this->tpl->setCurrentBlock(
'panel_code');
419 $this->tpl->setVariable(
'NUM',$this->num_appointments);
420 $this->tpl->parseCurrentBlock();
423 if ($a_app[
'event']->isMilestone())
425 $this->tpl->setCurrentBlock(
'fullday_ms_icon');
426 $this->tpl->setVariable(
'ALT_FD_MS', $this->lng->txt(
"cal_milestone"));
428 $this->tpl->parseCurrentBlock();
431 $this->tpl->setCurrentBlock(
'fullday_app');
433 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
435 $this->tpl->setVariable(
'F_DAY_ID',$this->num_appointments);
437 $compl = ($a_app[
'event']->isMilestone() && $a_app[
'event']->getCompletion() > 0)
438 ?
" (".$a_app[
'event']->getCompletion().
"%)"
441 $this->tpl->setVariable(
'F_APP_TITLE',$a_app[
'event']->getPresentationTitle().$compl);
443 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
444 $this->tpl->setVariable(
'F_APP_BGCOLOR',$color);
447 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
448 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
449 $this->tpl->setVariable(
'F_APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
451 $this->tpl->parseCurrentBlock();
453 $this->num_appointments++;
466 $this->tpl->setCurrentBlock(
'panel_code');
467 $this->tpl->setVariable(
'NUM',$this->num_appointments);
468 $this->tpl->parseCurrentBlock();
470 if (!$ilUser->prefs[
"screen_reader_optimization"])
472 $this->tpl->setCurrentBLock(
'not_empty');
476 $this->tpl->setCurrentBLock(
'scrd_not_empty');
479 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
482 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
483 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
484 $this->tpl->setVariable(
'APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
486 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
487 $style =
'background-color: '.$color.
';';
488 $style .= (
'color:'.ilCalendarUtil::calculateFontColor($color));
492 if($a_app[
'event']->isFullDay())
494 $title = $a_app[
'event']->getPresentationTitle();
498 switch($this->user_settings->getTimeFormat())
501 $title = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'H:i',$this->timezone);
505 $title = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'h:ia',$this->timezone);
509 if ($ilUser->prefs[
"screen_reader_optimization"])
511 switch($this->user_settings->getTimeFormat())
514 $title.=
"-".$a_app[
'event']->getEnd()->get(
IL_CAL_FKT_DATE,
'H:i',$this->timezone);
518 $title.=
"-".$a_app[
'event']->getEnd()->get(
IL_CAL_FKT_DATE,
'h:ia',$this->timezone);
523 $title .= (
' '.$a_app[
'event']->getPresentationTitle());
524 $td_style .= $a_app[
'event']->getPresentationStyle();
527 $this->tpl->setVariable(
'APP_TITLE',$title);
528 $this->tpl->setVariable(
'LINK_NUM',$this->num_appointments);
530 $this->tpl->setVariable(
'LINK_STYLE',$style);
533 if (!$ilUser->prefs[
"screen_reader_optimization"])
536 $this->tpl->parseCurrentBlock();
538 $this->tpl->setCurrentBlock(
'day_cell');
540 $this->tpl->setVariable(
'DAY_CELL_NUM',$this->num_appointments);
541 $this->tpl->setVariable(
'TD_ROWSPAN',$a_app[
'rowspan']);
542 $this->tpl->setVariable(
'TD_STYLE',$td_style);
543 $this->tpl->setVariable(
'TD_CLASS',
'calevent');
545 $this->tpl->parseCurrentBlock();
550 $this->tpl->setVariable(
'DIV_STYLE',$style);
551 $this->tpl->parseCurrentBlock();
554 $this->num_appointments++;
567 $morning_aggr, $evening_aggr, $raster)
571 for($i = $morning_aggr;$i <= $evening_aggr;$i+=$raster)
573 $hours[$i][$num_day][
'apps_start'] = array();
574 $hours[$i][$num_day][
'apps_num'] = 0;
575 switch($this->user_settings->getTimeFormat())
578 if ($morning_aggr > 0 && $i == $morning_aggr)
580 $hours[$i][$num_day][
'txt'] = sprintf(
'%02d:00',0).
"-".
581 sprintf(
'%02d:00',ceil(($i+1)/60));
585 $hours[$i][$num_day][
'txt'].= sprintf(
'%02d:%02d',floor($i/60),$i%60);
587 if ($evening_aggr < 23*60 && $i == $evening_aggr)
589 $hours[$i][$num_day][
'txt'].=
"-".sprintf(
'%02d:00',23);
594 if ($morning_aggr > 0 && $i == $morning_aggr)
596 $hours[$i][$num_day][
'txt'] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
598 $hours[$i][$num_day][
'txt'].= date(
'h a',mktime(floor($i/60),$i%60,0,1,1,2000));
599 if ($evening_aggr < 23 && $i == $evening_aggr)
601 $hours[$i][$num_day][
'txt'].=
"-".date(
'h a',mktime(23,0,0,1,1,2000));
610 foreach($daily_apps as $app)
618 if($app[
'start_info'][
'mday'] != $date_info[
'mday'])
624 $start = $app[
'start_info'][
'hours']*60+$app[
'start_info'][
'minutes'];
627 if($app[
'end_info'][
'mday'] != $date_info[
'mday'])
631 elseif($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours'])
633 $end = $start+$raster;
638 $end = $app[
'end_info'][
'hours']*60+$app[
'end_info'][
'minutes'];
642 if ($ilUser->prefs[
"screen_reader_optimization"])
644 $end = $start+$raster;
647 if ($start < $morning_aggr)
649 $start = $morning_aggr;
651 if ($end <= $morning_aggr)
653 $end = $morning_aggr+$raster;
655 if ($start > $evening_aggr)
657 $start = $evening_aggr;
659 if ($end > $evening_aggr+$raster)
661 $end = $evening_aggr+$raster;
665 $end = $start+$raster;
669 $start = floor($start/$raster)*$raster;
670 $end = ceil($end/$raster)*$raster;
673 for($i = $start;$i < $end;$i+=$raster)
677 if (!$ilUser->prefs[
"screen_reader_optimization"])
679 $app[
'rowspan'] = ceil(($end - $start)/$raster);
685 $hours[$i][$num_day][
'apps_start'][] = $app;
688 $hours[$i][$num_day][
'apps_num']++;
705 foreach($hours as $hour_num => $hours_per_day)
707 foreach($hours_per_day as $num_day => $hour)
709 $colspans[$num_day] = max($colspans[$num_day],$hour[
'apps_num']);
712 if ($ilUser->prefs[
"screen_reader_optimization"])
714 $colspans[$num_day] = 1;