19declare(strict_types=1);
41 public function initialize(
int $a_calendar_presentation_type): void
45 parent::initialize($a_calendar_presentation_type);
49 if ($this->
user->getTimeZone()) {
50 $this->timezone = $this->
user->getTimeZone();
56 $next_class = $this->
ctrl->getNextClass();
57 switch ($next_class) {
58 case "ilcalendarappointmentpresentationgui":
59 $this->
ctrl->setReturn($this,
"");
60 $this->
logger->debug(
"-ExecCommand - representation of ilDate: this->seed->get(IL_CAL_DATE) = " . $this->seed->get(
IL_CAL_DATE));
62 $this->
ctrl->forwardCommand($gui);
64 case 'ilcalendarappointmentgui':
65 $this->
ctrl->setReturn($this,
'');
66 $this->tabs_gui->setSubTabActive((
string)
ilSession::get(
'cal_last_tab'));
71 $this->
ctrl->forwardCommand($app);
75 $cmd = $this->
ctrl->getCmd(
"show");
77 $this->main_tpl->setContent($this->tpl->get());
86 protected function show(): void
90 if ($this->user_settings->getDayStart()) {
92 $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster);
96 $evening_aggr = $this->user_settings->getDayEnd() * 60;
98 $this->tpl =
new ilTemplate(
'tpl.day_view.html',
true,
true,
'components/ILIAS/Calendar');
112 $scheduler->addSubitemCalendars(
true);
113 $scheduler->calculate();
114 $daily_apps = $scheduler->getByDay($this->seed, $this->timezone);
117 if (count($daily_apps)) {
118 $this->view_with_appointments =
true;
131 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
134 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
135 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate', $this->seed->get(
IL_CAL_DATE));
136 $new_app_url = $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add');
138 $this->tpl->setCurrentBlock(
"new_app1");
139 $this->tpl->setVariable(
141 $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->add($new_app_url))
143 $this->tpl->parseCurrentBlock();
145 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
148 $this->tpl->setVariable(
'NAVIGATION', $navigation->getHTML());
150 $this->tpl->setVariable(
154 $this->tpl->setVariable(
158 $this->tpl->setVariable(
'HCOLSPAN', $colspan - 1);
160 $this->tpl->setVariable(
'TXT_TIME', $this->
lng->txt(
"time"));
163 foreach ($daily_apps as $event) {
164 if ($event[
'fullday']) {
168 $this->tpl->setCurrentBlock(
'fullday_apps');
169 $this->tpl->setVariable(
'TXT_F_DAY', $this->
lng->txt(
"cal_all_day"));
170 $this->tpl->setVariable(
'COLSPAN', $colspan - 1);
171 $this->tpl->parseCurrentBlock();
174 foreach ($hours as $numeric => $hour) {
175 if (!($numeric % 60) || ($numeric == $morning_aggr && $morning_aggr) ||
176 ($numeric == $evening_aggr && $evening_aggr)) {
178 $this->tpl->setCurrentBlock(
"new_app2");
179 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
180 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
181 $this->
ctrl->setParameterByClass(
182 'ilcalendarappointmentgui',
186 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour', floor($numeric / 60));
187 $this->tpl->setVariable(
189 $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->add(
190 $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add')
193 $this->tpl->parseCurrentBlock();
197 if (($numeric == $morning_aggr && $morning_aggr) ||
198 ($numeric == $evening_aggr && $evening_aggr)) {
199 $this->tpl->setVariable(
'TIME_ROWSPAN', 1);
202 $this->tpl->setVariable(
'TIME_ROWSPAN', 60 / $raster);
205 $this->tpl->setCurrentBlock(
'time_txt');
207 $this->tpl->setVariable(
'TIME', $hour[
'txt']);
208 $this->tpl->parseCurrentBlock();
211 foreach ($hour[
'apps_start'] as $app) {
215 for ($i = ($colspan - 1); $i > $hour[
'apps_num']; $i--) {
216 $this->tpl->setCurrentBlock(
'empty_cell');
217 $this->tpl->setVariable(
'EMPTY_WIDTH', (100 / ($colspan - 1)) .
'%');
220 if ($numeric % 60 == 60 - $raster ||
221 ($numeric == $morning_aggr && $morning_aggr) ||
222 ($numeric == $evening_aggr && $evening_aggr)) {
223 $this->tpl->setVariable(
'EMPTY_STYLE',
' calempty_border');
226 $this->tpl->parseCurrentBlock();
229 $this->tpl->touchBlock(
'time_row');
235 $event_tpl =
new ilTemplate(
'tpl.day_event_view.html',
true,
true,
'components/ILIAS/Calendar');
237 $event_tpl->setCurrentBlock(
'fullday_app');
241 $event_tpl->setVariable(
'EVENT_CONTENT', $content);
243 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
244 $event_tpl->setVariable(
'F_APP_BGCOLOR', $color);
247 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
248 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
249 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
250 $event_tpl->setVariable(
252 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit')
261 $body_html = $event_html_by_plugin;
263 $event_tpl->parseCurrentBlock();
264 $body_html = $event_tpl->get();
267 $this->tpl->setCurrentBlock(
"content_fd");
268 $this->tpl->setVariable(
"CONTENT_EVENT", $body_html);
269 $this->tpl->parseCurrentBlock();
270 $this->num_appointments++;
275 $event_tpl =
new ilTemplate(
'tpl.day_event_view.html',
true,
true,
'components/ILIAS/Calendar');
276 $event_tpl->setCurrentBlock(
'app');
277 $this->tpl->setVariable(
'APP_ROWSPAN', $a_app[
'rowspan']);
279 switch ($this->user_settings->getTimeFormat()) {
281 $time = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'H:i', $this->timezone);
285 $time = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'h:ia', $this->timezone);
292 $content = ($time !=
"") ? $time .
" " . $title : $title;
293 $event_tpl->setVariable(
'EVENT_CONTENT', $content);
295 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
296 $event_tpl->setVariable(
'APP_BGCOLOR', $color);
298 $event_tpl->setVariable(
'APP_ADD_STYLES', $a_app[
'event']->getPresentationStyle());
300 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
301 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
302 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
303 $event_tpl->setVariable(
'APP_EDIT_LINK', $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
311 $event_html = $event_html_by_plugin;
313 $event_tpl->parseCurrentBlock();
314 $event_html = $event_tpl->get();
317 $this->tpl->setCurrentBlock(
"event_nfd");
318 $this->tpl->setVariable(
"CONTENT_EVENT_NFD", $event_html);
319 $this->tpl->parseCurrentBlock();
321 $this->num_appointments++;
327 protected function parseInfoIntoRaster(array $daily_apps,
int $morning_aggr,
int $evening_aggr,
int $raster): array
330 for ($i = $morning_aggr; $i <= $evening_aggr; $i += $raster) {
331 $hours[$i][
'apps_start'] = array();
332 $hours[$i][
'apps_num'] = 0;
334 switch ($this->user_settings->getTimeFormat()) {
336 if ($morning_aggr > 0 && $i == $morning_aggr) {
337 $hours[$i][
'txt'] = sprintf(
'%02d:00', 0) .
' - ' .
338 sprintf(
'%02d:00', ceil(($i + 1) / 60));
340 if (!isset($hours[$i][
'txt'])) {
341 $hours[$i][
'txt'] = sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
343 $hours[$i][
'txt'] .= sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
346 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
347 if (!isset($hours[$i][
'txt'])) {
348 $hours[$i][
'txt'] =
' - ' . sprintf(
'%02d:00', 0);
350 $hours[$i][
'txt'] .=
' - ' . sprintf(
'%02d:00', 0);
356 $this->
logger->notice(
'Morning: ' . $morning_aggr .
' and $i:' . $i);
357 if ($morning_aggr > 0 && $i == $morning_aggr) {
359 date(
'h a', mktime(0, 0, 0, 1, 1, 2000)) .
' - ' .
360 date(
'h a', mktime($this->user_settings->getDayStart(), 0, 0, 1, 1, 2000));
362 $hours[$i][
'txt'] = date(
'h a', mktime((
int) floor($i / 60), $i % 60, 0, 1, 1, 2000));
364 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
365 if (!isset($hours[$i][
'txt'])) {
366 $hours[$i][
'txt'] =
' - ' . date(
'h a', mktime(0, 0, 0, 1, 1, 2000));
368 $hours[$i][
'txt'] .=
' - ' . date(
'h a', mktime(0, 0, 0, 1, 1, 2000));
375 foreach ($daily_apps as $app) {
377 if ($app[
'fullday']) {
382 if ($app[
'start_info'][
'mday'] != $this->seed_info[
'mday']) {
385 $start = $app[
'start_info'][
'hours'] * 60 + $app[
'start_info'][
'minutes'];
391 if ($app[
'end_info'][
'mday'] != $this->seed_info[
'mday']) {
393 } elseif ($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours']) {
394 $end = $start + $raster;
396 $end = $app[
'end_info'][
'hours'] * 60 + $app[
'end_info'][
'minutes'];
399 if ($start < $morning_aggr) {
400 $start = $morning_aggr;
402 if ($end <= $morning_aggr) {
403 $end = $morning_aggr + $raster;
405 if ($start > $evening_aggr) {
406 $start = $evening_aggr;
408 if ($end > $evening_aggr + $raster) {
409 $end = $evening_aggr + $raster;
411 if ($end <= $start) {
412 $end = $start + $raster;
416 $start = floor($start / $raster) * $raster;
417 $end = ceil($end / $raster) * $raster;
420 for ($i = $start; $i < $end; $i += $raster) {
422 $app[
'rowspan'] = ceil(($end - $start) / $raster);
423 $hours[$i][
'apps_start'][] = $app;
426 $hours[$i][
'apps_num']++;
435 foreach ($hours as $hour) {
436 $colspan = max($colspan, $hour[
'apps_num'] + 1);
438 return max($colspan, 2);
Administrate calendar appointments.
static _getInstance(ilDate $seed, array $a_app)
get singleton instance
showFulldayAppointment(array $a_app)
__construct(ilDate $seed_date)
show()
fill data section @access protected
ilCalendarUserSettings $user_settings
initialize(int $a_calendar_presentation_type)
showAppointment(array $a_app)
parseInfoIntoRaster(array $daily_apps, int $morning_aggr, int $evening_aggr, int $raster)
calculate overlapping hours
ilCalendarAppointmentColors $app_colors
calculateColspan(array $hours)
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
static _getInstanceByUserId(int $a_user_id)
static calculateFontColor(string $a_html_color_code)
Calculate best font color from html hex color code.
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
static _numericMonthToString(int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
numeric month to string
getAppointmentShyButton(ilCalendarEntry $a_calendar_entry, string $a_dstart, string $a_title_forced="")
initInitialDateFromQuery()
initAppointmentIdFromQuery()
initBookingUserFromQuery()
const CAL_PRESENTATION_DAY
getContentByPlugins(ilCalendarEntry $a_cal_entry, int $a_start_date, string $a_content, ilTemplate $a_tpl)
static get(string $a_var)
special template class to simplify handling of ITX/PEAR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc