ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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... 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 ()
 
- 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...
 

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

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

References $DIC, ilFormPropertyGUI\setType(), and 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: saml.php:7
user()
Definition: user.php:4
setType($a_type)
Set Type.
+ 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

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

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

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

References $date.

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

72  {
73  return $this->date;
74  }
+ Here is the caller graph for this function:

◆ getDatePickerTimeFormat()

ilDateTimeInputGUI::getDatePickerTimeFormat ( )
protected

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

References getShowSeconds(), and getShowTime().

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

176  {
177  return (int) $this->getShowTime() + (int) $this->getShowSeconds();
178  }
getShowTime()
Get Show Time Information.
getShowSeconds()
Get Show Seconds.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMinuteStepSize()

ilDateTimeInputGUI::getMinuteStepSize ( )

Get minute step size.

public

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

References $minute_step_size.

Referenced by parseDatePickerConfig().

136  {
138  }
+ 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 371 of file class.ilDateTimeInputGUI.php.

References $_POST, and ilFormPropertyGUI\getPostVar().

372  {
373  // :TODO:
374  return trim($_POST[$this->getPostVar()]);
375  }
getPostVar()
Get Post Variable.
$_POST["username"]
+ Here is the call graph for this function:

◆ getShowSeconds()

ilDateTimeInputGUI::getShowSeconds ( )

Get Show Seconds.

Returns
boolean Show Seconds

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

References $showseconds.

Referenced by getDatePickerTimeFormat().

156  {
157  return $this->showseconds;
158  }
+ Here is the caller graph for this function:

◆ getShowTime()

ilDateTimeInputGUI::getShowTime ( )

Get Show Time Information.

Returns
boolean Show Time Information

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

References $showtime.

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

92  {
93  return $this->showtime;
94  }
+ Here is the caller graph for this function:

◆ getStartYear()

ilDateTimeInputGUI::getStartYear ( )

Get start year.

Returns
integer Start year

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

References $startyear.

Referenced by checkInput(), and parseDatePickerConfig().

112  {
113  return $this->startyear;
114  }
+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilDateTimeInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

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

References $html, and render().

330  {
331  $html = $this->render();
332  return $html;
333  }
render()
Insert property html.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ getToolbarHTML()

ilDateTimeInputGUI::getToolbarHTML ( )

Get HTML for toolbar.

Implements ilToolbarItem.

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

References $html, and render().

381  {
382  $html = $this->render("toolbar");
383  return $html;
384  }
render()
Insert property html.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ hasInvalidInput()

ilDateTimeInputGUI::hasInvalidInput ( )

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

References $invalid_input.

181  {
182  return (bool) $this->invalid_input;
183  }

◆ hideSubForm()

ilDateTimeInputGUI::hideSubForm ( )

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

References getDate().

387  {
388  return (!$this->getDate() || $this->getDate()->isNull());
389  }
getDate()
Get Date, yyyy-mm-dd.
+ Here is the call graph for this function:

◆ insert()

ilDateTimeInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

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

References $html, and render().

318  {
319  $html = $this->render();
320 
321  $a_tpl->setCurrentBlock("prop_generic");
322  $a_tpl->setVariable("PROP_GENERIC", $html);
323  $a_tpl->parseCurrentBlock();
324  }
render()
Insert property html.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ parseDatePickerConfig()

ilDateTimeInputGUI::parseDatePickerConfig ( )
protected

parse properties to datepicker config

Returns
array

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

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

Referenced by render().

251  {
252  $config = null;
253  if ($this->getMinuteStepSize()) {
254  $config['stepping'] = (int) $this->getMinuteStepSize();
255  }
256  if ($this->getStartYear()) {
257  $config['minDate'] = $this->getStartYear() . '-01-01';
258  }
259  return $config;
260  }
getMinuteStepSize()
Get minute step size.
getStartYear()
Get start year.
+ 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 266 of file class.ilDateTimeInputGUI.php.

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

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

