ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilADTDateTimeSearchBridgeRange Class Reference
+ Inheritance diagram for ilADTDateTimeSearchBridgeRange:
+ Collaboration diagram for ilADTDateTimeSearchBridgeRange:

Public Member Functions

 loadFilter ()
 
 addToForm ()
 
 importFromPost (array $a_post=null)
 
 getSQLCondition ($a_element_id)
 
 isInCondition (ilADT $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 ($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...
 

Additional Inherited Members

- 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 31 of file class.ilADTDateTimeSearchBridgeRange.php.

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

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  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a date/time property in a property form.
$lng
This class represents a number property in a property form.
This class represents a custom property in a property form.
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 173 of file class.ilADTDateTimeSearchBridgeRange.php.

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

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
+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTDateTimeSearchBridgeRange::getSQLCondition (   $a_element_id)

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

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

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  }
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateTimeSearchBridgeRange::importFromPost ( array  $a_post = null)

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

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

99  {
100  $post = $this->extractPostValues($a_post);
101 
102  if ($post && $this->shouldBeImportedFromPost($post)) {
103  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
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_DATETIME
This class represents a property form user interface.
const IL_CAL_UNIX
extractPostValues(array $a_post=null)
Extract data from (post) values.
$start
Definition: bench.php:8
$post
Definition: post.php:34
writeFilter($a_value=null)
Write value(s) to filter store (in session)
getElementId()
Get element id.
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.
+ Here is the call graph for this function:

◆ isInCondition()

ilADTDateTimeSearchBridgeRange::isInCondition ( ilADT  $a_adt)

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

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

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  }
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 7 of file class.ilADTDateTimeSearchBridgeRange.php.

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

◆ loadFilter()

ilADTDateTimeSearchBridgeRange::loadFilter ( )

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

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

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  }
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 187 of file class.ilADTDateTimeSearchBridgeRange.php.

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

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  }
const IL_CAL_DATETIME
Date and time handling
+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTDateTimeSearchBridgeRange::shouldBeImportedFromPost (   $a_post)
protected

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

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

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  }
This class represents a property form user interface.
+ 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: