Skip to content

Commit

Permalink
Merge pull request #901 from michaelkubina/add_show_empty_years
Browse files Browse the repository at this point in the history
[FEATURE] Add an option to list empty years in calender plugin
  • Loading branch information
sebastian-meyer committed Feb 6, 2023
2 parents 4005317 + 5d02bf0 commit 8dacea6
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
19 changes: 19 additions & 0 deletions Classes/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,25 @@ public function yearsAction()
'title' => $year['title']
];
}
// create an array that includes years without issues
if (!empty($this->settings['showEmptyYears'])) {
$yearFilled = [];
$min = $yearArray[0]['title'];
// round the starting decade down to zero for equal rows
$min = substr_replace($min, "0", -1);
$max = $yearArray[count($yearArray) - 1]['title'];
// if we have an actual documentId it should be used, otherwise leave empty
for ($i = 0; $i < $max - $min + 1; $i++) {
$key = array_search($min + $i, array_column($yearArray, 'title'));
if (is_int($key)) {
$yearFilled[] = $yearArray[$key];
} else {
$yearFilled[] = ['title' => $min+$i, 'documentId' => ''];
}
}
$yearArray = $yearFilled;
}

$this->view->assign('yearName', $yearArray);
}

Expand Down
10 changes: 10 additions & 0 deletions Configuration/Flexforms/Calendar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
</config>
</TCEforms>
</settings.initialDocument>
<settings.showEmptyYears>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.calendar.flexform.showEmptyYears</label>
<config>
<type>check</type>
<default>0</default>
</config>
</TCEforms>
</settings.showEmptyYears>
<settings.showEmptyMonths>
<TCEforms>
<exclude>1</exclude>
Expand Down
7 changes: 7 additions & 0 deletions Documentation/Plugins/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ now.
:ref:`t3tsref:data-type-integer`
:Default:

- :Property:
showEmptyYears
:Data Type:
:ref:`t3tsref:data-type-boolean`
:Default:
0

- :Property:
showEmptyMonths
:Data Type:
Expand Down
4 changes: 4 additions & 0 deletions Resources/Private/Language/de.locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
<source><![CDATA[Initial document to show (e.g. of type "newspaper" or "ephemera")]]></source>
<target><![CDATA[Anfangsdokument (z.B. vom Typ "newspaper" oder "ephemera)]]></target>
</trans-unit>
<trans-unit id="plugins.calendar.flexform.showEmptyYears" approved="yes">
<source><![CDATA[Show years without issues in calendar?]]></source>
<target><![CDATA[Zeige Jahre ohne Ausgaben im Kalender?]]></target>
</trans-unit>
<trans-unit id="plugins.calendar.flexform.showEmptyMonths" approved="yes">
<source><![CDATA[Show months without issues in calendar?]]></source>
<target><![CDATA[Zeige Monate ohne Ausgaben im Kalender?]]></target>
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<trans-unit id="plugins.calendar.flexform.initialDocument">
<source><![CDATA[Initial document to show (e.g. of type "newspaper" or "ephemera")]]></source>
</trans-unit>
<trans-unit id="plugins.calendar.flexform.showEmptyYears">
<source><![CDATA[Show years without issues in calendar?]]></source>
</trans-unit>
<trans-unit id="plugins.calendar.flexform.showEmptyMonths">
<source><![CDATA[Show months without issues in calendar?]]></source>
</trans-unit>
Expand Down
19 changes: 14 additions & 5 deletions Resources/Private/Templates/Calendar/Years.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@
<div class="year-view">
<ul>
<f:for each="{yearName}" as="yearEntry">
<li class="year">
<f:link.page additionalParams="{'tx_dlf[id]': yearEntry.documentId}">
{yearEntry.title}
</f:link.page>
</li>
<f:if condition="{yearEntry.documentId}">
<f:then>
<li class="year">
<f:link.page additionalParams="{'tx_dlf[id]': yearEntry.documentId}">
{yearEntry.title}
</f:link.page>
</li>
</f:then>
<f:else>
<li class="year-empty">
<p>{yearEntry.title}</p>
</li>
</f:else>
</f:if>
</f:for>
</ul>
</div>
Expand Down

0 comments on commit 8dacea6

Please sign in to comment.