ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCalendarAgendaListGUI Class Reference

Calendar agenda list. More...

+ Inheritance diagram for ilCalendarAgendaListGUI:
+ Collaboration diagram for ilCalendarAgendaListGUI:

Public Member Functions

 __construct (ilDate $seed)
 
 executeCommand ()
 
 getHTML ()
 
 getPluginAgendaItem (Item $a_item, ilCalendarEntry $appointment)
 
- Public Member Functions inherited from ilCalendarViewGUI
 __construct (ilDate $seed, int $presentation_type)
 
 setConsulationHoursUserId (int $a_user_id)
 
 getConsultationHoursUserId ()
 
 initialize (int $a_calendar_presentation_type)
 
 getCurrentApp ()
 
 getEvents ()
 
 getDatesForItem ($item)
 
 getModalForApp ()
 Get modal for appointment (see similar code in ilCalendarBlockGUI) More...
 
 getAppointmentShyButton (ilCalendarEntry $a_calendar_entry, string $a_dstart, string $a_title_forced="")
 
 getActivePlugins (string $a_slot_id)
 
 getModalTitleByPlugins (string $a_current_title)
 
 getContentByPlugins (ilCalendarEntry $a_cal_entry, int $a_start_date, string $a_content, ilTemplate $a_tpl)
 
 addToolbarFileDownload ()
 Add download link to toolbar. More...
 
 downloadFiles ()
 Download files related to the appointments showed in the current calendar view (day,week,month,list). More...
 
 getBucketTitle ()
 get proper label to add in the background task popover More...
 
 countEventsInView ()
 get the events starting between 2 dates based in seed + view options. More...
 

Static Public Member Functions

static getPeriod ()
 needed in CalendarInboxGUI to get events using a proper period. More...
 

Data Fields

const PERIOD_DAY = 1
 
const PERIOD_WEEK = 2
 
const PERIOD_MONTH = 3
 
const PERIOD_HALF_YEAR = 4
 
- Data Fields inherited from ilCalendarViewGUI
const CAL_PRESENTATION_UNDEFINED = 0
 
const CAL_PRESENTATION_DAY = 1
 
const CAL_PRESENTATION_WEEK = 2
 
const CAL_PRESENTATION_MONTH = 3
 
const CAL_PRESENTATION_AGENDA_LIST = 9
 

Protected Member Functions

 initCalendarPeriodFromRequest ()
 
 initPeriod ()
 
 initEndPeriod ()
 Initialises end date for calendar list view. More...
 
- Protected Member Functions inherited from ilCalendarViewGUI
 initAppointmentIdFromQuery ()
 
 initInitialDateFromQuery ()
 
 initInitialDateTimeFromQuery ()
 
 initBookingUserFromQuery ()
 

Protected Attributes

int $period = self::PERIOD_WEEK
 
- Protected Attributes inherited from ilCalendarViewGUI
int $presentation_type = self::CAL_PRESENTATION_UNDEFINED
 
bool $view_with_appointments = false
 
ilDate $seed
 
int $ch_user_id = 0
 
string $period_end_day = null
 
Factory $ui_factory
 
Renderer $ui_renderer
 
ilCtrlInterface $ctrl
 
ilToolbarGUI $toolbar
 
ilLogger $logger
 
ILIAS DI UIServices $ui
 
ilLanguage $lng
 
ilObjUser $user
 
ilTemplate $tpl
 
ilGlobalTemplateInterface $main_tpl
 
ilComponentFactory $component_factory
 
ilTabsGUI $tabs_gui
 
RefineryFactory $refinery
 
HttpServices $http
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCalendarAgendaListGUI::__construct ( ilDate  $seed)

Definition at line 38 of file class.ilCalendarAgendaListGUI.php.

