ILIAS  release_8 Revision v8.24
class.ilADTDateTimeSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
23{
24 protected function isValidADTDefinition(ilADTDefinition $a_adt_def): bool
25 {
26 return ($a_adt_def instanceof ilADTDateTimeDefinition);
27 }
28
29 // table2gui / filter
30
31 public function loadFilter(): void
32 {
33 $value = $this->readFilter();
34 if ($value !== null) {
35 $this->getADT()->setDate(new ilDateTime($value, IL_CAL_DATETIME));
36 }
37 }
38
39 // form
40
41 public function addToForm(): void
42 {
43 $adt_date = $this->getADT()->getDate();
44
45 $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
46 $date->setShowTime(true);
47
48 $date->setDate($adt_date);
49
50 $this->addToParentElement($date);
51 }
52
56 protected function shouldBeImportedFromPost($a_post): bool
57 {
58 return ($a_post['lower'] ?? false) || ($a_post['upper'] ?? false);
59 }
60
61 public function importFromPost(array $a_post = null): bool
62 {
63 $post = $this->extractPostValues($a_post);
64
65 if ($post && $this->shouldBeImportedFromPost($post)) {
67
68 if ($this->getForm() instanceof ilPropertyFormGUI) {
69 $item = $this->getForm()->getItemByPostVar($this->getElementId());
70 $item->setDate($date);
71 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
72 $this->table_filter_fields[$this->getElementId()]->setDate($date);
73 $this->writeFilter($date->get(IL_CAL_DATETIME));
74 }
75
76 $this->getADT()->setDate($date);
77 } else {
78 $this->writeFilter();
79 $this->getADT()->setDate();
80 }
81 return true;
82 }
83
84 // db
85
86 public function getSQLCondition(string $a_element_id, int $mode = self::SQL_LIKE, array $quotedWords = []): string
87 {
88 if (!$this->isNull() && $this->isValid()) {
89 return $a_element_id . " = " . $this->db->quote($this->getADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
90 }
91 return '';
92 }
93
94 public function isInCondition(ilADT $a_adt): bool
95 {
96 assert($a_adt instanceof ilADTDateTime);
97
98 return $this->getADT()->equals($a_adt);
99 }
100
101 // import/export
102
103 public function getSerializedValue(): string
104 {
105 if (!$this->isNull() && $this->isValid()) {
106 return serialize(array($this->getADT()->getDate()->get(IL_CAL_DATETIME)));
107 }
108 return '';
109 }
110
111 public function setSerializedValue(string $a_value): void
112 {
113 $a_value = unserialize($a_value);
114 if (is_array($a_value)) {
115 $this->getADT()->setDate(new ilDateTime($a_value[0], IL_CAL_DATETIME));
116 }
117 }
118}
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
isInCondition(ilADT $a_adt)
Compare directly against ADT.
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
setSerializedValue(string $a_value)
Set current value(s) in serialized form (for easy persisting)
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:12
static parseIncomingDate($a_value, bool $a_add_time=false)
Try to parse incoming value to date object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@classDescription Date and time handling
This class represents a property form user interface.
$post
Definition: ltitoken.php:49