ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCalendarMonthGUI Class Reference
+ Inheritance diagram for ilCalendarMonthGUI:
+ Collaboration diagram for ilCalendarMonthGUI:

Public Member Functions

 __construct (ilDate $seed_date)
 
 setBkId (int $bkid=0)
 
 initialize (int $a_calendar_presentation_type)
 
 executeCommand ()
 
 addScheduleFilter (ilCalendarScheduleFilter $a_filter)
 Add schedule filter. More...
 
 show ()
 
 getHTML ()
 
- 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...
 

Protected Member Functions

 showEvents (ilCalendarSchedule $scheduler, ilDate $date)
 
- Protected Member Functions inherited from ilCalendarViewGUI
 initAppointmentIdFromQuery ()
 
 initInitialDateFromQuery ()
 
 initInitialDateTimeFromQuery ()
 
 initBookingUserFromQuery ()
 

Protected Attributes

int $bkid
 
int $num_appointments = 1
 
array $schedule_filters = array()
 
ilCalendarUserSettings $user_settings
 
ilCalendarAppointmentColors $app_colors
 
string $timezone = 'UTC'
 
- 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
 

Additional Inherited Members

- 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
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCalendarMonthGUI::__construct ( ilDate  $seed_date)

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

38 {
40 $this->bkid = $this->initBookingUserFromQuery();
41 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), ilCalendarViewGUI\CAL_PRESENTATION_MONTH, and ilCalendarViewGUI\initBookingUserFromQuery().

+ Here is the call graph for this function:

Member Function Documentation

◆ addScheduleFilter()

ilCalendarMonthGUI::addScheduleFilter ( ilCalendarScheduleFilter  $a_filter)

Add schedule filter.

Definition at line 91 of file class.ilCalendarMonthGUI.php.

91 : void
92 {
93 $this->schedule_filters[] = $a_filter;
94 }

◆ executeCommand()

ilCalendarMonthGUI::executeCommand ( )

Definition at line 59 of file class.ilCalendarMonthGUI.php.

59 : void
60 {
61 $this->ctrl->saveParameter($this, 'seed');
62
63 $next_class = $this->ctrl->getNextClass();
64 switch ($next_class) {
65 case "ilcalendarappointmentpresentationgui":
66 $this->ctrl->setReturn($this, "");
67 $gui = ilCalendarAppointmentPresentationGUI::_getInstance($this->seed, (array) $this->getCurrentApp());
68 $this->ctrl->forwardCommand($gui);
69 break;
70 case 'ilcalendarappointmentgui':
71 $this->ctrl->setReturn($this, '');
72 $this->tabs_gui->setSubTabActive((string) ilSession::get('cal_last_tab'));
73 // initial date for new calendar appointments
74 $idate = new ilDate($this->initInitialDateFromQuery(), IL_CAL_DATE);
75 $app = new ilCalendarAppointmentGUI($this->seed, $idate, $this->initAppointmentIdFromQuery());
76 $this->ctrl->forwardCommand($app);
77 break;
78
79 default:
80 $time = microtime(true);
81 $cmd = $this->ctrl->getCmd("show");
82 $this->$cmd();
83 $this->main_tpl->setContent($this->tpl->get());
84 break;
85 }
86 }
const IL_CAL_DATE
Administrate calendar appointments.
static _getInstance(ilDate $seed, array $a_app)
get singleton instance
Class for single dates.
static get(string $a_var)

References ilCalendarAppointmentPresentationGUI\_getInstance(), ILIAS\Repository\ctrl(), ilSession\get(), ilCalendarViewGUI\getCurrentApp(), IL_CAL_DATE, ilCalendarViewGUI\initAppointmentIdFromQuery(), and ilCalendarViewGUI\initInitialDateFromQuery().

+ Here is the call graph for this function:

◆ getHTML()

ilCalendarMonthGUI::getHTML ( )

Definition at line 217 of file class.ilCalendarMonthGUI.php.

217 : string
218 {
219 $this->show();
220 return $this->tpl->get();
221 }

References show().

+ Here is the call graph for this function:

◆ initialize()

ilCalendarMonthGUI::initialize ( int  $a_calendar_presentation_type)

Reimplemented from ilCalendarViewGUI.

Definition at line 48 of file class.ilCalendarMonthGUI.php.

48 : void
49 {
50 parent::initialize($a_calendar_presentation_type);
51 $this->tabs_gui->setSubTabActive('app_month');
52 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
53 $this->app_colors = new ilCalendarAppointmentColors($this->user->getId());
54 if ($this->user->getTimeZone()) {
55 $this->timezone = $this->user->getTimeZone();
56 }
57 }
static _getInstanceByUserId(int $a_user_id)