39 {
41 $this->ctrl->saveParameter($this, "cal_agenda_per");
42 $this->initPeriod();
43 $this->ctrl->setParameterByClass("ilcalendarinboxgui", "seed", $this->seed->get(IL_CAL_DATE));
44 $this->initEndPeriod();
45 }
const IL_CAL_DATE
initEndPeriod()
Initialises end date for calendar list view.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ilCalendarViewGUI\$seed, ILIAS\GlobalScreen\Provider\__construct(), ilCalendarViewGUI\CAL_PRESENTATION_AGENDA_LIST, ILIAS\Repository\ctrl(), IL_CAL_DATE, initEndPeriod(), and initPeriod().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilCalendarAgendaListGUI::executeCommand ( )

Definition at line 101 of file class.ilCalendarAgendaListGUI.php.

101 : ?string
102 {
103 $next_class = $this->ctrl->getNextClass($this);
104 $cmd = $this->ctrl->getCmd("getHTML");
105
106 switch ($next_class) {
107 case "ilcalendarappointmentpresentationgui":
108 $this->ctrl->setReturn($this, "");
110 new ilDate(
111 $this->seed->get(IL_CAL_DATE),
113 ),
114 (array) $this->getCurrentApp()
115 );
116 $this->ctrl->forwardCommand($gui);
117 break;
118
119 default:
120 $this->ctrl->setReturn($this, "");
121 if (in_array($cmd, array("getHTML", "getModalForApp"))) {
122 return $this->$cmd();
123 }
124 }
125 return '';
126 }
static _getInstance(ilDate $seed, array $a_app)
get singleton instance
Class for single dates.

References ilCalendarAppointmentPresentationGUI\_getInstance(), ILIAS\Repository\ctrl(), and IL_CAL_DATE.

+ Here is the call graph for this function:

◆ getHTML()

ilCalendarAgendaListGUI::getHTML ( )

Definition at line 128 of file class.ilCalendarAgendaListGUI.php.

