ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ($a_title="", $a_postvar="")
 Constructor. More...
 
 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 ()
 Get Date, yyyy-mm-dd. More...
 
 setShowTime ($a_showtime)
 Set Show Time Information. More...
 
 getShowTime ()
 Get Show Time Information. More...
 
 setStartYear ($a_year)
 Set start year. More...
 
 getStartYear ()
 Get start year. More...
 
 setMinuteStepSize ($a_step_size)
 Set minute step size E.g 5 => The selection will only show 00,05,10... minutes. More...
 
 getMinuteStepSize ()
 Get minute step size. More...
 
 setShowSeconds ($a_showseconds)
 Set Show Seconds. More...
 
 getShowSeconds ()
 Get Show Seconds. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 hasInvalidInput ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 render ()
 Insert property html. More...
 
 insert ($a_tpl)
 Insert property html. More...
 
 getTableFilterHTML ()
 Get HTML for table filter. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 getPostValueForComparison ()
 parse post value to make it comparable More...
 
 getToolbarHTML ()
 Get HTML for toolbar. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback ($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...
 
- 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 ()
 
 parseDatePickerConfig ()
 parse properties to datepicker config More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Protected Attributes

 $lng
 
 $user
 
 $date
 
 $time = "00:00:00"
 
 $showtime = false
 
 $showseconds = false
 
 $minute_step_size = 5
 
 $startyear = ''
 
 $invalid_input = ''
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $ctrl
 
 $lng
 
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

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

Detailed Description

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

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFormPropertyGUI.

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

38 {
39 global $DIC;
40
41 $this->lng = $DIC->language();
42 $this->user = $DIC->user();
43 parent::__construct($a_title, $a_postvar);
44 $this->setType("datetime");
45 }
user()
Definition: user.php:4
setType($a_type)
Set Type.
global $DIC
Definition: saml.php:7

References $DIC, ilFormPropertyGUI\setType(), and 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.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

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

188 {
190
191 if ($this->getDisabled()) {
192 return true;
193 }
194
195 $post = $_POST[$this->getPostVar()];
196
197 // always done to make sure there are no obsolete values left
198 $this->setDate(null);
199
200 $valid = false;
201 if (trim($post)) {
203 if ($parsed) {
204 $this->setDate($parsed);
205 $valid = true;
206 }
207 } elseif (!$this->getRequired()) {
208 $valid = true;
209 }
210
211 if ($valid &&
212 $this->getDate() &&
213 $this->getStartYear() &&
214 $this->getDate()->get(IL_CAL_FKT_DATE, "Y") < $this->getStartYear()) {
215 $valid = false;
216 }
217
218 if (!$valid) {
219 $this->invalid_input = $post;
220 $_POST[$this->getPostVar()] = null;
221
222 $this->setAlert($lng->txt("form_msg_wrong_date"));
223 } else {
224 if ($this->getDate() !== null) {
225 // getInput() should return a generic format
226 $post_format = $this->getShowTime()
228 : IL_CAL_DATE;
229 $_POST[$this->getPostVar()] = $this->getDate()->get($post_format);
230 } else {
231 $_POST[$this->getPostVar()] = null;
232 }
233 }
234
235 if ($valid) {
236 $valid = $this->checkSubItemsInput();
237 }
238
239 return $valid;
240 }
$_POST["username"]
const IL_CAL_DATE
const IL_CAL_DATETIME
const IL_CAL_FKT_DATE
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.
getShowTime()
Get Show Time Information.
getDate()
Get Date, yyyy-mm-dd.
setDate(ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
$valid
$post
Definition: post.php:34

References $_POST, $lng, $post, $valid, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), getDate(), getDatePickerTimeFormat(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), getShowTime(), getStartYear(), IL_CAL_DATE, IL_CAL_DATETIME, IL_CAL_FKT_DATE, ilCalendarUtil\parseIncomingDate(), ilFormPropertyGUI\setAlert(), and setDate().

+ Here is the call graph for this function:

◆ getDate()

ilDateTimeInputGUI::getDate ( )

Get Date, yyyy-mm-dd.

Returns
object Date, yyyy-mm-dd

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

References $date.

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

+ Here is the caller graph for this function:

◆ getDatePickerTimeFormat()

ilDateTimeInputGUI::getDatePickerTimeFormat ( )
protected

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

173 {
174 return (int) $this->getShowTime() + (int) $this->getShowSeconds();
175 }
getShowSeconds()
Get Show Seconds.

References getShowSeconds(), and getShowTime().

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

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

◆ getMinuteStepSize()

ilDateTimeInputGUI::getMinuteStepSize ( )

Get minute step size.

@access public

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

References $minute_step_size.

Referenced by parseDatePickerConfig().

+ Here is the caller graph for this function:

◆ getPostValueForComparison()

ilDateTimeInputGUI::getPostValueForComparison ( )

parse post value to make it comparable

used by combination input gui

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

376 {
377 // :TODO:
378 return trim($_POST[$this->getPostVar()]);
379 }

References $_POST, and ilFormPropertyGUI\getPostVar().

+ Here is the call graph for this function:

◆ getShowSeconds()

ilDateTimeInputGUI::getShowSeconds ( )

Get Show Seconds.

Returns
boolean Show Seconds

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

References $showseconds.

Referenced by getDatePickerTimeFormat().

+ Here is the caller graph for this function:

◆ getShowTime()

ilDateTimeInputGUI::getShowTime ( )

Get Show Time Information.

Returns
boolean Show Time Information

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

References $showtime.

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

+ Here is the caller graph for this function:

◆ getStartYear()

ilDateTimeInputGUI::getStartYear ( )

Get start year.

Returns
integer Start year

Reimplemented in ilBirthdayInputGUI.

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

References $startyear.

Referenced by checkInput(), and parseDatePickerConfig().

+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilDateTimeInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

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

334 {
335 $html = $this->render();
336 return $html;
337 }
render()
Insert property html.
$html
Definition: example_001.php:87

References $html, and render().

+ Here is the call graph for this function:

◆ getToolbarHTML()

ilDateTimeInputGUI::getToolbarHTML ( )

Get HTML for toolbar.

Implements ilToolbarItem.

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

385 {
386 $html = $this->render("toolbar");
387 return $html;
388 }

References $html, and render().

+ Here is the call graph for this function:

◆ hasInvalidInput()

ilDateTimeInputGUI::hasInvalidInput ( )

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

178 {
179 return (bool) $this->invalid_input;
180 }

References $invalid_input.

◆ hideSubForm()

ilDateTimeInputGUI::hideSubForm ( )

Sub form hidden on init?

Reimplemented from ilFormPropertyGUI.

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

391 {
392 return (!$this->getDate() || $this->getDate()->isNull());
393 }

References getDate().

+ Here is the call graph for this function:

◆ insert()

ilDateTimeInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

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

322 {
323 $html = $this->render();
324
325 $a_tpl->setCurrentBlock("prop_generic");
326 $a_tpl->setVariable("PROP_GENERIC", $html);
327 $a_tpl->parseCurrentBlock();
328 }

References $html, and render().

+ Here is the call graph for this function:

◆ parseDatePickerConfig()

ilDateTimeInputGUI::parseDatePickerConfig ( )
protected

parse properties to datepicker config

Returns
array

Reimplemented in ilBirthdayInputGUI.

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

248 {
249 $config = null;
250 if ($this->getMinuteStepSize()) {
251 $config['stepping'] = (int) $this->getMinuteStepSize();
252 }
253 if ($this->getStartYear()) {
254 $config['minDate'] = $this->getStartYear() . '-01-01';
255 }
256 return $config;
257 }
getMinuteStepSize()
Get minute step size.
$config
Definition: bootstrap.php:15

References $config, getMinuteStepSize(), and getStartYear().

Referenced by render().

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

◆ render()

ilDateTimeInputGUI::render ( )

Insert property html.

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

264 {
267
268 $tpl = new ilTemplate("tpl.prop_datetime.html", true, true, "Services/Form");
269
270 // config picker
271 if (!$this->getDisabled()) {
272 $picker_id = md5($this->getPostVar()); // :TODO: unique?
273 $tpl->setVariable('DATEPICKER_ID', $picker_id);
274
276 $picker_id,
278 $this->parseDatePickerConfig(),
279 null,
280 null,
281 null,
282 "subform_" . $this->getPostVar()
283 );
284 } else {
285 $tpl->setVariable('DATEPICKER_DISABLED', 'disabled="disabled" ');
286 }
287
288 // :TODO: i18n?
290 $tpl->setVariable('PLACEHOLDER', $pl_format);
291
292 // accessibility description
293 $tpl->setVariable(
294 'DESCRIPTION',
295 ilUtil::prepareFormOutput($lng->txt("form_date_aria_desc") . " " . $pl_format)
296 );
297
298 // current value
299 $date_value = htmlspecialchars($this->invalid_input);
300 if (!$date_value &&
301 $this->getDate()) {
303 $date_value = $this->getDate()->get(IL_CAL_FKT_DATE, $out_format, $ilUser->getTimeZone());
304 }
305
306 $tpl->setVariable('DATEPICKER_VALUE', $date_value);
307 $tpl->setVariable('DATE_ID', $this->getPostVar());
308
309 if ($this->getRequired()) {
310 $tpl->setVariable("REQUIRED", "required=\"required\"");
311 }
312
313 return $tpl->get();
314 }
$tpl
Definition: ilias.php:10
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.
static getUserDateFormat($a_add_time=false, $a_for_parsing=false)
Parse current user setting into date/time format.
parseDatePickerConfig()
parse properties to datepicker config
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$ilUser
Definition: imgupload.php:18

References $ilUser, $lng, $tpl, $user, ilCalendarUtil\addDateTimePicker(), getDate(), getDatePickerTimeFormat(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilCalendarUtil\getUserDateFormat(), IL_CAL_FKT_DATE, parseDatePickerConfig(), and ilUtil\prepareFormOutput().

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

serialize data

Reimplemented from ilFormPropertyGUI.

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

343 {
344 if ($this->getDate()) {
345 return serialize($this->getDate()->get(IL_CAL_UNIX));
346 }
347 }
const IL_CAL_UNIX

References getDate(), and IL_CAL_UNIX.

+ Here is the call 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));
Parameters
object$a_dateilDate or ilDateTime object

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

59 {
60 $this->date = $a_date;
61 }

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

+ Here is the caller graph for this function:

◆ setMinuteStepSize()

ilDateTimeInputGUI::setMinuteStepSize (   $a_step_size)

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

@access public

Parameters
intminute step_size 1,5,10,15,20...

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

122 {
123 $this->minute_step_size = $a_step_size;
124 }

◆ setShowSeconds()

ilDateTimeInputGUI::setShowSeconds (   $a_showseconds)

Set Show Seconds.

Parameters
boolean$a_showsecondsShow Seconds

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

143 {
144 $this->showseconds = $a_showseconds;
145 }

