ILIAS  release_8 Revision v8.23
VCalender.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
23 final class VCalender
24 {
25  private string $name;
26 
32  private string $uid;
33 
37  private array $events;
38 
44  private string $method;
45 
53  public function __construct(string $name, string $uid, array $events, string $method)
54  {
55  $this->name = $name;
56  $this->uid = $uid;
57  $this->events = $events;
58  $this->method = $method;
59  }
60 
61  public function render(): string
62  {
63  return 'BEGIN:VCALENDAR' . "\r\n" .
64  'PRODID:-//ILIAS' . "\r\n" .
65  'VERSION:2.0' . "\r\n" .
66  'UID:' . $this->uid . "\r\n" .
67  'X-WR-RELCALID:' . $this->uid . "\r\n" .
68  'NAME:' . $this->name . "\r\n" .
69  'X-WR-CALNAME:' . $this->name . "\r\n" .
70  'LAST-MODIFIED:' . date("Ymd\THis") . "\r\n" .
71  'METHOD:' . $this->method . "\r\n" .
72  'BEGIN:VTIMEZONE' . "\r\n" .
73  'TZID:Europe/Paris' . "\r\n" .
74  'X-LIC-LOCATION:Europe/Paris' . "\r\n" .
75  'BEGIN:DAYLIGHT' . "\r\n" .
76  'TZOFFSETFROM:+0100' . "\r\n" .
77  'TZOFFSETTO:+0200' . "\r\n" .
78  'TZNAME:CEST' . "\r\n" .
79  'DTSTART:19700329T020000' . "\r\n" .
80  'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU' . "\r\n" .
81  'END:DAYLIGHT' . "\r\n" .
82  'BEGIN:STANDARD' . "\r\n" .
83  'TZOFFSETFROM:+0200' . "\r\n" .
84  'TZOFFSETTO:+0100' . "\r\n" .
85  'TZNAME:CET' . "\r\n" .
86  'DTSTART:19701025T030000' . "\r\n" .
87  'RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU' . "\r\n" .
88  'END:STANDARD' . "\r\n" .
89  'END:VTIMEZONE' . "\r\n" .
90 
91  $this->renderVEvents() .
92 
93  'END:VCALENDAR' . "\r\n";
94  }
95 
99  public function getName(): string
100  {
101  return $this->name;
102  }
103 
107  public function getUid(): string
108  {
109  return $this->uid;
110  }
111 
115  public function getEvents(): array
116  {
117  return $this->events;
118  }
119 
123  public function getMethod(): string
124  {
125  return $this->method;
126  }
127 
128  private function renderVEvents(): string
129  {
130  $eventString = "";
131  foreach ($this->events as $event) {
132  $eventString .= $event->render();
133  }
134 
135  return $eventString;
136  }
137 }
__construct(string $name, string $uid, array $events, string $method)
VCalender constructor.
Definition: VCalender.php:53
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...