ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $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 $lng;
34 
35  if ($this->getForm() instanceof ilPropertyFormGUI) {
36  // :TODO: use DateDurationInputGUI ?!
37 
38  $check = new ilCustomInputGUI($this->getTitle());
39 
40  $date_from = new ilDateTimeInputGUI($lng->txt('from'), $this->addToElementId("lower"));
41  $date_from->setShowTime(true);
42  $check->addSubItem($date_from);
43 
44  if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
45  $date_from->setDate($this->getLowerADT()->getDate());
46  $checked = true;
47  }
48 
49  $date_until = new ilDateTimeInputGUI($lng->txt('until'), $this->addToElementId("upper"));
50  $date_until->setShowTime(true);
51  $check->addSubItem($date_until);
52 
53  if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
54  $date_until->setDate($this->getUpperADT()->getDate());
55  $checked = true;
56  }
57 
58  $this->addToParentElement($check);
59  } else {
60  // see ilTable2GUI::addFilterItemByMetaType()
61  include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
62  include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
63  $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
64 
65  $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
66  $lower->setShowTime(true);
67  $item->addCombinationItem("lower", $lower, $lng->txt("from"));
68 
69  if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
70  $lower->setDate($this->getLowerADT()->getDate());
71  }
72 
73  $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
74  $upper->setShowTime(true);
75  $item->addCombinationItem("upper", $upper, $lng->txt("to"));
76 
77  if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
78  $upper->setDate($this->getUpperADT()->getDate());
79  }
80 
81  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
82 
83  $this->addToParentElement($item);
84  }
85  }
This class represents a property form user interface.
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:17
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 169 of file class.ilADTDateTimeSearchBridgeRange.php.

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

170  {
171  if (!$this->isNull() && $this->isValid()) {
172  $res = array();
173  if (!$this->getLowerADT()->isNull()) {
174  $res["lower"] = $this->getLowerADT()->getDate()->get(IL_CAL_DATETIME);
175  }
176  if (!$this->getUpperADT()->isNull()) {
177  $res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATETIME);
178  }
179  return serialize($res);
180  }
181  }
const IL_CAL_DATETIME
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTDateTimeSearchBridgeRange::getSQLCondition (   $a_element_id)

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

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

138  {
139  global $ilDB;
140 
141  if (!$this->isNull() && $this->isValid()) {
142  $sql = array();
143  if (!$this->getLowerADT()->isNull()) {
144  $sql[] = $a_element_id . " >= " . $ilDB->quote($this->getLowerADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
145  }
146  if (!$this->getUpperADT()->isNull()) {
147  $sql[] = $a_element_id . " <= " . $ilDB->quote($this->getUpperADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
148  }
149  return "(" . implode(" AND ", $sql) . ")";
150  }
151  }
const IL_CAL_DATETIME
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateTimeSearchBridgeRange::importFromPost ( array  $a_post = null)

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

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

97  {
98  $post = $this->extractPostValues($a_post);
99 
100  if ($post && $this->shouldBeImportedFromPost($post)) {
101  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
102  $start = ilCalendarUtil::parseIncomingDate($post["lower"], 1);
104 
105  if ($start && $end && $start->get(IL_CAL_UNIX) > $end->get(IL_CAL_UNIX)) {
106  $tmp = $start;
107  $start = $end;
108  $end = $tmp;
109  }
110 
111  if ($this->getForm() instanceof ilPropertyFormGUI) {
112  $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[lower]");
113  $item->setDate($start);
114 
115  $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[upper]");
116  $item->setDate($end);
117  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
118  $this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
119  $this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
120  $this->writeFilter(array(
121  "lower" => (!$start || $start->isNull()) ? null: $start->get(IL_CAL_DATETIME),
122  "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATETIME)
123  ));
124  }
125 
126  $this->getLowerADT()->setDate($start);
127  $this->getUpperADT()->setDate($end);
128  } else {
129  $this->getLowerADT()->setDate();
130  $this->getUpperADT()->setDate();
131  }
132  }
const IL_CAL_DATETIME
This class represents a property form user interface.
$end
Definition: saml1-acs.php:18
const IL_CAL_UNIX
extractPostValues(array $a_post=null)
Extract data from (post) values.
$post
Definition: post.php:34
Create styles array
The data for the language used.
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 153 of file class.ilADTDateTimeSearchBridgeRange.php.

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

154  {
155  assert($a_adt instanceof ilADTDateTime);
156 
157  if (!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull()) {
158  return $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
159  } elseif (!$this->getLowerADT()->isNull()) {
160  return $a_adt->isLargerOrEqual($this->getLowerADT());
161  } else {
162  return $a_adt->isSmallerOrEqual($this->getUpperADT());
163  }
164  }
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 183 of file class.ilADTDateTimeSearchBridgeRange.php.

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

184  {
185  $a_value = unserialize($a_value);
186  if (is_array($a_value)) {
187  if (isset($a_value["lower"])) {
188  $this->getLowerADT()->setDate(new ilDateTime($a_value["lower"], IL_CAL_DATETIME));
189  }
190  if (isset($a_value["upper"])) {
191  $this->getUpperADT()->setDate(new ilDateTime($a_value["upper"], IL_CAL_DATETIME));
192  }
193  }
194  }
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 87 of file class.ilADTDateTimeSearchBridgeRange.php.

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

88  {
89  if ($this->getForm() instanceof ilPropertyFormGUI &&
90  !(bool) $this->text_input) {
91  return (bool) $a_post["tgl"];
92  }
93  return parent::shouldBeImportedFromPost($a_post);
94  }
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: