ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCalendarUtil Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCalendarUtil:

Static Public Member Functions

static convertDateToUtcDBTimestamp (?\ilDateTime $date=null)
 
static _isToday (ilDateTime $date)
 
static _numericMonthToString (int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
 numeric month to string More...
 
static _numericDayToString (int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
 
static _buildWeekDayList (ilDate $a_day, int $a_weekstart)
 build week day list public More...
 
static _buildMonthDayList (int $a_month, int $a_year, int $weekstart)
 Build a month day list. More...
 
static initJSCalendar ()
 
static getZoneInfoFile ($a_tz)
 
static _getShortTimeZoneList ()
 get short timezone list More...
 
static _isLeapYear (int $a_year)
 check if a given year is a leap year More...
 
static _getMaxDayOfMonth (int $a_year, int $a_month)
 get max day of month 2008,2 => 29 More...
 
static calculateFontColor (string $a_html_color_code)
 Calculate best font color from html hex color code. More...
 
static getHourSelection (int $a_format)
 Get hour selection depending on user specific hour format. More...
 
static initDefaultCalendarByType (int $a_type_id, int $a_usr_id, string $a_title, bool $a_create=false)
 Init the default calendar for given type and user. More...
 
static getUserDateFormat (int $a_add_time=0, bool $a_for_parsing=false)
 Parse current user setting into date/time format. More...
 
static initDateTimePicker ()
 
static parseDateString (string $date, bool $add_time=false, ?string $force_format=null)
 Parse (incoming) string to date/time object. More...
 
static parseIncomingDate ($value, bool $add_time=false)
 Try to parse incoming value to date object. More...
 

Static Public Attributes

static string $init_done
 

Static Protected Attributes

static bool $init_datetimepicker = false
 

Static Private Attributes

static ilDateTime $today = null
 
static array $default_calendar = array()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilCalendarUtil

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

Definition at line 23 of file class.ilCalendarUtil.php.

Member Function Documentation

◆ _buildMonthDayList()

static ilCalendarUtil::_buildMonthDayList ( int  $a_month,
int  $a_year,
int  $weekstart 
)
static

Build a month day list.

Parameters
intmonth
intyear
intweekstart (0 => Sunday,1 => Monday)
Returns
ilDateList

Definition at line 118 of file class.ilCalendarUtil.php.

References IL_CAL_FKT_DATE, IL_CAL_FKT_GETDATE, IL_CAL_UNIX, and ilDateList\TYPE_DATE.

Referenced by ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), and ilCalendarMonthGUI\show().

118  : ilDateList
119  {
120  $day_list = new ilDateList(ilDateList::TYPE_DATE);
121 
122  $prev_month = ($a_month == 1) ? 12 : $a_month - 1;
123  $prev_year = ($prev_month == 12) ? $a_year - 1 : $a_year;
124  $next_month = $a_month == 12 ? 1 : $a_month + 1;
125  $next_year = $a_month == 12 ? $a_year + 1 : $a_year;
126 
127  $days_in_month = self::_getMaxDayOfMonth($a_year, $a_month);
128  $days_in_prev_month = self::_getMaxDayOfMonth($a_year, $prev_month);
129 
130  $week_day['year'] = $a_year;
131  $week_day['mon'] = $a_month;
132  $week_day['mday'] = 1;
133  $week_day['hours'] = 0;
134  $week_day['minutes'] = 0;
135  $week_day = new ilDate($week_day, IL_CAL_FKT_GETDATE);
136 
137  $weekday = $week_day->get(IL_CAL_FKT_DATE, 'w');
138  $first_day_offset = (($weekday - $weekstart) < 0) ? 6 : $weekday - $weekstart;
139 
140  for ($i = 0; $i < 42; $i++) {
141  if ($i < $first_day_offset) {
142  $day = $days_in_prev_month - $first_day_offset + $i + 1;
143 
144  $day_list->add(new ilDate(
145  gmmktime(
146  0,
147  0,
148  0,
149  $prev_month,
150  $days_in_prev_month - $first_day_offset + $i + 1,
151  $prev_year
152  ),
154  ));
155  } elseif ($i < $days_in_month + $first_day_offset) {
156  $day = $i - $first_day_offset + 1;
157 
158  $day_list->add(new ilDate(
159  gmmktime(
160  0,
161  0,
162  0,
163  $a_month,
164  $i - $first_day_offset + 1,
165  $a_year
166  ),
168  ));
169  } else {
170  $day = $i - $days_in_month - $first_day_offset + 1;
171  $day_list->add(new ilDate(
172  gmmktime(
173  0,
174  0,
175  0,
176  $next_month,
177  $i - $days_in_month - $first_day_offset + 1,
178  $next_year
179  ),
181  ));
182  }
183  if ($i == 34 and ($day < 15 or $day == $days_in_month)) {
184  break;
185  }
186  }
187  return $day_list;
188  }
const IL_CAL_UNIX
List of dates.
const IL_CAL_FKT_DATE
const IL_CAL_FKT_GETDATE
+ Here is the caller graph for this function:

◆ _buildWeekDayList()

static ilCalendarUtil::_buildWeekDayList ( ilDate  $a_day,
int  $a_weekstart 
)
static

build week day list public

Parameters
ilDatea day in a week
intweekstart
Returns
ilDateList

Definition at line 92 of file class.ilCalendarUtil.php.

References ilDate\get(), IL_CAL_DAY, IL_CAL_FKT_GETDATE, and ilDateList\TYPE_DATE.

Referenced by ilCalendarViewGUI\getBucketTitle(), ILIAS\BookingManager\BookingProcess\WeekGridGUI\getHoursOfDay(), ilCalendarHeaderNavigationGUI\getHTML(), ILIAS\BookingManager\BookingProcess\WeekGUI\getHTML(), and ilCalendarWeekGUI\show().

92  : ilDateList
93  {
94  $day_list = new ilDateList(ilDateList::TYPE_DATE);
95 
96  $start = clone $a_day;
97  $start_info = $start->get(IL_CAL_FKT_GETDATE, '', 'UTC');
98  $day_diff = $a_weekstart - $start_info['isoday'];
99  if (abs($day_diff) === 7) {
100  $day_diff = 0;
101  }
102  $start->increment(IL_CAL_DAY, $day_diff);
103  $day_list->add($start);
104  for ($i = 1; $i < 7; $i++) {
105  $start->increment(IL_CAL_DAY, 1);
106  $day_list->add($start);
107  }
108  return $day_list;
109  }
get(int $a_format, string $a_format_str='', string $a_tz='')
const IL_CAL_DAY
List of dates.
const IL_CAL_FKT_GETDATE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getMaxDayOfMonth()

static ilCalendarUtil::_getMaxDayOfMonth ( int  $a_year,
int  $a_month 
)
static

get max day of month 2008,2 => 29

Definition at line 385 of file class.ilCalendarUtil.php.

Referenced by ilCalendarRecurrenceCalculator\applyBYMONTHDAYRules(), ilCalendarRecurrenceCalculator\getMonthWeekDays(), and ilCalendarSchedule\initPeriod().

385  : int
386  {
387  if (function_exists('cal_days_in_month')) {
388  return cal_days_in_month(CAL_GREGORIAN, $a_month, $a_year);
389  }
390  return (int) date('t', mktime(0, 0, 0, $a_month, 1, $a_year));
391  }
+ Here is the caller graph for this function:

◆ _getShortTimeZoneList()

static ilCalendarUtil::_getShortTimeZoneList ( )
static

get short timezone list

Definition at line 288 of file class.ilCalendarUtil.php.

Referenced by ilObjCalendarSettingsGUI\initFormSettings(), ilPersonalSettingsGUI\initGeneralSettingsForm(), and ilCalendarUserSettingsGUI\initSettingsForm().

288  : array
289  {
290  return array(
291  'Pacific/Samoa' => 'GMT-11: Midway Islands, Samoa',
292  'US/Hawaii' => 'GMT-10:00: Hawaii, Polynesia',
293  'US/Alaska' => 'GMT-9:00: Alaska',
294  'America/Los_Angeles' => 'GMT-8:00: Tijuana, Los Angeles, Seattle, Vancouver',
295  'US/Arizona' => 'GMT-7:00: Arizona',
296  'America/Chihuahua' => 'GMT-7:00: Chihuahua, La Paz, Mazatlan',
297  'America/Denver' => 'GMT-7:00: Arizona, Denver, Salt Lake City, Calgary',
298  'America/Chicago' => 'GMT-6:00: Chicago, Dallas, Kansas City, Winnipeg',
299  'America/Monterrey' => 'GMT-6:00: Guadalajara, Mexico City, Monterrey',
300  'Canada/Saskatchewan' => 'GMT-6:00: Saskatchewan',
301  'US/Central' => 'GMT-6:00: Central America',
302  'America/Bogota' => 'GMT-5:00: Bogota, Lima, Quito',
303  'US/East-Indiana' => 'GMT-5:00: East-Indiana',
304  'America/New_York' => 'GMT-5:00: New York, Miami, Atlanta, Detroit, Toronto',
305  'Canada/Atlantic' => 'GMT-4:00: Atlantic (Canada)',
306  'America/La_Paz' => 'GMT-4:00: Carcas, La Paz',
307  'America/Santiago' => 'GMT-4:00: Santiago',
308  'Canada/Newfoundland' => 'GMT-3:00: Newfoundland',
309  'Brazil/East' => 'GMT-3:00: Sao Paulo',
310  'America/Argentina/Buenos_Aires' => 'GMT-3:00: Buenes Aires, Georgtown',
311  'Etc/GMT+3' => 'GMT-3:00: Greenland, Uruguay, Surinam',
312  'Atlantic/Cape_Verde' => 'GMT-2:00: Cape Verde, Greenland, South Georgia',
313  'Atlantic/Azores' => 'GMT-1:00: Azores',
314  'Africa/Casablanca' => 'GMT+0:00: Casablanca, Monrovia',
315  'Europe/London' => 'GMT+0:00: Dublin, Edinburgh, Lisbon, London',
316  'Europe/Berlin' => 'GMT+1:00: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna',
317  'Europe/Belgrade' => 'GMT+1:00: Belgrade, Bratislava, Budapest, Ljubljana, Prague',
318  'Europe/Paris' => 'GMT+1:00: Brussels, Copenhagen, Paris, Madrid',
319  'Europe/Sarajevo' => 'GMT+1:00: Sarajevo, Skopje, Warsaw, Zagreb',
320  'Africa/Lagos' => 'GMT+1:00: West-Central Africa',
321  'Europe/Athens' => 'GMT+2:00: Athens, Beirut, Istanbul, Minsk',
322  'Europe/Bucharest' => 'GMT+2:00: Bucharest',
323  'Africa/Harare' => 'GMT+2:00: Harare, Pratoria',
324  'Europe/Helsinki' => 'GMT+2:00: Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius',
325  'Asia/Jerusalem' => 'GMT+2:00: Jerusalem',
326  'Africa/Cairo' => 'GMT+2:00: Cairo',
327  'Asia/Baghdad' => 'GMT+3:00: Baghdad',
328  'Asia/Kuwait' => 'GMT+3:00: Kuwait, Riyadh',
329  'Europe/Moscow' => 'GMT+3:00: Moscow, Saint Petersburg',
330  'Africa/Nairobi' => 'GMT+3:00: Nairobi',
331  'Asia/Tehran' => 'GMT+3:30: Tehran',
332  'Asia/Muscat' => 'GMT+4:00: Abu Dhabi, Muscat',
333  'Asia/Baku' => 'GMT+4:00: Baku, Tbilisi, Erivan',
334  'Asia/Kabul' => 'GMT+4:00: Kabul',
335  'Asia/Karachi' => 'GMT+5:00: Islamabad, Karachi, Taschkent',
336  'Asia/Yekaterinburg' => 'GMT+5:00: Yekaterinburg',
337  'Asia/Calcutta' => 'GMT+5:30: New Dehli',
338  'Asia/Katmandu' => 'GMT+5:45: Katmandu',
339  'Asia/Novosibirsk' => 'GMT+6:00: Almaty, Novosibirsk',
340  'Asia/Dhaka' => 'GMT+6:00: Astana, Dhaka',
341  'Asia/Rangoon' => 'GMT+6:00: Sri Jayawardenepura, Rangoon',
342  'Asia/Jakarta' => 'GMT+7:00: Bangkok, Hanoi, Jakarta',
343  'Asia/Krasnoyarsk' => 'GMT+7:00: Krasnoyarsk',
344  'Asia/Irkutsk' => 'GMT+8:00: Irkutsk, Ulan Bator',
345  'Asia/Singapore' => 'GMT+8:00: Kuala Lumpour, Singapore',
346  'Asia/Hong_Kong' => 'GMT+8:00: Beijing, Chongqing, Hong kong, Urumchi',
347  'Australia/Perth' => 'GMT+8:00: Perth',
348  'Asia/Taipei' => 'GMT+8:00: Taipei',
349  'Asia/Yakutsk' => 'GMT+9:00: Yakutsk',
350  'Asia/Tokyo' => 'GMT+9:00: Osaka, Sapporo, Tokyo',
351  'Asia/Seoul' => 'GMT+9:00: Seoul, Darwin, Adelaide',
352  'Australia/Brisbane' => 'GMT+10:00: Brisbane',
353  'Australia/Sydney' => 'GMT+10:00: Canberra, Melbourne, Sydney',
354  'Pacific/Guam' => 'GMT+10:00: Guam, Port Moresby',
355  'Australia/Hobart' => 'GMT+10:00: Hobart',
356  'Asia/Vladivostok' => 'GMT+10:00: Vladivostok',
357  'Asia/Magadan' => 'GMT+11:00: Salomon Islands, New Caledonia, Magadan',
358  'Pacific/Auckland' => 'GMT+12:00: Auckland, Wellington',
359  'Pacific/Fiji' => 'GMT+12:00: Fiji, Kamchatka, Marshall-Islands'
360  );
361  }
+ Here is the caller graph for this function:

◆ _isLeapYear()

static ilCalendarUtil::_isLeapYear ( int  $a_year)
static

check if a given year is a leap year

Definition at line 366 of file class.ilCalendarUtil.php.

Referenced by ilCalendarRecurrenceCalculator\getYearWeekDays().

366  : bool
367  {
368  $is_leap = false;
369  if ($a_year % 4 == 0) {
370  $is_leap = true;
371  if ($a_year % 100 == 0) {
372  $is_leap = false;
373  if ($a_year % 400) {
374  return true;
375  }
376  }
377  }
378  return $is_leap;
379  }
+ Here is the caller graph for this function:

◆ _isToday()

static ilCalendarUtil::_isToday ( ilDateTime  $date)
static

Definition at line 41 of file class.ilCalendarUtil.php.

References $DIC, ilDateTime\_equals(), IL_CAL_DAY, and IL_CAL_UNIX.

Referenced by ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), and ilCalendarMonthGUI\show().

