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

Class ilCalendarUtil. More...

+ Collaboration diagram for ilCalendarUtil:

Static Public Member Functions

static _isToday ($date)
 check if a date is today More...
 
static _numericMonthToString ($a_month, $a_long=true)
 numeric month to string More...
 
static _numericDayToString ($a_day, $a_long=true)
 get More...
 
static _buildWeekDayList ($a_day, $a_weekstart)
 build week day list More...
 
static _buildMonthDayList ($a_month, $a_year, $weekstart)
 Build a month day list. More...
 
static initJSCalendar ()
 Init Javascript Calendar. More...
 
static getZoneInfoFile ($a_tz)
 
static _getShortTimeZoneList ()
 get short timezone list More...
 
static _isLeapYear ($a_year)
 check if a given year is a leap year More...
 
static _getMaxDayOfMonth ($a_year, $a_month)
 get max day of month 2008,2 => 29 More...
 
static calculateFontColor ($a_html_color_code)
 Calculate best font color from html hex color code. More...
 
static getHourSelection ($a_format)
 Get hour selectio depending on user specific hour format. More...
 
static initDefaultCalendarByType ($a_type_id, $a_usr_id, $a_title, $a_create=false)
 Init the default calendar for given type and user. More...
 
static getUserDateFormat ($a_add_time=false, $a_for_parsing=false)
 Parse current user setting into date/time format. More...
 
static initDateTimePicker ()
 
static addDateTimePicker ($a_id, $a_add_time=null, array $a_custom_config=null, $a_id2=null, $a_custom_config2=null, $a_toggle_id=null, $a_subform_id=null)
 Add date time picker to element. More...
 
static parseDateString ($a_date, $a_add_time=null, $a_use_generic_format=false)
 Parse (incoming) string to date/time object. More...
 
static parseIncomingDate ($a_value, $a_add_time=null)
 Try to parse incoming value to date object. More...
 

Static Public Attributes

static $init_done
 

Static Protected Attributes

static $init_datetimepicker
 

Static Private Attributes

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

Detailed Description

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
Version
$Id$

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

Member Function Documentation

◆ _buildMonthDayList()

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

Build a month day list.

public

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

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

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

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

134  {
135  include_once('Services/Calendar/classes/class.ilDateList.php');
136  $day_list = new ilDateList(ilDateList::TYPE_DATE);
137 
138  $prev_month = ($a_month == 1) ? 12 : $a_month - 1;
139  $prev_year = ($prev_month == 12) ? $a_year - 1 : $a_year;
140  $next_month = $a_month == 12 ? 1 : $a_month + 1;
141  $next_year = $a_month == 12 ? $a_year + 1 : $a_year;
142 
143  $days_in_month = self::_getMaxDayOfMonth($a_year, $a_month);
144  $days_in_prev_month = self::_getMaxDayOfMonth($a_year, $prev_month);
145 
146  $week_day['year'] = $a_year;
147  $week_day['mon'] = $a_month;
148  $week_day['mday'] = 1;
149  $week_day['hours'] = 0;
150  $week_day['minutes'] = 0;
151  $week_day = new ilDate($week_day, IL_CAL_FKT_GETDATE);
152 
153  $weekday = $week_day->get(IL_CAL_FKT_DATE, 'w');
154  $first_day_offset = (($weekday - $weekstart) < 0) ? 6 : $weekday - $weekstart;
155 
156 
157  for ($i = 0;$i < 42;$i++) {
158  if ($i < $first_day_offset) {
159  $day = $days_in_prev_month - $first_day_offset + $i + 1;
160 
161  $day_list->add(new ilDate(
162  gmmktime(
163  0,
164  0,
165  0,
166  $prev_month,
167  $days_in_prev_month - $first_day_offset + $i + 1,
168  $prev_year
169  ),
171  ));
172  } elseif ($i < $days_in_month + $first_day_offset) {
173  $day = $i - $first_day_offset + 1;
174 
175 
176  $day_list->add(new ilDate(
177  gmmktime(
178  0,
179  0,
180  0,
181  $a_month,
182  $i - $first_day_offset + 1,
183  $a_year
184  ),
186  ));
187  } else {
188  $day = $i - $days_in_month - $first_day_offset + 1;
189  $day_list->add(new ilDate(
190  gmmktime(
191  0,
192  0,
193  0,
194  $next_month,
195  $i - $days_in_month - $first_day_offset + 1,
196  $next_year
197  ),
199  ));
200  }
201  if ($i == 34 and ($day < 15 or $day == $days_in_month)) {
202  break;
203  }
204  }
205  return $day_list;
206  }
const IL_CAL_UNIX
Class for single dates.
List of dates.
const IL_CAL_FKT_DATE
const IL_CAL_FKT_GETDATE
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ _buildWeekDayList()

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

