ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTDateFormBridge.php
Go to the documentation of this file.
1 <?php
2 
3 require_once "Services/ADT/classes/Bridges/class.ilADTFormBridge.php";
4 
6 {
7  protected $invalid_input; // [bool]
8  protected $text_input; // [bool]
9 
10  protected function isValidADT(ilADT $a_adt)
11  {
12  return ($a_adt instanceof ilADTDate);
13  }
14 
15  public function setTextInputMode($a_value)
16  {
17  $this->text_input = (bool)$a_value;
18  }
19 
20  protected function addToElementId($a_add)
21  {
22  return $this->getElementId()."[".$a_add."]";
23  }
24 
25  public function addToForm()
26  {
27  $adt_date = $this->getADT()->getDate();
28 
29  $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
30  $date->setShowTime(false);
31 
32  $this->addBasicFieldProperties($date, $this->getADT()->getCopyOfDefinition());
33 
34  if((bool)$this->text_input)
35  {
36  $date->setMode(ilDateTimeInputGUI::MODE_INPUT);
37  }
38  else
39  {
40  if(!$this->isRequired())
41  {
42  $date->enableDateActivation("", $this->getElementId()."_tgl", !(!$adt_date || $adt_date->isNull()));
43  }
44  }
45 
46  $date->setDate($adt_date);
47 
48  $this->addToParentElement($date);
49  }
50 
51  public function importFromPost()
52  {
53  $field = $this->getForm()->getItemByPostvar($this->getElementId());
54 
55  // :TODO: refactor ilDateTimeInputGUI
56 
57  // because of ilDate the ADT can only have valid dates
58 
59  if(!$field->invalid_input)
60  {
61  $date = null;
62 
63  $toggle = true;
64 
65  if(!$this->isRequired() &&
66  !(bool)$this->text_input)
67  {
68  // :TODO: should be handle by ilDateTimeInputGUI
69  $toggle = $_POST[$field->getActivationPostVar()];
70  }
71 
72  if($toggle)
73  {
74  // ilPropertyFormGUI::checkInput() is pre-requisite
75  $incoming = $this->getForm()->getInput($this->getElementId());
76  if($incoming["date"])
77  {
78  $date = new ilDate($incoming["date"], IL_CAL_DATE);
79  }
80  }
81 
82  $this->getADT()->setDate($date);
83 
84  $field->setDate($this->getADT()->getDate());
85  }
86  else
87  {
88  $this->invalid_input = true;
89  }
90  }
91 
92  public function validate()
93  {
94  // :TODO: error handling is done by ilDateTimeInputGUI
95  return !(bool)$this->invalid_input;
96  }
97 }
98 
99 ?>
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
$_POST['username']
Definition: cron.php:12
ADT form bridge base class.
isRequired()
Get required.
ADT base class.
Definition: class.ilADT.php:11
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.
Class for single dates.
getElementId()
Get element id.
const IL_CAL_DATE