ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng;
29 
30  $adt_date = $this->getADT()->getDate();
31 
32  $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
33  $date->setShowTime(true);
34 
35  $date->setDate($adt_date);
36 
37  $this->addToParentElement($date);
38  }
39 
40  protected function shouldBeImportedFromPost($a_post)
41  {
42  if (!(bool) $this->text_input) {
43  return (bool) $a_post["tgl"];
44  }
45  return parent::shouldBeImportedFromPost($a_post);
46  }
47 
48  public function importFromPost(array $a_post = null)
49  {
50  $post = $this->extractPostValues($a_post);
51 
52  if ($post && $this->shouldBeImportedFromPost($post)) {
53  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
55 
56  if ($this->getForm() instanceof ilPropertyFormGUI) {
57  $item = $this->getForm()->getItemByPostVar($this->getElementId());
58  $item->setDate($date);
59  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
60  $this->table_filter_fields[$this->getElementId()]->setDate($date);
61  $this->writeFilter($date->get(IL_CAL_DATETIME));
62  }
63 
64  $this->getADT()->setDate($date);
65  } else {
66  $this->writeFilter();
67  $this->getADT()->setDate();
68  }
69  }
70 
71 
72  // db
73 
74  public function getSQLCondition($a_element_id)
75  {
76  global $ilDB;
77 
78  if (!$this->isNull() && $this->isValid()) {
79  return $a_element_id . " = " . $ilDB->quote($this->getADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
80  }
81  }
82 
83  public function isInCondition(ilADT $a_adt)
84  {
85  assert($a_adt instanceof ilADTDateTime);
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_DATETIME)));
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 ilDateTime($a_value[0], IL_CAL_DATETIME));
105  }
106  }
107 }
const IL_CAL_DATETIME
This class represents a property form user interface.
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)
$post
Definition: post.php:34
Date and time handling
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
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.