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... 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...
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. 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 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

Reimplemented from ilFormPropertyGUI.

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

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

191 {
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 }
$_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 71 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 175 of file class.ilDateTimeInputGUI.php.

176 {
177 return (int) $this->getShowTime() + (int) $this->getShowSeconds();
178 }
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 135 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 371 of file class.ilDateTimeInputGUI.php.

372 {
373 // :TODO:
374 return trim($_POST[$this->getPostVar()]);
375 }

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 155 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 91 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 111 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 329 of file class.ilDateTimeInputGUI.php.

330 {
331 $html = $this->render();
332 return $html;
333 }
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 380 of file class.ilDateTimeInputGUI.php.

381 {
382 $html = $this->render("toolbar");
383 return $html;
384 }

References $html, and render().

+ Here is the call graph for this function:

◆ hasInvalidInput()

ilDateTimeInputGUI::hasInvalidInput ( )

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

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

References $invalid_input.

◆ hideSubForm()

ilDateTimeInputGUI::hideSubForm ( )

Sub form hidden on init?

Reimplemented from ilFormPropertyGUI.

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

387 {
388 return (!$this->getDate() || $this->getDate()->isNull());
389 }

References getDate().

+ 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.

318 {
319 $html = $this->render();
320
321 $a_tpl->setCurrentBlock("prop_generic");
322 $a_tpl->setVariable("PROP_GENERIC", $html);
323 $a_tpl->parseCurrentBlock();
324 }

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

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.

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

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,
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()) {
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 }
$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
$ilUser
Definition: imgupload.php:18

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

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

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

62 {
63 $this->date = $a_date;
64 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())

References date.

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

Set Show Time Information.

Parameters
boolean$a_showtimeShow Time Information

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

82 {
83 $this->showtime = $a_showtime;
84 }

◆ 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.

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

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

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 }
@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 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: