ILIAS  release_7 Revision v7.30-3-g800a261c036
ilADTDateTimeSearchBridgeRange Class Reference
+ Inheritance diagram for ilADTDateTimeSearchBridgeRange:
+ Collaboration diagram for ilADTDateTimeSearchBridgeRange:

Public Member Functions

 loadFilter ()
 Load filter value(s) into ADT. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 importFromPost (array $a_post=null)
 Import values from (search) form request POST data. More...
 
 getSQLCondition ($a_element_id)
 Get SQL condition for current value(s) More...
 
 isInCondition (ilADT $a_adt)
 Compare directly against ADT. More...
 
 getSerializedValue ()
 Get current value(s) in serialized form (for easy persisting) More...
 
 setSerializedValue ($a_value)
 Set current value(s) in serialized form (for easy persisting) More...
 
- Public Member Functions inherited from ilADTSearchBridgeRange
 getLowerADT ()
 Get lower ADT. More...
 
 getUpperADT ()
 Get lower ADT. More...
 
 isNull ()
 Is null ? More...
 
 isValid ()
 
 validate ()
 Validate current data. More...
 
- Public Member Functions inherited from ilADTSearchBridge
 __construct (ilADTDefinition $a_adt_def)
 Constructor. More...
 
 isNull ()
 Is null ? 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...
 
 getSearchColumn ()
 
 setTableGUI (ilTable2GUI $a_table)
 Set table gui (for filter mode) More...
 
 getTableGUI ()
 Get table gui. More...
 
 loadFilter ()
 Load filter value(s) into ADT. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 importFromPost (array $a_post=null)
 Import values from (search) form request POST data. More...
 
 validate ()
 Validate current data. More...
 
 getSQLCondition ($a_element_id)
 Get SQL condition for current value(s) More...
 
 isInCondition (ilADT $a_adt)
 Compare directly against ADT. More...
 
 getSerializedValue ()
 Get current value(s) in serialized form (for easy persisting) More...
 
 setSerializedValue ($a_value)
 Set current value(s) in serialized form (for easy persisting) More...
 

Protected Member Functions

 isValidADTDefinition (ilADTDefinition $a_adt_def)
 Check if given ADT definition is valid. More...
 
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all. More...
 
- Protected Member Functions inherited from ilADTSearchBridgeRange
 setDefinition (ilADTDefinition $a_adt_def)
 Set ADT definition. More...
 
- Protected Member Functions inherited from ilADTSearchBridge
 isValidADTDefinition (ilADTDefinition $a_adt_def)
 Check if given ADT definition is valid. More...
 
 setDefinition (ilADTDefinition $a_adt_def)
 Set ADT definition. More...
 
 writeFilter ($a_value=null)
 Write value(s) to filter store (in session) More...
 
 readFilter ()
 Load value(s) from filter store (in session) More...
 
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element. More...
 
 addToElementId ($a_add)
 Add sub-element. More...
 
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all. More...
 
 extractPostValues (array $a_post=null)
 Extract data from (post) values. More...
 

Additional Inherited Members

- Data Fields inherited from ilADTSearchBridge
const DEFAULT_SEARCH_COLUMN = 'value'
 
- Protected Attributes inherited from ilADTSearchBridgeRange
 $adt_lower
 
 $adt_upper
 
- Protected Attributes inherited from ilADTSearchBridge
 $form
 
 $table_gui
 
 $table_filter_fields = []
 
 $id
 
 $title
 
 $info
 

Detailed Description

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

Member Function Documentation

◆ addToForm()

ilADTDateTimeSearchBridgeRange::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

Definition at line 31 of file class.ilADTDateTimeSearchBridgeRange.php.