128 : string
129 {
130 $navigation = new ilCalendarHeaderNavigationGUI(
131 $this,
132 new ilDate($this->seed->get(IL_CAL_DATE), IL_CAL_DATE),
134 );
135 $navigation->getHTML();
136
137 // set return now (after header navigation) to the list (e.g. for profile links)
138 $this->ctrl->setReturn($this, "");
139
140 // get events
141 $events = $this->getEvents();
142 $events = ilArrayUtil::sortArray($events, "dstart", "asc", true);
143
144 $df = new \ILIAS\Data\Factory();
145 $items = array();
146 $groups = array();
147 $modals = array();
148 $group_date = new ilDate(0, IL_CAL_UNIX);
149 $end_day = new ilDate($this->period_end_day, IL_CAL_DATE);
150 $end_day->increment(ilDateTime::DAY, -1);
151 foreach ($events as $e) {
152 if ($e['event']->isFullDay()) {
153 // begin/end is Date (without timzone)
154 $begin = new ilDate($e['dstart'], IL_CAL_UNIX);
155 $end = new ilDate($e['dend'], IL_CAL_UNIX);
156 } else {
157 // begin/end is DateTime (with timezone conversion)
158 $begin = new ilDateTime($e['dstart'], IL_CAL_UNIX);
159 $end = new ilDateTime($e['dend'], IL_CAL_UNIX);
160 }
161
162 // if the begin is before seed date (due to timezone conversion) => continue
164 $begin,
165 $this->seed,
167 $this->user->getTimeZone()
168 )) {
169 continue;
170 }
171
173 $begin,
174 $end_day,
176 $this->user->getTimeZone()
177 )
178 ) {
179 break;
180 }
181
182 // initialize group date for first iteration
183 if ($group_date->isNull()) {
184 $group_date = new ilDate(
185 $begin->get(IL_CAL_DATE, '', $this->user->getTimeZone()),
187 );
188 }
189
190 if (!ilDateTime::_equals($group_date, $begin, IL_CAL_DAY, $this->user->getTimeZone())) {
191 // create new group
192 $groups[] = $this->ui_factory->item()->group(
193 ilDatePresentation::formatDate($group_date, false, true),
194 $items
195 );
196
197 $group_date = new ilDate(
198 $begin->get(IL_CAL_DATE, '', $GLOBALS['DIC']->user()->getTimezone()),
200 );
201 $items = [];
202 }
203
204 // get calendar
205 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($e["event"]->getEntryId());
206 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
207
208 /*TODO:
209 * All this code related with the ctrl and shy button can be centralized in
210 * ilCalendarViewGUI refactoring the method getAppointmentShyButton or
211 * if we want extend this class from ilCalendarInboxGUI we can just keep it here.
212 */
213
214 // shy button for title
215 $this->ctrl->setParameter($this, 'app_id', $e["event"]->getEntryId());
216 $this->ctrl->setParameter($this, 'dt', $e['dstart']);
217 $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
218
219
220 $url = $this->ctrl->getLinkTarget($this, "getModalForApp", "", true, false);
221 $this->ctrl->setParameter($this, "app_id", $this->initAppointmentIdFromQuery());
222 $this->ctrl->setParameter($this, "dt", $this->initInitialDateTimeFromQuery());
223 $this->ctrl->setParameter($this, "idate", (new ilDate(time(), IL_CAL_UNIX))->get(IL_CAL_DATE));
224
225 $modal_title = '';
226 if ($this->http->wrapper()->query()->has('modal_title')) {
227 $modal_title = $this->http->wrapper()->query()->retrieve(
228 'modal_title',
229 $this->refinery->kindlyTo()->string()
230 );
231 }
232 $this->ctrl->setParameter($this, 'modal_title', $modal_title);
233 $modal = $this->ui_factory->modal()->roundtrip('', [])->withAsyncRenderUrl($url);
234 $shy = $this->ui_factory->button()->shy(
235 $e["event"]->getPresentationTitle(false),
236 ""
237 )->withOnClick($modal->getShowSignal());
238
239 $modals[] = $modal;
240 if ($e['event']->isFullDay()) {
241 $lead_text = $this->lng->txt("cal_all_day");
242 } else {
243 $lead_text = ilDatePresentation::formatPeriod($begin, $end, true);
244 }
245 $li = $this->ui_factory->item()->standard($shy)
246 ->withDescription("" . nl2br(strip_tags($e["event"]->getDescription())))
247 ->withLeadText($lead_text)
248 ->withProperties([])
249 ->withColor($df->color('#' . $cat_info["color"]));
250
251 if ($li_edited_by_plugin = $this->getPluginAgendaItem($li, $e['event'])) {
252 $li = $li_edited_by_plugin;
253 }
254
255 // add type specific actions/properties
257 new ilDate(
258 $this->seed->get(IL_CAL_DATE),
260 ),
261 $e
262 );
263 $app_gui->setListItemMode($li);
264 $this->ctrl->getHTML($app_gui);
265 $items[] = $app_gui->getListItem();
266 }
267 // terminate last group
268 if (!$group_date->isNull()) {
269 $groups[] = $this->ui_factory->item()->group(
270 ilDatePresentation::formatDate($group_date, false, true),
271 $items
272 );
273 }
274
275 // list actions
276 $images = array_fill(1, 4, "<span class=\"ilAdvNoImg\"></span>");
277
278 $cal_agenda_per = $this->initCalendarPeriodFromRequest();
279 if ($cal_agenda_per > 0) {
280 $images[$cal_agenda_per] = "<img src='./assets/images/standard/icon_checked.svg' alt='Month'>";
281 } else {
282 $images[$this->period] = "<img src='./assets/images/standard/icon_checked.svg' alt='Month'>";
283 }
284
285 #21479 Set seed if the view does not contain any event.
286 $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
287
288 $items = [];
289 $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_DAY);
290 $items[] = $this->ui_factory->button()->shy(
291 $images[1] . "1 " . $this->lng->txt("day"),
292 $this->ctrl->getLinkTarget($this, "getHTML")
293 );
294 $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_WEEK);
295 $items[] = $this->ui_factory->button()->shy(
296 $images[2] . "1 " . $this->lng->txt("week"),
297 $this->ctrl->getLinkTarget($this, "getHTML")
298 );
299 $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_MONTH);
300 $items[] = $this->ui_factory->button()->shy(
301 $images[3] . "1 " . $this->lng->txt("month"),
302 $this->ctrl->getLinkTarget($this, "getHTML")
303 );
304 $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_HALF_YEAR);
305 $items[] = $this->ui_factory->button()->shy(
306 $images[4] . "6 " . $this->lng->txt("months"),
307 $this->ctrl->getLinkTarget($this, "getHTML")
308 );
309 $this->ctrl->setParameter($this, "cal_agenda_per", $this->period);
310
311 $actions = $this->ui_factory->dropdown()->standard($items)->withLabel($this->lng->txt("cal_period"));
312
313 $list_title =
314 $this->lng->txt("cal_agenda") . ": " . ilDatePresentation::formatDate(new ilDate(
315 $this->seed->get(IL_CAL_DATE),
317 ));
318 if ($this->period != self::PERIOD_DAY) {
319 $end_day = new ilDate($this->period_end_day, IL_CAL_DATE);
320 $end_day->increment(ilDateTime::DAY, -1);
321 $list_title .= " - " . ilDatePresentation::formatDate($end_day);
322 }
323
324 $list = $this->ui_factory->panel()->listing()->standard($list_title, $groups)
325 ->withActions($actions);
326 $comps = array_merge($modals, array($list));
327 $html = $this->ui_renderer->render($comps);
328 if (count($groups) == 0) {
329 $html .= ilUtil::getSystemMessageHTML($this->lng->txt("cal_no_events_info"));
330 }
331 return $html;
332 }
const IL_CAL_UNIX
const IL_CAL_DAY
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
getPluginAgendaItem(Item $a_item, ilCalendarEntry $appointment)
static _getInstance($a_usr_id=0)
get singleton instance
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
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.
static getSystemMessageHTML(string $a_txt, string $a_type="info")
Get HTML for a system message.
static http()
Fetches the global http state from ILIAS.
$url
Definition: shib_logout.php:68
$GLOBALS["DIC"]
Definition: wac.php:54

