ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilADTDateTimeSearchBridgeRange Class Reference
+ Inheritance diagram for ilADTDateTimeSearchBridgeRange:
+ Collaboration diagram for ilADTDateTimeSearchBridgeRange:

Public Member Functions

 setTextInputMode ($a_value)
 
 loadFilter ()
 
 addToForm ()
 
 importFromPost (array $a_post=null)
 
 getSQLCondition ($a_element_id)
 
 isInCondition (ilADTDateTime $a_adt)
 
 getSerializedValue ()
 
 setSerializedValue ($a_value)
 
- Public Member Functions inherited from ilADTSearchBridgeRange
 getLowerADT ()
 Get lower ADT. More...
 
 getUpperADT ()
 Get lower ADT. More...
 
 isNull ()
 
 isValid ()
 
 validate ()
 
- 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)
 
 shouldBeImportedFromPost (array $a_post)
 
- Protected Member Functions inherited from ilADTSearchBridgeRange
 setDefinition (ilADTDefinition $a_adt_def)
 
- 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.ilADTDateTimeSearchBridgeRange.php.

Member Function Documentation

◆ addToForm()

ilADTDateTimeSearchBridgeRange::addToForm ( )

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

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

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(true);
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(true);
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  // see ilTable2GUI::addFilterItemByMetaType()
95  include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
96  include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
97  $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
98 
99  $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
100  $lower->setShowTime(true);
101  $item->addCombinationItem("lower", $lower, $lng->txt("from"));
102 
103  if($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull())
104  {
105  $lower->setDate($this->getLowerADT()->getDate());
106  }
107 
108  $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
109  $upper->setShowTime(true);
110  $item->addCombinationItem("upper", $upper, $lng->txt("to"));
111 
112  if($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull())
113  {
114  $upper->setDate($this->getUpperADT()->getDate());
115  }
116 
117  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
118  $item->setMode(ilDateTimeInputGUI::MODE_INPUT);
119 
120  $this->addToParentElement($item);
121  }
122  }
This class represents a property form user interface.
This class represents a checkbox property in a property form.
This class represents a date/time 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.
global $lng
Definition: privfeed.php:40
getElementId()
Get element id.
setShowTime($a_showtime)
Set Show Time Information.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
addToElementId($a_add)
Add sub-element.
+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTDateTimeSearchBridgeRange::getSerializedValue ( )

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

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

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_DATETIME);
264  }
265  if(!$this->getUpperADT()->isNull())
266  {
267  $res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATETIME);
268  }
269  return serialize($res);
270  }
271  }
const IL_CAL_DATETIME
+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTDateTimeSearchBridgeRange::getSQLCondition (   $a_element_id)

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

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

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_DATETIME), "timestamp");
228  }
229  if(!$this->getUpperADT()->isNull())
230  {
231  $sql[] = $a_element_id." <= ".$ilDB->quote($this->getUpperADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
232  }
233  return "(".implode(" AND ", $sql).")";
234  }
235  }
const IL_CAL_DATETIME
global $ilDB
+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateTimeSearchBridgeRange::importFromPost ( array  $a_post = null)

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

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

135  {
136  $post = $this->extractPostValues($a_post);
137 
138  if($post && $this->shouldBeImportedFromPost($post))
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 ilDateTime($start, IL_CAL_UNIX);
168  }
169  if($end)
170  {
171  $end = new ilDateTime($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_DATETIME),
194  "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATETIME)
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  }
static handleSelectInputPost($a_mode, $a_post)
Import select post data.
const IL_CAL_DATETIME
This class represents a property form user interface.
static handleTextInputPost($a_mode, $a_post)
Import text input post data.
const IL_CAL_UNIX
extractPostValues(array $a_post=null)
Extract data from (post) values.
Date and time handling
writeFilter($a_value=null)
Write value(s) to filter store (in session)
getElementId()
Get element id.
+ Here is the call graph for this function:

◆ isInCondition()

ilADTDateTimeSearchBridgeRange::isInCondition ( ilADTDateTime  $a_adt)

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

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

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  }
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)
isSmallerOrEqual(ilADT $a_adt)
Check if given ADT is smaller or equal than self.
+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTDateTimeSearchBridgeRange::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

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

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

◆ loadFilter()

ilADTDateTimeSearchBridgeRange::loadFilter ( )

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

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

23  {
24  $value = $this->readFilter();
25  if($value !== null)
26  {
27  if($value["lower"])
28  {
29  $this->getLowerADT()->setDate(new ilDateTime($value["lower"], IL_CAL_DATETIME));
30  }
31  if($value["upper"])
32  {
33  $this->getUpperADT()->setDate(new ilDateTime($value["upper"], IL_CAL_DATETIME));
34  }
35  }
36  }
const IL_CAL_DATETIME
readFilter()
Load value(s) from filter store (in session)
Date and time handling
+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTDateTimeSearchBridgeRange::setSerializedValue (   $a_value)

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

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

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 ilDateTime($a_value["lower"], IL_CAL_DATETIME));
281  }
282  if(isset($a_value["upper"]))
283  {
284  $this->getUpperADT()->setDate(new ilDateTime($a_value["upper"], IL_CAL_DATETIME));
285  }
286  }
287  }
const IL_CAL_DATETIME
Date and time handling
+ Here is the call graph for this function:

◆ setTextInputMode()

ilADTDateTimeSearchBridgeRange::setTextInputMode (   $a_value)

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

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

◆ shouldBeImportedFromPost()

ilADTDateTimeSearchBridgeRange::shouldBeImportedFromPost ( array  $a_post)
protected

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

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

125  {
126  if($this->getForm() instanceof ilPropertyFormGUI &&
127  !(bool)$this->text_input)
128  {
129  return (bool)$a_post["tgl"];
130  }
131  return parent::shouldBeImportedFromPost($a_post);
132  }
This class represents a property form user interface.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $text_input

ilADTDateTimeSearchBridgeRange::$text_input
protected

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


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