add new feature to donwload a calendar

This commit is contained in:
2022-03-04 17:06:49 +01:00
parent 6c08d2462a
commit 508439e8cf
8 changed files with 45 additions and 28 deletions

View File

@@ -17,7 +17,8 @@ class Plugin extends PluginBase {
public function registerComponents() { public function registerComponents() {
return [ return [
'NicoSt\GCalendar\Components\Upcoming' => 'upcoming', 'NicoSt\GCalendar\Components\Upcoming' => 'upcoming',
'NicoSt\GCalendar\Components\EmbeddedCalendar' => 'embeddedCalendar' 'NicoSt\GCalendar\Components\EmbeddedCalendar' => 'embeddedCalendar',
'NicoSt\GCalendar\Components\Download' => 'download'
]; ];
} }

View File

@@ -176,6 +176,7 @@ class EmbeddedCalendar extends ComponentBase {
$data += ['wkst' => 2]; $data += ['wkst' => 2];
} }
// Calenders from config
$calendarList = $this->getCalendarsFromProperties(); $calendarList = $this->getCalendarsFromProperties();
$dataParams = http_build_query($data); $dataParams = http_build_query($data);
@@ -220,9 +221,9 @@ class EmbeddedCalendar extends ComponentBase {
$exp_key = explode($this->calPropSeparator, $key); $exp_key = explode($this->calPropSeparator, $key);
if($exp_key[0] == 'cal' && $this->property($key) == true){ if($exp_key[0] == 'cal' && $this->property($key) == true){
$calendar = []; $calendar = [];
$calendar['src'] = $exp_key[2];
$calendar['color'] = $exp_key[1]; $calendar['color'] = $exp_key[1];
$calendars[] = $calendar; $calendar['src'] = $exp_key[2];
array_push($calendars, $calendar);
} }
} }
@@ -230,7 +231,6 @@ class EmbeddedCalendar extends ComponentBase {
} }
private function calendarProperties() { private function calendarProperties() {
// ToDo: Add cache => https://octobercms.com/docs/services/cache
$service = new GoogleCalendarService(); $service = new GoogleCalendarService();
$calendars = $service->calendarList(); $calendars = $service->calendarList();

View File

@@ -41,7 +41,7 @@ class Upcoming extends ComponentBase {
]; ];
} }
public function events() { public function getEvents() {
$connector = new GoogleCalendarService(); $connector = new GoogleCalendarService();
$maxEvents = $this->property('maxEvents'); $maxEvents = $this->property('maxEvents');
$calendarEvents = $connector->allEventList($maxEvents); $calendarEvents = $connector->allEventList($maxEvents);

View File

@@ -1,4 +1,4 @@
{% set events = upcoming.events %} {% set events = __SELF__.events %}
{% if not events.error and events is not empty %} {% if not events.error and events is not empty %}
<table> <table>

34
composer.lock generated
View File

@@ -136,16 +136,16 @@
}, },
{ {
"name": "google/apiclient-services", "name": "google/apiclient-services",
"version": "v0.228.0", "version": "v0.232.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git", "url": "https://github.com/googleapis/google-api-php-client-services.git",
"reference": "ec64bbf1d6af9475bee7b1ce4fc0ed8a0a8d8889" "reference": "e671adddfd3d2b36a415e7bf22189b1626bc13f8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ec64bbf1d6af9475bee7b1ce4fc0ed8a0a8d8889", "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/e671adddfd3d2b36a415e7bf22189b1626bc13f8",
"reference": "ec64bbf1d6af9475bee7b1ce4fc0ed8a0a8d8889", "reference": "e671adddfd3d2b36a415e7bf22189b1626bc13f8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -174,9 +174,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/googleapis/google-api-php-client-services/issues", "issues": "https://github.com/googleapis/google-api-php-client-services/issues",
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.228.0" "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.232.0"
}, },
"time": "2021-12-21T12:26:12+00:00" "time": "2022-01-28T12:22:13+00:00"
}, },
{ {
"name": "google/auth", "name": "google/auth",
@@ -720,16 +720,16 @@
}, },
{ {
"name": "paragonie/constant_time_encoding", "name": "paragonie/constant_time_encoding",
"version": "v2.4.0", "version": "v2.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git", "url": "https://github.com/paragonie/constant_time_encoding.git",
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c" "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c", "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/9229e15f2e6ba772f0c55dd6986c563b937170a8",
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c", "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -783,7 +783,7 @@
"issues": "https://github.com/paragonie/constant_time_encoding/issues", "issues": "https://github.com/paragonie/constant_time_encoding/issues",
"source": "https://github.com/paragonie/constant_time_encoding" "source": "https://github.com/paragonie/constant_time_encoding"
}, },
"time": "2020-12-06T15:14:20+00:00" "time": "2022-01-17T05:32:27+00:00"
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
@@ -837,16 +837,16 @@
}, },
{ {
"name": "phpseclib/phpseclib", "name": "phpseclib/phpseclib",
"version": "3.0.12", "version": "3.0.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpseclib/phpseclib.git", "url": "https://github.com/phpseclib/phpseclib.git",
"reference": "89bfb45bd8b1abc3b37e910d57f5dbd3174f40fb" "reference": "1443ab79364eea48665fa8c09ac67f37d1025f7e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/89bfb45bd8b1abc3b37e910d57f5dbd3174f40fb", "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/1443ab79364eea48665fa8c09ac67f37d1025f7e",
"reference": "89bfb45bd8b1abc3b37e910d57f5dbd3174f40fb", "reference": "1443ab79364eea48665fa8c09ac67f37d1025f7e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -928,7 +928,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/phpseclib/phpseclib/issues", "issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.12" "source": "https://github.com/phpseclib/phpseclib/tree/3.0.13"
}, },
"funding": [ "funding": [
{ {
@@ -944,7 +944,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-11-28T23:46:03+00:00" "time": "2022-01-30T08:50:05+00:00"
}, },
{ {
"name": "psr/cache", "name": "psr/cache",

View File

@@ -74,8 +74,14 @@
], ],
'showCalendarList' => [ 'showCalendarList' => [
'title' => 'Kalender Liste Anzeigen' 'title' => 'Kalender Liste Anzeigen'
]
]
], ],
'download' => [
'name' => 'Download Kalender',
'description' => 'Kalender als "ICS-Datei" downloaden.',
'groups' => [
'calendars' => 'Kalender'
] ]
] ]
], ],

View File

@@ -74,8 +74,14 @@
], ],
'showCalendarList' => [ 'showCalendarList' => [
'title' => 'Show Calendar List' 'title' => 'Show Calendar List'
]
]
], ],
'download' => [
'name' => 'Download Calendar',
'description' => 'Download calendar as "ICS-File".',
'groups' => [
'calendars' => 'Calendars'
] ]
] ]
], ],

View File

@@ -1,3 +1,7 @@
1.0.0: 1.0.0:
- Initialize plugin. - Initialize plugin.
- Prepare for October marketplace. - Prepare for October marketplace.
1.1.0
- Add new "Download" component to display a list of calendars to be downloaded as ics-file.
- Update dependencies
- Fix some minor bugs