32 {
33 global $DIC;
34
35 $lng = $DIC['lng'];
36
37 if ($this->getForm() instanceof ilPropertyFormGUI) {
38 // :TODO: use DateDurationInputGUI ?!
39
40 $check = new ilCustomInputGUI($this->getTitle());
41
42 $date_from = new ilDateTimeInputGUI($lng->txt('from'), $this->addToElementId("lower"));
43 $date_from->setShowTime(true);
44 $check->addSubItem($date_from);
45
46 if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
47 $date_from->setDate($this->getLowerADT()->getDate());
48 $checked = true;
49 }
50
51 $date_until = new ilDateTimeInputGUI($lng->txt('until'), $this->addToElementId("upper"));
52 $date_until->setShowTime(true);
53 $check->addSubItem($date_until);
54
55 if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
56 $date_until->setDate($this->getUpperADT()->getDate());
57 $checked = true;
58 }
59
60 $this->addToParentElement($check);
61 } else {
62 // see ilTable2GUI::addFilterItemByMetaType()
63 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
64 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
65 $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
66
67 $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
68 $lower->setShowTime(true);
69 $item->addCombinationItem("lower", $lower, $lng->txt("from"));
70
71 if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
72 $lower->setDate($this->getLowerADT()->getDate());
73 }
74
75 $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
76 $upper->setShowTime(true);
77 $item->addCombinationItem("upper", $upper, $lng->txt("to"));
78
79 if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
80 $upper->setDate($this->getUpperADT()->getDate());
81 }
82
83 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
84
85 $this->addToParentElement($item);
86 }
87 }
addToElementId($a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
getElementId()
Get element id.
This class represents a number property in a property form.
This class represents a custom property in a property form.
This class represents a date/time property in a property form.
This class represents a property form user interface.
global $DIC
Definition: goto.php:24
$lng

References $DIC, $lng, ilADTSearchBridge\addToElementId(), ilADTSearchBridge\addToParentElement(), ilCombinationInputGUI\COMPARISON_ASCENDING, ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridge\getTitle(), ilADTSearchBridgeRange\getUpperADT(), and ilADTSearchBridgeRange\isNull().

+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTDateTimeSearchBridgeRange::getSerializedValue ( )

Get current value(s) in serialized form (for easy persisting)

Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 173 of file class.ilADTDateTimeSearchBridgeRange.php.

174 {
175 if (!$this->isNull() && $this->isValid()) {
176 $res = array();
177 if (!$this->getLowerADT()->isNull()) {
178 $res["lower"] = $this->getLowerADT()->getDate()->get(IL_CAL_DATETIME);
179 }
180 if (!$this->getUpperADT()->isNull()) {
181 $res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATETIME);
182 }
183 return serialize($res);
184 }
185 }
const IL_CAL_DATETIME
foreach($_POST as $key=> $value) $res

References $res, ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATETIME, ilADTSearchBridgeRange\isNull(), and ilADTSearchBridgeRange\isValid().

+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTDateTimeSearchBridgeRange::getSQLCondition (   $a_element_id)

Get SQL condition for current value(s)

Parameters
string$a_element_id
Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 139 of file class.ilADTDateTimeSearchBridgeRange.php.

140 {
141 global $DIC;
142
143 $ilDB = $DIC['ilDB'];
144
145 if (!$this->isNull() && $this->isValid()) {
146 $sql = array();
147 if (!$this->getLowerADT()->isNull()) {
148 $sql[] = $a_element_id . " >= " . $ilDB->quote($this->getLowerADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
149 }
150 if (!$this->getUpperADT()->isNull()) {
151 $sql[] = $a_element_id . " <= " . $ilDB->quote($this->getUpperADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
152 }
153 return "(" . implode(" AND ", $sql) . ")";
154 }
155 }
global $ilDB

References $DIC, $ilDB, ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATETIME, ilADTSearchBridgeRange\isNull(), and ilADTSearchBridgeRange\isValid().

+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateTimeSearchBridgeRange::importFromPost ( array  $a_post = null)

Import values from (search) form request POST data.

Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 98 of file class.ilADTDateTimeSearchBridgeRange.php.

99 {
100 $post = $this->extractPostValues($a_post);
101
102 if ($post && $this->shouldBeImportedFromPost($post)) {
103 include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
104 $start = ilCalendarUtil::parseIncomingDate($post["lower"], 1);
105 $end = ilCalendarUtil::parseIncomingDate($post["upper"], 1);
106
107 if ($start && $end && $start->get(IL_CAL_UNIX) > $end->get(IL_CAL_UNIX)) {
108 $tmp = $start;
109 $start = $end;
110 $end = $tmp;
111 }
112
113 if ($this->getForm() instanceof ilPropertyFormGUI) {
114 $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[lower]");
115 $item->setDate($start);
116
117 $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[upper]");
118 $item->setDate($end);
119 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
120 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
121 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
122 $this->writeFilter(array(
123 "lower" => (!$start || $start->isNull()) ? null: $start->get(IL_CAL_DATETIME),
124 "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATETIME)
125 ));
126 }
127
128 $this->getLowerADT()->setDate($start);
129 $this->getUpperADT()->setDate($end);
130 } else {
131 $this->getLowerADT()->setDate();
132 $this->getUpperADT()->setDate();
133 }
134 }
const IL_CAL_UNIX
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
extractPostValues(array $a_post=null)
Extract data from (post) values.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.

References ilADTSearchBridge\extractPostValues(), ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATETIME, IL_CAL_UNIX, ilCalendarUtil\parseIncomingDate(), shouldBeImportedFromPost(), and ilADTSearchBridge\writeFilter().

+ Here is the call graph for this function:

◆ isInCondition()

ilADTDateTimeSearchBridgeRange::isInCondition ( ilADT  $a_adt)

Compare directly against ADT.

Parameters
ilADT$a_adt
Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 157 of file class.ilADTDateTimeSearchBridgeRange.php.

158 {
159 assert($a_adt instanceof ilADTDateTime);
160
161 if (!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull()) {
162 return $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
163 } elseif (!$this->getLowerADT()->isNull()) {
164 return $a_adt->isLargerOrEqual($this->getLowerADT());
165 } else {
166 return $a_adt->isSmallerOrEqual($this->getUpperADT());
167 }
168 }
isSmallerOrEqual(ilADT $a_adt)
Check if given ADT is smaller or equal than self.
isLargerOrEqual(ilADT $a_adt)
Check if given ADT is larger or equal than self.
isInbetweenOrEqual(ilADT $a_adt_from, ilADT $a_adt_to)
Check if self is inbetween given ADTs (inclusive)

References ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), ilADT\isInbetweenOrEqual(), ilADT\isLargerOrEqual(), ilADTSearchBridgeRange\isNull(), and ilADT\isSmallerOrEqual().

+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTDateTimeSearchBridgeRange::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

Check if given ADT definition is valid.

:TODO: This could be avoided with type-specifc constructors :TODO: bridge base class?

Parameters
ilADTDefinition$a_adt_def

Reimplemented from ilADTSearchBridge.

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

8 {
9 return ($a_adt_def instanceof ilADTDateTimeDefinition);
10 }

◆ loadFilter()

ilADTDateTimeSearchBridgeRange::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

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

16 {
17 $value = $this->readFilter();
18 if ($value !== null) {
19 if ($value["lower"]) {
20 $this->getLowerADT()->setDate(new ilDateTime($value["lower"], IL_CAL_DATETIME));
21 }
22 if ($value["upper"]) {
23 $this->getUpperADT()->setDate(new ilDateTime($value["upper"], IL_CAL_DATETIME));
24 }
25 }
26 }
readFilter()
Load value(s) from filter store (in session)
@classDescription Date and time handling

References ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATETIME, and ilADTSearchBridge\readFilter().

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTDateTimeSearchBridgeRange::setSerializedValue (   $a_value)

Set current value(s) in serialized form (for easy persisting)

Parameters
string

Reimplemented from ilADTSearchBridge.

Definition at line 187 of file class.ilADTDateTimeSearchBridgeRange.php.

188 {
189 $a_value = unserialize($a_value);
190 if (is_array($a_value)) {
191 if (isset($a_value["lower"])) {
192 $this->getLowerADT()->setDate(new ilDateTime($a_value["lower"], IL_CAL_DATETIME));
193 }
194 if (isset($a_value["upper"])) {
195 $this->getUpperADT()->setDate(new ilDateTime($a_value["upper"], IL_CAL_DATETIME));
196 }
197 }
198 }

References ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), and IL_CAL_DATETIME.

+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTDateTimeSearchBridgeRange::shouldBeImportedFromPost (   $a_post)
protected

Check if incoming values should be imported at all.

Parameters
mixed$a_post
Returns
bool

Reimplemented from ilADTSearchBridge.

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

90 {
91 if ($this->getForm() instanceof ilPropertyFormGUI &&
92 !(bool) $this->text_input) {
93 return (bool) $a_post["tgl"];
94 }
95 return parent::shouldBeImportedFromPost($a_post);
96 }

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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