References Vendor\Package\$e, $GLOBALS, $period, $url, ilDateTime\_after(), ilDateTime\_before(), ilDateTime\_equals(), ilCalendarCategories\_getInstance(), ilCalendarAppointmentPresentationGUI\_getInstance(), ilCalendarCategoryAssignments\_lookupCategory(), ILIAS\Repository\ctrl(), ilDateTime\DAY, ilDatePresentation\formatDate(), ilDatePresentation\formatPeriod(), ilCalendarViewGUI\getEvents(), getPluginAgendaItem(), ilUtil\getSystemMessageHTML(), ILIAS\FileDelivery\http(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_UNIX, ilCalendarViewGUI\initAppointmentIdFromQuery(), initCalendarPeriodFromRequest(), ilCalendarViewGUI\initInitialDateTimeFromQuery(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilArrayUtil\sortArray(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getPeriod()

static ilCalendarAgendaListGUI::getPeriod ( )
static

needed in CalendarInboxGUI to get events using a proper period.

todo define default period only once (self::PERIOD_WEEK, protected $period = self::PERIOD_WEEK)

Definition at line 350 of file class.ilCalendarAgendaListGUI.php.

350 : int
351 {
352 global $DIC;
353
354 $user = $DIC->user();
355
357
358 $calendar_agenda_period = (int) ($DIC->http()->request()->getQueryParams()['cal_agenda_per'] ?? 0);
359 if ($calendar_agenda_period > 0 && $calendar_agenda_period <= 4) {
360 return $calendar_agenda_period;
361 } elseif ($period = $user->getPref('cal_list_view')) {
362 return (int) $period;
363 } else {
364 return $settings->getDefaultPeriod();
365 }
366 }
getPref(string $a_keyword)
global $DIC
Definition: shib_login.php:26

References $DIC, $period, ilCalendarViewGUI\$user, ilCalendarSettings\_getInstance(), ilObjUser\getPref(), and ILIAS\Repository\int().

Referenced by ilCalendarViewGUI\countEventsInView(), and ilCalendarViewGUI\getEvents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPluginAgendaItem()

ilCalendarAgendaListGUI::getPluginAgendaItem ( Item  $a_item,
ilCalendarEntry  $appointment 
)

Definition at line 334 of file class.ilCalendarAgendaListGUI.php.

334 : ?Item
335 {
336 //"capg" is the plugin slot id for AppointmentCustomGrid
337 $li = null;
338 foreach ($this->getActivePlugins("capg") as $plugin) {
339 $plugin->setAppointment($appointment, $appointment->getStart());
340 // @todo check if last wins is desired
341 $li = $plugin->editAgendaItem($a_item);
342 }
343 return $li;
344 }
getStart()
Get start of date period.
getActivePlugins(string $a_slot_id)
Common interface to all items.
Definition: Item.php:32

References XapiProxy\$plugin, ilCalendarViewGUI\getActivePlugins(), and ilCalendarEntry\getStart().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCalendarPeriodFromRequest()

ilCalendarAgendaListGUI::initCalendarPeriodFromRequest ( )
protected

Definition at line 47 of file class.ilCalendarAgendaListGUI.php.

47 : int
48 {
49 if ($this->http->wrapper()->query()->has('cal_agenda_per')) {
50 return $this->http->wrapper()->query()->retrieve(
51 'cal_agenda_per',
52 $this->refinery->kindlyTo()->int()
53 );
54 }
55 return 0;
56 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by getHTML(), and initPeriod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initEndPeriod()

ilCalendarAgendaListGUI::initEndPeriod ( )
protected

Initialises end date for calendar list view.

Definition at line 78 of file class.ilCalendarAgendaListGUI.php.

78 : void
79 {
80 $end_date = clone $this->seed;
81 switch ($this->period) {
83 $end_date->increment(IL_CAL_DAY, 1);
84 break;
85
87 $end_date->increment(IL_CAL_WEEK, 1);
88 break;
89
91 $end_date->increment(IL_CAL_MONTH, 1);
92 break;
93
95 $end_date->increment(IL_CAL_MONTH, 6);
96 break;
97 }
98 $this->period_end_day = $end_date->get(IL_CAL_DATE);
99 }
const IL_CAL_WEEK
const IL_CAL_MONTH

References ilCalendarViewGUI\$seed, IL_CAL_DATE, IL_CAL_DAY, IL_CAL_MONTH, IL_CAL_WEEK, PERIOD_DAY, PERIOD_HALF_YEAR, PERIOD_MONTH, and PERIOD_WEEK.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initPeriod()

ilCalendarAgendaListGUI::initPeriod ( )
protected

Definition at line 58 of file class.ilCalendarAgendaListGUI.php.

58 : void
59 {
60 global $DIC;
61
62 $cal_setting = ilCalendarSettings::_getInstance();
63
64 $calendar_period = $this->initCalendarPeriodFromRequest();
65 if ($calendar_period > 0 && $calendar_period <= 4) {
66 $this->period = $calendar_period;
67 } elseif (!empty($this->user->getPref('cal_list_view'))) {
68 $this->period = intval($this->user->getPref('cal_list_view'));
69 } else {
70 $this->period = $cal_setting->getDefaultPeriod();
71 }
72 $this->user->writePref('cal_list_view', (string) $this->period);
73 }

References $DIC, ilCalendarSettings\_getInstance(), initCalendarPeriodFromRequest(), and ILIAS\Repository\user().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $period

int ilCalendarAgendaListGUI::$period = self::PERIOD_WEEK
protected

Definition at line 36 of file class.ilCalendarAgendaListGUI.php.

Referenced by getHTML(), and getPeriod().

◆ PERIOD_DAY

◆ PERIOD_HALF_YEAR

◆ PERIOD_MONTH

◆ PERIOD_WEEK


The documentation for this class was generated from the following file: