From 508439e8cf4338118fc64fd0ac202670c8ec023c Mon Sep 17 00:00:00 2001 From: "nico.stoerzbach" Date: Fri, 4 Mar 2022 17:06:49 +0100 Subject: [PATCH] add new feature to donwload a calendar --- Plugin.php | 3 ++- components/EmbeddedCalendar.php | 6 +++--- components/Upcoming.php | 2 +- components/upcoming/default.htm | 2 +- composer.lock | 34 ++++++++++++++++----------------- lang/de/lang.php | 10 ++++++++-- lang/en/lang.php | 10 ++++++++-- updates/version.yaml | 6 +++++- 8 files changed, 45 insertions(+), 28 deletions(-) diff --git a/Plugin.php b/Plugin.php index 176dbad..a78a7fc 100644 --- a/Plugin.php +++ b/Plugin.php @@ -17,7 +17,8 @@ class Plugin extends PluginBase { public function registerComponents() { return [ 'NicoSt\GCalendar\Components\Upcoming' => 'upcoming', - 'NicoSt\GCalendar\Components\EmbeddedCalendar' => 'embeddedCalendar' + 'NicoSt\GCalendar\Components\EmbeddedCalendar' => 'embeddedCalendar', + 'NicoSt\GCalendar\Components\Download' => 'download' ]; } diff --git a/components/EmbeddedCalendar.php b/components/EmbeddedCalendar.php index f254507..39ed78a 100644 --- a/components/EmbeddedCalendar.php +++ b/components/EmbeddedCalendar.php @@ -176,6 +176,7 @@ class EmbeddedCalendar extends ComponentBase { $data += ['wkst' => 2]; } + // Calenders from config $calendarList = $this->getCalendarsFromProperties(); $dataParams = http_build_query($data); @@ -220,9 +221,9 @@ class EmbeddedCalendar extends ComponentBase { $exp_key = explode($this->calPropSeparator, $key); if($exp_key[0] == 'cal' && $this->property($key) == true){ $calendar = []; - $calendar['src'] = $exp_key[2]; $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() { - // ToDo: Add cache => https://octobercms.com/docs/services/cache $service = new GoogleCalendarService(); $calendars = $service->calendarList(); diff --git a/components/Upcoming.php b/components/Upcoming.php index 79dc869..2153168 100644 --- a/components/Upcoming.php +++ b/components/Upcoming.php @@ -41,7 +41,7 @@ class Upcoming extends ComponentBase { ]; } - public function events() { + public function getEvents() { $connector = new GoogleCalendarService(); $maxEvents = $this->property('maxEvents'); $calendarEvents = $connector->allEventList($maxEvents); diff --git a/components/upcoming/default.htm b/components/upcoming/default.htm index 724f62a..043fba6 100644 --- a/components/upcoming/default.htm +++ b/components/upcoming/default.htm @@ -1,4 +1,4 @@ -{% set events = upcoming.events %} +{% set events = __SELF__.events %} {% if not events.error and events is not empty %} diff --git a/composer.lock b/composer.lock index 8ac3e55..e1c9efe 100644 --- a/composer.lock +++ b/composer.lock @@ -136,16 +136,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.228.0", + "version": "v0.232.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "ec64bbf1d6af9475bee7b1ce4fc0ed8a0a8d8889" + "reference": "e671adddfd3d2b36a415e7bf22189b1626bc13f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ec64bbf1d6af9475bee7b1ce4fc0ed8a0a8d8889", - "reference": "ec64bbf1d6af9475bee7b1ce4fc0ed8a0a8d8889", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/e671adddfd3d2b36a415e7bf22189b1626bc13f8", + "reference": "e671adddfd3d2b36a415e7bf22189b1626bc13f8", "shasum": "" }, "require": { @@ -174,9 +174,9 @@ ], "support": { "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", @@ -720,16 +720,16 @@ }, { "name": "paragonie/constant_time_encoding", - "version": "v2.4.0", + "version": "v2.5.0", "source": { "type": "git", "url": "https://github.com/paragonie/constant_time_encoding.git", - "reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c" + "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c", - "reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/9229e15f2e6ba772f0c55dd6986c563b937170a8", + "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8", "shasum": "" }, "require": { @@ -783,7 +783,7 @@ "issues": "https://github.com/paragonie/constant_time_encoding/issues", "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", @@ -837,16 +837,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.12", + "version": "3.0.13", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "89bfb45bd8b1abc3b37e910d57f5dbd3174f40fb" + "reference": "1443ab79364eea48665fa8c09ac67f37d1025f7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/89bfb45bd8b1abc3b37e910d57f5dbd3174f40fb", - "reference": "89bfb45bd8b1abc3b37e910d57f5dbd3174f40fb", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/1443ab79364eea48665fa8c09ac67f37d1025f7e", + "reference": "1443ab79364eea48665fa8c09ac67f37d1025f7e", "shasum": "" }, "require": { @@ -928,7 +928,7 @@ ], "support": { "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": [ { @@ -944,7 +944,7 @@ "type": "tidelift" } ], - "time": "2021-11-28T23:46:03+00:00" + "time": "2022-01-30T08:50:05+00:00" }, { "name": "psr/cache", diff --git a/lang/de/lang.php b/lang/de/lang.php index d736d52..ea534d6 100644 --- a/lang/de/lang.php +++ b/lang/de/lang.php @@ -74,8 +74,14 @@ ], 'showCalendarList' => [ 'title' => 'Kalender Liste Anzeigen' - ], - + ] + ] + ], + 'download' => [ + 'name' => 'Download Kalender', + 'description' => 'Kalender als "ICS-Datei" downloaden.', + 'groups' => [ + 'calendars' => 'Kalender' ] ] ], diff --git a/lang/en/lang.php b/lang/en/lang.php index 1a9ab54..5b74757 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -74,8 +74,14 @@ ], 'showCalendarList' => [ 'title' => 'Show Calendar List' - ], - + ] + ] + ], + 'download' => [ + 'name' => 'Download Calendar', + 'description' => 'Download calendar as "ICS-File".', + 'groups' => [ + 'calendars' => 'Calendars' ] ] ], diff --git a/updates/version.yaml b/updates/version.yaml index 208c3ef..7aa32c6 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -1,3 +1,7 @@ 1.0.0: - Initialize plugin. - - Prepare for October marketplace. \ No newline at end of file + - 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 \ No newline at end of file