build week day list

public

Parameters
ilDatea day in a week
intweekstart
Returns
ilDateList

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

References $i, IL_CAL_DAY, IL_CAL_FKT_GETDATE, and ilDateList\TYPE_DATE.

Referenced by ilObjBookingPoolGUI\buildDatesBySchedule(), ilCalendarViewGUI\getBucketTitle(), ilCalendarHeaderNavigationGUI\getHTML(), ilObjBookingPoolGUI\renderSlots(), and ilCalendarWeekGUI\show().

104  {
105  include_once('Services/Calendar/classes/class.ilDateList.php');
106  $day_list = new ilDateList(ilDateList::TYPE_DATE);
107 
108  $start = clone $a_day;
109  $start_info = $start->get(IL_CAL_FKT_GETDATE, '', 'UTC');
110  $day_diff = $a_weekstart - $start_info['isoday'];
111  if ($day_diff == 7) {
112  $day_diff = 0;
113  }
114  $start->increment(IL_CAL_DAY, $day_diff);
115  $day_list->add($start);
116  for ($i = 1; $i < 7;$i++) {
117  $start->increment(IL_CAL_DAY, 1);
118  $day_list->add($start);
119  }
120  return $day_list;
121  }
const IL_CAL_DAY
List of dates.
const IL_CAL_FKT_GETDATE
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ _getMaxDayOfMonth()

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

get max day of month 2008,2 => 29

public

Parameters
intyear
intmonth
Returns

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

References array.

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

