ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
VCalendar.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 class VCalendar
24 {
25  protected string $name;
26  protected string $uid;
27 
31  protected array $events;
32  protected Method $method;
33 
34  public function __construct(Method $method, string $name, string $uid, VEvent ...$events)
35  {
36  $this->name = $name;
37  $this->uid = $uid;
38  $this->events = $events;
39  $this->method = $method;
40  }
41 
42  public function render(): string
43  {
44  return 'BEGIN:VCALENDAR' . "\r\n" .
45  'PRODID:-//ILIAS' . "\r\n" .
46  'VERSION:2.0' . "\r\n" .
47  'UID:' . $this->uid . "\r\n" .
48  'X-WR-RELCALID:' . $this->uid . "\r\n" .
49  'NAME:' . $this->name . "\r\n" .
50  'X-WR-CALNAME:' . $this->name . "\r\n" .
51  'LAST-MODIFIED:' . date("Ymd\THis") . "\r\n" .
52  'METHOD:' . $this->method->value . "\r\n" .
53  'BEGIN:VTIMEZONE' . "\r\n" .
54  'TZID:Europe/Paris' . "\r\n" .
55  'X-LIC-LOCATION:Europe/Paris' . "\r\n" .
56  'BEGIN:DAYLIGHT' . "\r\n" .
57  'TZOFFSETFROM:+0100' . "\r\n" .
58  'TZOFFSETTO:+0200' . "\r\n" .
59  'TZNAME:CEST' . "\r\n" .
60  'DTSTART:19700329T020000' . "\r\n" .
61  'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU' . "\r\n" .
62  'END:DAYLIGHT' . "\r\n" .
63  'BEGIN:STANDARD' . "\r\n" .
64  'TZOFFSETFROM:+0200' . "\r\n" .
65  'TZOFFSETTO:+0100' . "\r\n" .
66  'TZNAME:CET' . "\r\n" .
67  'DTSTART:19701025T030000' . "\r\n" .
68  'RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU' . "\r\n" .
69  'END:STANDARD' . "\r\n" .
70  'END:VTIMEZONE' . "\r\n" .
71 
72  $this->renderVEvents() .
73 
74  'END:VCALENDAR' . "\r\n";
75  }
76 
77  private function renderVEvents(): string
78  {
79  $eventString = '';
80  foreach ($this->events as $event) {
81  $eventString .= $event->render();
82  }
83 
84  return $eventString;
85  }
86 }
__construct(Method $method, string $name, string $uid, VEvent ... $events)
Definition: VCalendar.php:34