ILIAS  release_8 Revision v8.24
ilADTDateTimeSearchBridgeRange Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ 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)
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 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 (string $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 upper ADT. More...
 
 isNull ()
 
 isValid ()
 
 validate ()
 Validate current data. More...
 
- Public Member Functions inherited from ilADTSearchBridge
 __construct (ilADTDefinition $a_adt_def)
 
 isNull ()
 
 setForm (ilPropertyFormGUI $a_form)
 
 getForm ()
 
 setElementId (string $a_value)
 
 getElementId ()
 
 setTitle (string $a_value)
 
 getTitle ()
 
 getSearchColumn ()
 
 setTableGUI (ilTable2GUI $a_table)
 
 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)
 
 validate ()
 Validate current data. More...
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 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 (string $a_value)
 Set current value(s) in serialized form (for easy persisting) More...
 

Protected Member Functions

 isValidADTDefinition (ilADTDefinition $a_adt_def)
 
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all. More...
 
- Protected Member Functions inherited from ilADTSearchBridgeRange
 setDefinition (ilADTDefinition $a_adt_def)
 
- Protected Member Functions inherited from ilADTSearchBridge
 isValidADTDefinition (ilADTDefinition $a_adt_def)
 
 setDefinition (ilADTDefinition $a_adt_def)
 
 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 (string $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 SQL_STRICT = 1
 
const SQL_LIKE = 2
 
const SQL_LIKE_END = 3
 
const SQL_LIKE_START = 4
 
const DEFAULT_SEARCH_COLUMN = 'value'
 
- Protected Attributes inherited from ilADTSearchBridgeRange
ilADT $adt_lower
 
ilADT $adt_upper
 
- Protected Attributes inherited from ilADTSearchBridge
ilPropertyFormGUI $form = null
 
ilTable2GUI $table_gui = null
 
array $table_filter_fields = []
 
string $id = ''
 
string $title = ''
 
string $info = ''
 
ilLanguage $lng
 
ilDBInterface $db
 
HttpServices $http
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilADTDateTimeSearchBridgeRange

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

Member Function Documentation

◆ addToForm()

ilADTDateTimeSearchBridgeRange::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

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

49 : void
50 {
51 if ($this->getForm() instanceof ilPropertyFormGUI) {
52 // :TODO: use DateDurationInputGUI ?!
53
54 $check = new ilCustomInputGUI($this->getTitle());
55
56 $date_from = new ilDateTimeInputGUI($this->lng->txt('from'), $this->addToElementId("lower"));
57 $date_from->setShowTime(true);
58 $check->addSubItem($date_from);
59
60 if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
61 $date_from->setDate($this->getLowerADT()->getDate());
62 $checked = true;
63 }
64
65 $date_until = new ilDateTimeInputGUI($this->lng->txt('until'), $this->addToElementId("upper"));
66 $date_until->setShowTime(true);
67 $check->addSubItem($date_until);
68
69 if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
70 $date_until->setDate($this->getUpperADT()->getDate());
71 $checked = true;
72 }
73
75 } else {
76 // see ilTable2GUI::addFilterItemByMetaType()
77 $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
78
79 $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
80 $lower->setShowTime(true);
81 $item->addCombinationItem("lower", $lower, $this->lng->txt("from"));
82
83 if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
84 $lower->setDate($this->getLowerADT()->getDate());
85 }
86
87 $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
88 $upper->setShowTime(true);
89 $item->addCombinationItem("upper", $upper, $this->lng->txt("to"));
90
91 if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
92 $upper->setDate($this->getUpperADT()->getDate());
93 }
94
95 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
96
97 $this->addToParentElement($item);
98 }
99 }
$check
Definition: buildRTE.php:81
addToElementId(string $a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.

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

+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTDateTimeSearchBridgeRange::getSerializedValue ( )

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

Reimplemented from ilADTSearchBridge.

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

184 : string
185 {
186 if (!$this->isNull() && $this->isValid()) {
187 $res = array();
188 if (!$this->getLowerADT()->isNull()) {
189 $res["lower"] = $this->getLowerADT()->getDate()->get(IL_CAL_DATETIME);
190 }
191 if (!$this->getUpperADT()->isNull()) {
192 $res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATETIME);
193 }
194 return serialize($res);
195 }
196 return '';
197 }
const IL_CAL_DATETIME
$res
Definition: ltiservices.php:69

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 ( string  $a_element_id,
int  $mode = self::SQL_LIKE,
array  $quotedWords = [] 
)

