ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAdvancedMDFieldDefinitionDate.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 //
29 // generic types
30 //
31
32 public function getType(): int
33 {
34 return self::TYPE_DATE;
35 }
36
37
38 //
39 // ADT
40 //
41
42 protected function initADTDefinition(): ilADTDefinition
43 {
44 return ilADTFactory::getInstance()->getDefinitionInstanceByType("Date");
45 }
46
47
48 //
49 // import/export
50 //
51
52 public function getValueForXML(ilADT $element): string
53 {
54 return $element->getDate()->get(IL_CAL_DATE);
55 }
56
57 public function importValueFromXML(string $a_cdata): void
58 {
59 $this->getADT()->setDate(new ilDate($a_cdata, IL_CAL_DATE));
60 }
61
62 public function importFromECS(string $a_ecs_type, $a_value, string $a_sub_id): bool
63 {
64 $value = '';
65 switch ($a_ecs_type) {
67 if ($a_value instanceof ilECSTimePlace) {
68 $value = new ilDate($a_value->{'getUT' . ucfirst($a_sub_id)}(), IL_CAL_UNIX);
69 }
70 break;
71 }
72
73 if ($a_value instanceof ilDate) {
74 $this->getADT()->setDate($value);
75 return true;
76 }
77 return false;
78 }
79
83 public function getLuceneSearchString($a_value): string
84 {
85 $start = new ilDate('1970-01-01', IL_CAL_DATE);
86 $end = new ilDate('2038-01-19', IL_CAL_DATE);
87
88 if (!($a_value['lower'] ?? false) || !($a_value['upper'])) {
89 return '';
90 }
91 if ($a_value['lower'] ?? false) {
92 $start = ilCalendarUtil::parseIncomingDate($a_value['lower']);
93 }
94 if ($a_value['upper'] ?? false) {
95 $end = ilCalendarUtil::parseIncomingDate($a_value['upper']);
96 }
97 return '[' . $start->get(IL_CAL_DATE) . ' TO ' . $end->get(IL_CAL_DATE) . ']';
98 }
99}
const IL_CAL_DATE
const IL_CAL_UNIX
ADT definition base class.
ADT base class.
Definition: class.ilADT.php:26
importValueFromXML(string $a_cdata)
Import value from xml.
getValueForXML(ilADT $element)
Parse ADT value for xml (export)
importFromECS(string $a_ecs_type, $a_value, string $a_sub_id)
Import meta data from ECS.
getLuceneSearchString($a_value)
Get search string in lucene syntax.with php 8 support change parameter to union type
static parseIncomingDate($value, bool $add_time=false)
Try to parse incoming value to date object.
Class for single dates.
Representation of ECS EContent Time Place.
const TYPE_TIMEPLACE