ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php";
5
15{
16 //
17 // generic types
18 //
19
20 public function getType()
21 {
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)
53 {
55 if($a_value instanceof ilECSTimePlace)
56 {
57 $value = new ilDateTime($a_value->{'getUT'.ucfirst($a_sub_id)}(), IL_CAL_UNIX);
58 }
59 break;
60 }
61
62 if($value instanceof ilDateTime)
63 {
64 $this->getADT()->setDate($value);
65 return true;
66 }
67 return false;
68 }
69
70
71 //
72 // search
73 //
74
75 public function getLuceneSearchString($a_value)
76 {
77 // see ilADTDateTimeSearchBridgeRange::importFromPost();
78
79 if($a_value["tgl"])
80 {
81 $start = mktime(
82 $a_value["lower"]["time"]["h"],
83 $a_value["lower"]["time"]["m"],
84 1,
85 $a_value["lower"]["date"]["m"],
86 $a_value["lower"]["date"]["d"],
87 $a_value["lower"]["date"]["y"]);
88
89 $end = mktime(
90 $a_value["upper"]["time"]["h"],
91 $a_value["upper"]["time"]["m"],
92 1,
93 $a_value["upper"]["date"]["m"],
94 $a_value["upper"]["date"]["d"],
95 $a_value["upper"]["date"]["y"]);
96
97 if($start && $end && $start > $end)
98 {
99 $tmp = $start;
100 $start = $end;
101 $end = $tmp;
102 }
103
105 $end = new ilDateTime($end, IL_CAL_UNIX);
106
107 return "{".$start->get(IL_CAL_DATETIME)." TO ".$end->get(IL_CAL_DATETIME)."}";
108 }
109 }
110}
111
112?>
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
static getInstance()
Get singleton.
ADT base class.
Definition: class.ilADT.php:12
getLuceneSearchString($a_value)
Get search string in lucene syntax.
importFromECS($a_ecs_type, $a_value, $a_sub_id)
Import meta data from ECS.
getValueForXML(ilADT $element)
Parse ADT value for xml (export)
@classDescription Date and time handling
Class for single dates.
Representation of ECS EContent Time Place.
const TYPE_TIMEPLACE