ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTDateSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected function isValidADTDefinition(ilADTDefinition $a_adt_def): bool
24 {
25 return ($a_adt_def instanceof ilADTDateDefinition);
26 }
27
28 // table2gui / filter
29
30 public function loadFilter(): void
31 {
32 $value = $this->readFilter();
33 if ($value !== null) {
34 // $this->getADT()->setDate(new ilDate($value, IL_CAL_DATE));
35 }
36 }
37
38 // form
39
40 public function addToForm(): void
41 {
42 $adt_date = $this->getADT()->getDate();
43
44 $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
45 $date->setShowTime(false);
46
47 $date->setDate($adt_date);
48
49 $this->addToParentElement($date);
50 }
51
55 protected function shouldBeImportedFromPost($a_post): bool
56 {
57 return ($a_post['lower'] ?? false) || ($a_post['upper'] ?? false);
58 }
59
60 public function importFromPost(?array $a_post = null): bool
61 {
62 $post = $this->extractPostValues($a_post);
63
64 if ($post && $this->shouldBeImportedFromPost($post)) {
66
67 if ($this->getForm() instanceof ilPropertyFormGUI) {
68 $item = $this->getForm()->getItemByPostVar($this->getElementId());
69 $item->setDate($date);
70 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
71 $this->table_filter_fields[$this->getElementId()]->setDate($date);
72 $this->writeFilter($date->get(IL_CAL_DATE));
73 }
74
75 $this->getADT()->setDate($date);
76 } else {
77 $this->writeFilter();
78 $this->getADT()->setDate();
79 }
80 return true;
81 }
82
83 // db
84
85 public function getSQLCondition(string $a_element_id, int $mode = self::SQL_LIKE, array $quotedWords = []): string
86 {
87 if (!$this->isNull() && $this->isValid()) {
88 return $a_element_id . " = " . $this->db->quote($this->getADT()->getDate()->get(IL_CAL_DATE), "date");
89 }
90 return '';
91 }
92
93 public function isInCondition(ilADT $a_adt): bool
94 {
95 assert($a_adt instanceof ilADTDate);
96
97 return $this->getADT()->equals($a_adt);
98 }
99
100 // import/export
101
102 public function getSerializedValue(): string
103 {
104 if (!$this->isNull() && $this->isValid()) {
105 return serialize(array($this->getADT()->getDate()->get(IL_CAL_DATE)));
106 }
107 return '';
108 }
109
110 public function setSerializedValue(string $a_value): void
111 {
112 $a_value = unserialize($a_value);
113 if (is_array($a_value)) {
114 $this->getADT()->setDate(new ilDate($a_value[0], IL_CAL_DATE));
115 }
116 }
117}
const IL_CAL_DATE
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
isInCondition(ilADT $a_adt)
Compare directly against ADT.
setSerializedValue(string $a_value)
Set current value(s) in serialized form (for easy persisting)
isValidADTDefinition(ilADTDefinition $a_adt_def)
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
addToForm()
Add ADT-specific fields to form.
loadFilter()
Load filter value(s) into ADT.
ADT definition base class.
Class ilADTSearchBridgeSingle.
readFilter()
Load value(s) from filter store (in session)
extractPostValues(?array $a_post=null)
Extract data from (post) values.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
ADT base class.
Definition: class.ilADT.php:26
static parseIncomingDate($value, bool $add_time=false)
Try to parse incoming value to date object.
This class represents a date/time property in a property form.
Class for single dates.
This class represents a property form user interface.
$post
Definition: ltitoken.php:46