Skip to content

Commit

Permalink
Merge pull request #19 from bramwaas/develop
Browse files Browse the repository at this point in the history
v2.2.0 develop
  • Loading branch information
bramwaas authored Jan 7, 2024
2 parents 2a5f013 + 80dbc30 commit 872b04b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 21 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,41 @@ Check if you can download the ics file you have designated in the block with a b

Yes you can, I have tested this with [https://p24-calendars.icloud.com/holiday/NL_nl.ics](https://p24-calendars.icloud.com/holiday/NL_nl.ics) .

= How do I set different colours and text size for the dates, the summary, and the details? =

There is no setting for the color or font of parts in this plugin.
My philosophy is that layout and code/content should be separated as much as possible.
Furthermore, the plugin should seamlessly fit the style of the website and be fully customizable via CSS

So for color and font, the settings of the template are used and are then applied via CSS.
But you can give each element within the plugin its own style (such as color and font size) from the theme via CSS.

If you know your template css well and it contains classes you want to use on these fields you can add those class-names in
the Settings Tab Advanced : "SUFFIX GROUP CLASS:", "SUFFIX EVENT START CLASS:" and "SUFFIX EVENT DETAILS CLASS:"

Otherwise you can add a block of additional CSS (or extra css or user css or something like that), which is possible with most templates.
IMPORTANT:
In order to target the CSS very specifically to the simple-ical-block, it is best to enter something unique in the settings of the module Tab Advanced in "HTML ANCHOR", for example 'Simple-ical-Block-1' the code translated into a high-level ID of the module.
With the next block of additional CSS you can make the Dates red and 24 px, the Summary blue and 16 px,
and the Details green with a gray background.

~~~
/*additional CSS for Simple-ical-Block-1 */
#Simple-ical-Block-1 .ical-date {
color: #ff0000;
font-size: 24px;
}
#Simple-ical-Block-1 .ical_summary {
color: #0000ff;
font-size: 16px;
}
#Simple-ical-Block-1 .ical_details {
color: #00ff00;
background-color: gray;
}
/*end additional CSS for Simple-ical-Block-1 */
~~~

== Documentation ==

* Gets calendar events via iCal url or google calendar ID
Expand All @@ -118,7 +153,7 @@ Check if you can download the ics file you have designated in the block with a b
* End of repeating by COUNT or UNTIL
* By day month, monthday or setpos (BYDAY, BYMONTH, BYMONTHDAY, BYSETPOS) no other by...
(not parsed: BYWEEKNO, BYYEARDAY, BYHOUR, BYMINUTE, RDATE)
* Exclude events on EXDATE from repeat (after evaluating BYSETPOS)
* Exclude events on EXDATE from recurrence set (after evaluating BYSETPOS)
* Respects Timezone and Day Light Saving time. Build and tested with Iana timezones as used in php, Google, and Apple now also tested with Microsoft timezones and unknown timezones. For unknown timezone-names using the default timezone of te site (probably the local timezone set in Joomla administration).

