mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Upgraded eluceo/ical
This commit is contained in:
parent
82c474d0ae
commit
735743047f
@ -8,13 +8,13 @@
|
||||
"rubellum/slim-blade-view": "^0.1.1",
|
||||
"morris/lessql": "^0.4.1",
|
||||
"gettext/gettext": "^4.8",
|
||||
"eluceo/ical": "^0.16.0",
|
||||
"eluceo/ical": "^2.2.0",
|
||||
"erusev/parsedown": "^1.7",
|
||||
"gumlet/php-image-resize": "^1.9",
|
||||
"ezyang/htmlpurifier": "^4.13",
|
||||
"jucksearm/php-barcode": "^1.0",
|
||||
"guzzlehttp/guzzle": "^7.0",
|
||||
"mike42/escpos-php": "^3.0"
|
||||
"mike42/escpos-php": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
37
composer.lock
generated
37
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9c4580f416241994ddaffb569998b7f8",
|
||||
"content-hash": "e17584947a63f049cc9c381a91bf05e8",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
@ -104,26 +104,33 @@
|
||||
},
|
||||
{
|
||||
"name": "eluceo/ical",
|
||||
"version": "0.16.1",
|
||||
"version": "2.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/markuspoerschke/iCal.git",
|
||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f"
|
||||
"reference": "84bba8f438a2746a88057ad13032d71e8f9c4104"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/7043337feaeacbc016844e7e52ef41bba504ad8f",
|
||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f",
|
||||
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/84bba8f438a2746a88057ad13032d71e8f9c4104",
|
||||
"reference": "84bba8f438a2746a88057ad13032d71e8f9c4104",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1 || ~8.0.0"
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=7.4 || ~8.0.0",
|
||||
"symfony/deprecation-contracts": "^2.1"
|
||||
},
|
||||
"conflict": {
|
||||
"php": "7.4.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "Massive performance enhancement of line folding"
|
||||
"ergebnis/composer-normalize": "^2.8",
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"infection/infection": "^0.20.1 || ^0.21.0",
|
||||
"phpmd/phpmd": "~2.9.1 || ~2.10.0",
|
||||
"phpunit/phpunit": "^9",
|
||||
"vimeo/psalm": "^4.4.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@ -138,11 +145,11 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "Markus Poerschke",
|
||||
"email": "markus@eluceo.de",
|
||||
"email": "markus@poerschke.nrw",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "The eluceo/iCal package offers a abstraction layer for creating iCalendars. You can easily create iCal files by using PHP object instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.",
|
||||
"description": "The eluceo/iCal package offers an abstraction layer for creating iCalendars. You can easily create iCal files by using PHP objects instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.",
|
||||
"homepage": "https://github.com/markuspoerschke/iCal",
|
||||
"keywords": [
|
||||
"calendar",
|
||||
@ -152,10 +159,12 @@
|
||||
"php calendar"
|
||||
],
|
||||
"support": {
|
||||
"docs": "https://ical.poerschke.nrw",
|
||||
"forum": "https://github.com/markuspoerschke/iCal/discussions",
|
||||
"issues": "https://github.com/markuspoerschke/iCal/issues",
|
||||
"source": "https://github.com/markuspoerschke/iCal"
|
||||
},
|
||||
"time": "2020-10-04T17:41:11+00:00"
|
||||
"time": "2021-05-03T12:29:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "erusev/parsedown",
|
||||
@ -3054,5 +3063,5 @@
|
||||
"php": ">=7.4"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.0.0"
|
||||
"plugin-api-version": "2.1.0"
|
||||
}
|
||||
|
@ -2,44 +2,54 @@
|
||||
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use Eluceo\iCal\Domain\Entity\Calendar;
|
||||
use Eluceo\iCal\Domain\Entity\Event;
|
||||
use Eluceo\iCal\Domain\ValueObject\Date;
|
||||
use Eluceo\iCal\Domain\ValueObject\DateTime;
|
||||
use Eluceo\iCal\Domain\ValueObject\SingleDay;
|
||||
use Eluceo\iCal\Domain\ValueObject\TimeSpan;
|
||||
use Eluceo\iCal\Presentation\Factory\CalendarFactory;
|
||||
|
||||
class CalendarApiController extends BaseApiController
|
||||
{
|
||||
public function Ical(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('grocy');
|
||||
|
||||
$events = $this->getCalendarService()->GetEvents();
|
||||
|
||||
$vCalendar = new Calendar();
|
||||
foreach ($events as $event)
|
||||
{
|
||||
$date = new \DateTime($event['start']);
|
||||
$date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
if ($event['date_format'] === 'date')
|
||||
{
|
||||
$date->setTime(23, 59, 59);
|
||||
}
|
||||
|
||||
$description = '';
|
||||
if (isset($event['description']))
|
||||
{
|
||||
$description = $event['description'];
|
||||
}
|
||||
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart($date)
|
||||
->setDtEnd($date)
|
||||
->setSummary($event['title'])
|
||||
->setDescription($description)
|
||||
->setNoTime($event['date_format'] === 'date' || (isset($event['allDay']) && $event['allDay']))
|
||||
->setUseTimezone(true);
|
||||
if ($event['date_format'] === 'date' || (isset($event['allDay']) && $event['allDay']))
|
||||
{
|
||||
// All-day event
|
||||
$date = new Date(\DateTimeImmutable::createFromFormat('Y-m-d', $event['start']));
|
||||
$vEventOccurrence = new SingleDay($date);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Time-point event
|
||||
$start = new DateTime(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $event['start']), false);
|
||||
$end = new DateTime(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $event['start']), false);
|
||||
$vEventOccurrence = new TimeSpan($start, $end);
|
||||
}
|
||||
|
||||
$vCalendar->addComponent($vEvent);
|
||||
$vEvent = new Event();
|
||||
$vEvent->setOccurrence($vEventOccurrence)
|
||||
->setSummary($event['title'])
|
||||
->setDescription($description);
|
||||
|
||||
$vCalendar->addEvent($vEvent);
|
||||
}
|
||||
|
||||
$response->write($vCalendar->render());
|
||||
$response->write((new CalendarFactory())->createCalendar($vCalendar));
|
||||
$response = $response->withHeader('Content-Type', 'text/calendar; charset=utf-8');
|
||||
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user