From f090f5e7229f7c9c8f0e962033c3b7ab98272efa Mon Sep 17 00:00:00 2001 From: ctr49 Date: Sat, 21 Jan 2017 16:02:06 +0100 Subject: [PATCH] add capability to fetch generic ics feed and remove any escape characters prior to html display --- GoogleCalendarHelper/README.md | 8 ++++++-- GoogleCalendarHelper/googlecalendar_ical_parser.php | 11 +++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/GoogleCalendarHelper/README.md b/GoogleCalendarHelper/README.md index c3c3b26d..46882f3e 100644 --- a/GoogleCalendarHelper/README.md +++ b/GoogleCalendarHelper/README.md @@ -1,9 +1,9 @@ # GoogleCalendar Helper for CometVisu -This is a simple helper for displaying Google Calendar events in CometVisu. +This is a simple helper for displaying generic iCal and Google Calendar events in CometVisu. It's composed of two parts: - an iCal reader php class to parse an ics file -- a php script (that also holds the private calendar URL) fetching iCal calendar from Google, calling the parser class and nicely format the content CometVisu-friendly +- a php script (that also holds the private calendar URL) fetching iCal calendar, calling the parser class and nicely format the content CometVisu-friendly ## Requirements @@ -13,9 +13,13 @@ The assumption is that you already have a working CometVisu, served by a web ser Copy the php files into a web-browsable and php-executable directory on this web server. If you use any subdirectories you will have to specify it in the URL later. ## Configuration +Google Calendar: 1. Fetch your private Google Calendar URL: ![alt text](https://raw.githubusercontent.com/OpenAutomationProject/OpenAutomation/master/GoogleCalendarHelper/image_46687.jpg "copy link") 2. Adjust configuration in googlecalendar_ical_parser.php header (use link(s) fetched in step 1) +Generic iCal feed: +1. Just put the link to the ics file as first parameter. Second parameter stays empty, third (days in advance to display) and fourth (color formatting) can be used exactly like described for Google Calendar + ## Usage Use the following syntax in your CometVisu configuration xml: diff --git a/GoogleCalendarHelper/googlecalendar_ical_parser.php b/GoogleCalendarHelper/googlecalendar_ical_parser.php index aa19ec47..e49a2edf 100644 --- a/GoogleCalendarHelper/googlecalendar_ical_parser.php +++ b/GoogleCalendarHelper/googlecalendar_ical_parser.php @@ -18,6 +18,8 @@ ReadCalendar('xxxxxxxxxxxxxxxxxxxxxxxxxx@group.calendar.google.com', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 7, '1'); # Blau - xxxx ersetzen ReadCalendar('yyyyyyyyyyyyyyyyyyyyyyyyyy@group.calendar.google.com', 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy', 7, '3'); # Rot - yyyy ersetzen ReadCalendar('rr7mkkascn405ksj67ttoh524aioaijm@import.calendar.google.com', '', 7, '5'); # Feiertage Sachsen +// Beispiel fuer frei verfuergbaren iCal Kalender ausserhalb von Google: +// ReadCalendar('http://i.cal.to/ical/661/aktionstagegedenktage/umstellung-sommer-winterzeit/a0ea7dbe.88ed4c6b-5d78d8f4.ics', '', 14, '5'); # Zeitumstellung //Hier die Farbe für die ShortCuts angeben $SC_Farbe[1] = "#6E6E6E"; # grau @@ -63,8 +65,9 @@ function DateCompare($a, $b) { function ReadCalendar($userid, $magicCookie, $maxDays, $shortCut) { global $calcData; - if ($magicCookie != '') {$feedURL = "https://www.google.com/calendar/ical/$userid/private-$magicCookie/basic.ics";} - else $feedURL = "https://www.google.com/calendar/ical/$userid/public/basic.ics"; + if (substr($userid, 0, 4) === "http") $feedURL = $userid; + elseif ($magicCookie != '') {$feedURL = "https://www.google.com/calendar/ical/$userid/private-$magicCookie/basic.ics";} + else $feedURL = "https://www.google.com/calendar/ical/$userid/public/basic.ics"; $date = ""; @@ -166,11 +169,11 @@ function SetEintrag($thisData) if($thisData['DatumTxt'] == date("d.m.Y")) { - return "".$thisData['Bezeichnung']."  ".$thisData['ZeitTxt'].""; + return "".str_replace("\\", "", $thisData['Bezeichnung'])."  ".$thisData['ZeitTxt'].""; } else { - return "".$thisData['Bezeichnung']."  ".$thisData['ZeitTxt'].""; + return "".str_replace("\\", "", $thisData['Bezeichnung'])."  ".$thisData['ZeitTxt'].""; } }