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