ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCalendarAgendaListGUI Class Reference

Calendar agenda list. More...

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

Public Member Functions

 __construct (ilDate $seed)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getHTML ()
 Get output. More...
 
 getPluginAgendaItem ($a_item, $appointment)
 
- Public Member Functions inherited from ilCalendarViewGUI
 __construct (ilDate $seed, $presentation_type)
 
 setConsulationHoursUserId ($a_user_id)
 
 getConsultationHoursUserId ()
 
 initialize ($a_calendar_presentation_type)
 View initialization. More...
 
 getCurrentApp ()
 Get app for id. More...
 
 getEvents ()
 Get events. More...
 
 getDatesForItem ($item)
 Get start/end date for item. More...
 
 getModalForApp ()
 Get modal for appointment (see similar code in ilCalendarBlockGUI) More...
 
 getAppointmentShyButton ($a_calendar_entry, $a_dstart, $a_title_forced="")
 
 getActivePlugins ($a_slot_id)
 
 getModalTitleByPlugins ($a_current_title)
 
 getContentByPlugins ($a_cal_entry, $a_start_date, $a_content, $a_tpl)
 
 addToolbarActions ()
 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_DAY = 1
 
const CAL_PRESENTATION_WEEK = 2
 
const CAL_PRESENTATION_MONTH = 3
 
const CAL_PRESENTATION_AGENDA_LIST = 9
 

Protected Attributes

 $ctrl
 
 $user
 
 $lng
 
 $period = self::PERIOD_WEEK
 
 $period_end_day = null
 
- Protected Attributes inherited from ilCalendarViewGUI
 $ui_factory
 
 $ui_renderer
 
 $ctrl
 
 $presentation_type
 
 $toolbar
 
 $logger
 
 $ui
 
 $view_with_appointments
 
 $lng
 
 $user
 
 $seed
 
 $ch_user_id = 0
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCalendarAgendaListGUI::__construct ( ilDate  $seed)

Constructor.

Parameters
ilDate$seed
Todo:
make parent constructor (initialize) and init also seed and other common stuff

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