Get SQL condition for current value(s)

Reimplemented from ilADTSearchBridge.

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

148 : string
149 {
150 if (!$this->isNull() && $this->isValid()) {
151 $sql = array();
152 if (!$this->getLowerADT()->isNull()) {
153 $sql[] = $a_element_id . " >= " . $this->db->quote(
154 $this->getLowerADT()->getDate()->get(IL_CAL_DATETIME),
155 "timestamp"
156 );
157 }
158 if (!$this->getUpperADT()->isNull()) {
159 $sql[] = $a_element_id . " <= " . $this->db->quote(
160 $this->getUpperADT()->getDate()->get(IL_CAL_DATETIME),
161 "timestamp"
162 );
163 }
164 return "(" . implode(" AND ", $sql) . ")";
165 }
166 return '';
167 }

References 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)
Todo:
make post required

Reimplemented from ilADTSearchBridge.

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

109 : bool
110 {
111 $post = $this->extractPostValues($a_post);
112
113 if ($post && $this->shouldBeImportedFromPost($post)) {
114 $start = ilCalendarUtil::parseIncomingDate($post["lower"], true);
115 $end = ilCalendarUtil::parseIncomingDate($post["upper"], true);
116 if ($start && $end && $start->get(IL_CAL_UNIX) > $end->get(IL_CAL_UNIX)) {
117 $tmp = $start;
118 $start = $end;
119 $end = $tmp;
120 }
121
122 if ($this->getForm() instanceof ilPropertyFormGUI) {
123 $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[lower]");
124 $item->setDate($start);
125
126 $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[upper]");
127 $item->setDate($end);
128 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
129 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
130 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
131 $this->writeFilter(array(
132 "lower" => (!$start || $start->isNull()) ? null : $start->get(IL_CAL_DATETIME),
133 "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATETIME)
134 ));
135 }
136
137 $this->getLowerADT()->setDate($start);
138 $this->getUpperADT()->setDate($end);
139 } else {
140 $this->getLowerADT()->setDate();
141 $this->getUpperADT()->setDate();
142 }
143 return true;
144 }
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, bool $a_add_time=false)
Try to parse incoming value to date object.
$post
Definition: ltitoken.php:49

References $post, 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.

Reimplemented from ilADTSearchBridge.

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

169 : bool
170 {
171 assert($a_adt instanceof ilADTDateTime);
172
173 if (!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull()) {
174 return (bool) $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
175 } elseif (!$this->getLowerADT()->isNull()) {
176 return (bool) $a_adt->isLargerOrEqual($this->getLowerADT());
177 } else {
178 return (bool) $a_adt->isSmallerOrEqual($this->getUpperADT());
179 }
180 }
isSmallerOrEqual(ilADT $a_adt)
Check if given ADT is smaller or equal than self.
isLargerOrEqual(ilADT $a_adt)
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

Reimplemented from ilADTSearchBridge.

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

27 : bool
28 {
29 return ($a_adt_def instanceof ilADTDateTimeDefinition);
30 }

◆ loadFilter()

ilADTDateTimeSearchBridgeRange::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

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

34 : void
35 {
36 $value = $this->readFilter();
37 if (isset($value) && is_array($value)) {
38 if ($value["lower"] ?? false) {
39 $this->getLowerADT()->setDate(new ilDateTime($value["lower"], IL_CAL_DATETIME));
40 }
41 if ($value["upper"] ?? false) {
42 $this->getUpperADT()->setDate(new ilDateTime($value["upper"], IL_CAL_DATETIME));
43 }
44 }
45 }
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 ( string  $a_value)

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

Reimplemented from ilADTSearchBridge.

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

199 : void
200 {
201 $a_value = unserialize($a_value);
202 if (is_array($a_value)) {
203 if (isset($a_value["lower"])) {
204 $this->getLowerADT()->setDate(new ilDateTime($a_value["lower"], IL_CAL_DATETIME));
205 }
206 if (isset($a_value["upper"])) {
207 $this->getUpperADT()->setDate(new ilDateTime($a_value["upper"], IL_CAL_DATETIME));
208 }
209 }
210 }

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
string | int$a_post
Returns
bool

Reimplemented from ilADTSearchBridge.

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

101 : bool
102 {
103 if ($this->getForm() instanceof ilPropertyFormGUI) {
104 return ($a_post['lower'] ?? false) || ($a_post['upper'] ?? false);
105 }
106 return parent::shouldBeImportedFromPost($a_post);
107 }

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: