19 declare(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');
114 $scheduler->addSubitemCalendars(
true);
115 $scheduler->calculate();
116 $daily_apps = $scheduler->getByDay($this->seed, $this->timezone);
119 if (count($daily_apps)) {
120 $this->view_with_appointments =
true;
133 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
136 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
137 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate', $this->seed->get(
IL_CAL_DATE));
138 $new_app_url = $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add');
140 $this->tpl->setCurrentBlock(
"new_app1");
141 $this->tpl->setVariable(
143 $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->add($new_app_url))
145 $this->tpl->parseCurrentBlock();
147 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
150 $this->tpl->setVariable(
'NAVIGATION', $navigation->getHTML());
152 $this->tpl->setVariable(
156 $this->tpl->setVariable(
160 $this->tpl->setVariable(
'HCOLSPAN', $colspan - 1);
162 $this->tpl->setVariable(
'TXT_TIME', $this->
lng->txt(
"time"));
165 foreach ($daily_apps as $event) {
166 if ($event[
'fullday']) {
170 $this->tpl->setCurrentBlock(
'fullday_apps');
171 $this->tpl->setVariable(
'TXT_F_DAY', $this->
lng->txt(
"cal_all_day"));
172 $this->tpl->setVariable(
'COLSPAN', $colspan - 1);
173 $this->tpl->parseCurrentBlock();
176 foreach ($hours as $numeric => $hour) {
177 if (!($numeric % 60) || ($numeric == $morning_aggr && $morning_aggr) ||
178 ($numeric == $evening_aggr && $evening_aggr)) {
180 $this->tpl->setCurrentBlock(
"new_app2");
181 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
182 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
183 $this->
ctrl->setParameterByClass(
184 'ilcalendarappointmentgui',
188 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour', floor($numeric / 60));
189 $this->tpl->setVariable(
191 $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->add(
192 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add')
195 $this->tpl->parseCurrentBlock();
199 if (($numeric == $morning_aggr && $morning_aggr) ||
200 ($numeric == $evening_aggr && $evening_aggr)) {
201 $this->tpl->setVariable(
'TIME_ROWSPAN', 1);
204 $this->tpl->setVariable(
'TIME_ROWSPAN', 60 / $raster);
207 $this->tpl->setCurrentBlock(
'time_txt');
209 $this->tpl->setVariable(
'TIME', $hour[
'txt']);
210 $this->tpl->parseCurrentBlock();
213 foreach ($hour[
'apps_start'] as $app) {
217 for ($i = ($colspan - 1); $i > $hour[
'apps_num']; $i--) {
218 $this->tpl->setCurrentBlock(
'empty_cell');
219 $this->tpl->setVariable(
'EMPTY_WIDTH', (100 / ($colspan - 1)) .
'%');
222 if ($numeric % 60 == 60 - $raster ||
223 ($numeric == $morning_aggr && $morning_aggr) ||
224 ($numeric == $evening_aggr && $evening_aggr)) {
225 $this->tpl->setVariable(
'EMPTY_STYLE',
' calempty_border');
228 $this->tpl->parseCurrentBlock();
231 $this->tpl->touchBlock(
'time_row');
237 $event_tpl =
new ilTemplate(
'tpl.day_event_view.html',
true,
true,
'components/ILIAS/Calendar');
239 $event_tpl->setCurrentBlock(
'fullday_app');
243 $event_tpl->setVariable(
'EVENT_CONTENT', $content);
245 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
246 $event_tpl->setVariable(
'F_APP_BGCOLOR', $color);
249 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
250 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
251 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
252 $event_tpl->setVariable(
254 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit')
263 $body_html = $event_html_by_plugin;
265 $event_tpl->parseCurrentBlock();
266 $body_html = $event_tpl->get();
269 $this->tpl->setCurrentBlock(
"content_fd");
270 $this->tpl->setVariable(
"CONTENT_EVENT", $body_html);
271 $this->tpl->parseCurrentBlock();
272 $this->num_appointments++;
277 $event_tpl =
new ilTemplate(
'tpl.day_event_view.html',
true,
true,
'components/ILIAS/Calendar');
278 $event_tpl->setCurrentBlock(
'app');
279 $this->tpl->setVariable(
'APP_ROWSPAN', $a_app[
'rowspan']);
281 switch ($this->user_settings->getTimeFormat()) {
283 $time = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'H:i', $this->timezone);
287 $time = $a_app[
'event']->getStart()->get(
IL_CAL_FKT_DATE,
'h:ia', $this->timezone);
294 $content = ($time !=
"") ? $time .
" " . $title : $title;
295 $event_tpl->setVariable(
'EVENT_CONTENT', $content);
297 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
298 $event_tpl->setVariable(
'APP_BGCOLOR', $color);
300 $event_tpl->setVariable(
'APP_ADD_STYLES', $a_app[
'event']->getPresentationStyle());
302 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
303 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
304 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
305 $event_tpl->setVariable(
'APP_EDIT_LINK', $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
313 $event_html = $event_html_by_plugin;
315 $event_tpl->parseCurrentBlock();
316 $event_html = $event_tpl->get();
319 $this->tpl->setCurrentBlock(
"event_nfd");
320 $this->tpl->setVariable(
"CONTENT_EVENT_NFD", $event_html);
321 $this->tpl->parseCurrentBlock();
323 $this->num_appointments++;
329 protected function parseInfoIntoRaster(array $daily_apps,
int $morning_aggr,
int $evening_aggr,
int $raster): array
332 for ($i = $morning_aggr; $i <= $evening_aggr; $i += $raster) {
333 $hours[$i][
'apps_start'] = array();
334 $hours[$i][
'apps_num'] = 0;
336 switch ($this->user_settings->getTimeFormat()) {
338 if ($morning_aggr > 0 && $i == $morning_aggr) {
339 $hours[$i][
'txt'] = sprintf(
'%02d:00', 0) .
' - ' .
340 sprintf(
'%02d:00', ceil(($i + 1) / 60));
342 if (!isset($hours[$i][
'txt'])) {
343 $hours[$i][
'txt'] = sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
345 $hours[$i][
'txt'] .= sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
348 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
349 if (!isset($hours[$i][
'txt'])) {
350 $hours[$i][
'txt'] =
' - ' . sprintf(
'%02d:00', 0);
352 $hours[$i][
'txt'] .=
' - ' . sprintf(
'%02d:00', 0);
358 $this->
logger->notice(
'Morning: ' . $morning_aggr .
' and $i:' . $i);
359 if ($morning_aggr > 0 && $i == $morning_aggr) {
361 date(
'h a', mktime(0, 0, 0, 1, 1, 2000)) .
' - ' .
362 date(
'h a', mktime($this->user_settings->getDayStart(), 0, 0, 1, 1, 2000));
364 $hours[$i][
'txt'] = date(
'h a', mktime((
int) floor($i / 60), $i % 60, 0, 1, 1, 2000));
366 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
367 if (!isset($hours[$i][
'txt'])) {
368 $hours[$i][
'txt'] =
' - ' . date(
'h a', mktime(0, 0, 0, 1, 1, 2000));
370 $hours[$i][
'txt'] .=
' - ' . date(
'h a', mktime(0, 0, 0, 1, 1, 2000));
377 foreach ($daily_apps as $app) {
379 if ($app[
'fullday']) {
384 if ($app[
'start_info'][
'mday'] != $this->seed_info[
'mday']) {
387 $start = $app[
'start_info'][
'hours'] * 60 + $app[
'start_info'][
'minutes'];
393 if ($app[
'end_info'][
'mday'] != $this->seed_info[
'mday']) {
395 } elseif ($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours']) {
396 $end = $start + $raster;
398 $end = $app[
'end_info'][
'hours'] * 60 + $app[
'end_info'][
'minutes'];
401 if ($start < $morning_aggr) {
402 $start = $morning_aggr;
404 if ($end <= $morning_aggr) {
405 $end = $morning_aggr + $raster;
407 if ($start > $evening_aggr) {
408 $start = $evening_aggr;
410 if ($end > $evening_aggr + $raster) {
411 $end = $evening_aggr + $raster;
413 if ($end <= $start) {
414 $end = $start + $raster;
418 $start = floor($start / $raster) * $raster;
419 $end = ceil($end / $raster) * $raster;
422 for ($i = $start; $i < $end; $i += $raster) {
424 $app[
'rowspan'] = ceil(($end - $start) / $raster);
425 $hours[$i][
'apps_start'][] = $app;
428 $hours[$i][
'apps_num']++;
437 foreach ($hours as $hour) {
438 $colspan = max($colspan, $hour[
'apps_num'] + 1);
440 return max($colspan, 2);
calculateColspan(array $hours)
static _getInstance(ilDate $seed, array $a_app)
get singleton instance
static get(string $a_var)
showAppointment(array $a_app)
ilCalendarUserSettings $user_settings
static _numericMonthToString(int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
numeric month to string
getContentByPlugins(ilCalendarEntry $a_cal_entry, int $a_start_date, string $a_content, ilTemplate $a_tpl)
parseInfoIntoRaster(array $daily_apps, int $morning_aggr, int $evening_aggr, int $raster)
calculate overlapping hours
initAppointmentIdFromQuery()
__construct(ilDate $seed_date)
static _getInstanceByUserId(int $a_user_id)
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
showFulldayAppointment(array $a_app)
initBookingUserFromQuery()
static initDragDrop(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop used in Modules/Survey, Services/Calendar, Services/COPage, Services/Form (Jan 2022)
const CAL_PRESENTATION_DAY
ilCalendarAppointmentColors $app_colors
initInitialDateFromQuery()
Administrate calendar appointments.
__construct(Container $dic, ilPlugin $plugin)
static calculateFontColor(string $a_html_color_code)
Calculate best font color from html hex color code.
show()
fill data section protected
getAppointmentShyButton(ilCalendarEntry $a_calendar_entry, string $a_dstart, string $a_title_forced="")
initialize(int $a_calendar_presentation_type)
Represents a list of calendar appointments (including recurring events) for a specific user in a give...