ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
20  $this->getADT()->setDate(new ilDateTime($value, IL_CAL_DATETIME));
21  }
22  }
23 
24 
25  // form
26 
27  public function addToForm()
28  {
29  global $lng;
30 
31  $adt_date = $this->getADT()->getDate();
32 
33  $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
34  $date->setShowTime(true);
35 
36  $date->setDate($adt_date);
37 
38  $this->addToParentElement($date);
39  }
40 
41  protected function shouldBeImportedFromPost($a_post)
42  {
43  if(!(bool)$this->text_input)
44  {
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  {
56  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
57  $date = ilCalendarUtil::parseIncomingDate($post, 1);
58 
59  if($this->getForm() instanceof ilPropertyFormGUI)
60  {
61  $item = $this->getForm()->getItemByPostVar($this->getElementId());
62  $item->setDate($date);
63  }
64  else if(array_key_exists($this->getElementId(), $this->table_filter_fields))
65  {
66  $this->table_filter_fields[$this->getElementId()]->setDate($date);
67  $this->writeFilter($date->get(IL_CAL_DATETIME));
68  }
69 
70  $this->getADT()->setDate($date);
71  }
72  else
73  {
74  $this->writeFilter();
75  $this->getADT()->setDate();
76  }
77  }
78 
79 
80  // db
81 
82  public function getSQLCondition($a_element_id)
83  {
84  global $ilDB;
85 
86  if(!$this->isNull() && $this->isValid())
87  {
88  return $a_element_id." = ".$ilDB->quote($this->getADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
89  }
90  }
91 
92  public function isInCondition(ilADT $a_adt)
93  {
94  assert($a_adt instanceof ilADTDateTime);
95 
96  return $this->getADT()->equals($a_adt);
97  }
98 
99 
100  // import/export
101 
102  public function getSerializedValue()
103  {
104  if(!$this->isNull() && $this->isValid())
105  {
106  return serialize(array($this->getADT()->getDate()->get(IL_CAL_DATETIME)));
107  }
108  }
109 
110  public function setSerializedValue($a_value)
111  {
112  $a_value = unserialize($a_value);
113  if(is_array($a_value))
114  {
115  $this->getADT()->setDate(new ilDateTime($a_value[0], IL_CAL_DATETIME));
116  }
117  }
118 }
119 
120 ?>
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)
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.