ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTDateTimeSearchBridgeSingle.php
Go to the documentation of this file.
1 <?php
2 
3 require_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 ilADTDateTimeDefinition);
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 ilDateTime($value, IL_CAL_DATETIME));
20  }
21  }
22 
23 
24  // form
25 
26  public function addToForm()
27  {
28  global $DIC;
29 
30  $lng = $DIC['lng'];
31 
32  $adt_date = $this->getADT()->getDate();
33 
34  $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
35  $date->setShowTime(true);
36 
37  $date->setDate($adt_date);
38 
39  $this->addToParentElement($date);
40  }
41 
42  protected function shouldBeImportedFromPost($a_post)
43  {
44  if (!(bool) $this->text_input) {
45  return (bool) $a_post["tgl"];
46  }
47  return parent::shouldBeImportedFromPost($a_post);
48  }
49 
50  public function importFromPost(array $a_post = null)
51  {
52  $post = $this->extractPostValues($a_post);
53 
54  if ($post && $this->shouldBeImportedFromPost($post)) {
55  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
57 
58  if ($this->getForm() instanceof ilPropertyFormGUI) {
59  $item = $this->getForm()->getItemByPostVar($this->getElementId());
60  $item->setDate($date);
61  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
62  $this->table_filter_fields[$this->getElementId()]->setDate($date);
63  $this->writeFilter($date->get(IL_CAL_DATETIME));
64  }
65 
66  $this->getADT()->setDate($date);
67  } else {
68  $this->writeFilter();
69  $this->getADT()->setDate();
70  }
71  }
72 
73 
74  // db
75 
76  public function getSQLCondition($a_element_id)
77  {
78  global $DIC;
79 
80  $ilDB = $DIC['ilDB'];
81 
82  if (!$this->isNull() && $this->isValid()) {
83  return $a_element_id . " = " . $ilDB->quote($this->getADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
84  }
85  }
86 
87  public function isInCondition(ilADT $a_adt)
88  {
89  assert($a_adt instanceof ilADTDateTime);
90 
91  return $this->getADT()->equals($a_adt);
92  }
93 
94 
95  // import/export
96 
97  public function getSerializedValue()
98  {
99  if (!$this->isNull() && $this->isValid()) {
100  return serialize(array($this->getADT()->getDate()->get(IL_CAL_DATETIME)));
101  }
102  }
103 
104  public function setSerializedValue($a_value)
105  {
106  $a_value = unserialize($a_value);
107  if (is_array($a_value)) {
108  $this->getADT()->setDate(new ilDateTime($a_value[0], IL_CAL_DATETIME));
109  }
110  }
111 }
const IL_CAL_DATETIME
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
ADT base class.
Definition: class.ilADT.php:11
extractPostValues(array $a_post=null)
Extract data from (post) values.
This class represents a date/time property in a property form.
readFilter()
Load value(s) from filter store (in session)
$lng
$post
Definition: post.php:34
Date and time handling
writeFilter($a_value=null)
Write value(s) to filter store (in session)
global $ilDB
ADT definition base class.
getElementId()
Get element id.
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.