Skip to content

Commit

Permalink
Repair the (personal) duty roster iCal export file: simple blank line…
Browse files Browse the repository at this point in the history
…s are not allowed. iCal needs a special coding.
  • Loading branch information
Clemens Gogoljn committed Jan 5, 2024
1 parent 3ad1a8b commit 1c984cd
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 7 deletions.
10 changes: 10 additions & 0 deletions Classes/ViewHelpers/ContainsObjectWithUidViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

/**
* This file is part of the "Participants" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2024 C. Gogolin <[email protected]>
*
* @package Cylancer\Participants\ViewHelpers
*/
class ContainsObjectWithUidViewHelper extends AbstractViewHelper
{

Expand Down
40 changes: 40 additions & 0 deletions Classes/ViewHelpers/IcsBlankLineEncoderViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace Cylancer\Participants\ViewHelpers;

use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

/**
* This file is part of the "Participants" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2024 C. Gogolin <[email protected]>
*
* @package Cylancer\Participants\ViewHelpers
*/
class IcsBlankLineEncoderViewHelper extends AbstractViewHelper
{

public function initializeArguments()
{
$this->registerArgument('value', '*', 'The value ', true);
}

/**
* Escapes special characters with their escaped counterparts as needed using PHPs htmlspecialchars() function.
*
* @return string the altered string
* @see http://www.php.net/manual/function.htmlspecialchars.php
* @api
*/
public function render()
{
$value = $this->arguments['value'];
if ($value === null) {
$value = $this->renderChildren();
}
return str_replace("\\n\\n", "\\n \\n", str_replace(["\r\n","\r","\n"], "\\n", strip_tags($value)));
}

}
10 changes: 10 additions & 0 deletions Classes/ViewHelpers/InArrayViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;

/**
* This file is part of the "Participants" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2024 C. Gogolin <[email protected]>
*
* @package Cylancer\Participants\ViewHelpers
*/
class InArrayViewHelper extends AbstractViewHelper
{

Expand Down
1 change: 1 addition & 0 deletions Resources/Private/Layouts/ICS.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<f:render section="content" />
1 change: 1 addition & 0 deletions Resources/Private/Layouts/ICS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<f:render section="content" />
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
DTSTART;<f:if condition="{event.fullDay}"><f:then>VALUE=DATE</f:then><f:else>TZID=Europe/Berlin</f:else></f:if>:<f:format.date format="%Y%m%d" >{event.date}</f:format.date><f:if condition="!{event.fullDay}"><f:format.date format="T%H%M%S" >{event.time}</f:format.date></f:if>
DTEND;<f:if condition="{event.fullDay}"><f:then>VALUE=DATE</f:then><f:else>TZID=Europe/Berlin</f:else></f:if>:<f:if condition="{event.fullDay}"><f:then><f:format.date format="%Y%m%d" base="{event.date}"> +1 day</f:format.date></f:then><f:else><f:format.date format="%Y%m%dT%H%M%S" base="{event.dateTime}"> +{event.duration} hours</f:format.date></f:else></f:if>
SUMMARY:🚒 {event.eventType.title -> f:format.htmlspecialchars()}
DESCRIPTION:<f:for each="{event.visiblePublicUsergroups}" as="ug" iteration="iter">{ug.title}<f:if condition="!{iter.isLast}">, </f:if></f:for><f:if condition="{event.description}"> ( {event.description -> f:format.stripTags()} )</f:if>
DESCRIPTION:<f:for each="{event.visiblePublicUsergroups}" as="ug" iteration="iter">{ug.title}<f:if condition="!{iter.isLast}">, </f:if></f:for><f:if condition="{event.description}"> ( {event.description -> c:icsBlankLineEncoder()} )</f:if>
END:VEVENT
</f:for></f:if>END:VCALENDAR
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
DTSTART;<f:if condition="{commitment.event.fullDay}"><f:then>VALUE=DATE</f:then><f:else>TZID=Europe/Berlin</f:else></f:if>:<f:format.date format="%Y%m%d" >{commitment.event.date}</f:format.date><f:if condition="!{commitment.event.fullDay}"><f:format.date format="T%H%M%S" >{commitment.event.time}</f:format.date></f:if>
DTEND;<f:if condition="{commitment.event.fullDay}"><f:then>VALUE=DATE</f:then><f:else>TZID=Europe/Berlin</f:else></f:if>:<f:if condition="{commitment.event.fullDay}"><f:then><f:format.date format="%Y%m%d" base="{commitment.event.date}"> +1 day</f:format.date></f:then><f:else><f:format.date format="%Y%m%dT%H%M%S" base="{commitment.event.dateTime}"> +{commitment.event.duration} hours</f:format.date></f:else></f:if>
SUMMARY:🚒 {commitment.event.eventType.title -> f:format.htmlspecialchars()}
DESCRIPTION:<f:for each="{commitment.event.visiblePublicUsergroups}" as="ug" iteration="iter">{ug.title}<f:if condition="!{iter.isLast}">, </f:if></f:for><f:if condition="{commitment.event.description}"> ( {commitment.event.description -> f:format.stripTags()} )</f:if>
DESCRIPTION:<f:for each="{commitment.event.visiblePublicUsergroups}" as="ug" iteration="iter">{ug.title}<f:if condition="!{iter.isLast}">, </f:if></f:for><f:if condition="{commitment.event.description}"> ( {commitment.event.description -> c:icsBlankLineEncoder()} )</f:if>
END:VEVENT
</f:for></f:if>END:VCALENDAR
13 changes: 12 additions & 1 deletion Resources/Private/Templates/DutyRoster/DownloadIcs.html
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
<f:render partial="DutyRoster/DefaultICalendarEntries" arguments="{_all}" />
<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Strict//EN"
"http://www.w.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:c="http://typo3.org/ns/Cylancer/Participants/ViewHelpers"
data-namespace-typo3-fluid="true" xmlns="http://www.w.org//xhtml" xml:lang="en" lang="en"
>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<f:layout name="ICS" />
<f:section name="content"><f:render partial="DutyRoster/DefaultICalendarEntries" arguments="{_all}" /></f:section>
</body></html>
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
<f:render partial="personalDutyRoster/DefaultICalendarEntries" arguments="{_all}" />
<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Strict//EN"
"http://www.w.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:c="http://typo3.org/ns/Cylancer/Participants/ViewHelpers"
data-namespace-typo3-fluid="true" xmlns="http://www.w.org//xhtml" xml:lang="en" lang="en"
>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<f:layout name="ICS" />
<f:section name="content"><f:render partial="personalDutyRoster/DefaultICalendarEntries" arguments="{_all}" /></f:section>
</body></html>
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
<f:render partial="personalDutyRoster/DefaultICalendarEntries" arguments="{_all}" />
<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Strict//EN"
"http://www.w.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:c="http://typo3.org/ns/Cylancer/Participants/ViewHelpers"
data-namespace-typo3-fluid="true" xmlns="http://www.w.org//xhtml" xml:lang="en" lang="en"
>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<f:layout name="ICS" />
<f:section name="content"><f:render partial="personalDutyRoster/DefaultICalendarEntries" arguments="{_all}" /></f:section>
</body></html>
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
<f:render partial="personalDutyRoster/DefaultICalendarEntries" arguments="{_all}" />
<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Strict//EN"
"http://www.w.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:c="http://typo3.org/ns/Cylancer/Participants/ViewHelpers"
data-namespace-typo3-fluid="true" xmlns="http://www.w.org//xhtml" xml:lang="en" lang="en"
>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<f:layout name="ICS" />
<f:section name="content"><f:render partial="personalDutyRoster/DefaultICalendarEntries" arguments="{_all}" /></f:section>
</body></html>
3 changes: 2 additions & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 1,
'version' => '3.7.9',
'version' => '3.7.10',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-11.5.99',
Expand All @@ -30,6 +30,7 @@
* Change log:
*
3.7.10 :: Fix : Repair the (personal) duty roster iCal export file: simple blank lines are not allowed. iCal needs a special coding.
3.7.9 :: Fix : Fix the default user setting for automatic apply commitments.
3.7.8 :: Fix : Fix the return value type in the frontend user service.
3.7.7 :: Fix : Adapts the personal duty roster folter column counts.
Expand Down

0 comments on commit 1c984cd

Please sign in to comment.