ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 // presentation
73 //
74
75 public function prepareElementForEditor(ilADTFormBridge $a_bridge)
76 {
77 $a_bridge->setTextInputMode(true);
78 }
79
80
81 //
82 // search
83 //
84
85 public function getLuceneSearchString($a_value)
86 {
87 // see ilADTDateTimeSearchBridgeRange::importFromPost();
88
89 if($a_value["tgl"])
90 {
91 $start = mktime(
92 $a_value["lower"]["time"]["h"],
93 $a_value["lower"]["time"]["m"],
94 1,
95 $a_value["lower"]["date"]["m"],
96 $a_value["lower"]["date"]["d"],
97 $a_value["lower"]["date"]["y"]);
98
99 $end = mktime(
100 $a_value["upper"]["time"]["h"],
101 $a_value["upper"]["time"]["m"],
102 1,
103 $a_value["upper"]["date"]["m"],
104 $a_value["upper"]["date"]["d"],
105 $a_value["upper"]["date"]["y"]);
106
107 if($start && $end && $start > $end)
108 {
109 $tmp = $start;
110 $start = $end;
111 $end = $tmp;
112 }
113
114 $start = new ilDateTime($start, IL_CAL_UNIX);
115 $end = new ilDateTime($end, IL_CAL_UNIX);
116
117 return "{".$start->get(IL_CAL_DATETIME)." TO ".$end->get(IL_CAL_DATETIME)."}";
118 }
119 }
120
122 {
123 $a_bridge->setTextInputMode(true);
124 }
125}
126
127?>
const IL_CAL_UNIX
const IL_CAL_DATETIME
static getInstance()
Get singleton.
ADT form bridge base class.
ADT search bridge base class.
ADT base class.
Definition: class.ilADT.php:12
getLuceneSearchString($a_value)
Get search string in lucene syntax.
prepareElementForEditor(ilADTFormBridge $a_bridge)
Prepare editor form elements.
importFromECS($a_ecs_type, $a_value, $a_sub_id)
Import meta data from ECS.
prepareElementForSearch(ilADTSearchBridge $a_bridge)
Prepare search form elements.
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