ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDateTimeInputGUI Class Reference

This class represents a date/time property in a property form. More...

+ Inheritance diagram for ilDateTimeInputGUI:
+ Collaboration diagram for ilDateTimeInputGUI:

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 setDate (?ilDateTime $a_date=null)
 set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTime('2008-06-12 08:00:00',IL_CAL_DATETIME)); More...
 
 getDate ()
 
 setShowTime (bool $a_showtime)
 
 getShowTime ()
 
 setStartYear (int $a_year)
 
 getStartYear ()
 
 setMinuteStepSize (int $a_step_size)
 Set minute step size E.g 5 => The selection will only show 00,05,10... More...
 
 getMinuteStepSize ()
 Fixed to one minute increments, see https://mantis.ilias.de/view.php?id=42740. More...
 
 setValueByArray (array $a_values)
 
 hasInvalidInput ()
 
 checkInput ()
 
 getInput ()
 
 setSideBySide (bool $a_val)
 
 render ()
 
 getOnloadCode ()
 
 insert (ilTemplate $a_tpl)
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 getPostValueForComparison ()
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 hideSubForm ()
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. More...
 
- Public Member Functions inherited from ilTableFilterItem
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 

Protected Member Functions

 getDatePickerTimeFormat ()
 
 getDatetimeFormatForInput ()
 
- Protected Member Functions inherited from ilFormPropertyGUI
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Protected Attributes

ilObjUser $user
 
ilDateTime $date = null
 
string $time = "00:00:00"
 
bool $showtime = false
 
int $minute_step_size = 5
 
int $startyear = null
 
string $invalid_input = ''
 
bool $side_by_side = true
 
bool $valid = false
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 

Detailed Description

This class represents a date/time property in a property form.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilDateTimeInputGUI::__construct ( string  $a_title = "",
string  $a_postvar = "" 
)

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), ilFormPropertyGUI\setType(), and ILIAS\Repository\user().

41  {
42  global $DIC;
43 
44  $this->lng = $DIC->language();
45  $this->user = $DIC->user();
46  parent::__construct($a_title, $a_postvar);
47  $this->setType("datetime");
48  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilDateTimeInputGUI::checkInput ( )

Definition at line 127 of file class.ilDateTimeInputGUI.php.

References ilFormPropertyGUI\$lng, $post, $valid, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), getDate(), getDatePickerTimeFormat(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), getStartYear(), IL_CAL_FKT_DATE, null, ilCalendarUtil\parseIncomingDate(), ilFormPropertyGUI\setAlert(), setDate(), ilFormPropertyGUI\str(), and ilLanguage\txt().

