diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
commit | 23563c7188e089929b60f9e10721c6fc43a220ff (patch) | |
tree | edfe2b009c82900d4ac27db02222d2f68dcad846 /includes/composer/ical | |
parent | 7a7a49332df7c852abbaa33c7e8e87f93d064d61 (diff) | |
download | pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.gz pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.bz2 pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.zip |
Updated 15 files, added includes/maintenance/deleteUnusedAssets.php and deleted 4944 files (automated)
Diffstat (limited to 'includes/composer/ical')
-rw-r--r-- | includes/composer/ical/ical.php | 69 | ||||
-rw-r--r-- | includes/composer/ical/icalEvent.php | 56 |
2 files changed, 0 insertions, 125 deletions
diff --git a/includes/composer/ical/ical.php b/includes/composer/ical/ical.php deleted file mode 100644 index 84d637c..0000000 --- a/includes/composer/ical/ical.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php declare(strict_types=1); - -require_once('icalEvent.php'); - -class iCal -{ - public $Events = array(); - - public function __construct(string $content) - { - $isUrl = strpos($content, 'http') === 0 && filter_var($content, FILTER_VALIDATE_URL); - $isFile = strpos($content, "\n") === false && file_exists($content); - - if ($isUrl || $isFile) - { - $this->parse(file_get_contents($content)); - } - } - - protected function parse(string $content) : iCal - { - $content = str_replace("\r\n ", '', $content); - - preg_match_all('`BEGIN:VEVENT(.+)END:VEVENT`Us', $content, $matches); - foreach($matches[0] as $eventContent) - { - $this->Events[] = new iCalEvent($eventContent); - } - - return $this; - } - - public function getEventsAfterDate(string $date) : array - { - $output = array(); - - $date = strtotime($date); - foreach ($this->Events as $event) - { - $eventTimestamp = strtotime($event->startDateTime); - if ($eventTimestamp >= $date) - { - $output[] = $event; - } - } - - asort($output); - return $output; - } - - public function getActiveEvents() : array - { - $output = array(); - - $currentDate = strtotime(date('Y-m-d')); - foreach ($this->Events as $event) - { - $eventStartTimestamp = strtotime($event->startDateTime); - $eventEndTimestamp = strtotime($event->endDateTime); - if ($currentDate >= $eventStartTimestamp && $currentDate <= $eventEndTimestamp) - { - $output[] = $event; - } - } - - asort($output); - return $output; - } -}
\ No newline at end of file diff --git a/includes/composer/ical/icalEvent.php b/includes/composer/ical/icalEvent.php deleted file mode 100644 index a2791c2..0000000 --- a/includes/composer/ical/icalEvent.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php declare(strict_types=1); - -class iCalEvent -{ - public $title; - public $description; - public $startDateTime; - public $endDateTime; - public $location; - public $created; - public $lastModified; - - public function __construct(string $eventContent) - { - $this->parseEvent($eventContent); - } - - protected function parseEvent(string $eventContent) : iCalEvent - { - $content = str_replace("\r\n ", '', $eventContent); - - $this->title = $this->getEventDetail($content, "SUMMARY:"); - $this->description = $this->getEventDetail($content, "DESCRIPTION:"); - $this->startDateTime = $this->getEventDateTime($content, "DTSTART"); - $this->endDateTime = $this->getEventDateTime($content, "DTEND"); - $this->location = $this->getEventDetail($content, "LOCATION:"); - $this->created = date('d.m.Y H:i', strtotime($this->getEventDetail($content, "CREATED:"))); - $this->lastModified = date('d.m.Y H:i', strtotime($this->getEventDetail($content, "LAST-MODIFIED:"))); - - return $this; - } - - protected function getEventDetail(string $eventContent, string $eventDetailKey) : string - { - $output = ""; - - if (preg_match('`^' . $eventDetailKey . '(.*)$`m', $eventContent, $match)) - { - $output = trim($match[1]); - } - - return $output; - } - - protected function getEventDateTime(string $eventContent, string $eventDetailKey) : string - { - $output = ""; - - if (preg_match('`^' . $eventDetailKey . '(?:;.+)?:([0-9]+(T[0-9]+Z?)?)`m', $eventContent, $match)) - { - $output = date('d.m.Y H:i', strtotime($match[1])); - } - - return $output; - } -}
\ No newline at end of file |