From b88e169cfc1fb113a68d057bc56c6e3524f40e35 Mon Sep 17 00:00:00 2001 From: gruinelli Date: Sun, 17 Mar 2024 17:19:02 +0000 Subject: [PATCH] Dateien nach "ICal" hochladen --- ICal/Event.php | 187 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 ICal/Event.php diff --git a/ICal/Event.php b/ICal/Event.php new file mode 100644 index 0000000..6777461 --- /dev/null +++ b/ICal/Event.php @@ -0,0 +1,187 @@ + $value) { + $variable = lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', strtolower($key))))); + $this->{$variable} = self::prepareData($value); + } + } + } + + /** + * Prepares the data for output + * + * @param mixed $value + * @return mixed + */ + protected function prepareData($value) { + if (is_string($value)) { + return stripslashes(trim(str_replace('\n', "\n", $value))); + } else if (is_array($value)) { + return array_map('self::prepareData', $value); + } + + return $value; + } + + /** + * Return Event data excluding anything blank + * within an HTML template + * + * @param string $html HTML template to use + * @return string + */ + public function printData($html = '

%s: %s

') + { + $data = array( + 'SUMMARY' => $this->summary, + 'DTSTART' => $this->dtstart, + 'DTEND' => $this->dtend, + 'DTSTART_TZ' => $this->dtstart_tz, + 'DTEND_TZ' => $this->dtend_tz, + 'DURATION' => $this->duration, + 'DTSTAMP' => $this->dtstamp, + 'UID' => $this->uid, + 'CREATED' => $this->created, + 'LAST-MODIFIED' => $this->lastmodified, + 'DESCRIPTION' => $this->description, + 'LOCATION' => $this->location, + 'SEQUENCE' => $this->sequence, + 'STATUS' => $this->status, + 'TRANSP' => $this->transp, + 'ORGANISER' => $this->organizer, + 'ATTENDEE(S)' => $this->attendee, + ); + + $data = array_map('trim', $data); // Trim all values + $data = array_filter($data); // Remove any blank values + $output = ''; + + foreach ($data as $key => $value) { + $output .= sprintf($html, $key, $value); + } + + return $output; + } +} \ No newline at end of file