ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAdvancedMDFieldDefinitionDate.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php";
5 
15 {
16  //
17  // generic types
18  //
19 
20  public function getType()
21  {
22  return self::TYPE_DATE;
23  }
24 
25 
26  //
27  // ADT
28  //
29 
30  protected function initADTDefinition()
31  {
32  return ilADTFactory::getInstance()->getDefinitionInstanceByType("Date");
33  }
34 
35 
36  //
37  // import/export
38  //
39 
40  public function getValueForXML(ilADT $element)
41  {
42  return $element->getDate()->get(IL_CAL_DATE);
43  }
44 
45  public function importValueFromXML($a_cdata)
46  {
47  $this->getADT()->setDate(new ilDate($a_cdata, IL_CAL_DATE));
48  }
49 
50  public function importFromECS($a_ecs_type, $a_value, $a_sub_id)
51  {
52  switch ($a_ecs_type) {
54  if ($a_value instanceof ilECSTimePlace) {
55  $value = new ilDate($a_value->{'getUT' . ucfirst($a_sub_id)}(), IL_CAL_UNIX);
56  }
57  break;
58  }
59 
60  if ($value instanceof ilDate) {
61  $this->getADT()->setDate($value);
62  return true;
63  }
64  return false;
65  }
66 
67 
68  //
69  // search
70  //
71 
72  public function getLuceneSearchString($a_value)
73  {
74  // see ilADTDateSearchBridgeRange::importFromPost();
75 
76  if ($a_value["tgl"]) {
77  $start = $end = null;
78 
79  if ($a_value["lower"]["date"]) {
80  $start = mktime(
81  12,
82  0,
83  0,
84  $a_value["lower"]["date"]["m"],
85  $a_value["lower"]["date"]["d"],
86  $a_value["lower"]["date"]["y"]
87  );
88  }
89  if ($a_value["upper"]["date"]) {
90  $end = mktime(
91  12,
92  0,
93  0,
94  $a_value["upper"]["date"]["m"],
95  $a_value["upper"]["date"]["d"],
96  $a_value["upper"]["date"]["y"]
97  );
98  }
99 
100  if ($start && $end && $start > $end) {
101  $tmp = $start;
102  $start = $end;
103  $end = $tmp;
104  }
105 
107  $end = new ilDate($end, IL_CAL_UNIX);
108 
109  return "{" . $start->get(IL_CAL_DATE) . " TO " . $end->get(IL_CAL_DATE) . "}";
110  }
111  }
112 }
Representation of ECS EContent Time Place.
const IL_CAL_UNIX
static getInstance()
Get singleton.
ADT base class.
Definition: class.ilADT.php:11
const TYPE_TIMEPLACE
$start
Definition: bench.php:8
Class for single dates.
const IL_CAL_DATE