mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +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",
|
"rubellum/slim-blade-view": "^0.1.1",
|
||||||
"morris/lessql": "^0.4.1",
|
"morris/lessql": "^0.4.1",
|
||||||
"gettext/gettext": "^4.8",
|
"gettext/gettext": "^4.8",
|
||||||
"eluceo/ical": "^0.16.0",
|
"eluceo/ical": "^2.2.0",
|
||||||
"erusev/parsedown": "^1.7",
|
"erusev/parsedown": "^1.7",
|
||||||
"gumlet/php-image-resize": "^1.9",
|
"gumlet/php-image-resize": "^1.9",
|
||||||
"ezyang/htmlpurifier": "^4.13",
|
"ezyang/htmlpurifier": "^4.13",
|
||||||
"jucksearm/php-barcode": "^1.0",
|
"jucksearm/php-barcode": "^1.0",
|
||||||
"guzzlehttp/guzzle": "^7.0",
|
"guzzlehttp/guzzle": "^7.0",
|
||||||
"mike42/escpos-php": "^3.0"
|
"mike42/escpos-php": "^3.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"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",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "9c4580f416241994ddaffb569998b7f8",
|
"content-hash": "e17584947a63f049cc9c381a91bf05e8",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/inflector",
|
"name": "doctrine/inflector",
|
||||||
@ -104,26 +104,33 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "eluceo/ical",
|
"name": "eluceo/ical",
|
||||||
"version": "0.16.1",
|
"version": "2.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/markuspoerschke/iCal.git",
|
"url": "https://github.com/markuspoerschke/iCal.git",
|
||||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f"
|
"reference": "84bba8f438a2746a88057ad13032d71e8f9c4104"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/7043337feaeacbc016844e7e52ef41bba504ad8f",
|
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/84bba8f438a2746a88057ad13032d71e8f9c4104",
|
||||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f",
|
"reference": "84bba8f438a2746a88057ad13032d71e8f9c4104",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"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": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7.0"
|
"ergebnis/composer-normalize": "^2.8",
|
||||||
},
|
"friendsofphp/php-cs-fixer": "^2.16",
|
||||||
"suggest": {
|
"infection/infection": "^0.20.1 || ^0.21.0",
|
||||||
"ext-mbstring": "Massive performance enhancement of line folding"
|
"phpmd/phpmd": "~2.9.1 || ~2.10.0",
|
||||||
|
"phpunit/phpunit": "^9",
|
||||||
|
"vimeo/psalm": "^4.4.1"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -138,11 +145,11 @@
|
|||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Markus Poerschke",
|
"name": "Markus Poerschke",
|
||||||
"email": "markus@eluceo.de",
|
"email": "markus@poerschke.nrw",
|
||||||
"role": "Developer"
|
"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",
|
"homepage": "https://github.com/markuspoerschke/iCal",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"calendar",
|
"calendar",
|
||||||
@ -152,10 +159,12 @@
|
|||||||
"php calendar"
|
"php calendar"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
|
"docs": "https://ical.poerschke.nrw",
|
||||||
|
"forum": "https://github.com/markuspoerschke/iCal/discussions",
|
||||||
"issues": "https://github.com/markuspoerschke/iCal/issues",
|
"issues": "https://github.com/markuspoerschke/iCal/issues",
|
||||||
"source": "https://github.com/markuspoerschke/iCal"
|
"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",
|
"name": "erusev/parsedown",
|
||||||
@ -3054,5 +3063,5 @@
|
|||||||
"php": ">=7.4"
|
"php": ">=7.4"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.0.0"
|
"plugin-api-version": "2.1.0"
|
||||||
}
|
}
|
||||||
|
@ -2,44 +2,54 @@
|
|||||||
|
|
||||||
namespace Grocy\Controllers;
|
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
|
class CalendarApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
public function Ical(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
public function Ical(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('grocy');
|
|
||||||
|
|
||||||
$events = $this->getCalendarService()->GetEvents();
|
$events = $this->getCalendarService()->GetEvents();
|
||||||
|
|
||||||
|
$vCalendar = new Calendar();
|
||||||
foreach ($events as $event)
|
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 = '';
|
$description = '';
|
||||||
if (isset($event['description']))
|
if (isset($event['description']))
|
||||||
{
|
{
|
||||||
$description = $event['description'];
|
$description = $event['description'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
if ($event['date_format'] === 'date' || (isset($event['allDay']) && $event['allDay']))
|
||||||
$vEvent->setDtStart($date)
|
{
|
||||||
->setDtEnd($date)
|
// All-day event
|
||||||
->setSummary($event['title'])
|
$date = new Date(\DateTimeImmutable::createFromFormat('Y-m-d', $event['start']));
|
||||||
->setDescription($description)
|
$vEventOccurrence = new SingleDay($date);
|
||||||
->setNoTime($event['date_format'] === 'date' || (isset($event['allDay']) && $event['allDay']))
|
}
|
||||||
->setUseTimezone(true);
|
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');
|
$response = $response->withHeader('Content-Type', 'text/calendar; charset=utf-8');
|
||||||
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
|
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user