420  {
421  if (@function_exists('cal_days_in_month')) {
422  return cal_days_in_month(CAL_GREGORIAN, $a_month, $a_year);
423  }
424  $months = array(0,31,
425  self::_isLeapYear($a_year) ? 29 : 28,
426  31,30,31,30,31,31,30,31,30,31);
427  return $months[(int) $a_month];
428  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ _getShortTimeZoneList()

static ilCalendarUtil::_getShortTimeZoneList ( )
static

get short timezone list

public

Parameters

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

References array.

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

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

◆ _isLeapYear()

static ilCalendarUtil::_isLeapYear (   $a_year)
static

check if a given year is a leap year

public

Parameters
intyear
Returns
bool

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

Referenced by ilCalendarRecurrenceCalculator\getYearWeekDays().

395  {
396  $is_leap = false;
397 
398  if ($a_year % 4 == 0) {
399  $is_leap = true;
400  if ($a_year % 100 == 0) {
401  $is_leap = false;
402  if ($a_year % 400) {
403  return true;
404  }
405  }
406  }
407  return $is_leap;
408  }
+ Here is the caller graph for this function:

◆ _isToday()

static ilCalendarUtil::_isToday (   $date)
static

check if a date is today

Parameters
ilDateTime$datedate to check
Returns
bool

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

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

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

47  {
48  global $ilUser;
49 
50 
51  if (!is_object(self::$today)) {
52  self::$today = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
53  }
54  return ilDateTime::_equals(self::$today, $date, IL_CAL_DAY, $ilUser->getTimeZone());
55  }
const IL_CAL_UNIX
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Date and time handling
$ilUser
Definition: imgupload.php:18
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _numericDayToString()

static ilCalendarUtil::_numericDayToString (   $a_day,
  $a_long = true 
)
static

get

public

Parameters
intday of week (0 for sunday, 1 for monday)
boolshort or long day translation

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

References $lng, and array.

Referenced by ilCalendarWeekGUI\addHeaderDate(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ilCalendarMonthGUI\addScheduleFilter(), ilRecurrenceInputGUI\buildMonthlyByDaySelection(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilCalendarDayGUI\executeCommand(), ilSessionStatisticsGUI\exportCSV(), ilBookingReservationsTableGUI\fillRow(), ilBookingReservationsTableGUI\fillRowCSV(), ilBookingReservationsTableGUI\fillRowExcel(), ilSessionStatisticsGUI\getChart(), ilCalendarHeaderNavigationGUI\getHTML(), ilBookingReservationsTableGUI\initFilter(), and ilObjBookingPoolGUI\renderSlots().

85  {
86  global $lng;
87 
88  $lng->loadLanguageModule('dateplaner');
89  static $days = array('Su','Mo','Tu','We','Th','Fr','Sa','Su');
90 
91  return $a_long ? $lng->txt($days[$a_day] . '_long') : $lng->txt($days[$a_day] . '_short');
92  }
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ _numericMonthToString()

static ilCalendarUtil::_numericMonthToString (   $a_month,
  $a_long = true 
)
static

numeric month to string

public

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

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

References $lng.

Referenced by ilCalendarMonthGUI\addScheduleFilter(), ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilRecurrenceInputGUI\buildYearlyByMonthDaySelection(), ilCalendarDayGUI\executeCommand(), ilDatePresentation\formatDate(), ilObjBlogGUI\renderList(), ilObjBlogGUI\renderNavigationByDate(), ilObjBookingPoolGUI\renderSlots(), and ilWikiStatGUI\viewToolbar().

67  {
68  global $lng;
69 
70  $month = $a_month < 10 ? '0' . $a_month : $a_month;
71 
72  return $a_long ? $lng->txt('month_' . $month . '_long') : $lng->txt('month_' . $month . '_short');
73  }
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ addDateTimePicker()

static ilCalendarUtil::addDateTimePicker (   $a_id,
  $a_add_time = null,
array  $a_custom_config = null,
  $a_id2 = null,
  $a_custom_config2 = null,
  $a_toggle_id = null,
  $a_subform_id = null 
)
static

Add date time picker to element.

Parameters
string$a_id
int$a_add_time1=hh:mm, 2=hh:mm:ss
array$a_custom_config
string$a_id2
array$a_custom_config2
string$a_toggle_id
string$a_subform_id
Returns
string

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

References $config, $ilUser, $tpl, and array.

Referenced by ilDateTimeInputGUI\render(), and ilDateDurationInputGUI\render().

603  {
604  global $tpl, $ilUser;
605 
606  self::initDateTimePicker();
607 
608  // weekStart is currently governed by locale and cannot be changed
609 
610  // fix for mantis 22994 => default to english language
611  $language = 'en';
612  if ($ilUser->getLanguage() != 'ar') {
613  $language = $ilUser->getLanguage();
614  }
615  $default = array(
616  'locale' => $language
617  ,'stepping' => 5
618  ,'useCurrent' => false
619  ,'calendarWeeks' => true
620  ,'toolbarPlacement' => 'top'
621  // ,'showTodayButton' => true
622  ,'showClear' => true
623  // ,'showClose' => true
624  ,'keepInvalid' => true
625  ,'sideBySide' => true
626  // ,'collapse' => false
627  ,'format' => self::getUserDateFormat($a_add_time)
628  );
629 
630  $config = (!$a_custom_config)
631  ? $default
632  : array_merge($default, $a_custom_config);
633 
634  $tpl->addOnLoadCode('$("#' . $a_id . '").datetimepicker(' . json_encode($config) . ')');
635 
636 
637  // optional 2nd picker aka duration
638  if ($a_id2) {
639  $config2 = (!$a_custom_config2)
640  ? $default
641  : array_merge($default, $a_custom_config2);
642 
643  $config2["useCurrent"] = false; //Important! See issue #1075
644 
645  $tpl->addOnLoadCode('$("#' . $a_id2 . '").datetimepicker(' . json_encode($config2) . ')');
646 
647  // duration limits, diff and subform handling
648  $tpl->addOnLoadCode('il.Form.initDateDurationPicker("' . $a_id . '","' . $a_id2 . '","' . $a_toggle_id . '","' . $a_subform_id . '");');
649  } elseif ($a_subform_id) {
650  // subform handling
651  $tpl->addOnLoadCode('il.Form.initDatePicker("' . $a_id . '","' . $a_subform_id . '");');
652  }
653  }
$tpl
Definition: ilias.php:10
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ calculateFontColor()

static ilCalendarUtil::calculateFontColor (   $a_html_color_code)
static

Calculate best font color from html hex color code.

public

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

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

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

439  {
440  if (strpos($a_html_color_code, '#') !== 0 or strlen($a_html_color_code) != 7) {
441  return '#000000';
442  }
443 
444  // http://en.wikipedia.org/wiki/Luminance_(relative)
445  $lum = round(hexdec(substr($a_html_color_code, 1, 2))*0.2126+
446  hexdec(substr($a_html_color_code, 3, 2))*0.7152+
447  hexdec(substr($a_html_color_code, 5, 2))*0.0722);
448 
449  return ($lum <= 128) ? "#FFFFFF" : "#000000";
450 
451  /*
452  $hex = str_replace('#','0x',$a_html_color_code);
453  return hexdec($hex) > 8000000 ? '#000000' : '#FFFFFF';
454  */
455  }
+ Here is the caller graph for this function:

◆ getHourSelection()

static ilCalendarUtil::getHourSelection (   $a_format)
static

Get hour selectio depending on user specific hour format.

Returns
Parameters
int$a_format

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

References $i, $options, array, date, ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

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

463  {
464  switch ($a_format) {
466  for ($i = 0; $i < 24; $i++) {
467  $options[$i] = sprintf('%02d:00', $i);
468  }
469  break;
470 
472  for ($i = 0; $i < 24; $i++) {
473  $options[$i] = date('h a', mktime($i, 0, 0, 1, 1, 2000));
474  }
475  break;
476  }
477  return $options ? $options : array();
478  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the caller graph for this function:

◆ getUserDateFormat()

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

Parse current user setting into date/time format.

Parameters
int$a_add_time1=hh:mm, 2=hh:mm:ss
bool$a_for_parsing
Returns
string

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

References $format, $ilUser, ilCalendarSettings\DATE_FORMAT_DMY, ilCalendarSettings\DATE_FORMAT_MDY, ilCalendarSettings\DATE_FORMAT_YMD, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilDateTimeInputGUI\render(), and ilDateDurationInputGUI\render().

534  {
535  global $ilUser;
536 
537  // getDateFormat() should return calendar defaults for ANONYMOUS user
538  switch ($ilUser->getDateFormat()) {
540  $format = "DD.MM.YYYY";
541  break;
542 
544  $format = "YYYY-MM-DD";
545  break;
546 
548  $format = "MM/DD/YYYY";
549  break;
550  }
551  if ($a_add_time) {
552  $format .= " " . (($ilUser->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_24)
553  ? "HH:mm"
554  : "hh:mma");
555  if ($a_add_time == 2) {
556  $format .= ":ss";
557  }
558  }
559 
560  // translate datepicker format to PHP format
561  if ((bool) $a_for_parsing) {
562  $format = str_replace("DD", "d", $format);
563  $format = str_replace("MM", "m", $format);
564  $format = str_replace("mm", "i", $format);
565  $format = str_replace("YYYY", "Y", $format);
566  $format = str_replace("HH", "H", $format);
567  $format = str_replace("hh", "h", $format);
568  }
569 
570  return $format;
571  }
$format
Definition: metadata.php:141
$ilUser
Definition: imgupload.php:18
+ Here is the caller graph for this function:

◆ getZoneInfoFile()

static ilCalendarUtil::getZoneInfoFile (   $a_tz)
static

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

Referenced by ilCalendarExport\addTimezone().

294  {
295  if (!array_key_exists($a_tz, self::_getShortTimeZoneList())) {
296  return '';
297  }
298  $timezone_filename = str_replace('/', '_', $a_tz);
299  $timezone_filename .= '.ics';
300  return './Services/Calendar/zoneinfo/' . $timezone_filename;
301  }
+ Here is the caller graph for this function:

◆ initDateTimePicker()

static ilCalendarUtil::initDateTimePicker ( )
static

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

References $tpl.

Referenced by ilExerciseManagementGUI\initIndividualDeadlineModal().

574  {
575  global $tpl;
576 
577  if (!self::$init_datetimepicker) {
578  $tpl->addJavaScript("./libs/bower/bower_components/moment/min/moment-with-locales.min.js");
579 
580  // unminified version does not work with jQuery 3.0
581  // https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1684
582  $tpl->addJavaScript("./libs/bower/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js");
583 
584  $tpl->addJavaScript("Services/Form/js/Form.js"); // see ilPropertyFormGUI
585 
586  self::$init_datetimepicker = true;
587  }
588  }
$tpl
Definition: ilias.php:10
+ Here is the caller graph for this function:

◆ initDefaultCalendarByType()

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

Init the default calendar for given type and user.

Parameters
int$a_type_id
int$a_usr_id
string$a_title
bool$create
Returns

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

References $ilDB, $query, $res, $row, ilCalendarCategory\DEFAULT_COLOR, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilConsultationHourUtils\bookAppointment(), ilConsultationHoursGUI\createAppointments(), and ilObjBookingPoolGUI\processBooking().

489  {
490  global $ilDB;
491 
492  if (isset(self::$default_calendar[$a_usr_id]) and isset(self::$default_calendar[$a_usr_id][$a_type_id])) {
493  return self::$default_calendar[$a_usr_id][$a_type_id];
494  }
495 
496  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
497 
498  $query = "SELECT cat_id FROM cal_categories " .
499  "WHERE obj_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
500  "AND type = " . $ilDB->quote($a_type_id, 'integer');
501  $res = $ilDB->query($query);
502  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
503  return self::$default_calendar[$a_usr_id][$a_type_id] = new ilCalendarCategory($row->cat_id);
504  }
505 
506  if (!$a_create) {
507  return null;
508  }
509 
510  // Create default calendar
511  self::$default_calendar[$a_usr_id][$a_type_id] = new ilCalendarCategory();
512  self::$default_calendar[$a_usr_id][$a_type_id]->setType($a_type_id);
513  self::$default_calendar[$a_usr_id][$a_type_id]->setColor(ilCalendarCategory::DEFAULT_COLOR);
514  self::$default_calendar[$a_usr_id][$a_type_id]->setTitle($a_title);
515  self::$default_calendar[$a_usr_id][$a_type_id]->setObjId($a_usr_id);
516  self::$default_calendar[$a_usr_id][$a_type_id]->add();
517 
518  return self::$default_calendar[$a_usr_id][$a_type_id];
519  }
Stores calendar categories.
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ initJSCalendar()

static ilCalendarUtil::initJSCalendar ( )
static

Init Javascript Calendar.

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

References $lng, and $tpl.

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

◆ parseDateString()

static ilCalendarUtil::parseDateString (   $a_date,
  $a_add_time = null,
  $a_use_generic_format = false 
)
static

Parse (incoming) string to date/time object.

Parameters
string$a_date
int$a_add_time1=hh:mm, 2=hh:mm:ss
Returns
array date, warnings, errors

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

References $format, $ilUser, array, IL_CAL_DATE, and IL_CAL_DATETIME.

662  {
663  global $ilUser;
664 
665  if (!$a_use_generic_format) {
666  $out_format = self::getUserDateFormat($a_add_time, true);
667  } else {
668  $out_format = $a_add_time
669  ? "Y-m-d H:i:s"
670  : "Y-m-d";
671  }
672  $tmp = date_parse_from_format($out_format, $a_date);
673 
674  $date = null;
675 
676  if (!$tmp["error_count"] &&
677  !$tmp["warning_count"]) {
678  $format = $tmp["year"] . "-" .
679  str_pad($tmp["month"], 2, "0", STR_PAD_LEFT) . "-" .
680  str_pad($tmp["day"], 2, "0", STR_PAD_LEFT);
681 
682  if ($a_add_time) {
683  $format .= " " .
684  str_pad($tmp["hour"], 2, "0", STR_PAD_LEFT) . ":" .
685  str_pad($tmp["minute"], 2, "0", STR_PAD_LEFT) . ":" .
686  str_pad($tmp["second"], 2, "0", STR_PAD_LEFT);
687 
688  $date = new ilDateTime($format, IL_CAL_DATETIME, $ilUser->getTimeZone());
689  } else {
690  $date = new ilDate($format, IL_CAL_DATE);
691  }
692  }
693 
694  return array(
695  "date" => $date
696  , "warnings" => sizeof($tmp["warnings"])
697  ? $tmp["warnings"]
698  : null
699  , "errors" => sizeof($tmp["errors"])
700  ? $tmp["errors"]
701  : null
702  );
703  }
$format
Definition: metadata.php:141
const IL_CAL_DATETIME
Class for single dates.
Date and time handling
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
const IL_CAL_DATE

◆ parseIncomingDate()

static ilCalendarUtil::parseIncomingDate (   $a_value,
  $a_add_time = null 
)
static

Try to parse incoming value to date object.

Parameters
mixed$a_value
int$a_add_time
Returns
ilDateTime|ilDate

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

Referenced by ilDateTimeInputGUI\checkInput(), ilDateDurationInputGUI\checkInput(), ilObjBookingPoolGUI\confirmedBookingNumbersObject(), ilSessionStatisticsGUI\importDate(), ilADTDateSearchBridgeSingle\importFromPost(), ilADTDateTimeSearchBridgeSingle\importFromPost(), ilADTDateSearchBridgeRange\importFromPost(), ilADTDateTimeSearchBridgeRange\importFromPost(), ilDateTimeInputGUI\setValueByArray(), and ilDateDurationInputGUI\setValueByArray().

713  {
714  // already datetime object?
715  if (is_object($a_value) &&
716  $a_value instanceof ilDateTime) {
717  return $a_value;
718  } elseif (trim($a_value)) {
719  // try user-specific format
720  $parsed = self::parseDateString($a_value, $a_add_time);
721  if (is_object($parsed["date"])) {
722  return $parsed["date"];
723  } else {
724  // try generic format
725  $parsed = self::parseDateString($a_value, $a_add_time, true);
726  if (is_object($parsed["date"])) {
727  return $parsed["date"];
728  }
729  }
730  }
731  }
Date and time handling
+ Here is the caller graph for this function:

Field Documentation

◆ $default_calendar

ilCalendarUtil::$default_calendar = array()
staticprivate

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

◆ $init_datetimepicker

ilCalendarUtil::$init_datetimepicker
staticprotected

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

◆ $init_done

ilCalendarUtil::$init_done
static

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

◆ $today

ilCalendarUtil::$today = null
staticprivate

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


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