ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilADTDateSearchBridgeRange Class Reference
+ Inheritance diagram for ilADTDateSearchBridgeRange:
+ Collaboration diagram for ilADTDateSearchBridgeRange:

Public Member Functions

 setTextInputMode ($a_value)
 
 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 (ilADTDate $a_adt)
 
 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...
 
 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 (array $a_post)
 
- 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...
 

Protected Attributes

 $text_input
 
- 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.ilADTDateSearchBridgeRange.php.

Member Function Documentation

◆ addToForm()

ilADTDateSearchBridgeRange::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

Definition at line 41 of file class.ilADTDateSearchBridgeRange.php.

42 {
43 global $lng;
44
45 if($this->getForm() instanceof ilPropertyFormGUI)
46 {
47 // :TODO: use DateDurationInputGUI ?!
48
49 if(!(bool)$this->text_input)
50 {
51 $check = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl"));
52 $check->setValue(1);
53 $checked = false;
54 }
55 else
56 {
57 $check = new ilCustomInputGUI($this->getTitle());
58 }
59
60 $date_from = new ilDateTimeInputGUI($lng->txt('from'), $this->addToElementId("lower"));
61 $date_from->setShowTime(false);
62 $check->addSubItem($date_from);
63
64 if($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull())
65 {
66 $date_from->setDate($this->getLowerADT()->getDate());
67 $checked = true;
68 }
69
70 $date_until = new ilDateTimeInputGUI($lng->txt('until'), $this->addToElementId("upper"));
71 $date_until->setShowTime(false);
72 $check->addSubItem($date_until);
73
74 if($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull())
75 {
76 $date_until->setDate($this->getUpperADT()->getDate());
77 $checked = true;
78 }
79
80 if(!(bool)$this->text_input)
81 {
82 $check->setChecked($checked);
83 }
84 else
85 {
86 $date_from->setMode(ilDateTimeInputGUI::MODE_INPUT);
87 $date_until->setMode(ilDateTimeInputGUI::MODE_INPUT);
88 }
89
90 $this->addToParentElement($check);
91 }
92 else
93 {
94 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
95 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
96
97 $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
98
99 $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
100 $item->addCombinationItem("lower", $lower, $lng->txt("from"));
101
102 if($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull())
103 {
104 $lower->setDate($this->getLowerADT()->getDate());
105 }
106
107 $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
108 $item->addCombinationItem("upper", $upper, $lng->txt("to"));
109
110 if($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull())
111 {
112 $upper->setDate($this->getUpperADT()->getDate());
113 }
114
115 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
116 $item->setMode(ilDateTimeInputGUI::MODE_INPUT);
117
118 $this->addToParentElement($item);
119 }
120 }
addToElementId($a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
getElementId()
Get element id.
This class represents a checkbox property in a property form.
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 $lng
Definition: privfeed.php:40

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

+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTDateSearchBridgeRange::getSerializedValue ( )

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

Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 256 of file class.ilADTDateSearchBridgeRange.php.

257 {
258 if(!$this->isNull() && $this->isValid())
259 {
260 $res = array();
261 if(!$this->getLowerADT()->isNull())
262 {
263 $res["lower"] = $this->getLowerADT()->getDate()->get(IL_CAL_DATE);
264 }
265 if(!$this->getUpperADT()->isNull())
266 {
267 $res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATE);
268 }
269 return serialize($res);
270 }
271 }
const IL_CAL_DATE

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

+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTDateSearchBridgeRange::getSQLCondition (   $a_element_id)

Get SQL condition for current value(s)

Parameters
string$a_element_id
Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 218 of file class.ilADTDateSearchBridgeRange.php.

219 {
220 global $ilDB;
221
222 if(!$this->isNull() && $this->isValid())
223 {
224 $sql = array();
225 if(!$this->getLowerADT()->isNull())
226 {
227 $sql[] = $a_element_id." >= ".$ilDB->quote($this->getLowerADT()->getDate()->get(IL_CAL_DATE), "date");
228 }
229 if(!$this->getUpperADT()->isNull())
230 {
231 $sql[] = $a_element_id." <= ".$ilDB->quote($this->getUpperADT()->getDate()->get(IL_CAL_DATE), "date");
232 }
233 return "(".implode(" AND ", $sql).")";
234 }
235 }
global $ilDB

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

+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateSearchBridgeRange::importFromPost ( array  $a_post = null)

Import values from (search) form request POST data.

Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 132 of file class.ilADTDateSearchBridgeRange.php.