References $_GET, $period, ilCalendarViewGUI\$seed, ilCalendarViewGUI\CAL_PRESENTATION_AGENDA_LIST, ilSession\get(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_MONTH, and IL_CAL_WEEK.

53  {
54  parent::__construct($seed, ilCalendarViewGUI::CAL_PRESENTATION_AGENDA_LIST);
55 
56  $this->ctrl->saveParameter($this, "cal_agenda_per");
57 
58  //$qp = $DIC->http()->request()->getQueryParams();
59  #21479
60  $qp = $_GET;
61  if ((int) $qp["cal_agenda_per"] > 0 && (int) $qp["cal_agenda_per"] <= 4) {
62  $this->period = $qp["cal_agenda_per"];
63  } elseif ($period = ilSession::get('cal_list_view')) {
64  $this->period = $period;
65  }
66 
67  $get_seed = $qp["seed"];
68  $this->ctrl->setParameterByClass("ilcalendarinboxgui", "seed", $this->seed->get(IL_CAL_DATE));
69  $end_date = clone $this->seed;
70  switch ($this->period) {
71  case self::PERIOD_DAY:
72  $end_date->increment(IL_CAL_DAY, 1);
73  break;
74 
75  case self::PERIOD_WEEK:
76  $end_date->increment(IL_CAL_WEEK, 1);
77  break;
78 
79  case self::PERIOD_MONTH:
80  $end_date->increment(IL_CAL_MONTH, 1);
81  break;
82 
83  case self::PERIOD_HALF_YEAR:
84  $end_date->increment(IL_CAL_MONTH, 6);
85  break;
86  }
87  $this->period_end_day = $end_date->get(IL_CAL_DATE);
88  }
$_GET["client_id"]
static get($a_var)
Get a value.
const IL_CAL_MONTH
const IL_CAL_WEEK
const IL_CAL_DAY
const IL_CAL_DATE
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilCalendarAgendaListGUI::executeCommand ( )

Execute command.

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

References ilCalendarAppointmentPresentationGUI\_getInstance(), array, ilCalendarViewGUI\getCurrentApp(), and IL_CAL_DATE.

94  {
95  $next_class = $this->ctrl->getNextClass($this);
96  $cmd = $this->ctrl->getCmd("getHTML");
97 
98  switch ($next_class) {
99  case "ilcalendarappointmentpresentationgui":
100  $this->ctrl->setReturn($this, "");
101  include_once("./Services/Calendar/classes/class.ilCalendarAppointmentPresentationGUI.php");
103  $this->ctrl->forwardCommand($gui);
104  break;
105 
106  default:
107  $this->ctrl->setReturn($this, "");
108  if (in_array($cmd, array("getHTML", "getModalForApp"))) {
109  return $this->$cmd();
110  }
111  }
112  }
static _getInstance(ilDate $seed, $a_app)
get singleton instance
getCurrentApp()
Get app for id.
Class for single dates.
Create styles array
The data for the language used.
const IL_CAL_DATE
+ Here is the call graph for this function:

◆ getHTML()

ilCalendarAgendaListGUI::getHTML ( )

Get output.

Parameters

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

References $_GET, $end, $GLOBALS, $html, $list, $period, $tpl, $url, ilDateTime\_after(), ilDateTime\_before(), ilDateTime\_equals(), ilCalendarAppointmentPresentationGUI\_getInstance(), ilCalendarCategories\_getInstance(), ilCalendarCategoryAssignments\_lookupCategory(), array, ilDateTime\DAY, ilDatePresentation\formatDate(), ilDatePresentation\formatPeriod(), ilCalendarViewGUI\getEvents(), getPluginAgendaItem(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_UNIX, ilUtil\sortArray(), and user().

121  {
122  $navigation = new ilCalendarHeaderNavigationGUI($this, new ilDate($this->seed->get(IL_CAL_DATE), IL_CAL_DATE), ilDateTime::DAY);
123  $navigation->getHTML();
124 
125  // set return now (after header navigation) to the list (e.g. for profile links)
126  $this->ctrl->setReturn($this, "");
127 
128  // get events
129  $events = $this->getEvents();
130  $events = ilUtil::sortArray($events, "dstart", "asc", true);
131 
132  $df = new \ILIAS\Data\Factory();
133  $items = array();
134  $groups = array();
135  $modals = array();
136  $group_date = new ilDate(0, IL_CAL_UNIX);
137  $end_day = new ilDate($this->period_end_day, IL_CAL_DATE);
138  $end_day->increment(ilDateTime::DAY, -1);
139  foreach ($events as $e) {
140  if ($e['event']->isFullDay()) {
141  // begin/end is Date (without timzone)
142  $begin = new ilDate($e['dstart'], IL_CAL_UNIX);
143  $end = new ilDate($e['dend'], IL_CAL_UNIX);
144  } else {
145  // begin/end is DateTime (with timezone conversion)
146  $begin = new ilDateTime($e['dstart'], IL_CAL_UNIX);
147  $end = new ilDateTime($e['dend'], IL_CAL_UNIX);
148  }
149 
150  // if the begin is before seed date (due to timezone conversion) => continue
152  $begin,
153  $this->seed,
155  $GLOBALS['DIC']->user()->getTimezone()
156  )) {
157  continue;
158  }
159 
160  if (ilDateTime::_after(
161  $begin,
162  $end_day,
164  $GLOBALS['DIC']->user()->getTimezone()
165  )
166  ) {
167  break;
168  }
169 
170 
171  // initialize group date for first iteration
172  if ($group_date->isNull()) {
173  $group_date = new ilDate(
174  $begin->get(IL_CAL_DATE, '', $GLOBALS['DIC']->user()->getTimezone()),
176  );
177  }
178 
179  if (!ilDateTime::_equals($group_date, $begin, IL_CAL_DAY, $GLOBALS['DIC']->user()->getTimezone())) {
180  // create new group
181  $groups[] = $this->ui_factory->item()->group(
182  ilDatePresentation::formatDate($group_date, false, true),
183  $items
184  );
185 
186  $group_date = new ilDate(
187  $begin->get(IL_CAL_DATE, '', $GLOBALS['DIC']->user()->getTimezone()),
189  );
190  $items = [];
191  }
192 
193  // get calendar
194  $cat_id = ilCalendarCategoryAssignments::_lookupCategory($e["event"]->getEntryId());
195  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
196 
197  $properties = array();
198 
199  /*TODO:
200  * All this code related with the ctrl and shy button can be centralized in
201  * ilCalendarViewGUI refactoring the method getAppointmentShyButton or
202  * if we want extend this class from ilCalendarInboxGUI we can just keep it here.
203  */
204 
205  // shy button for title
206  $this->ctrl->setParameter($this, 'app_id', $e["event"]->getEntryId());
207  $this->ctrl->setParameter($this, 'dt', $e['dstart']);
208  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
209 
210  $url = $this->ctrl->getLinkTarget($this, "getModalForApp", "", true, false);
211  $this->ctrl->setParameter($this, "app_id", $_GET["app_id"]);
212  $this->ctrl->setParameter($this, "dt", $_GET["dt"]);
213  $this->ctrl->setParameter($this, 'modal_title', $_GET["modal_title"]);
214  $modal = $this->ui_factory->modal()->roundtrip('', [])->withAsyncRenderUrl($url);
215  $shy = $this->ui_factory->button()->shy($e["event"]->getPresentationTitle(false), "")->withOnClick($modal->getShowSignal());
216 
217  $modals[] = $modal;
218  if ($e['event']->isFullDay()) {
219  $lead_text = $this->lng->txt("cal_all_day");
220  } else {
221  $lead_text = ilDatePresentation::formatPeriod($begin, $end, true);
222  }
223  $li = $this->ui_factory->item()->standard($shy)
224  ->withDescription("" . nl2br(strip_tags($e["event"]->getDescription())))
225  ->withLeadText($lead_text)
226  ->withProperties($properties)
227  ->withColor($df->color('#' . $cat_info["color"]));
228 
229  if ($li_edited_by_plugin = $this->getPluginAgendaItem($li, $e['event'])) {
230  $li = $li_edited_by_plugin;
231  }
232 
233  // add type specific actions/properties
234  include_once("./Services/Calendar/classes/class.ilCalendarAppointmentPresentationGUI.php");
236  $app_gui->setListItemMode($li);
237  $this->ctrl->getHTML($app_gui);
238  $items[] = $app_gui->getListItem();
239  }
240  // terminate last group
241  if (!$group_date->isNull()) {
242  $groups[] = $this->ui_factory->item()->group(
243  ilDatePresentation::formatDate($group_date, false, true),
244  $items
245  );
246  }
247 
248  // list actions
249  $images = array_fill(1, 4, "<span class=\"ilAdvNoImg\"></span>");
250  if ($cal_agenda_per = (int) $_GET['cal_agenda_per']) {
251  $images[$cal_agenda_per] = "<img src='./templates/default/images/icon_checked.svg' alt='Month'>";
252  } else {
253  $images[$this->period] = "<img src='./templates/default/images/icon_checked.svg' alt='Month'>";
254  }
255 
256  #21479 Set seed if the view does not contain any event.
257  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
258 
259  $items = array();
260  $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_DAY);
261  $items[] = $this->ui_factory->button()->shy($images[1] . "1 " . $this->lng->txt("day"), $this->ctrl->getLinkTarget($this, "getHTML"));
262  $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_WEEK);
263  $items[] = $this->ui_factory->button()->shy($images[2] . "1 " . $this->lng->txt("week"), $this->ctrl->getLinkTarget($this, "getHTML"));
264  $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_MONTH);
265  $items[] = $this->ui_factory->button()->shy($images[3] . "1 " . $this->lng->txt("month"), $this->ctrl->getLinkTarget($this, "getHTML"));
266  $this->ctrl->setParameter($this, "cal_agenda_per", self::PERIOD_HALF_YEAR);
267  $items[] = $this->ui_factory->button()->shy($images[4] . "6 " . $this->lng->txt("months"), $this->ctrl->getLinkTarget($this, "getHTML"));
268  $this->ctrl->setParameter($this, "cal_agenda_per", $this->period);
269 
270 
271  $actions = $this->ui_factory->dropdown()->standard($items)->withLabel($this->lng->txt("days"));
272 
273  $list_title =
274  $this->lng->txt("cal_agenda") . ": " . ilDatePresentation::formatDate(new ilDate($this->seed->get(IL_CAL_DATE), IL_CAL_DATE));
275  if ($this->period != self::PERIOD_DAY) {
276  $end_day = new ilDate($this->period_end_day, IL_CAL_DATE);
277  $end_day->increment(ilDateTime::DAY, -1);
278  $list_title.= " - " . ilDatePresentation::formatDate($end_day);
279  }
280 
281  $list = $this->ui_factory->panel()->listing()->standard($list_title, $groups)
282  ->withActions($actions);
283 
284 
285  $comps = array_merge($modals, array($list));
286 
287  $html = $this->ui_renderer->render($comps);
288 
289  if (count($groups) == 0) {
290  $tpl = $this->ui->mainTemplate();
291  $html.= $tpl->getMessageHTML($this->lng->txt("cal_no_events_info"));
292  }
293 
294  return $html;
295  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _lookupCategory($a_cal_id)
Lookup category id.
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$_GET["client_id"]
$tpl
Definition: ilias.php:10
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
$end
Definition: saml1-acs.php:18
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _getInstance(ilDate $seed, $a_app)
get singleton instance
const IL_CAL_UNIX
user()
Definition: user.php:4
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Class for single dates.
Date and time handling
static _getInstance($a_usr_id=0)
get singleton instance
Create styles array
The data for the language used.
getPluginAgendaItem($a_item, $appointment)
const IL_CAL_DATE
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
$url
$html
Definition: example_001.php:87
+ 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)