127  : bool
128  {
129  $lng = $this->lng;
130 
131  if ($this->getDisabled()) {
132  return true;
133  }
134 
135  $post = $this->str($this->getPostVar());
136 
137  // always done to make sure there are no obsolete values left
138  $this->setDate(null);
139 
140  $valid = false;
141  if (trim($post)) {
143  if ($parsed) {
144  $this->setDate($parsed);
145  $valid = true;
146  }
147  } elseif (!$this->getRequired()) {
148  $valid = true;
149  }
150 
151  if ($valid &&
152  $this->getDate() &&
153  $this->getStartYear() &&
154  $this->getDate()->get(IL_CAL_FKT_DATE, "Y") < $this->getStartYear()) {
155  $valid = false;
156  }
157 
158  $this->valid = $valid;
159 
160  if (!$valid) {
161  $this->invalid_input = $post;
162  $this->setAlert($lng->txt("form_msg_wrong_date"));
163  }
164 
165  if ($valid) {
166  $valid = $this->checkSubItemsInput();
167  }
168 
169  return $valid;
170  }
static parseIncomingDate($value, bool $add_time=false)
Try to parse incoming value to date object.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const IL_CAL_FKT_DATE
setDate(?ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

◆ getDate()

ilDateTimeInputGUI::getDate ( )

Definition at line 64 of file class.ilDateTimeInputGUI.php.

References $date.

Referenced by checkInput(), getInput(), hideSubForm(), render(), and serializeData().

64  : ?ilDateTime
65  {
66  return $this->date;
67  }
+ Here is the caller graph for this function:

◆ getDatePickerTimeFormat()

ilDateTimeInputGUI::getDatePickerTimeFormat ( )
protected

Definition at line 117 of file class.ilDateTimeInputGUI.php.

References getShowTime().

Referenced by checkInput(), and setValueByArray().

117  : int
118  {
119  return (int) $this->getShowTime();
120  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDatetimeFormatForInput()

ilDateTimeInputGUI::getDatetimeFormatForInput ( )
protected

Definition at line 189 of file class.ilDateTimeInputGUI.php.

References getShowTime().

Referenced by render().

189  : string
190  {
191  $format = 'Y-m-d';
192  if ($this->getShowTime()) {
193  $format .= '\TH:i';
194  }
195  return $format;
196  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInput()

ilDateTimeInputGUI::getInput ( )

Definition at line 172 of file class.ilDateTimeInputGUI.php.

References getDate(), getShowTime(), IL_CAL_DATE, IL_CAL_DATETIME, and null.

172  : ?string
173  {
174  if ($this->valid && $this->getDate() !== null) {
175  // getInput() should return a generic format
176  $post_format = $this->getShowTime()
178  : IL_CAL_DATE;
179  return $this->getDate()->get($post_format);
180  }
181  return null;
182  }
const IL_CAL_DATETIME
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const IL_CAL_DATE
+ Here is the call graph for this function:

◆ getMinuteStepSize()

ilDateTimeInputGUI::getMinuteStepSize ( )

Fixed to one minute increments, see https://mantis.ilias.de/view.php?id=42740.

Definition at line 102 of file class.ilDateTimeInputGUI.php.

102  : int
103  {
104  return 1;
105  }

◆ getOnloadCode()

ilDateTimeInputGUI::getOnloadCode ( )

Definition at line 256 of file class.ilDateTimeInputGUI.php.

256  : array
257  {
258  // no js necessary anymore
259  return [];
260  }

◆ getPostValueForComparison()

ilDateTimeInputGUI::getPostValueForComparison ( )

Definition at line 303 of file class.ilDateTimeInputGUI.php.

References serializeData().

303  : string
304  {
305  return $this->serializeData();
306  }
+ Here is the call graph for this function:

◆ getShowTime()

ilDateTimeInputGUI::getShowTime ( )

Definition at line 74 of file class.ilDateTimeInputGUI.php.

References $showtime.

Referenced by getDatePickerTimeFormat(), getDatetimeFormatForInput(), getInput(), render(), and unserializeData().

74  : bool
75  {
76  return $this->showtime;
77  }
+ Here is the caller graph for this function:

◆ getStartYear()

ilDateTimeInputGUI::getStartYear ( )

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

References $startyear.

Referenced by checkInput(), and render().

84  : ?int
85  {
86  return $this->startyear;
87  }
+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilDateTimeInputGUI::getTableFilterHTML ( )

Get input item HTML to be inserted into table filters.

Implements ilTableFilterItem.

Definition at line 271 of file class.ilDateTimeInputGUI.php.

References render().

271  : string
272  {
273  $html = $this->render();
274  return $html;
275  }
+ Here is the call graph for this function:

◆ getToolbarHTML()

ilDateTimeInputGUI::getToolbarHTML ( )

Get input item HTML to be inserted into ilToolbarGUI.

Implements ilToolbarItem.

Definition at line 308 of file class.ilDateTimeInputGUI.php.

References render().

308  : string
309  {
310  $html = $this->render();
311  return $html;
312  }
+ Here is the call graph for this function:

◆ hasInvalidInput()

ilDateTimeInputGUI::hasInvalidInput ( )

Definition at line 122 of file class.ilDateTimeInputGUI.php.

References $invalid_input.

122  : bool
123  {
124  return (bool) $this->invalid_input;
125  }

◆ hideSubForm()

ilDateTimeInputGUI::hideSubForm ( )

Definition at line 314 of file class.ilDateTimeInputGUI.php.

References getDate().

314  : bool
315  {
316  return (!$this->getDate() || $this->getDate()->isNull());
317  }
+ Here is the call graph for this function:

◆ insert()

ilDateTimeInputGUI::insert ( ilTemplate  $a_tpl)

Definition at line 262 of file class.ilDateTimeInputGUI.php.

References ilTemplate\parseCurrentBlock(), render(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

262  : void
263  {
264  $html = $this->render();
265 
266  $a_tpl->setCurrentBlock("prop_generic");
267  $a_tpl->setVariable("PROP_GENERIC", $html);
268  $a_tpl->parseCurrentBlock();
269  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ render()

ilDateTimeInputGUI::render ( )

Definition at line 198 of file class.ilDateTimeInputGUI.php.

References ilFormPropertyGUI\$lng, ilFormPropertyGUI\$type, $user, getDate(), getDatetimeFormatForInput(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), getShowTime(), getStartYear(), and IL_CAL_FKT_DATE.

Referenced by getTableFilterHTML(), getToolbarHTML(), and insert().

198  : string
199  {
200  $ilUser = $this->user;
201  $lng = $this->lng;
202 
203  $tpl = new ilTemplate("tpl.prop_datetime.html", true, true, "components/ILIAS/Form");
204 
205  // config picker
206  if (!$this->getDisabled()) {
207  $picker_id = 'p' . md5($this->getPostVar()); // :TODO: unique?
208  $tpl->setVariable('DATEPICKER_ID', $picker_id);
209  } else {
210  $tpl->setVariable('DATEPICKER_DISABLED', 'disabled="disabled" ');
211  }
212 
213  $type = 'date';
214  if ($this->getShowTime()) {
215  $type = 'datetime-local';
216  }
217  $tpl->setVariable('DATEPICKER_TYPE', $type);
218 
219  // current value
220  $out_format = $this->getDatetimeFormatForInput();
221  $date_value = htmlspecialchars($this->invalid_input);
222  if (!$date_value &&
223  $this->getDate()) {
224  $date_value = $this->getDate()->get(IL_CAL_FKT_DATE, $out_format, $ilUser->getTimeZone());
225  }
226  $tpl->setVariable('DATEPICKER_START_VALUE', $date_value);
227 
228  /*
229  * For date input, step is in days, for datetime-local
230  * it is in seconds.
231  */
232  $step_size = 60;
233  if (!$this->getShowTime()) {
234  $step_size = 1;
235  }
236  $tpl->setVariable('DATEPICKER_STEP', $step_size);
237 
238  if ($this->getStartYear()) {
239  $min = DateTimeImmutable::createFromFormat(
240  'Y',
241  (string) $this->getStartYear()
242  )->format($this->getDatetimeFormatForInput());
243  $tpl->setVariable('DATEPICKER_MIN', $min);
244  }
245 
246  $tpl->setVariable('DATEPICKER_VALUE', $date_value);
247  $tpl->setVariable('DATE_ID', $this->getPostVar());
248 
249  if ($this->getRequired()) {
250  $tpl->setVariable("REQUIRED", "required=\"required\"");
251  }
252 
253  return $tpl->get();
254  }
const IL_CAL_FKT_DATE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serializeData()

ilDateTimeInputGUI::serializeData ( )

Definition at line 277 of file class.ilDateTimeInputGUI.php.

References getDate(), and IL_CAL_UNIX.

Referenced by getPostValueForComparison().

277  : string
278  {
279  if ($this->getDate()) {
280  return serialize($this->getDate()->get(IL_CAL_UNIX));
281  }
282  return "";
283  }
const IL_CAL_UNIX
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDate()

ilDateTimeInputGUI::setDate ( ?ilDateTime  $a_date = null)

set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTime('2008-06-12 08:00:00',IL_CAL_DATETIME));

For fullday (no timezone conversion) events use:

            $dt_form->setDate(new ilDate('2008-08-01',IL_CAL_DATE));

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

Referenced by ilObjRemoteCourseGUI\addCustomEditForm(), ilObjRemoteGroupGUI\addCustomEditForm(), ilObjRemoteTestGUI\addCustomEditForm(), ilPersonalSkillsFilterGUI\addToToolbar(), checkInput(), ilUserTableGUI\initFilter(), ilPCSectionGUI\initForm(), ilSessionStatisticsGUI\long(), ilSessionStatisticsGUI\periodic(), setValueByArray(), ilSessionStatisticsGUI\short(), and unserializeData().

59  : void
60  {
61  $this->date = $a_date;
62  }
+ Here is the caller graph for this function:

◆ setMinuteStepSize()

ilDateTimeInputGUI::setMinuteStepSize ( int  $a_step_size)

Set minute step size E.g 5 => The selection will only show 00,05,10...

minutes

Parameters
int$a_step_sizeminute step_size 1,5,10,15,20...

Definition at line 94 of file class.ilDateTimeInputGUI.php.

94  : void
95  {
96  $this->minute_step_size = $a_step_size;
97  }

◆ setShowTime()

ilDateTimeInputGUI::setShowTime ( bool  $a_showtime)

◆ setSideBySide()

ilDateTimeInputGUI::setSideBySide ( bool  $a_val)

Definition at line 184 of file class.ilDateTimeInputGUI.php.

184  : void
185  {
186  // not relevant for native html date(time) pickers
187  }

◆ setStartYear()

ilDateTimeInputGUI::setStartYear ( int  $a_year)

Definition at line 79 of file class.ilDateTimeInputGUI.php.

79  : void
80  {
81  $this->startyear = $a_year;
82  }

◆ setValueByArray()

ilDateTimeInputGUI::setValueByArray ( array  $a_values)

Definition at line 107 of file class.ilDateTimeInputGUI.php.

References getDatePickerTimeFormat(), ilFormPropertyGUI\getPostVar(), ilSubEnabledFormPropertyGUI\getSubItems(), ilCalendarUtil\parseIncomingDate(), and setDate().

107  : void
108  {
109  $incoming = $a_values[$this->getPostVar()] ?? "";
110  $this->setDate(ilCalendarUtil::parseIncomingDate($incoming, (bool) $this->getDatePickerTimeFormat()));
111 
112  foreach ($this->getSubItems() as $item) {
113  $item->setValueByArray($a_values);
114  }
115  }
static parseIncomingDate($value, bool $add_time=false)
Try to parse incoming value to date object.
setDate(?ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
+ Here is the call graph for this function:

◆ unserializeData()

ilDateTimeInputGUI::unserializeData ( string  $a_data)

Definition at line 285 of file class.ilDateTimeInputGUI.php.

References getShowTime(), IL_CAL_UNIX, and setDate().

285  : void
286  {
287  $tmp = unserialize($a_data);
288  if ($tmp) {
289  // we used to serialize the complete instance
290  if (is_object($tmp)) {
291  $date = $tmp;
292  } else {
293  $date = $this->getShowTime()
294  ? new ilDateTime($tmp, IL_CAL_UNIX)
295  : new ilDate($tmp, IL_CAL_UNIX);
296  }
297  $this->setDate($date);
298  } else {
299  $this->setDate();
300  }
301  }
const IL_CAL_UNIX
setDate(?ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
+ Here is the call graph for this function:

Field Documentation

◆ $date

ilDateTime ilDateTimeInputGUI::$date = null
protected

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

Referenced by getDate().

◆ $invalid_input

string ilDateTimeInputGUI::$invalid_input = ''
protected

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

Referenced by hasInvalidInput().

◆ $minute_step_size

int ilDateTimeInputGUI::$minute_step_size = 5
protected

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

◆ $showtime

bool ilDateTimeInputGUI::$showtime = false
protected

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

Referenced by getShowTime().

◆ $side_by_side

bool ilDateTimeInputGUI::$side_by_side = true
protected

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

◆ $startyear

int ilDateTimeInputGUI::$startyear = null
protected

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

Referenced by getStartYear().

◆ $time

string ilDateTimeInputGUI::$time = "00:00:00"
protected

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

◆ $user

ilObjUser ilDateTimeInputGUI::$user
protected

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

Referenced by render().

◆ $valid

bool ilDateTimeInputGUI::$valid = false
protected

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

Referenced by checkInput().


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