ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTDateSearchBridgeRange 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 ilADTDateSearchBridgeRange:
+ Collaboration diagram for ilADTDateSearchBridgeRange:

Public Member Functions

 loadFilter ()
 
 addToForm ()
 
 importFromPost (array $a_post=null)
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 
 isInCondition (ilADT $a_adt)
 
 getSerializedValue ()
 
 setSerializedValue (string $a_value)
 
- Public Member Functions inherited from ilADTSearchBridgeRange
 getLowerADT ()
 Get lower ADT. More...
 
 getUpperADT ()
 Get upper ADT. More...
 
 isNull ()
 
 isValid ()
 
 validate ()
 
- 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)
 
- 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 ilADTDateSearchBridgeRange

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

Member Function Documentation

◆ addToForm()

ilADTDateSearchBridgeRange::addToForm ( )

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

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

48  : void
49  {
50  if ($this->getForm() instanceof ilPropertyFormGUI) {
51  $check = new ilCustomInputGUI($this->getTitle());
52 
53  $date_from = new ilDateTimeInputGUI($this->lng->txt('from'), $this->addToElementId("lower"));
54  $date_from->setShowTime(false);
55  $check->addSubItem($date_from);
56 
57  if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
58  $date_from->setDate($this->getLowerADT()->getDate());
59  $checked = true;
60  }
61 
62  $date_until = new ilDateTimeInputGUI($this->lng->txt('until'), $this->addToElementId("upper"));
63  $date_until->setShowTime(false);
64  $check->addSubItem($date_until);
65 
66  if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
67  $date_until->setDate($this->getUpperADT()->getDate());
68  $checked = true;
69  }
70 
71  $this->addToParentElement($check);
72  } else {
73  $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
74 
75  $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
76  $item->addCombinationItem("lower", $lower, $this->lng->txt("from"));
77 
78  if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
79  $lower->setDate($this->getLowerADT()->getDate());
80  }
81 
82  $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
83  $item->addCombinationItem("upper", $upper, $this->lng->txt("to"));
84 
85  if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
86  $upper->setDate($this->getUpperADT()->getDate());
87  }
88 
89  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
90 
91  $this->addToParentElement($item);
92  }
93  }
setShowTime(bool $a_showtime)
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...
$check
Definition: buildRTE.php:81
addToElementId(string $a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTDateSearchBridgeRange::getSerializedValue ( )

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

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

178  : string
179  {
180  if (!$this->isNull() && $this->isValid()) {
181  $res = array();
182  if (!$this->getLowerADT()->isNull()) {
183  $res["lower"] = $this->getLowerADT()->getDate()->get(IL_CAL_DATE);
184  }
185  if (!$this->getUpperADT()->isNull()) {
186  $res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATE);
187  }
188  return serialize($res);
189  }
190  return '';
191  }
$res
Definition: ltiservices.php:69
const IL_CAL_DATE
+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTDateSearchBridgeRange::getSQLCondition ( string  $a_element_id,
int  $mode = self::SQL_LIKE,
array  $quotedWords = [] 
)

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

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

142  : string
143  {
144  if (!$this->isNull() && $this->isValid()) {
145  $sql = array();
146  if (!$this->getLowerADT()->isNull()) {
147  $sql[] = $a_element_id . " >= " . $this->db->quote(
148  $this->getLowerADT()->getDate()->get(IL_CAL_DATE),
149  "date"
150  );
151  }
152  if (!$this->getUpperADT()->isNull()) {
153  $sql[] = $a_element_id . " <= " . $this->db->quote(
154  $this->getUpperADT()->getDate()->get(IL_CAL_DATE),
155  "date"
156  );
157  }
158  return "(" . implode(" AND ", $sql) . ")";
159  }
160  return '';
161  }
const IL_CAL_DATE
+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateSearchBridgeRange::importFromPost ( array  $a_post = null)

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

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

103  : bool
104  {
105  $post = $this->extractPostValues($a_post);
106  if ($post && $this->shouldBeImportedFromPost($post)) {
107  $start = ilCalendarUtil::parseIncomingDate($post["lower"]);
108  $end = ilCalendarUtil::parseIncomingDate($post["upper"]);
109 
110  if ($start && $end && $start->get(IL_CAL_UNIX) > $end->get(IL_CAL_UNIX)) {
111  $tmp = $start;
112  $start = $end;
113  $end = $tmp;
114  }
115 
116  if ($this->getForm() instanceof ilPropertyFormGUI) {
117  $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[lower]");
118  $item->setDate($start);
119 
120  $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[upper]");
121  $item->setDate($end);
122  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
123  $this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
124  $this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
125  $this->writeFilter(array(
126  "lower" => (!$start || $start->isNull()) ? null : $start->get(IL_CAL_DATE),
127  "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATE)
128  ));
129  }
130 
131  $this->getLowerADT()->setDate($start);
132  $this->getUpperADT()->setDate($end);
133  } else {
134  $this->getLowerADT()->setDate();
135  $this->getUpperADT()->setDate();
136  }
137  return true;
138  }
const IL_CAL_UNIX
extractPostValues(array $a_post=null)
Extract data from (post) values.
const IL_CAL_DATE
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
+ Here is the call graph for this function:

◆ isInCondition()

ilADTDateSearchBridgeRange::isInCondition ( ilADT  $a_adt)

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

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

163  : bool
164  {
165  assert($a_adt instanceof ilADTDate);
166 
167  if (!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull()) {
168  return (bool) $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
169  } elseif (!$this->getLowerADT()->isNull()) {
170  return (bool) $a_adt->isLargerOrEqual($this->getLowerADT());
171  } else {
172  return (bool) $a_adt->isSmallerOrEqual($this->getUpperADT());
173  }
174  }
isLargerOrEqual(ilADT $a_adt)
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()

ilADTDateSearchBridgeRange::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

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

26  : bool
27  {
28  return ($a_adt_def instanceof ilADTDateDefinition);
29  }

◆ loadFilter()

ilADTDateSearchBridgeRange::loadFilter ( )

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

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

33  : void
34  {
35  $value = $this->readFilter();
36  if ($value !== null) {
37  if ($value["lower"] ?? false) {
38  $this->getLowerADT()->setDate(new ilDate($value["lower"], IL_CAL_DATE));
39  }
40  if ($value["upper"] ?? false) {
41  $this->getUpperADT()->setDate(new ilDate($value["upper"], IL_CAL_DATE));
42  }
43  }
44  }
readFilter()
Load value(s) from filter store (in session)
const IL_CAL_DATE
+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTDateSearchBridgeRange::setSerializedValue ( string  $a_value)

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

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

193  : void
194  {
195  $a_value = unserialize($a_value);
196  if (is_array($a_value)) {
197  if (isset($a_value["lower"])) {
198  $this->getLowerADT()->setDate(new ilDate($a_value["lower"], IL_CAL_DATE));
199  }
200  if (isset($a_value["upper"])) {
201  $this->getUpperADT()->setDate(new ilDate($a_value["upper"], IL_CAL_DATE));
202  }
203  }
204  }
const IL_CAL_DATE
+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTDateSearchBridgeRange::shouldBeImportedFromPost (   $a_post)
protected

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

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

95  : bool
96  {
97  if ($this->getForm() instanceof ilPropertyFormGUI) {
98  return ($a_post['lower'] ?? false) || ($a_post['upper'] ?? false);
99  }
100  return parent::shouldBeImportedFromPost($a_post);
101  }
+ 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: