ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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... minutes. More...
 
 getMinuteStepSize ()
 Fixed to one minute increments, see https://mantis.ilias.de/view.php?id=42740. More...
 
 setValueByArray (array $a_values)
 
 hasInvalidInput ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 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)
 Get item by post var. More...
 
- 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
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. 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
Deprecated:
12 This component will be removed with ILIAS 12

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilFormPropertyGUI.

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

42 {
43 global $DIC;
44
45 $this->lng = $DIC->language();
46 $this->user = $DIC->user();
47 parent::__construct($a_title, $a_postvar);
48 $this->setType("datetime");
49 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilDateTimeInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilFormPropertyGUI.

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

128 : bool
129 {
131
132 if ($this->getDisabled()) {
133 return true;
134 }
135
136 $post = $this->str($this->getPostVar());
137
138 // always done to make sure there are no obsolete values left
139 $this->setDate(null);
140
141 $valid = false;
142 if (trim($post)) {
144 if ($parsed) {
145 $this->setDate($parsed);
146 $valid = true;
147 }
148 } elseif (!$this->getRequired()) {
149 $valid = true;
150 }
151
152 if ($valid &&
153 $this->getDate() &&
154 $this->getStartYear() &&
155 $this->getDate()->get(IL_CAL_FKT_DATE, "Y") < $this->getStartYear()) {
156 $valid = false;
157 }
158
159 $this->valid = $valid;
160
161 if (!$valid) {
162 $this->invalid_input = $post;
163 $this->setAlert($lng->txt("form_msg_wrong_date"));
164 }
165
166 if ($valid) {
167 $valid = $this->checkSubItemsInput();
168 }
169
170 return $valid;
171 }
const IL_CAL_FKT_DATE
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...
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...
$post
Definition: ltitoken.php:46

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

+ Here is the call graph for this function:

◆ getDate()

ilDateTimeInputGUI::getDate ( )

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

65 : ?ilDateTime
66 {
67 return $this->date;
68 }
@classDescription Date and time handling

References $date.

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

+ Here is the caller graph for this function:

◆ getDatePickerTimeFormat()

ilDateTimeInputGUI::getDatePickerTimeFormat ( )
protected

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

118 : int
119 {
120 return (int) $this->getShowTime();
121 }

References getShowTime().

Referenced by checkInput(), and setValueByArray().

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

◆ getDatetimeFormatForInput()

ilDateTimeInputGUI::getDatetimeFormatForInput ( )
protected

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

190 : string
191 {
192 $format = 'Y-m-d';
193 if ($this->getShowTime()) {
194 $format .= '\TH:i';
195 }
196 return $format;
197 }

References getShowTime().

Referenced by render().

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

◆ getInput()

ilDateTimeInputGUI::getInput ( )

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

173 : ?string
174 {
175 if ($this->valid && $this->getDate() !== null) {
176 // getInput() should return a generic format
177 $post_format = $this->getShowTime()
179 : IL_CAL_DATE;
180 return $this->getDate()->get($post_format);
181 }
182 return null;
183 }
const IL_CAL_DATE
const IL_CAL_DATETIME

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

+ 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 103 of file class.ilDateTimeInputGUI.php.

103 : int
104 {
105 return 1;
106 }

◆ getOnloadCode()

ilDateTimeInputGUI::getOnloadCode ( )

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

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

◆ getPostValueForComparison()

ilDateTimeInputGUI::getPostValueForComparison ( )

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

304 : string
305 {
306 return $this->serializeData();
307 }

References serializeData().

+ Here is the call graph for this function:

◆ getShowTime()

ilDateTimeInputGUI::getShowTime ( )

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

75 : bool
76 {
77 return $this->showtime;
78 }

References $showtime.

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

+ Here is the caller graph for this function:

◆ getStartYear()

ilDateTimeInputGUI::getStartYear ( )

Reimplemented in ilBirthdayInputGUI.

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

85 : ?int
86 {
87 return $this->startyear;
88 }

References $startyear.

Referenced by checkInput(), and render().

+ 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 272 of file class.ilDateTimeInputGUI.php.

272 : string
273 {
274 $html = $this->render();
275 return $html;
276 }

References render().

+ 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 309 of file class.ilDateTimeInputGUI.php.

309 : string
310 {
311 $html = $this->render();
312 return $html;
313 }

References render().

+ Here is the call graph for this function:

◆ hasInvalidInput()

ilDateTimeInputGUI::hasInvalidInput ( )

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

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

References $invalid_input.

◆ hideSubForm()

ilDateTimeInputGUI::hideSubForm ( )

Reimplemented from ilFormPropertyGUI.

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

315 : bool
316 {
317 return (!$this->getDate() || $this->getDate()->isNull());
318 }

References getDate().

+ Here is the call graph for this function:

◆ insert()

ilDateTimeInputGUI::insert ( ilTemplate  $a_tpl)

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

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

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

+ Here is the call graph for this function:

◆ render()

ilDateTimeInputGUI::render ( )

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

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

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().

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

◆ serializeData()

ilDateTimeInputGUI::serializeData ( )

Reimplemented from ilFormPropertyGUI.

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

278 : string
279 {
280 if ($this->getDate()) {
281 return serialize($this->getDate()->get(IL_CAL_UNIX));
282 }
283 return "";
284 }
const IL_CAL_UNIX

References getDate(), and IL_CAL_UNIX.

Referenced by getPostValueForComparison().

+ 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 60 of file class.ilDateTimeInputGUI.php.

60 : void
61 {
62 $this->date = $a_date;
63 }

Referenced by checkInput(), setValueByArray(), and unserializeData().

+ 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 95 of file class.ilDateTimeInputGUI.php.

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

◆ setShowTime()

ilDateTimeInputGUI::setShowTime ( bool  $a_showtime)

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

70 : void
71 {
72 $this->showtime = $a_showtime;
73 }

◆ setSideBySide()

ilDateTimeInputGUI::setSideBySide ( bool  $a_val)

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

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

◆ setStartYear()

ilDateTimeInputGUI::setStartYear ( int  $a_year)

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

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

◆ setValueByArray()

ilDateTimeInputGUI::setValueByArray ( array  $a_values)

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

108 : void
109 {
110 $incoming = $a_values[$this->getPostVar()] ?? "";
111 $this->setDate(ilCalendarUtil::parseIncomingDate($incoming, (bool) $this->getDatePickerTimeFormat()));
112
113 foreach ($this->getSubItems() as $item) {
114 $item->setValueByArray($a_values);
115 }
116 }

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

+ Here is the call graph for this function:

◆ unserializeData()

ilDateTimeInputGUI::unserializeData ( string  $a_data)

Reimplemented from ilFormPropertyGUI.

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

286 : void
287 {
288 $tmp = unserialize($a_data);
289 if ($tmp) {
290 // we used to serialize the complete instance
291 if (is_object($tmp)) {
292 $date = $tmp;
293 } else {
294 $date = $this->getShowTime()
295 ? new ilDateTime($tmp, IL_CAL_UNIX)
296 : new ilDate($tmp, IL_CAL_UNIX);
297 }
298 $this->setDate($date);
299 } else {
300 $this->setDate();
301 }
302 }
Class for single dates.

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

+ Here is the call graph for this function:

Field Documentation

◆ $date

ilDateTime ilDateTimeInputGUI::$date = null
protected

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

Referenced by getDate(), and unserializeData().

◆ $invalid_input

string ilDateTimeInputGUI::$invalid_input = ''
protected

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

Referenced by hasInvalidInput().

◆ $minute_step_size

int ilDateTimeInputGUI::$minute_step_size = 5
protected

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

◆ $showtime

bool ilDateTimeInputGUI::$showtime = false
protected

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

Referenced by getShowTime().

◆ $side_by_side

bool ilDateTimeInputGUI::$side_by_side = true
protected

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

◆ $startyear

int ilDateTimeInputGUI::$startyear = null
protected

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

Referenced by getStartYear().

◆ $time

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

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

◆ $user

ilObjUser ilDateTimeInputGUI::$user
protected

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

Referenced by render().

◆ $valid

bool ilDateTimeInputGUI::$valid = false
protected

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

Referenced by checkInput().


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