ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

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

31 {
32 parent::__construct($a_title, $a_postvar);
33 $this->setType("datetime");
34 }
setType($a_type)
Set Type.

References ilFormPropertyGUI\setType().

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

178 {
179 global $lng;
180
181 if ($this->getDisabled())
182 {
183 return true;
184 }
185
186 $post = $_POST[$this->getPostVar()];
187
188 // always done to make sure there are no obsolete values left
189 $this->setDate(null);
190
191 $valid = false;
192 if(trim($post))
193 {
195 if($parsed)
196 {
197 $this->setDate($parsed);
198 $valid = true;
199 }
200 }
201 else if(!$this->getRequired())
202 {
203 $valid = true;
204 }
205
206 if($valid &&
207 $this->getDate() &&
208 $this->getStartYear() &&
209 $this->getDate()->get(IL_CAL_FKT_DATE, "Y") < $this->getStartYear())
210 {
211 $valid = false;
212 }
213
214 if(!$valid)
215 {
216 $this->invalid_input = $post;
217 $_POST[$this->getPostVar()] = null;
218
219 $this->setAlert($lng->txt("form_msg_wrong_date"));
220 }
221 else
222 {
223 if($this->getDate() !== null)
224 {
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 }
231 else
232 {
233 $_POST[$this->getPostVar()] = null;
234 }
235 }
236
237 if($valid)
238 {
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.
setDate(ilDateTime $a_date=NULL)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
getDate()
Get Date, yyyy-mm-dd.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
$valid
global $lng
Definition: privfeed.php:17

References $_POST, $lng, $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 57 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 162 of file class.ilDateTimeInputGUI.php.

163 {
164 return (int)$this->getShowTime() + (int)$this->getShowSeconds();
165 }
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 121 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 385 of file class.ilDateTimeInputGUI.php.

386 {
387 // :TODO:
388 return trim($_POST[$this->getPostVar()]);
389 }

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 141 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 77 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 97 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 336 of file class.ilDateTimeInputGUI.php.

337 {
338 $html = $this->render();
339 return $html;
340 }
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 394 of file class.ilDateTimeInputGUI.php.

395 {
396 $html = $this->render("toolbar");
397 return $html;
398 }

References $html, and render().

+ Here is the call graph for this function:

◆ hasInvalidInput()

ilDateTimeInputGUI::hasInvalidInput ( )

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

168 {
169 return (bool)$this->invalid_input;
170 }

References $invalid_input.

◆ hideSubForm()

ilDateTimeInputGUI::hideSubForm ( )

Sub form hidden on init?

Reimplemented from ilFormPropertyGUI.

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

401 {
402 return (!$this->getDate() || $this->getDate()->isNull());
403 }

References getDate().

+ Here is the call graph for this function:

◆ insert()

ilDateTimeInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

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

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

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 {
255 $config['stepping'] = (int)$this->getMinuteStepSize();
256 }
257 if($this->getStartYear())
258 {
259 $config['minDate'] = $this->getStartYear().'-01-01';
260 }
261 return $config;
262 }
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 268 of file class.ilDateTimeInputGUI.php.

269 {
270 global $ilUser;
271
272 $tpl = new ilTemplate("tpl.prop_datetime.html", true, true, "Services/Form");
273
274 // config picker
275 if(!$this->getDisabled())
276 {
277 $picker_id = md5($this->getPostVar()); // :TODO: unique?
278 $tpl->setVariable('DATEPICKER_ID', $picker_id);
279
281 $picker_id,
283 $this->parseDatePickerConfig(),
284 null,
285 null,
286 null,
287 "subform_".$this->getPostVar()
288 );
289 }
290 else
291 {
292 $tpl->setVariable('DATEPICKER_DISABLED', 'disabled="disabled" ');
293 }
294
295 // :TODO: i18n?
297 $tpl->setVariable('PLACEHOLDER', $pl_format);
298
299 // current value
300 $date_value = htmlspecialchars($this->invalid_input);
301 if(!$date_value &&
302 $this->getDate())
303 {
304 $out_format = ilCalendarUtil::getUserDateFormat($this->getDatePickerTimeFormat(), true);
305 $date_value = $this->getDate()->get(IL_CAL_FKT_DATE, $out_format, $ilUser->getTimeZone());
306 }
307
308 $tpl->setVariable('DATEPICKER_VALUE', $date_value);
309 $tpl->setVariable('DATE_ID', $this->getPostVar());
310
311 if($this->getRequired())
312 {
313 $tpl->setVariable("REQUIRED", "required=\"required\"");
314 }
315
316 return $tpl->get();
317 }
global $tpl
Definition: ilias.php:8
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, 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 345 of file class.ilDateTimeInputGUI.php.

346 {
347 if($this->getDate())
348 {
349 return serialize($this->getDate()->get(IL_CAL_UNIX));
350 }
351 }
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 47 of file class.ilDateTimeInputGUI.php.

48 {
49 $this->date = $a_date;
50 }
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 110 of file class.ilDateTimeInputGUI.php.

111 {
112 $this->minute_step_size = $a_step_size;
113 }

◆ setShowSeconds()

ilDateTimeInputGUI::setShowSeconds (   $a_showseconds)

Set Show Seconds.

Parameters
boolean$a_showsecondsShow Seconds

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

132 {
133 $this->showseconds = $a_showseconds;
134 }

◆ setShowTime()

ilDateTimeInputGUI::setShowTime (   $a_showtime)

Set Show Time Information.

Parameters
boolean$a_showtimeShow Time Information

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

68 {
69 $this->showtime = $a_showtime;
70 }

◆ setStartYear()

ilDateTimeInputGUI::setStartYear (   $a_year)

Set start year.

Parameters
integerStart year

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

88 {
89 $this->startyear = $a_year;
90 }

◆ setValueByArray()

ilDateTimeInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

152 {
153 $incoming = $a_values[$this->getPostVar()];
155
156 foreach($this->getSubItems() as $item)
157 {
158 $item->setValueByArray($a_values);
159 }
160 }

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

357 {
358 $tmp = unserialize($a_data);
359 if($tmp)
360 {
361 // we used to serialize the complete instance
362 if(is_object($tmp))
363 {
364 $date = $tmp;
365 }
366 else
367 {
368 $date = $this->getShowTime()
369 ? new ilDateTime($tmp, IL_CAL_UNIX)
370 : new ilDate($tmp, IL_CAL_UNIX);
371 }
372 $this->setDate($date);
373 }
374 else
375 {
376 $this->setDate(null);
377 }
378 }
@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 16 of file class.ilDateTimeInputGUI.php.

Referenced by getDate(), and unserializeData().

◆ $invalid_input

ilDateTimeInputGUI::$invalid_input = ''
protected

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

Referenced by hasInvalidInput().

◆ $minute_step_size

ilDateTimeInputGUI::$minute_step_size = 5
protected

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

Referenced by getMinuteStepSize().

◆ $showseconds

ilDateTimeInputGUI::$showseconds = false
protected

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

Referenced by getShowSeconds().

◆ $showtime

ilDateTimeInputGUI::$showtime = false
protected

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

Referenced by getShowTime().

◆ $startyear

ilDateTimeInputGUI::$startyear = ''
protected

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

Referenced by getStartYear().

◆ $time

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

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


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