ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilADTDateTimeSearchBridgeRange Class Reference

Class ilADTDateTimeSearchBridgeRange. More...

+ Inheritance diagram for ilADTDateTimeSearchBridgeRange:
+ Collaboration diagram for ilADTDateTimeSearchBridgeRange:

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...
 
 addToFilterForm ()
 Add ADT-specific fields to filter. 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

Member Function Documentation

◆ addToForm()

ilADTDateTimeSearchBridgeRange::addToForm ( )

Definition at line 48 of file class.ilADTDateTimeSearchBridgeRange.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  // :TODO: use DateDurationInputGUI ?!
52 
53  $check = new ilCustomInputGUI($this->getTitle());
54 
55  $date_from = new ilDateTimeInputGUI($this->lng->txt('from'), $this->addToElementId("lower"));
56  $date_from->setShowTime(true);
57  $check->addSubItem($date_from);
58 
59  if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
60  $date_from->setDate($this->getLowerADT()->getDate());
61  $checked = true;
62  }
63 
64  $date_until = new ilDateTimeInputGUI($this->lng->txt('until'), $this->addToElementId("upper"));
65  $date_until->setShowTime(true);
66  $check->addSubItem($date_until);
67 
68  if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
69  $date_until->setDate($this->getUpperADT()->getDate());
70  $checked = true;
71  }
72 
73  $this->addToParentElement($check);
74  } else {
75  // see ilTable2GUI::addFilterItemByMetaType()
76  $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
77 
78  $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
79  $lower->setShowTime(true);
80  $item->addCombinationItem("lower", $lower, $this->lng->txt("from"));
81 
82  if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
83  $lower->setDate($this->getLowerADT()->getDate());
84  }
85 
86  $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
87  $upper->setShowTime(true);
88  $item->addCombinationItem("upper", $upper, $this->lng->txt("to"));
89 
90  if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
91  $upper->setDate($this->getUpperADT()->getDate());
92  }
93 
94  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
95 
96  $this->addToParentElement($item);
97  }
98  }
setShowTime(bool $a_showtime)
This class represents a date/time property in a property form.
This class represents a number property in a property form.
$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()

ilADTDateTimeSearchBridgeRange::getSerializedValue ( )

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

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

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

◆ getSQLCondition()

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

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

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

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

◆ importFromPost()

ilADTDateTimeSearchBridgeRange::importFromPost ( ?array  $a_post = null)

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

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

108  : bool
109  {
110  $post = $this->extractPostValues($a_post);
111 
112  if ($post && $this->shouldBeImportedFromPost($post)) {
113  $start = ilCalendarUtil::parseIncomingDate($post["lower"], true);
114  $end = ilCalendarUtil::parseIncomingDate($post["upper"], true);
115  if ($start && $end && $start->get(IL_CAL_UNIX) > $end->get(IL_CAL_UNIX)) {
116  $tmp = $start;
117  $start = $end;
118  $end = $tmp;
119  }
120 
121  if ($this->getForm() instanceof ilPropertyFormGUI) {
122  $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[lower]");
123  $item->setDate($start);
124 
125  $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[upper]");
126  $item->setDate($end);
127  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
128  $this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
129  $this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
130  $this->writeFilter(array(
131  "lower" => (!$start || $start->isNull()) ? null : $start->get(IL_CAL_DATETIME),
132  "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATETIME)
133  ));
134  }
135 
136  $this->getLowerADT()->setDate($start);
137  $this->getUpperADT()->setDate($end);
138  } else {
139  $this->getLowerADT()->setDate();
140  $this->getUpperADT()->setDate();
141  }
142  return true;
143  }
static parseIncomingDate($value, bool $add_time=false)
Try to parse incoming value to date object.
const IL_CAL_DATETIME
const IL_CAL_UNIX
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
extractPostValues(?array $a_post=null)
Extract data from (post) values.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

◆ isInCondition()

ilADTDateTimeSearchBridgeRange::isInCondition ( ilADT  $a_adt)

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

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

168  : bool
169  {
170  assert($a_adt instanceof ilADTDateTime);
171 
172  if (!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull()) {
173  return (bool) $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
174  } elseif (!$this->getLowerADT()->isNull()) {
175  return (bool) $a_adt->isLargerOrEqual($this->getLowerADT());
176  } else {
177  return (bool) $a_adt->isSmallerOrEqual($this->getUpperADT());
178  }
179  }
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()

ilADTDateTimeSearchBridgeRange::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

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

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

◆ loadFilter()

ilADTDateTimeSearchBridgeRange::loadFilter ( )

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

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

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

◆ setSerializedValue()

ilADTDateTimeSearchBridgeRange::setSerializedValue ( string  $a_value)

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

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

198  : void
199  {
200  $a_value = unserialize($a_value);
201  if (is_array($a_value)) {
202  if (isset($a_value["lower"])) {
203  $this->getLowerADT()->setDate(new ilDateTime($a_value["lower"], IL_CAL_DATETIME));
204  }
205  if (isset($a_value["upper"])) {
206  $this->getUpperADT()->setDate(new ilDateTime($a_value["upper"], IL_CAL_DATETIME));
207  }
208  }
209  }
const IL_CAL_DATETIME
+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTDateTimeSearchBridgeRange::shouldBeImportedFromPost (   $a_post)
protected

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

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

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