133 {
134 $post = $this->extractPostValues($a_post);
135
136 if($post && $this->shouldBeImportedFromPost($post))
137 {
138 $start = $end = null;
139
140 include_once "Services/ADT/classes/class.ilADTDateSearchUtil.php";
141
142 if(!$this->getForm() instanceof ilPropertyFormGUI ||
143 (bool)$this->text_input)
144 {
147 }
148 else
149 {
150 // if checkInput() is called before, this will not work
151
154 }
155
156 if($start && $end && $start > $end)
157 {
158 $tmp = $start;
159 $start = $end;
160 $end = $tmp;
161 }
162
163 // :TODO: all dates are imported as valid
164
165 if($start)
166 {
167 $start = new ilDate($start, IL_CAL_UNIX);
168 }
169 if($end)
170 {
171 $end = new ilDate($end, IL_CAL_UNIX);
172 }
173
174 if($this->getForm() instanceof ilPropertyFormGUI)
175 {
176 $item = $this->getForm()->getItemByPostVar($this->getElementId()."[lower]");
177 $item->setDate($start);
178
179 $item = $this->getForm()->getItemByPostVar($this->getElementId()."[upper]");
180 $item->setDate($end);
181
182 if(!(bool)$this->text_input)
183 {
184 $item = $this->getForm()->getItemByPostVar($this->getElementId()."[tgl]");
185 $item->setChecked(true);
186 }
187 }
188 else if(array_key_exists($this->getElementId(), $this->table_filter_fields))
189 {
190 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
191 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
192 $this->writeFilter(array(
193 "lower" => (!$start || $start->isNull()) ? null: $start->get(IL_CAL_DATE),
194 "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATE)
195 ));
196 }
197
198 $this->getLowerADT()->setDate($start);
199 $this->getUpperADT()->setDate($end);
200 }
201 else
202 {
203 if($this->getForm() instanceof ilPropertyFormGUI &&
204 !(bool)$this->text_input)
205 {
206 $item = $this->getForm()->getItemByPostVar($this->getElementId()."[tgl]");
207 $item->setChecked(false);
208 }
209
210 $this->getLowerADT()->setDate();
211 $this->getUpperADT()->setDate();
212 }
213 }
const IL_CAL_UNIX
static handleTextInputPost($a_mode, $a_post)
Import text input post data.
static handleSelectInputPost($a_mode, $a_post)
Import select post data.
extractPostValues(array $a_post=null)
Extract data from (post) values.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
Class for single dates.

References ilADTSearchBridge\extractPostValues(), ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), ilADTDateSearchUtil\handleSelectInputPost(), ilADTDateSearchUtil\handleTextInputPost(), IL_CAL_DATE, IL_CAL_UNIX, ilADTDateSearchUtil\MODE_DATE, shouldBeImportedFromPost(), and ilADTSearchBridge\writeFilter().

+ Here is the call graph for this function:

◆ isInCondition()

ilADTDateSearchBridgeRange::isInCondition ( ilADTDate  $a_adt)

Definition at line 237 of file class.ilADTDateSearchBridgeRange.php.

238 {
239 if(!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull())
240 {
241 return $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
242 }
243 else if(!$this->getLowerADT()->isNull())
244 {
245 return $a_adt->isLargerOrEqual($this->getLowerADT());
246 }
247 else
248 {
249 return $a_adt->isSmallerOrEqual($this->getUpperADT());
250 }
251 }
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()

ilADTDateSearchBridgeRange::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 9 of file class.ilADTDateSearchBridgeRange.php.

10 {
11 return ($a_adt_def instanceof ilADTDateDefinition);
12 }

◆ loadFilter()

ilADTDateSearchBridgeRange::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

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

23 {
24 $value = $this->readFilter();
25 if($value !== null)
26 {
27 if($value["lower"])
28 {
29 $this->getLowerADT()->setDate(new ilDate($value["lower"], IL_CAL_DATE));
30 }
31 if($value["upper"])
32 {
33 $this->getUpperADT()->setDate(new ilDate($value["upper"], IL_CAL_DATE));
34 }
35 }
36 }
readFilter()
Load value(s) from filter store (in session)

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

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTDateSearchBridgeRange::setSerializedValue (   $a_value)

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

Parameters
string

Reimplemented from ilADTSearchBridge.

Definition at line 273 of file class.ilADTDateSearchBridgeRange.php.

274 {
275 $a_value = unserialize($a_value);
276 if(is_array($a_value))
277 {
278 if(isset($a_value["lower"]))
279 {
280 $this->getLowerADT()->setDate(new ilDate($a_value["lower"], IL_CAL_DATE));
281 }
282 if(isset($a_value["upper"]))
283 {
284 $this->getUpperADT()->setDate(new ilDate($a_value["upper"], IL_CAL_DATE));
285 }
286 }
287 }

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

+ Here is the call graph for this function:

◆ setTextInputMode()

ilADTDateSearchBridgeRange::setTextInputMode (   $a_value)

Definition at line 14 of file class.ilADTDateSearchBridgeRange.php.

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

◆ shouldBeImportedFromPost()

ilADTDateSearchBridgeRange::shouldBeImportedFromPost ( array  $a_post)
protected

Definition at line 122 of file class.ilADTDateSearchBridgeRange.php.

123 {
124 if($this->getForm() instanceof ilPropertyFormGUI &&
125 !(bool)$this->text_input)
126 {
127 return (bool)$a_post["tgl"];
128 }
129 return parent::shouldBeImportedFromPost($a_post);
130 }

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

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

Field Documentation

◆ $text_input

ilADTDateSearchBridgeRange::$text_input
protected

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


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