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(
142 $this->ui_factory->button()->shy(
145 )->withSymbol($this->ui_factory->symbol()->glyph()->add())
148 $this->tpl->parseCurrentBlock();
150 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
153 $this->tpl->setVariable(
'NAVIGATION', $navigation->getHTML());
155 $this->tpl->setVariable(
159 $this->tpl->setVariable(
163 $this->tpl->setVariable(
'HCOLSPAN', $colspan - 1);
165 $this->tpl->setVariable(
'TXT_TIME', $this->
lng->txt(
"time"));
168 foreach ($daily_apps as $event) {
169 if ($event[
'fullday']) {
173 $this->tpl->setCurrentBlock(
'fullday_apps');
174 $this->tpl->setVariable(
'TXT_F_DAY', $this->
lng->txt(
"cal_all_day"));
175 $this->tpl->setVariable(
'COLSPAN', $colspan - 1);
176 $this->tpl->parseCurrentBlock();
179 foreach ($hours as $numeric => $hour) {
180 if (!($numeric % 60) || ($numeric == $morning_aggr && $morning_aggr) ||
181 ($numeric == $evening_aggr && $evening_aggr)) {
183 $this->tpl->setCurrentBlock(
"new_app2");
184 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
185 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
186 $this->
ctrl->setParameterByClass(
187 'ilcalendarappointmentgui',
191 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour', floor($numeric / 60));
192 $this->tpl->setVariable(
194 $this->ui_renderer->render(
195 $this->ui_factory->button()->shy(
197 $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add')
198 )->withSymbol($this->ui_factory->symbol()->glyph()->add())
201 $this->tpl->parseCurrentBlock();
205 if (($numeric == $morning_aggr && $morning_aggr) ||
206 ($numeric == $evening_aggr && $evening_aggr)) {
207 $this->tpl->setVariable(
'TIME_ROWSPAN', 1);
210 $this->tpl->setVariable(
'TIME_ROWSPAN', 60 / $raster);
213 $this->tpl->setCurrentBlock(
'time_txt');
215 $this->tpl->setVariable(
'TIME', $hour[
'txt']);
216 $this->tpl->parseCurrentBlock();
219 foreach ($hour[
'apps_start'] as $app) {
223 for ($i = ($colspan - 1); $i > $hour[
'apps_num']; $i--) {
224 $this->tpl->setCurrentBlock(
'empty_cell');
225 $this->tpl->setVariable(
'EMPTY_WIDTH', (100 / ($colspan - 1)) .
'%');
228 if ($numeric % 60 == 60 - $raster ||
229 ($numeric == $morning_aggr && $morning_aggr) ||
230 ($numeric == $evening_aggr && $evening_aggr)) {
231 $this->tpl->setVariable(
'EMPTY_STYLE',
' calempty_border');
234 $this->tpl->parseCurrentBlock();
237 $this->tpl->touchBlock(
'time_row');
243 $event_tpl =
new ilTemplate(
'tpl.day_event_view.html',
true,
true,
'components/ILIAS/Calendar');
245 $event_tpl->setCurrentBlock(
'fullday_app');
249 $event_tpl->setVariable(
'EVENT_CONTENT', $content);
251 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
252 $event_tpl->setVariable(
'F_APP_BGCOLOR', $color);
255 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
256 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
257 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
258 $event_tpl->setVariable(
260 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit')
269 $body_html = $event_html_by_plugin;
271 $event_tpl->parseCurrentBlock();
272 $body_html = $event_tpl->get();
275 $this->tpl->setCurrentBlock(
"content_fd");
276 $this->tpl->setVariable(
"CONTENT_EVENT", $body_html);
277 $this->tpl->parseCurrentBlock();
278 $this->num_appointments++;
283 $event_tpl =
new ilTemplate(
'tpl.day_event_view.html',
true,
true,
'components/ILIAS/Calendar');
284 $event_tpl->setCurrentBlock(
'app');
285 $this->tpl->setVariable(
'APP_ROWSPAN', $a_app[
'rowspan']);
287 switch ($this->user_settings->getTimeFormat()) {
289 $time = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'H:i', $this->timezone);
293 $time = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'h:ia', $this->timezone);
300 $content = ($time !=
"") ? $time .
" " . $title : $title;
301 $event_tpl->setVariable(
'EVENT_CONTENT', $content);
303 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
304 $event_tpl->setVariable(
'APP_BGCOLOR', $color);
306 $event_tpl->setVariable(
'APP_ADD_STYLES', $a_app[
'event']->getPresentationStyle());
308 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
309 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
310 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
311 $event_tpl->setVariable(
'APP_EDIT_LINK', $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
319 $event_html = $event_html_by_plugin;
321 $event_tpl->parseCurrentBlock();
322 $event_html = $event_tpl->get();
325 $this->tpl->setCurrentBlock(
"event_nfd");
326 $this->tpl->setVariable(
"CONTENT_EVENT_NFD", $event_html);
327 $this->tpl->parseCurrentBlock();
329 $this->num_appointments++;
335 protected function parseInfoIntoRaster(array $daily_apps,
int $morning_aggr,
int $evening_aggr,
int $raster): array
338 for ($i = $morning_aggr; $i <= $evening_aggr; $i += $raster) {
339 $hours[$i][
'apps_start'] = array();
340 $hours[$i][
'apps_num'] = 0;
342 switch ($this->user_settings->getTimeFormat()) {
344 if ($morning_aggr > 0 && $i == $morning_aggr) {
345 $hours[$i][
'txt'] = sprintf(
'%02d:00', 0) .
' - ' .
346 sprintf(
'%02d:00', ceil(($i + 1) / 60));
348 if (!isset($hours[$i][
'txt'])) {
349 $hours[$i][
'txt'] = sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
351 $hours[$i][
'txt'] .= sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
354 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
355 if (!isset($hours[$i][
'txt'])) {
356 $hours[$i][
'txt'] =
' - ' . sprintf(
'%02d:00', 0);
358 $hours[$i][
'txt'] .=
' - ' . sprintf(
'%02d:00', 0);
364 $this->
logger->notice(
'Morning: ' . $morning_aggr .
' and $i:' . $i);
365 if ($morning_aggr > 0 && $i == $morning_aggr) {
367 date(
'h a', mktime(0, 0, 0, 1, 1, 2000)) .
' - ' .
368 date(
'h a', mktime($this->user_settings->getDayStart(), 0, 0, 1, 1, 2000));
370 $hours[$i][
'txt'] = date(
'h a', mktime((
int) floor($i / 60), $i % 60, 0, 1, 1, 2000));
372 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
373 if (!isset($hours[$i][
'txt'])) {
374 $hours[$i][
'txt'] =
' - ' . date(
'h a', mktime(0, 0, 0, 1, 1, 2000));
376 $hours[$i][
'txt'] .=
' - ' . date(
'h a', mktime(0, 0, 0, 1, 1, 2000));
383 foreach ($daily_apps as $app) {
385 if ($app[
'fullday']) {
390 if ($app[
'start_info'][
'mday'] != $this->seed_info[
'mday']) {
393 $start = $app[
'start_info'][
'hours'] * 60 + $app[
'start_info'][
'minutes'];
399 if ($app[
'end_info'][
'mday'] != $this->seed_info[
'mday']) {
401 } elseif ($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours']) {
402 $end = $start + $raster;
404 $end = $app[
'end_info'][
'hours'] * 60 + $app[
'end_info'][
'minutes'];
407 if ($start < $morning_aggr) {
408 $start = $morning_aggr;
410 if ($end <= $morning_aggr) {
411 $end = $morning_aggr + $raster;
413 if ($start > $evening_aggr) {
414 $start = $evening_aggr;
416 if ($end > $evening_aggr + $raster) {
417 $end = $evening_aggr + $raster;
419 if ($end <= $start) {
420 $end = $start + $raster;
424 $start = floor($start / $raster) * $raster;
425 $end = ceil($end / $raster) * $raster;
428 for ($i = $start; $i < $end; $i += $raster) {
430 $app[
'rowspan'] = ceil(($end - $start) / $raster);
431 $hours[$i][
'apps_start'][] = $app;
434 $hours[$i][
'apps_num']++;
443 foreach ($hours as $hour) {
444 $colspan = max($colspan, $hour[
'apps_num'] + 1);
446 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