ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
ilADTDateTimeFormBridge Class Reference
+ Inheritance diagram for ilADTDateTimeFormBridge:
+ Collaboration diagram for ilADTDateTimeFormBridge:

Public Member Functions

 setTextInputMode ($a_value)
 
 addToForm ()
 
 importFromPost ()
 
 validate ()
 
- Public Member Functions inherited from ilADTFormBridge
 __construct (ilADT $a_adt)
 Constructor. More...
 
 getADT ()
 Get ADT. More...
 
 setForm (ilPropertyFormGUI $a_form)
 Set form. More...
 
 getForm ()
 Get form. More...
 
 setElementId ($a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 Get element id. More...
 
 setTitle ($a_value)
 Set title (aka form field caption) More...
 
 getTitle ()
 Get title. More...
 
 setInfo ($a_value)
 Set info (aka form field info text) More...
 
 getInfo ()
 Get info. More...
 
 setParentElement ($a_value)
 Set parent element. More...
 
 getParentElement ()
 Get parent element. More...
 
 setDisabled ($a_value)
 Set disabled. More...
 
 isDisabled ()
 Get disabled. More...
 
 setRequired ($a_value)
 Set required. More...
 
 isRequired ()
 Get required. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 addJS (ilTemplate $a_tpl)
 Add ADT-specific JS-files to template. More...
 
 shouldBeImportedFromPost (ilADTFormBridge $a_parent_adt=null)
 Check if incoming values should be imported at all. More...
 
 importFromPost ()
 Import values from form request POST data. More...
 
 validate ()
 Validate ADT and parse error codes. More...
 
 setExternalErrors ($a_errors)
 

Protected Member Functions

 isValidADT (ilADT $a_adt)
 
- Protected Member Functions inherited from ilADTFormBridge
 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 setADT (ilADT $a_adt)
 Set ADT. More...
 
 addBasicFieldProperties (ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
 Helper method to handle generic properties like setRequired(), setInfo() More...
 
 findParentElementInForm ()
 Try to find parent element in form (could be option) More...
 
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element. More...
 
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s) More...
 

Protected Attributes

 $invalid_input
 
 $text_input
 
- Protected Attributes inherited from ilADTFormBridge
 $adt
 
 $form
 
 $id
 
 $title
 
 $info
 
 $parent_element
 
 $required
 
 $disabled
 

Detailed Description

Definition at line 5 of file class.ilADTDateTimeFormBridge.php.

Member Function Documentation

◆ addToForm()

ilADTDateTimeFormBridge::addToForm ( )

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

References $lng, ilADTFormBridge\addBasicFieldProperties(), ilADTFormBridge\addToParentElement(), ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), ilADTFormBridge\getTitle(), ilADTFormBridge\isRequired(), and ilDateTimeInputGUI\MODE_INPUT.

21  {
22  global $lng;
23 
24  $adt_date = $this->getADT()->getDate();
25 
26  $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
27  $date->setShowTime(true);
28 
29  $this->addBasicFieldProperties($date, $this->getADT()->getCopyOfDefinition());
30 
31  if((bool)$this->text_input)
32  {
33  $date->setMode(ilDateTimeInputGUI::MODE_INPUT);
34  }
35  else
36  {
37  if(!$this->isRequired())
38  {
39  $date->enableDateActivation("", $this->getElementId()."_tgl", !(!$adt_date || $adt_date->isNull()));
40  }
41  }
42 
43  $date->setDate($adt_date);
44 
45  $this->addToParentElement($date);
46  }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
isRequired()
Get required.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
This class represents a date/time property in a property form.
getElementId()
Get element id.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateTimeFormBridge::importFromPost ( )

Definition at line 48 of file class.ilADTDateTimeFormBridge.php.

References $_POST, ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), ilADTFormBridge\getForm(), IL_CAL_DATETIME, and ilADTFormBridge\isRequired().

49  {
50  $field = $this->getForm()->getItemByPostvar($this->getElementId());
51 
52  // :TODO: refactor ilDateTimeInputGUI
53 
54  // because of ilDateTime the ADT can only have valid dates
55 
56  if(!$field->invalid_input)
57  {
58  $date = null;
59 
60  $toggle = true;
61 
62  if(!$this->isRequired() &&
63  !(bool)$this->text_input)
64  {
65  // :TODO: should be handle by ilDateTimeInputGUI
66  $toggle = $_POST[$field->getActivationPostVar()];
67  }
68 
69  if($toggle)
70  {
71  // ilPropertyFormGUI::checkInput() is pre-requisite
72  $incoming = $this->getForm()->getInput($this->getElementId());
73  if($incoming["date"] && $incoming["time"])
74  {
75  $date = new ilDateTime($incoming["date"]." ".$incoming["time"], IL_CAL_DATETIME);
76  }
77  }
78 
79  $this->getADT()->setDate($date);
80 
81  $field->setDate($this->getADT()->getDate());
82  }
83  else
84  {
85  $this->invalid_input = true;
86  }
87  }
$_POST['username']
Definition: cron.php:12
const IL_CAL_DATETIME
isRequired()
Get required.
Date and time handling
getElementId()
Get element id.
+ Here is the call graph for this function:

◆ isValidADT()

ilADTDateTimeFormBridge::isValidADT ( ilADT  $a_adt)
protected

Definition at line 10 of file class.ilADTDateTimeFormBridge.php.

11  {
12  return ($a_adt instanceof ilADTDateTime);
13  }

◆ setTextInputMode()

ilADTDateTimeFormBridge::setTextInputMode (   $a_value)

Definition at line 15 of file class.ilADTDateTimeFormBridge.php.

16  {
17  $this->text_input = (bool)$a_value;
18  }

◆ validate()

ilADTDateTimeFormBridge::validate ( )

Definition at line 89 of file class.ilADTDateTimeFormBridge.php.

90  {
91  // :TODO: error handling is done by ilDateTimeInputGUI
92  return !(bool)$this->invalid_input;
93  }

Field Documentation

◆ $invalid_input

ilADTDateTimeFormBridge::$invalid_input
protected

Definition at line 7 of file class.ilADTDateTimeFormBridge.php.

◆ $text_input

ilADTDateTimeFormBridge::$text_input
protected

Definition at line 8 of file class.ilADTDateTimeFormBridge.php.


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