=== Recurrent events, Timezone, Daylight Saving Time ===
Expand All @@ -138,8 +173,10 @@ Theoretically this could als happen with recurrent events in the same timezone w
Test results and comparison with Google and Outlook calendar [with the wordpress plugin](https://wordpress.org/plugins/simple-google-icalendar-widget/) have been uploaded as DayLightSavingTime test.xlsx.

=== From the ical specifications ===

~~~
see http://www.ietf.org/rfc/rfc5545.txt for specification of te ical format.
see http://www.ietf.org/rfc/rfc5545.txt for specification of te ical format,
or https://icalendar.org/iCalendar-RFC-5545/
(see 3.3.10. [Page 38] Recurrence Rule in specification
.____________._________.________._________.________.
| |DAILY |WEEKLY |MONTHLY |YEARLY |
Expand Down Expand Up @@ -172,6 +209,9 @@ This project is licensed under the [GNU GPL](https://www.gnu.org/licenses/gpl-3.
* works with Joomla 4 or higher.

== Changelog ==
* 2.2.0 after an issue of gonzob (@gonzob) in WP support forum: 'Bug with repeating events
' improved handling of EXDATE so that also the first event of a recurrent set can be excluded.
Basic parse Recurrence-ID (only one Recurrence-ID event to replace one occurrence of the recurrent set) to support changes in individual recurrent events in Google Calendar. Remove _ chars from UID.
* 2.1.5 tested with joomla 5 added compatibility to 5.0.99
* 2.1.4 After a feature request of achimmm (in github on Joomla module) added optional placeholder HTML output when no upcoming events are avalable. Also added optional output after the events list (when upcoming events are available).
* 2.1.3 In response to a support issue of (@marijnvr) (on WP plugin). New lay-out for block with first date line on a higer level li. 'Start with summary' toggle-setting changed in 'layout' select-setting with options 'Startdate higher level', 'Start with summary', 'Old style'.
Expand Down
4 changes: 2 additions & 2 deletions mod_simple_ical_block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
</include>
</compatibility>
<name>Simple iCal Block</name>
<creationDate>09-12-2023</creationDate>
<creationDate>07-01-2024</creationDate>
<author>A.H.C. Waasdorp</author>
<copyright>Copyright (C) 2022 - 2024 A.H.C. Waasdorp, All rights reserved.</copyright>
<license>https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://www.waasdorpsoekhan.nl</authorUrl>
<version>2.1.5</version>
<version>2.2.0</version>
<description><![CDATA[<div class="sib-info" style="color: #3f48cc;"><p><img class="sib-img" src="../modules/mod_simple_ical_block/assets/simpleicalicon128x128.svg" style="display: inline-block; width: 2em; height:auto; margin-right: 0.5em;"/>Simple iCal Calendar Events Block</p></div>
]]></description>
<namespace path="src">WaasdorpSoekhan\Module\Simpleicalblock</namespace>
Expand Down
71 changes: 54 additions & 17 deletions src/IcsParser.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* a simple ICS parser.
* @copyright Copyright (C) 2022 - 2022 Bram Waasdorp. All rights reserved.
* @copyright Copyright (C) 2022 - 2024 Bram Waasdorp. All rights reserved.
* @license GNU General Public License version 3 or later
*
* note that this class does not implement all ICS functionality.
Expand All @@ -26,7 +26,9 @@
* Combined getFutureEvents and Limit array. usort eventsortcomparer now on start, end, cal_ord and with arithmic subtraction because all are integers.
* Parse event DURATION; (only) When DTEND is empty: determine end from start plus duration, when duration is empty and start is DATE start plus one day, else = start
* Parse event BYSETPOS; Parse WKST (default MO)
* 2.1.1 Solved Warning: Array to string conversion in .../Transport/Curl.php on line 183 that occured after using php 8.
* 2.1.1 Solved Warning: Array to string conversion in .../Transport/Curl.php on line 183 that occured after using php 8.
* 2.2.0 improved handling of EXDATE so that also the first event of a recurrent set can be excluded.
* Parse Recurrence-ID to support changes in individual recurrent events in Google Calendar. Remove _ chars from UID.
*/
namespace WaasdorpSoekhan\Module\Simpleicalblock\Site;
// no direct access
Expand All @@ -48,27 +50,27 @@ class IcsParser {
*/
private static $example_events = 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20220626T150000
DTEND:20220626T160000
DTSTART:20240127T150000
DTEND:20240127T160000
RRULE:FREQ=WEEKLY;INTERVAL=3;BYDAY=SU,WE,SA
UID:a-1
DESCRIPTION:Description event every 3 weeks sunday wednesday and saturday. t
DESCRIPTION:Description event every 3 weeks sunday wednesday and saturday. T
est A-Z.\nLine 2 of description.
LOCATION:Located at home or somewhere else
SUMMARY: Every 3 weeks sunday wednesday and saturday
END:VEVENT
BEGIN:VEVENT
DTSTART:20220629T143000
DTEND:20220629T153000
DTSTART:20240129T143000
DTEND:20240129T153000
RRULE:FREQ=MONTHLY;COUNT=24;BYMONTHDAY=29
UID:a-2
DESCRIPTION:
LOCATION:
SUMMARY:Example Monthly day 29
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20220618
//DTEND;VALUE=DATE:20220620
DTSTART;VALUE=DATE:20240127
//DTEND;VALUE=DATE:20240128
DURATION:P1DT23H59M60S
RRULE:FREQ=MONTHLY;COUNT=13;BYDAY=4SA
UID:a-3
Expand Down Expand Up @@ -266,6 +268,13 @@ class IcsParser {
* @since 1.5.1
*/
protected $events = [];
/**
* The array of events with RECURRENCE-ID parsed from the ics file, that may replace events with the same UID and Start-datetime.
*
* @var array array of event objects
* @since 2.2.0
*/
protected $replaceevents = [];
/**
* Timestamp of the start time fo parsing, set by parse function.
*
Expand Down Expand Up @@ -328,7 +337,12 @@ public function parse($str , $cal_class = '', $cal_ord = 0) {
$e = $this->parseVevent($eventStr);
$e->cal_class = $cal_class;
$e->cal_ord = $cal_ord;
$this->events[] = $e;
if (empty($e->exdate) || !in_array($e->start, $e->exdate)) {
$this->events[] = $e;
if (!empty($e->recurid)){
$this->replaceevents[] = array($e->uid, $e->recurid );
}
}
// Recurring event?
if (isset($e->rrule) && $e->rrule !== '') {
/* Recurring event, parse RRULE in associative array add appropriate duplicate events
Expand Down Expand Up @@ -582,7 +596,7 @@ public function parse($str , $cal_class = '', $cal_ord = 0) {
($fmdayok || $expand)
&& ($count == 0 || $i < $count)
&& $newstart->getTimestamp() <= $until
&& !(!empty($e->exdate) && in_array($newstart->getTimestamp(), $e->exdate))
&& (empty($e->exdate) || !in_array($newstart->getTimestamp(), $e->exdate))
&& $newstart> $edtstart) { // count events after dtstart
if ($newstart->getTimestamp() > $nowstart
) { // copy only events after now
Expand Down Expand Up @@ -648,7 +662,15 @@ public function getFutureEvents( ) {
$i=0;
foreach ($this->events as $e) {
if (($e->end >= $this->now)
&& $e->start <= $this->penddate) {
&& $e->start <= $this->penddate
) {
if (!empty($this->replaceevents) && empty($e->recurid)){
$a = explode ('_', $e->uid, 2);
$e_uid = (count($a) > 1) ? $a[1] : $a[0];
if ( in_array(array($e_uid, $e->start ), $this->replaceevents, true)) {
continue;
}
}
$i++;
if ($i > $this->event_count) {
break;
Expand Down Expand Up @@ -765,6 +787,7 @@ public function parseVevent($eventStr) {
$value = "";
$tzid = '';
$isdate = false;
$isperiod = false;
//bw 20171108 added, because sometimes there is timezone or other info after DTSTART, or DTEND
// eg. DTSTART;TZID=Europe/Amsterdam, or DTSTART;VALUE=DATE:20171203
$tl = explode(";", $list[0]);
Expand All @@ -778,7 +801,14 @@ public function parseVevent($eventStr) {
$tzid = $dtl[1];
break;
case 'VALUE':
$isdate = ('DATE' == $dtl[1]);
switch($dtl[1]) {
case 'DATE':
$isdate = true;
break;
case 'PERIOD':
$isperiod = true;
break;
}
break;
}
}
Expand Down Expand Up @@ -814,7 +844,7 @@ public function parseVevent($eventStr) {
$eventObj->duration = $value;
break;
case "UID":
$eventObj->uid = $value;
$eventObj->uid = str_replace('_', '', $value);
break;
case "RRULE":
$eventObj->rrule = $value;
Expand All @@ -825,6 +855,13 @@ public function parseVevent($eventStr) {
$eventObj->exdate[] = $this->parseIcsDateTime($value, $tzid);
}
break;
case "RECURRENCE-ID":
$tz = $this->parseIanaTimezoneid ($tzid,$value);
$tzid = $tz->getName();
$eventObj->recurtzid = $tzid;
$eventObj->recuridisdate = $isdate;
$eventObj->recurid = $this->parseIcsDateTime($value, $tzid);
break;
}
}else { // count($list) <= 1
if (strlen($l) > 1) {
Expand Down Expand Up @@ -925,7 +962,7 @@ function fetch()
$http = new Http(['headers' => ['Accept-Encoding' => '']]); //accepts known encoding and decodes.
try {
$httpResponse = $http->get($url);
} catch(\Exception $e) {
} catch(\Exception $exc) {
continue ;
}
if (200 != $httpResponse->code) {
Expand All @@ -935,7 +972,7 @@ function fetch()
if (200 != $httpResponse->code) {
continue ;
}
} catch(\Exception $e) {
} catch(\Exception $exc) {
continue ;
}
}
Expand All @@ -944,7 +981,7 @@ function fetch()

try {
$this->parse($httpBody, $cal_class, $cal_ord );
} catch(\Exception $e) {
} catch(\Exception $exc) {
continue ;
}
} // end foreach
Expand Down
40 changes: 40 additions & 0 deletions update/mod_simple_ical_block-update.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
<?xml version='1.0' encoding='UTF-8'?>
<updates>
<update>
<name>Simple iCal Block</name>
<description>Simple iCal Block Module Update</description>
<element>mod_simple_ical_block</element>
<type>module</type>
<version>2.2.0</version>
<infourl title="Simple iCal Block Module">https://github.com/bramwaas/joomla_mod_simple_ical_block/blob/main/README.md</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/bramwaas/joomla_mod_simple_ical_block/archive/refs/tags/v2.2.0.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>A.H.C. Waasdorp</maintainer>
<maintainerurl>https://www.waasdorpsoekhan.nl</maintainerurl>
<targetplatform name="joomla" version="5.[012345]"/>
<php_minimum>7.4.0</php_minimum>
<client>site</client>
<folder/>
</update>
<update>
<name>Simple iCal Block</name>
<description>Simple iCal Block Module Update</description>
<element>mod_simple_ical_block</element>
<type>module</type>
<version>2.2.0</version>
<infourl title="Simple iCal Block Module">https://github.com/bramwaas/joomla_mod_simple_ical_block/blob/main/README.md</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/bramwaas/joomla_mod_simple_ical_block/archive/refs/tags/v2.2.0.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>A.H.C. Waasdorp</maintainer>
<maintainerurl>https://www.waasdorpsoekhan.nl</maintainerurl>
<targetplatform name="joomla" version="4.[012345]"/>
<php_minimum>7.4.0</php_minimum>
<client>site</client>
<folder/>
</update>
<update>
<name>Simple iCal Block</name>
<description>Simple iCal Block Module Update</description>
Expand Down

0 comments on commit 872b04b

Please sign in to comment.