ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMiniCalendarGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
25{
26 public const PRESENTATION_CALENDAR = 1;
27
28 protected ilDate $seed;
32 protected ilLanguage $lng;
33 protected ilObjUser $user;
34 protected object $parentobject;
35
36 public function __construct(ilDate $seed, object $a_par_obj)
37 {
38 global $DIC;
39
40 $ilUser = $DIC['ilUser'];
41 $lng = $DIC['lng'];
42
43 $this->user = $DIC->user();
44 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
45 $this->ctrl = $DIC->ctrl();
46 $this->lng = $lng;
47 $this->lng->loadLanguageModule('dateplaner');
48 $this->seed = $seed;
49 $this->setParentObject($a_par_obj);
50 }
51
52 public function setParentObject(object $a_parentobject): void
53 {
54 $this->parentobject = $a_parentobject;
55 }
56
57 public function getParentObject(): object
58 {
60 }
61
65 public function getHTML(): string
66 {
67 $ftpl = new ilTemplate(
68 "tpl.calendar_block_frame.html",
69 true,
70 true,
71 "components/ILIAS/Calendar"
72 );
73
74 $tpl = new ilTemplate(
75 "tpl.calendar_block.html",
76 true,
77 true,
78 "components/ILIAS/Calendar"
79 );
80 $this->addMiniMonth($tpl);
81
82 $ftpl->setVariable("BLOCK_TITLE", $this->lng->txt("calendar"));
83 $ftpl->setVariable("CONTENT", $tpl->get());
84 return $ftpl->get();
85 }
86
91 public function addMiniMonth(ilTemplate $a_tpl): void
92 {
93 // weekdays
94 $a_tpl->setCurrentBlock('month_header_col');
95 $a_tpl->setVariable('TXT_WEEKDAY', $this->lng->txt("cal_week_abbrev"));
96 $a_tpl->parseCurrentBlock();
97 for ($i = $this->user_settings->getWeekStart(); $i < (7 + $this->user_settings->getWeekStart()); $i++) {
98 $a_tpl->setCurrentBlock('month_header_col');
99 $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
100 $a_tpl->parseCurrentBlock();
101 }
102
103 $scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH);
104 $scheduler->calculate();
105
106 $counter = 0;
108 (int) $this->seed->get(IL_CAL_FKT_DATE, 'm'),
109 (int) $this->seed->get(IL_CAL_FKT_DATE, 'Y'),
110 $this->user_settings->getWeekStart()
111 )->get() as $date) {
112 $counter++;
113 //$this->showEvents($date);
114
115 $a_tpl->setCurrentBlock('month_col');
116
117 if (count($scheduler->getByDay($date, $this->user->getTimeZone()))) {
118 $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
119 #$a_tpl->setVariable('TD_CLASS','calminiapp');
120 }
121
122 if (ilCalendarUtil::_isToday($date)) {
123 $a_tpl->setVariable('TD_CLASS', 'calminitoday');
124 } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
125 $a_tpl->setVariable('TD_CLASS', 'calministd');
126 } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
127 $a_tpl->setVariable('TD_CLASS', 'calminiprev');
128 } else {
129 $a_tpl->setVariable('TD_CLASS', 'calmininext');
130 }
131
132 $day = $date->get(IL_CAL_FKT_DATE, 'j');
133 $month = $date->get(IL_CAL_FKT_DATE, 'n');
134
135 $month_day = $day;
136
137 $this->ctrl->clearParametersByClass('ilcalendardaygui');
138 $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
139 $a_tpl->setVariable('OPEN_DAY_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''));
140 $this->ctrl->clearParametersByClass('ilcalendardaygui');
141
142 $a_tpl->setVariable('MONTH_DAY', $month_day);
143 $a_tpl->parseCurrentBlock();
144
145 if ($counter and !($counter % 7)) {
146 $a_tpl->setCurrentBlock('week');
147 $a_tpl->setVariable(
148 'WEEK',
149 $date->get(IL_CAL_FKT_DATE, 'W')
150 );
151 $a_tpl->parseCurrentBlock();
152
153 $a_tpl->setCurrentBlock('month_row');
154 $this->ctrl->clearParametersByClass('ilcalendarweekgui');
155 $this->ctrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
156 $this->ctrl->clearParametersByClass('ilcalendarweekgui');
157 $a_tpl->setVariable('TD_CLASS', 'calminiweek');
158 $a_tpl->parseCurrentBlock();
159 }
160 }
161 $a_tpl->setCurrentBlock('mini_month');
162 //$a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
163 $a_tpl->setVariable(
164 'TXT_MONTH',
165 $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') .
166 ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y')
167 );
168 $myseed = clone($this->seed);
169 $this->ctrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
170 $a_tpl->setVariable('OPEN_MONTH_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
171
172 $myseed->increment(ilDateTime::MONTH, -1);
173 $this->ctrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
174
175 $a_tpl->setVariable(
176 'PREV_MONTH',
177 $this->ctrl->getLinkTarget($this->getParentObject(), "")
178 );
179
180 $myseed->increment(ilDateTime::MONTH, 2);
181 $this->ctrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
182 $a_tpl->setVariable(
183 'NEXT_MONTH',
184 $this->ctrl->getLinkTarget($this->getParentObject(), "")
185 );
186
187 $this->ctrl->setParameter($this->getParentObject(), 'seed', "");
188 $a_tpl->parseCurrentBlock();
189 }
190}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
const IL_CAL_DATE
const IL_CAL_MONTH
const IL_CAL_FKT_DATE
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
static _getInstanceByUserId(int $a_user_id)
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
static _buildMonthDayList(int $a_month, int $a_year, int $weekstart)
Build a month day list.
static _isToday(ilDateTime $date)
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Class for single dates.
language handling
ilGlobalTemplateInterface $tpl
__construct(ilDate $seed, object $a_par_obj)
setParentObject(object $a_parentobject)
addMiniMonth(ilTemplate $a_tpl)
Add mini version of monthly overview (Maybe extracted to another class, if used in pd calendar tab.
getHTML()
Get HTML for calendar.
ilCalendarUserSettings $user_settings
User class.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
$counter