ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTDateSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
3require_once "Services/ADT/classes/Bridges/class.ilADTSearchBridgeSingle.php";
4
6{
7 protected function isValidADTDefinition(ilADTDefinition $a_adt_def)
8 {
9 return ($a_adt_def instanceof ilADTDateDefinition);
10 }
11
12
13 // table2gui / filter
14
15 public function loadFilter()
16 {
17 $value = $this->readFilter();
18 if ($value !== null) {
19 // $this->getADT()->setDate(new ilDate($value, IL_CAL_DATE));
20 }
21 }
22
23
24 // form
25
26 public function addToForm()
27 {
28 $adt_date = $this->getADT()->getDate();
29
30 $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
31 $date->setShowTime(false);
32
33 $date->setDate($adt_date);
34
35 $this->addToParentElement($date);
36 }
37
38 protected function shouldBeImportedFromPost($a_post)
39 {
40 if (!(bool) $this->text_input) {
41 return (bool) $a_post["tgl"];
42 }
43 return parent::shouldBeImportedFromPost($a_post);
44 }
45
46 public function importFromPost(array $a_post = null)
47 {
48 $post = $this->extractPostValues($a_post);
49
50 if ($post && $this->shouldBeImportedFromPost($post)) {
51 include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
53
54 if ($this->getForm() instanceof ilPropertyFormGUI) {
55 $item = $this->getForm()->getItemByPostVar($this->getElementId());
56 $item->setDate($date);
57 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
58 $this->table_filter_fields[$this->getElementId()]->setDate($date);
59 $this->writeFilter($date->get(IL_CAL_DATE));
60 }
61
62 $this->getADT()->setDate($date);
63 } else {
64 $this->writeFilter();
65 $this->getADT()->setDate();
66 }
67 }
68
69
70 // db
71
72 public function getSQLCondition($a_element_id)
73 {
74 global $DIC;
75
76 $ilDB = $DIC['ilDB'];
77
78 if (!$this->isNull() && $this->isValid()) {
79 return $a_element_id . " = " . $ilDB->quote($this->getADT()->getDate()->get(IL_CAL_DATE), "date");
80 }
81 }
82
83 public function isInCondition(ilADT $a_adt)
84 {
85 assert($a_adt instanceof ilADTDate);
86
87 return $this->getADT()->equals($a_adt);
88 }
89
90
91 // import/export
92
93 public function getSerializedValue()
94 {
95 if (!$this->isNull() && $this->isValid()) {
96 return serialize(array($this->getADT()->getDate()->get(IL_CAL_DATE)));
97 }
98 }
99
100 public function setSerializedValue($a_value)
101 {
102 $a_value = unserialize($a_value);
103 if (is_array($a_value)) {
104 $this->getADT()->setDate(new ilDate($a_value[0], IL_CAL_DATE));
105 }
106 }
107}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
isInCondition(ilADT $a_adt)
Compare directly against ADT.
setSerializedValue($a_value)
Set current value(s) in serialized form (for easy persisting)
isValidADTDefinition(ilADTDefinition $a_adt_def)
Check if given ADT definition is valid.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
getSQLCondition($a_element_id)
Get SQL condition for current value(s)
addToForm()
Add ADT-specific fields to form.
importFromPost(array $a_post=null)
Import values from (search) form request POST data.
loadFilter()
Load filter value(s) into ADT.
ADT definition base class.
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.
getElementId()
Get element id.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
ADT base class.
Definition: class.ilADT.php:12
static parseIncomingDate($a_value, $a_add_time=null)
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: post.php:34
global $DIC
Definition: saml.php:7
global $ilDB