References ilCalendarUserSettings\_getInstanceByUserId(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ setBkId()

ilCalendarMonthGUI::setBkId ( int  $bkid = 0)

Definition at line 43 of file class.ilCalendarMonthGUI.php.

43 : void
44 {
45 $this->bkid = $bkid;
46 }

References $bkid.

◆ show()

ilCalendarMonthGUI::show ( )

Definition at line 96 of file class.ilCalendarMonthGUI.php.

96 : void
97 {
98 $this->tpl = new ilTemplate('tpl.month_view.html', true, true, 'components/ILIAS/Calendar');
99
101
102 $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::MONTH);
103 $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
104
105 for ($i = $this->user_settings->getWeekStart(); $i < (7 + $this->user_settings->getWeekStart()); $i++) {
106 $this->tpl->setCurrentBlock('month_header_col');
107 $this->tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, true));
108 $this->tpl->parseCurrentBlock();
109 }
110
111 if ($this->bkid) {
113 $disable_empty = true;
114 $no_add = true;
115 } else {
116 if ($this->user->getId() == ANONYMOUS_USER_ID) {
117 $user_id = $this->user->getId();
118 $disable_empty = false;
119 $no_add = true;
120 } else {
121 $user_id = $this->user->getId();
122 $disable_empty = false;
123 $no_add = false;
124 }
125 }
126
127 $is_portfolio_embedded = false;
129 $no_add = true;
130 $is_portfolio_embedded = true;
131 }
132 $scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
133 $scheduler->addSubitemCalendars(true);
134 if (sizeof($this->schedule_filters)) {
135 foreach ($this->schedule_filters as $filter) {
136 $scheduler->addFilter($filter);
137 }
138 }
139 $scheduler->calculate();
140
142
143 $counter = 0;
145 (int) $this->seed->get(IL_CAL_FKT_DATE, 'm'),
146 (int) $this->seed->get(IL_CAL_FKT_DATE, 'Y'),
147 $this->user_settings->getWeekStart()
148 )->get() as $date) {
149 $counter++;
150 $has_events = (bool) $this->showEvents($scheduler, $date);
151
152 if (!$this->view_with_appointments && $has_events) {
153 $this->view_with_appointments = true;
154 }
155
156 if (!$no_add) {
157 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
158 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
159 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
160 $current_hour = (new ilDateTime(time(), IL_CAL_UNIX))->get(IL_CAL_FKT_DATE, 'G', $this->user->getTimeZone());
161 $this->ctrl->setParameterByClass("ilcalendarappointmentgui", "hour", $current_hour);
162 $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
163
164 $this->tpl->setCurrentBlock("new_app");
165 $this->tpl->setVariable(
166 'NEW_GLYPH',
167 $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->add($new_app_url))
168 );
169 $this->tpl->parseCurrentBlock();
170
171 // }
172 }
173
174 $day = (int) $date->get(IL_CAL_FKT_DATE, 'j');
175 $month = (int) $date->get(IL_CAL_FKT_DATE, 'n');
176
177 if ($day == 1) {
178 $month_day = '1 ' . ilCalendarUtil::_numericMonthToString($month, false);
179 } else {
180 $month_day = $day;
181 }
182
183 if (!$is_portfolio_embedded &&
184 (!$disable_empty || $has_events)) {
185 $this->tpl->setCurrentBlock('month_day_link');
186 $this->ctrl->clearParametersByClass('ilcalendardaygui');
187 $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
188 $this->tpl->setVariable('OPEN_DAY_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''));
189 $this->ctrl->clearParametersByClass('ilcalendardaygui');
190 } else {
191 $this->tpl->setCurrentBlock('month_day_no_link');
192 }
193
194 $this->tpl->setVariable('MONTH_DAY', $month_day);
195
196 $this->tpl->parseCurrentBlock();
197
198 $this->tpl->setCurrentBlock('month_col');
199
200 if (ilCalendarUtil::_isToday($date)) {
201 $this->tpl->setVariable('TD_CLASS', 'caltoday');
202 } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
203 $this->tpl->setVariable('TD_CLASS', 'calstd');
204 } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
205 $this->tpl->setVariable('TD_CLASS', 'calprev');
206 } else {
207 $this->tpl->setVariable('TD_CLASS', 'calnext');
208 }
209 $this->tpl->parseCurrentBlock();
210 if ($counter && !($counter % 7)) {
211 $this->tpl->setCurrentBlock('month_row');
212 $this->tpl->parseCurrentBlock();
213 }
214 }
215 }
const IL_CAL_UNIX
const IL_CAL_MONTH
const IL_CAL_FKT_DATE
static _getInstance($a_usr_id=0)
get singleton instance
showEvents(ilCalendarSchedule $scheduler, ilDate $date)
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
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 _numericMonthToString(int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
numeric month to string
static _isToday(ilDateTime $date)
@classDescription Date and time handling
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.
special template class to simplify handling of ITX/PEAR
static initDragDrop(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop used in Modules/Survey, Services/Calendar, Services/COPage,...
const ANONYMOUS_USER_ID
Definition: constants.php:27
$counter

References $bkid, $counter, $user_id, ilDateTime\_before(), ilCalendarUtil\_buildMonthDayList(), ilDateTime\_equals(), ilCalendarCategories\_getInstance(), ilCalendarSettings\_getInstance(), ilCalendarUtil\_isToday(), ilCalendarUtil\_numericDayToString(), ilCalendarUtil\_numericMonthToString(), ANONYMOUS_USER_ID, ILIAS\Repository\ctrl(), IL_CAL_DATE, IL_CAL_FKT_DATE, IL_CAL_MONTH, IL_CAL_UNIX, ilYuiUtil\initDragDrop(), ILIAS\Repository\int(), ilCalendarCategories\MODE_PORTFOLIO_CONSULTATION, ilDateTime\MONTH, showEvents(), ilCalendarSchedule\TYPE_MONTH, and ILIAS\Repository\user().

Referenced by getHTML().

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

◆ showEvents()

ilCalendarMonthGUI::showEvents ( ilCalendarSchedule  $scheduler,
ilDate  $date 
)
protected

Definition at line 223 of file class.ilCalendarMonthGUI.php.

223 : int
224 {
225 $count = 0;
226 $time = '';
227 foreach ($scheduler->getByDay($date, $this->timezone) as $item) {
228 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
229 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $item['event']->getEntryId());
230
231 $event_tpl = new ilTemplate('tpl.month_event_view.html', true, true, 'components/ILIAS/Calendar');
232
233 if (!$item['event']->isFullDay()) {
234 switch ($this->user_settings->getTimeFormat()) {
236 $time = $item['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
237 break;
238
240 $time = $item['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
241 break;
242 }
243 }
244
245 //plugins can change the modal title.
246 $shy = $this->getAppointmentShyButton($item['event'], (string) $item['dstart'], "");
247 $event_html = ($time != "") ? $time . " " . $shy : $shy;
248 $event_tpl->setCurrentBlock('il_event');
249
250 //Start configuring the default template
251 $event_tpl->setVariable(
252 'EVENT_EDIT_LINK',
253 $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit')
254 );
255 $event_tpl->setVariable('EVENT_NUM', $item['event']->getEntryId());
256 $event_tpl->setVariable('EVENT_CONTENT', $event_html);
257 $color = $this->app_colors->getColorByAppointment($item['event']->getEntryId());
258 $event_tpl->setVariable('EVENT_BGCOLOR', $color);
259 $event_tpl->setVariable('EVENT_ADD_STYLES', $item['event']->getPresentationStyle());
260 $event_tpl->setVariable('EVENT_FONTCOLOR', ilCalendarUtil::calculateFontColor($color));
261
262 //plugins can override the previous template variables. The plugin slot parses the current block because
263 //it needs to call the template get method to use the resulting HTML in the replaceContent method.
264 if ($event_html_by_plugin = $this->getContentByPlugins(
265 $item['event'],
266 $item['dstart'],
267 $event_html,
268 $event_tpl
269 )) {
270 $event_body_html = $event_html_by_plugin;
271 } else {
272 $event_tpl->parseCurrentBlock();
273 $event_body_html = $event_tpl->get();
274 }
275
276 $this->tpl->setCurrentBlock("event_nfd");
277 $this->tpl->setVariable("EVENT_CONTENT", $event_body_html);
278 $this->tpl->parseCurrentBlock();
279
280 $this->num_appointments++;
281 $count++;
282 }
283 return $count;
284 }
getByDay(ilDate $a_start, string $a_timezone)
static calculateFontColor(string $a_html_color_code)
Calculate best font color from html hex color code.
getAppointmentShyButton(ilCalendarEntry $a_calendar_entry, string $a_dstart, string $a_title_forced="")
getContentByPlugins(ilCalendarEntry $a_cal_entry, int $a_start_date, string $a_content, ilTemplate $a_tpl)

References ilCalendarUtil\calculateFontColor(), ILIAS\Repository\ctrl(), ilCalendarViewGUI\getAppointmentShyButton(), ilCalendarSchedule\getByDay(), ilCalendarViewGUI\getContentByPlugins(), IL_CAL_FKT_DATE, ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by show().

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

Field Documentation

◆ $app_colors

ilCalendarAppointmentColors ilCalendarMonthGUI::$app_colors
protected

Definition at line 34 of file class.ilCalendarMonthGUI.php.

◆ $bkid

int ilCalendarMonthGUI::$bkid
protected

Definition at line 29 of file class.ilCalendarMonthGUI.php.

Referenced by setBkId(), and show().

◆ $num_appointments

int ilCalendarMonthGUI::$num_appointments = 1
protected

Definition at line 30 of file class.ilCalendarMonthGUI.php.

◆ $schedule_filters

array ilCalendarMonthGUI::$schedule_filters = array()
protected

Definition at line 31 of file class.ilCalendarMonthGUI.php.

◆ $timezone

string ilCalendarMonthGUI::$timezone = 'UTC'
protected

Definition at line 35 of file class.ilCalendarMonthGUI.php.

◆ $user_settings

ilCalendarUserSettings ilCalendarMonthGUI::$user_settings
protected

Definition at line 33 of file class.ilCalendarMonthGUI.php.


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