267  {
269 
270  $tpl = new ilTemplate("tpl.prop_datetime.html", true, true, "Services/Form");
271 
272  // config picker
273  if (!$this->getDisabled()) {
274  $picker_id = md5($this->getPostVar()); // :TODO: unique?
275  $tpl->setVariable('DATEPICKER_ID', $picker_id);
276 
278  $picker_id,
279  $this->getDatePickerTimeFormat(),
280  $this->parseDatePickerConfig(),
281  null,
282  null,
283  null,
284  "subform_" . $this->getPostVar()
285  );
286  } else {
287  $tpl->setVariable('DATEPICKER_DISABLED', 'disabled="disabled" ');
288  }
289 
290  // :TODO: i18n?
292  $tpl->setVariable('PLACEHOLDER', $pl_format);
293 
294  // current value
295  $date_value = htmlspecialchars($this->invalid_input);
296  if (!$date_value &&
297  $this->getDate()) {
298  $out_format = ilCalendarUtil::getUserDateFormat($this->getDatePickerTimeFormat(), true);
299  $date_value = $this->getDate()->get(IL_CAL_FKT_DATE, $out_format, $ilUser->getTimeZone());
300  }
301 
302  $tpl->setVariable('DATEPICKER_VALUE', $date_value);
303  $tpl->setVariable('DATE_ID', $this->getPostVar());
304 
305  if ($this->getRequired()) {
306  $tpl->setVariable("REQUIRED", "required=\"required\"");
307  }
308 
309  return $tpl->get();
310  }
parseDatePickerConfig()
parse properties to datepicker config
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
getDate()
Get Date, yyyy-mm-dd.
static getUserDateFormat($a_add_time=false, $a_for_parsing=false)
Parse current user setting into date/time format.
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.
special template class to simplify handling of ITX/PEAR
const IL_CAL_FKT_DATE
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serializeData()

ilDateTimeInputGUI::serializeData ( )

serialize data

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

References getDate(), and IL_CAL_UNIX.

339  {
340  if ($this->getDate()) {
341  return serialize($this->getDate()->get(IL_CAL_UNIX));
342  }
343  }
getDate()
Get Date, yyyy-mm-dd.
const 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 61 of file class.ilDateTimeInputGUI.php.

References date.

Referenced by arEditGUI\addDateTimeInputField(), checkInput(), ilUserTableGUI\initFilter(), ilCalendarAppointmentGUI\initForm(), ilPCSectionGUI\initForm(), ilObjSurveyGUI\initPropertiesForm(), ilSessionStatisticsGUI\long(), ilSessionStatisticsGUI\periodic(), setValueByArray(), ilSessionStatisticsGUI\short(), and unserializeData().

62  {
63  $this->date = $a_date;
64  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
+ 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

public

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

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

125  {
126  $this->minute_step_size = $a_step_size;
127  }

◆ setShowSeconds()

ilDateTimeInputGUI::setShowSeconds (   $a_showseconds)

Set Show Seconds.

Parameters
boolean$a_showsecondsShow Seconds

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

146  {
147  $this->showseconds = $a_showseconds;
148  }

◆ setShowTime()

ilDateTimeInputGUI::setShowTime (   $a_showtime)

◆ setStartYear()

ilDateTimeInputGUI::setStartYear (   $a_year)

Set start year.

Parameters
integerStart year

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

102  {
103  $this->startyear = $a_year;
104  }

◆ setValueByArray()

ilDateTimeInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

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

166  {
167  $incoming = $a_values[$this->getPostVar()];
169 
170  foreach ($this->getSubItems() as $item) {
171  $item->setValueByArray($a_values);
172  }
173  }
getPostVar()
Get Post Variable.
setDate(ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.
+ Here is the call graph for this function:

◆ unserializeData()

ilDateTimeInputGUI::unserializeData (   $a_data)

unserialize data

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

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

349  {
350  $tmp = unserialize($a_data);
351  if ($tmp) {
352  // we used to serialize the complete instance
353  if (is_object($tmp)) {
354  $date = $tmp;
355  } else {
356  $date = $this->getShowTime()
357  ? new ilDateTime($tmp, IL_CAL_UNIX)
358  : new ilDate($tmp, IL_CAL_UNIX);
359  }
360  $this->setDate($date);
361  } else {
362  $this->setDate(null);
363  }
364  }
const IL_CAL_UNIX
getShowTime()
Get Show Time Information.
Class for single dates.
setDate(ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
Date and time handling
+ Here is the call graph for this function:

Field Documentation

◆ $date

ilDateTimeInputGUI::$date
protected

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

Referenced by getDate(), and unserializeData().

◆ $invalid_input

ilDateTimeInputGUI::$invalid_input = ''
protected

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

Referenced by hasInvalidInput().

◆ $lng

ilDateTimeInputGUI::$lng
protected

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

Referenced by checkInput().

◆ $minute_step_size

ilDateTimeInputGUI::$minute_step_size = 5
protected

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

Referenced by getMinuteStepSize().

◆ $showseconds

ilDateTimeInputGUI::$showseconds = false
protected

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

Referenced by getShowSeconds().

◆ $showtime

ilDateTimeInputGUI::$showtime = false
protected

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

Referenced by getShowTime().

◆ $startyear

ilDateTimeInputGUI::$startyear = ''
protected

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

Referenced by getStartYear().

◆ $time

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

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

◆ $user

ilDateTimeInputGUI::$user
protected

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

Referenced by render().


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