◆ setShowTime()

ilDateTimeInputGUI::setShowTime (   $a_showtime)

Set Show Time Information.

Parameters
boolean$a_showtimeShow Time Information

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

79 {
80 $this->showtime = $a_showtime;
81 }

◆ setStartYear()

ilDateTimeInputGUI::setStartYear (   $a_year)

Set start year.

Parameters
integerStart year

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

99 {
100 $this->startyear = $a_year;
101 }

◆ setValueByArray()

ilDateTimeInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

163 {
164 $incoming = $a_values[$this->getPostVar()];
166
167 foreach ($this->getSubItems() as $item) {
168 $item->setValueByArray($a_values);
169 }
170 }

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

+ Here is the call graph for this function:

◆ unserializeData()

ilDateTimeInputGUI::unserializeData (   $a_data)

unserialize data

Reimplemented from ilFormPropertyGUI.

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

353 {
354 $tmp = unserialize($a_data);
355 if ($tmp) {
356 // we used to serialize the complete instance
357 if (is_object($tmp)) {
358 $date = $tmp;
359 } else {
360 $date = $this->getShowTime()
361 ? new ilDateTime($tmp, IL_CAL_UNIX)
362 : new ilDate($tmp, IL_CAL_UNIX);
363 }
364 $this->setDate($date);
365 } else {
366 $this->setDate(null);
367 }
368 }
@classDescription Date and time handling
Class for single dates.

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

+ Here is the call graph for this function:

Field Documentation

◆ $date

ilDateTimeInputGUI::$date
protected

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

Referenced by getDate(), and unserializeData().

◆ $invalid_input

ilDateTimeInputGUI::$invalid_input = ''
protected

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

Referenced by hasInvalidInput().

◆ $lng

ilDateTimeInputGUI::$lng
protected

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

Referenced by checkInput(), and render().

◆ $minute_step_size

ilDateTimeInputGUI::$minute_step_size = 5
protected

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

Referenced by getMinuteStepSize().

◆ $showseconds

ilDateTimeInputGUI::$showseconds = false
protected

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

Referenced by getShowSeconds().

◆ $showtime

ilDateTimeInputGUI::$showtime = false
protected

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

Referenced by getShowTime().

◆ $startyear

ilDateTimeInputGUI::$startyear = ''
protected

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

Referenced by getStartYear().

◆ $time

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

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

◆ $user

ilDateTimeInputGUI::$user
protected

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

Referenced by render().


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