41  : bool
42  {
43  global $DIC;
44 
45  $ilUser = $DIC['ilUser'];
46  if (!is_object(self::$today)) {
47  self::$today = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
48  }
49  return ilDateTime::_equals(self::$today, $date, IL_CAL_DAY, $ilUser->getTimeZone());
50  }
const IL_CAL_UNIX
const IL_CAL_DAY
global $DIC
Definition: shib_login.php:22
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _numericDayToString()

static ilCalendarUtil::_numericDayToString ( int  $a_day,
bool  $a_long = true,
?ilLanguage  $lng = null 
)
static
Parameters
intday of week (0 for sunday, 1 for monday)
boolshort or long day translation

Definition at line 72 of file class.ilCalendarUtil.php.

References $DIC, and $lng.

Referenced by ilCalendarWeekGUI\addHeaderDate(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ilRecurrenceInputGUI\buildMonthlyByDaySelection(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilSessionStatisticsGUI\exportCSV(), ilBookingReservationsTableGUI\fillRow(), ilBookingReservationsTableGUI\fillRowCSV(), ilBookingReservationsTableGUI\fillRowExcel(), ilSessionStatisticsGUI\getChart(), ILIAS\BookingManager\BookingProcess\WeekGridGUI\getHoursOfDay(), ilCalendarHeaderNavigationGUI\getHTML(), ilBookingReservationsTableGUI\initFilter(), ilCalendarDayGUI\show(), and ilCalendarMonthGUI\show().

72  : string
73  {
74  global $DIC;
75 
76  if (is_null($lng)) {
77  $lng = $DIC['lng'];
78  }
79  $lng->loadLanguageModule('dateplaner');
80  static $days = array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su');
81 
82  return $a_long ? $lng->txt($days[$a_day] . '_long') : $lng->txt($days[$a_day] . '_short');
83  }
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ Here is the caller graph for this function:

◆ _numericMonthToString()

static ilCalendarUtil::_numericMonthToString ( int  $a_month,
bool  $a_long = true,
?ilLanguage  $lng = null 
)
static

numeric month to string

Parameters
intmonth (1-12)
boolshort or long month translation

Definition at line 57 of file class.ilCalendarUtil.php.

References $DIC, and $lng.

Referenced by ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilRecurrenceInputGUI\buildYearlyByMonthDaySelection(), ilDatePresentation\formatDate(), ILIAS\BookingManager\BookingProcess\WeekGridGUI\getHoursOfDay(), ilObjBlogGUI\renderNavigationByDate(), ilCalendarDayGUI\show(), ilCalendarMonthGUI\show(), and ilWikiStatGUI\viewToolbar().

57  : string
58  {
59  global $DIC;
60 
61  if (is_null($lng)) {
62  $lng = $DIC['lng'];
63  }
64  $month = $a_month < 10 ? '0' . $a_month : $a_month;
65  return $a_long ? $lng->txt('month_' . $month . '_long') : $lng->txt('month_' . $month . '_short');
66  }
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ Here is the caller graph for this function:

◆ calculateFontColor()

static ilCalendarUtil::calculateFontColor ( string  $a_html_color_code)
static

Calculate best font color from html hex color code.

Parameters
stringhex value of color
Returns
string #ffffff or #000000

Definition at line 398 of file class.ilCalendarUtil.php.

Referenced by ilCalendarWeekGUI\showAppointment(), ilCalendarDayGUI\showAppointment(), ilCalendarMonthGUI\showEvents(), ilCalendarWeekGUI\showFulldayAppointment(), and ilCalendarDayGUI\showFulldayAppointment().

398  : string
399  {
400  if (strpos($a_html_color_code, '#') !== 0 or strlen($a_html_color_code) != 7) {
401  return '#000000';
402  }
403 
404  // http://en.wikipedia.org/wiki/Luminance_(relative)
405  $lum = round(hexdec(substr($a_html_color_code, 1, 2)) * 0.2126 +
406  hexdec(substr($a_html_color_code, 3, 2)) * 0.7152 +
407  hexdec(substr($a_html_color_code, 5, 2)) * 0.0722);
408  return ($lum <= 128) ? "#FFFFFF" : "#000000";
409  }
+ Here is the caller graph for this function:

◆ convertDateToUtcDBTimestamp()

static ilCalendarUtil::convertDateToUtcDBTimestamp ( ?\ilDateTime  $date = null)
static

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

References IL_CAL_DATE, IL_CAL_DATETIME, null, and ilTimeZone\UTC.

Referenced by ilObjGroup\update(), and ilObjCourse\updateSettings().

30  : ?string
31  {
32  if (is_null($date)) {
33  return null;
34  }
35  if ($date instanceof \ilDate) {
36  return $date->get(IL_CAL_DATE);
37  }
38  return $date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC);
39  }
const IL_CAL_DATETIME
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const IL_CAL_DATE
+ Here is the caller graph for this function:

◆ getHourSelection()

static ilCalendarUtil::getHourSelection ( int  $a_format)
static

Get hour selection depending on user specific hour format.

Definition at line 414 of file class.ilCalendarUtil.php.

References ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilObjCalendarSettingsGUI\initFormSettings(), and ilCalendarUserSettingsGUI\initSettingsForm().

414  : array
415  {
416  $options = [];
417  switch ($a_format) {
419  for ($i = 0; $i < 24; $i++) {
420  $options[$i] = sprintf('%02d:00', $i);
421  }
422  break;
423 
425  for ($i = 0; $i < 24; $i++) {
426  $options[$i] = date('h a', mktime($i, 0, 0, 1, 1, 2000));
427  }
428  break;
429  }
430  return $options;
431  }
+ Here is the caller graph for this function:

◆ getUserDateFormat()

static ilCalendarUtil::getUserDateFormat ( int  $a_add_time = 0,
bool  $a_for_parsing = false 
)
static

Parse current user setting into date/time format.

Parameters
?int$a_add_time 1=hh:mm, 2=hh:mm:ss
bool$a_for_parsing
Returns
string

Definition at line 478 of file class.ilCalendarUtil.php.

References $DIC, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilPRGActionNoteBuilder\getUserDateFormat(), ilStudyProgrammeUserTable\getUserDateFormat(), and ILIAS\EmployeeTalk\Notification\NotificationHandler\send().

478  : string
479  {
480  global $DIC;
481 
482  $ilUser = $DIC['ilUser'];
483 
484  $format = (string) $ilUser->getDateFormat();
485 
486  if ($a_add_time) {
487  $format .= " " . (($ilUser->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_24)
488  ? "H:i"
489  : "h:ia");
490  if ($a_add_time == 2) {
491  $format .= ":s";
492  }
493  }
494 
495  // translate datepicker format to PHP format
496  if (!$a_for_parsing) {
497  $format = str_replace("d", "DD", $format);
498  $format = str_replace("m", "MM", $format);
499  $format = str_replace("i", "mm", $format);
500  $format = str_replace("Y", "YYYY", $format);
501  $format = str_replace("H", "HH", $format);
502  $format = str_replace("h", "hh", $format);
503  $format = str_replace("s", "ss", $format);
504  }
505 
506  return $format;
507  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getZoneInfoFile()

static ilCalendarUtil::getZoneInfoFile (   $a_tz)
static

Definition at line 275 of file class.ilCalendarUtil.php.

Referenced by ilCalendarExport\createTimezones().

275  : string
276  {
277  if (!array_key_exists($a_tz, self::_getShortTimeZoneList())) {
278  return '';
279  }
280  $timezone_filename = str_replace('/', '_', $a_tz);
281  $timezone_filename .= '.ics';
282  return '../components/ILIAS/Calendar/zoneinfo/' . $timezone_filename;
283  }
+ Here is the caller graph for this function:

◆ initDateTimePicker()

static ilCalendarUtil::initDateTimePicker ( )
static

Definition at line 509 of file class.ilCalendarUtil.php.

References $DIC.

Referenced by ilPageObjectGUI\initEditing(), and ilExerciseManagementGUI\initIndividualDeadlineModal().

509  : void
510  {
511  global $DIC;
512  $tpl = $DIC->ui()->mainTemplate();
513 
514  if (!self::$init_datetimepicker) {
515  //$tpl->addJavaScript("assets/js/moment-with-locales.min.js");
516  // unminified version does not work with jQuery 3.0
517  // https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1684
518  //$tpl->addJavaScript("assets/js/bootstrap-datetimepicker.min.js");
519  $tpl->addJavaScript("assets/js/Form.js"); // see ilPropertyFormGUI
520  self::$init_datetimepicker = true;
521  }
522  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ initDefaultCalendarByType()

static ilCalendarUtil::initDefaultCalendarByType ( int  $a_type_id,
int  $a_usr_id,
string  $a_title,
bool  $a_create = false 
)
static

Init the default calendar for given type and user.

Definition at line 436 of file class.ilCalendarUtil.php.

References $DIC, $ilDB, $res, ilCalendarCategory\DEFAULT_COLOR, ilDBConstants\FETCHMODE_OBJECT, and null.

Referenced by ilConsultationHourUtils\bookAppointment(), ILIAS\BookingManager\BookingProcess\BookingProcessManager\bookSingle(), and ilConsultationHoursGUI\createAppointments().

441  : ?ilCalendarCategory {
442  global $DIC;
443 
444  $ilDB = $DIC['ilDB'];
445  if (isset(self::$default_calendar[$a_usr_id]) and isset(self::$default_calendar[$a_usr_id][$a_type_id])) {
446  return self::$default_calendar[$a_usr_id][$a_type_id];
447  }
448 
449  $query = "SELECT cat_id FROM cal_categories " .
450  "WHERE obj_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
451  "AND type = " . $ilDB->quote($a_type_id, 'integer');
452  $res = $ilDB->query($query);
453  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
454  return self::$default_calendar[$a_usr_id][$a_type_id] = new ilCalendarCategory($row->cat_id);
455  }
456 
457  if (!$a_create) {
458  return null;
459  }
460 
461  // Create default calendar
462  self::$default_calendar[$a_usr_id][$a_type_id] = new ilCalendarCategory();
463  self::$default_calendar[$a_usr_id][$a_type_id]->setType($a_type_id);
464  self::$default_calendar[$a_usr_id][$a_type_id]->setColor(ilCalendarCategory::DEFAULT_COLOR);
465  self::$default_calendar[$a_usr_id][$a_type_id]->setTitle($a_title);
466  self::$default_calendar[$a_usr_id][$a_type_id]->setObjId($a_usr_id);
467  self::$default_calendar[$a_usr_id][$a_type_id]->add();
468 
469  return self::$default_calendar[$a_usr_id][$a_type_id];
470  }
$res
Definition: ltiservices.php:66
Stores calendar categories.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ initJSCalendar()

static ilCalendarUtil::initJSCalendar ( )
static

Definition at line 190 of file class.ilCalendarUtil.php.

References $DIC, and $lng.

190  : void
191  {
192  global $DIC;
193 
194  $tpl = $DIC['tpl'];
195  $lng = $DIC['lng'];
196 
197  if (self::$init_done == "done") {
198  return;
199  }
200 
201  $lng->loadLanguageModule("jscalendar");
202  $tpl->addBlockFile(
203  "CALENDAR_LANG_JAVASCRIPT",
204  "calendar_javascript",
205  "tpl.calendar.html",
206  "components/ILIAS/Calendar"
207  );
208  $tpl->setCurrentBlock("calendar_javascript");
209  $tpl->setVariable("FULL_SUNDAY", $lng->txt("l_su"));
210  $tpl->setVariable("FULL_MONDAY", $lng->txt("l_mo"));
211  $tpl->setVariable("FULL_TUESDAY", $lng->txt("l_tu"));
212  $tpl->setVariable("FULL_WEDNESDAY", $lng->txt("l_we"));
213  $tpl->setVariable("FULL_THURSDAY", $lng->txt("l_th"));
214  $tpl->setVariable("FULL_FRIDAY", $lng->txt("l_fr"));
215  $tpl->setVariable("FULL_SATURDAY", $lng->txt("l_sa"));
216  $tpl->setVariable("SHORT_SUNDAY", $lng->txt("s_su"));
217  $tpl->setVariable("SHORT_MONDAY", $lng->txt("s_mo"));
218  $tpl->setVariable("SHORT_TUESDAY", $lng->txt("s_tu"));
219  $tpl->setVariable("SHORT_WEDNESDAY", $lng->txt("s_we"));
220  $tpl->setVariable("SHORT_THURSDAY", $lng->txt("s_th"));
221  $tpl->setVariable("SHORT_FRIDAY", $lng->txt("s_fr"));
222  $tpl->setVariable("SHORT_SATURDAY", $lng->txt("s_sa"));
223  $tpl->setVariable("FULL_JANUARY", $lng->txt("l_01"));
224  $tpl->setVariable("FULL_FEBRUARY", $lng->txt("l_02"));
225  $tpl->setVariable("FULL_MARCH", $lng->txt("l_03"));
226  $tpl->setVariable("FULL_APRIL", $lng->txt("l_04"));
227  $tpl->setVariable("FULL_MAY", $lng->txt("l_05"));
228  $tpl->setVariable("FULL_JUNE", $lng->txt("l_06"));
229  $tpl->setVariable("FULL_JULY", $lng->txt("l_07"));
230  $tpl->setVariable("FULL_AUGUST", $lng->txt("l_08"));
231  $tpl->setVariable("FULL_SEPTEMBER", $lng->txt("l_09"));
232  $tpl->setVariable("FULL_OCTOBER", $lng->txt("l_10"));
233  $tpl->setVariable("FULL_NOVEMBER", $lng->txt("l_11"));
234  $tpl->setVariable("FULL_DECEMBER", $lng->txt("l_12"));
235  $tpl->setVariable("SHORT_JANUARY", $lng->txt("s_01"));
236  $tpl->setVariable("SHORT_FEBRUARY", $lng->txt("s_02"));
237  $tpl->setVariable("SHORT_MARCH", $lng->txt("s_03"));
238  $tpl->setVariable("SHORT_APRIL", $lng->txt("s_04"));
239  $tpl->setVariable("SHORT_MAY", $lng->txt("s_05"));
240  $tpl->setVariable("SHORT_JUNE", $lng->txt("s_06"));
241  $tpl->setVariable("SHORT_JULY", $lng->txt("s_07"));
242  $tpl->setVariable("SHORT_AUGUST", $lng->txt("s_08"));
243  $tpl->setVariable("SHORT_SEPTEMBER", $lng->txt("s_09"));
244  $tpl->setVariable("SHORT_OCTOBER", $lng->txt("s_10"));
245  $tpl->setVariable("SHORT_NOVEMBER", $lng->txt("s_11"));
246  $tpl->setVariable("SHORT_DECEMBER", $lng->txt("s_12"));
247  $tpl->setVariable("ABOUT_CALENDAR", $lng->txt("about_calendar"));
248  $tpl->setVariable("ABOUT_CALENDAR_LONG", $lng->txt("about_calendar_long"));
249  $tpl->setVariable("ABOUT_TIME_LONG", $lng->txt("about_time"));
250  $tpl->setVariable("PREV_YEAR", $lng->txt("prev_year"));
251  $tpl->setVariable("PREV_MONTH", $lng->txt("prev_month"));
252  $tpl->setVariable("GO_TODAY", $lng->txt("go_today"));
253  $tpl->setVariable("NEXT_MONTH", $lng->txt("next_month"));
254  $tpl->setVariable("NEXT_YEAR", $lng->txt("next_year"));
255  $tpl->setVariable("SEL_DATE", $lng->txt("select_date"));
256  $tpl->setVariable("DRAG_TO_MOVE", $lng->txt("drag_to_move"));
257  $tpl->setVariable("PART_TODAY", $lng->txt("part_today"));
258  $tpl->setVariable("DAY_FIRST", $lng->txt("day_first"));
259  $tpl->setVariable("CLOSE", $lng->txt("close"));
260  $tpl->setVariable("TODAY", $lng->txt("today"));
261  $tpl->setVariable("TIME_PART", $lng->txt("time_part"));
262  $tpl->setVariable("DEF_DATE_FORMAT", $lng->txt("def_date_format"));
263  $tpl->setVariable("TT_DATE_FORMAT", $lng->txt("tt_date_format"));
264  $tpl->setVariable("WK", $lng->txt("wk"));
265  $tpl->setVariable("TIME", $lng->txt("time"));
266  $tpl->parseCurrentBlock();
267  $tpl->setCurrentBlock("CalendarJS");
268  $tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./components/ILIAS/Calendar/js/calendar.js");
269  $tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./components/ILIAS/Calendar/js/calendar-setup.js");
270  $tpl->parseCurrentBlock();
271 
272  self::$init_done = "done";
273  }
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31

◆ parseDateString()

static ilCalendarUtil::parseDateString ( string  $date,
bool  $add_time = false,
?string  $force_format = null 
)
static

Parse (incoming) string to date/time object.

Parameters
string$date
bool$add_time1=hh:mm, 2=hh:mm:ss
bool$a_use_generic_format
Returns
array date, warnings, errors
Exceptions
ilDateTimeException

Definition at line 532 of file class.ilCalendarUtil.php.

References $DIC, IL_CAL_DATE, IL_CAL_DATETIME, and null.

532  : array
533  {
534  global $DIC;
535 
536  $ilUser = $DIC['ilUser'];
537  if (!$force_format) {
538  $out_format = self::getUserDateFormat($add_time, true);
539  } else {
540  $out_format = $force_format;
541  }
542 
543  $tmp = date_parse_from_format($out_format, $date);
544  $return_date = null;
545 
546  if (!$tmp["error_count"] &&
547  !$tmp["warning_count"]) {
548  $format = $tmp["year"] . "-" .
549  str_pad($tmp["month"], 2, "0", STR_PAD_LEFT) . "-" .
550  str_pad($tmp["day"], 2, "0", STR_PAD_LEFT);
551 
552  if ($add_time) {
553  $format .= " " .
554  str_pad($tmp["hour"], 2, "0", STR_PAD_LEFT) . ":" .
555  str_pad($tmp["minute"], 2, "0", STR_PAD_LEFT) . ":" .
556  str_pad($tmp["second"], 2, "0", STR_PAD_LEFT);
557 
558  $return_date = new ilDateTime($format, IL_CAL_DATETIME, $ilUser->getTimeZone());
559  } else {
560  $return_date = new ilDate($format, IL_CAL_DATE);
561  }
562  }
563 
564  return array(
565  "date" => $return_date
566  ,
567  "warnings" => sizeof($tmp["warnings"])
568  ? $tmp["warnings"]
569  : null
570  ,
571  "errors" => sizeof($tmp["errors"])
572  ? $tmp["errors"]
573  : null
574  );
575  }
const IL_CAL_DATETIME
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
const IL_CAL_DATE

◆ parseIncomingDate()

static ilCalendarUtil::parseIncomingDate (   $value,
bool  $add_time = false 
)
static

Try to parse incoming value to date object.

Parameters
string | ilDateTime$value
int$add_time
Returns
ilDateTime|ilDate

Definition at line 583 of file class.ilCalendarUtil.php.

References null.

Referenced by ilDateTimeInputGUI\checkInput(), ilDclGenericMultiInputGUI\checkInput(), ilDateDurationInputGUI\checkInput(), ilAdvancedMDFieldDefinitionDate\getLuceneSearchString(), ilAdvancedMDFieldDefinitionDateTime\getLuceneSearchString(), ilSessionStatisticsGUI\importDate(), ilADTDateSearchBridgeSingle\importFromPost(), ilADTDateTimeSearchBridgeSingle\importFromPost(), ilADTDateSearchBridgeRange\importFromPost(), ilADTDateTimeSearchBridgeRange\importFromPost(), ilDclGenericMultiInputGUI\setValue(), ilDateTimeInputGUI\setValueByArray(), ilDateDurationInputGUI\setValueByArray(), ilCourseContentGUI\updateManagedTimings(), and ilCourseContentGUI\updatePersonalTimings().

583  : ?ilDateTime
584  {
585  // already datetime object?
586  if ($value instanceof ilDateTime) {
587  return $value;
588  } elseif (!trim($value)) {
589  return null;
590  }
591 
592  // try user-specific format
593  $parsed = self::parseDateString($value, $add_time);
594  if (is_object($parsed['date'])) {
595  return $parsed['date'];
596  }
597 
598  // try the previously used generic format
599  $format = $add_time ? 'Y-m-d H:i:s' : 'Y-m-d';
600  $parsed = self::parseDateString($value, $add_time, $format);
601  if (is_object($parsed['date'])) {
602  return $parsed['date'];
603  }
604 
605  // try the formats returned by html native datetime-local/date inputs
606  $format = 'Y-m-d';
607  if ($add_time) {
608  // can be with or without seconds
609  $format .= '\TH:i';
610  }
611  $parsed = self::parseDateString($value, $add_time, $format);
612  if (is_object($parsed['date'])) {
613  return $parsed['date'];
614  }
615 
616  return null;
617  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

Field Documentation

◆ $default_calendar

array ilCalendarUtil::$default_calendar = array()
staticprivate

Definition at line 26 of file class.ilCalendarUtil.php.

◆ $init_datetimepicker

bool ilCalendarUtil::$init_datetimepicker = false
staticprotected

Definition at line 28 of file class.ilCalendarUtil.php.

◆ $init_done

string ilCalendarUtil::$init_done
static

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

◆ $today

ilDateTime ilCalendarUtil::$today = null
staticprivate

Definition at line 25 of file class.ilCalendarUtil.php.


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