ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAdvancedMDFieldDefinitionDate.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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 }
Representation of ECS EContent Time Place.
const IL_CAL_UNIX
ADT base class.
Definition: class.ilADT.php:11
const TYPE_TIMEPLACE
const IL_CAL_DATE
importFromECS(string $a_ecs_type, $a_value, string $a_sub_id)
static parseIncomingDate($a_value, bool $a_add_time=false)
Try to parse incoming value to date object.
ADT definition base class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...