Returns
int|mixed

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

References $_GET, $period, and ilSession\get().

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

318  {
319  #21479
320  $qp = $_GET;
321  if ((int) $qp["cal_agenda_per"] > 0 && (int) $qp["cal_agenda_per"] <= 4) {
322  return $qp["cal_agenda_per"];
323  } elseif ($period = ilSession::get('cal_list_view')) {
324  return $period;
325  } else {
326  return self::PERIOD_WEEK;
327  }
328  }
$_GET["client_id"]
static get($a_var)
Get a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPluginAgendaItem()

ilCalendarAgendaListGUI::getPluginAgendaItem (   $a_item,
  $appointment 
)
Parameters
$a_itemILIAS
$appointment
Returns
$li ILIAS

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

References ilCalendarViewGUI\getActivePlugins().

Referenced by getHTML().

303  {
304  //"capg" is the plugin slot id for AppointmentCustomGrid
305  foreach ($this->getActivePlugins("capg") as $plugin) {
306  $plugin->setAppointment($appointment, $appointment->getStart());
307  $li = $plugin->editAgendaItem($a_item);
308  }
309  return $li;
310  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCalendarAgendaListGUI::$ctrl
protected

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

◆ $lng

ilCalendarAgendaListGUI::$lng
protected

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

◆ $period

ilCalendarAgendaListGUI::$period = self::PERIOD_WEEK
protected

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

Referenced by __construct(), getHTML(), and getPeriod().

◆ $period_end_day

ilCalendarAgendaListGUI::$period_end_day = null
protected

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

◆ $user

ilCalendarAgendaListGUI::$user
protected

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

◆ PERIOD_DAY

const ilCalendarAgendaListGUI::PERIOD_DAY = 1

◆ PERIOD_HALF_YEAR

const ilCalendarAgendaListGUI::PERIOD_HALF_YEAR = 4

◆ PERIOD_MONTH

const ilCalendarAgendaListGUI::PERIOD_MONTH = 3

◆ PERIOD_WEEK

const ilCalendarAgendaListGUI::PERIOD_WEEK = 2

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