ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilADTDateTimeFormBridge.php
Go to the documentation of this file.
1<?php
2
3require_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 ilADTDateTime);
13 }
14
15 public function setTextInputMode($a_value)
16 {
17 $this->text_input = (bool)$a_value;
18 }
19
20 public function addToForm()
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 }
47
48 public function importFromPost()
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 }
88
89 public function validate()
90 {
91 // :TODO: error handling is done by ilDateTimeInputGUI
92 return !(bool)$this->invalid_input;
93 }
94}
95
96?>
const IL_CAL_DATETIME
importFromPost()
Import values from form request POST data.
validate()
Validate ADT and parse error codes.
addToForm()
Add ADT-specific fields to form.
isValidADT(ilADT $a_adt)
Check if given ADT is valid.
ADT form bridge base class.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
isRequired()
Get required.
ADT base class.
Definition: class.ilADT.php:12
This class represents a date/time property in a property form.
@classDescription Date and time handling
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40