ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAdvancedMDFieldDefinitionDateTime.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_DATETIME;
23  }
24 
25 
26  //
27  // ADT
28  //
29 
30  protected function initADTDefinition()
31  {
32  return ilADTFactory::getInstance()->getDefinitionInstanceByType("DateTime");
33  }
34 
35 
36  //
37  // import/export
38  //
39 
40  public function getValueForXML(ilADT $element)
41  {
42  return $element->getDate()->get(IL_CAL_DATETIME);
43  }
44 
45  public function importValueFromXML($a_cdata)
46  {
47  $this->getADT()->setDate(new ilDate($a_cdata, IL_CAL_DATETIME));
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 ilDateTime($a_value->{'getUT' . ucfirst($a_sub_id)}(), IL_CAL_UNIX);
56  }
57  break;
58  }
59 
60  if ($value instanceof ilDateTime) {
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 ilADTDateTimeSearchBridgeRange::importFromPost();
75 
76  if ($a_value["tgl"]) {
77  $start = mktime(
78  $a_value["lower"]["time"]["h"],
79  $a_value["lower"]["time"]["m"],
80  1,
81  $a_value["lower"]["date"]["m"],
82  $a_value["lower"]["date"]["d"],
83  $a_value["lower"]["date"]["y"]
84  );
85 
86  $end = mktime(
87  $a_value["upper"]["time"]["h"],
88  $a_value["upper"]["time"]["m"],
89  1,
90  $a_value["upper"]["date"]["m"],
91  $a_value["upper"]["date"]["d"],
92  $a_value["upper"]["date"]["y"]
93  );
94 
95  if ($start && $end && $start > $end) {
96  $tmp = $start;
97  $start = $end;
98  $end = $tmp;
99  }
100 
101  $start = new ilDateTime($start, IL_CAL_UNIX);
103 
104  return "{" . $start->get(IL_CAL_DATETIME) . " TO " . $end->get(IL_CAL_DATETIME) . "}";
105  }
106  }
107 }
const IL_CAL_DATETIME
Representation of ECS EContent Time Place.
$end
Definition: saml1-acs.php:18
const IL_CAL_UNIX
static getInstance()
Get singleton.
ADT base class.
Definition: class.ilADT.php:11
const TYPE_TIMEPLACE
Class for single dates.
Date and time handling