Skip to content

Commit

Permalink
enhance displaying subevents, fixed ordering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Feb 19, 2025
1 parent d53d821 commit 584ec56
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.7.0] - 2025-02-19
- Changed: better indication of parent event
- Changed: added urls to parent events
- Fixed: default order directive in model using non existing field

## [2.6.1] - 2025-02-18
- Fixed: missing token on subevents link in backend
- Fixed: performance issue on memberDocents field
Expand Down
13 changes: 12 additions & 1 deletion classes/EventListener/Hooks/ParseTemplateListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace HeimrichHannot\CalendarPlus\EventListener\Hooks;

use Contao\Backend;
use Contao\CalendarModel;
use Contao\Input;
use Contao\System;
use Contao\Template;
use HeimrichHannot\CalendarPlus\CalendarPlusEventsModel;
use HeimrichHannot\UtilsBundle\Util\Utils;

class ParseTemplateListener
{
Expand All @@ -24,9 +27,17 @@ public function __invoke(Template $template): void
return;
}

$utils = System::getContainer()->get(Utils::class);

$headlineParts = explode('> <', $template->headline);
unset($headlineParts[array_key_last($headlineParts)]);
$headlineParts[] = 'span>'.$eventModel->title.'</span';
$eventUrl = $utils->routing()->generateBackendRoute([
'do' => 'calendar',
'table' => 'tl_calendar_events',
'id' => $eventId,
'act' => 'edit',
]);
$headlineParts[] = 'span><a href="'. $eventUrl .'">'.$eventModel->title.'</a></span';
$headlineParts[] = 'span>'.$GLOBALS['TL_LANG']['MSC']['subevents'].'</span>';

$template->headline = implode('> <', $headlineParts);
Expand Down
21 changes: 21 additions & 0 deletions dca/tl_calendar_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,27 @@ public static function filterSubEvents()

if ($intEpid) {
$arrDca['list']['sorting']['mode'] = 1;
$arrDca['list']['sorting']['header_callback'] = static function (array $labels, DataContainer $dc) use ($intEpid): array {
$parentEvent = CalendarPlusEventsModel::findByPk($intEpid);
$archive = CalendarPlusModel::findByPk($parentEvent?->pid);
if (!$parentEvent || !$archive) {
return $labels;
}

$utils = \Contao\System::getContainer()->get(Utils::class);
$eventUrl = $utils->routing()->generateBackendRoute([
'do' => 'calendar',
'table' => 'tl_calendar_events',
'id' => $intEpid,
'act' => 'edit',
]);

$header = [
($GLOBALS['TL_LANG']['tl_calendar_events']['reference']['archive'] ?? 'Calendar') => $archive->title,
($GLOBALS['TL_LANG']['tl_calendar_events']['parentEvent'][0] ?? 'Event') => '<a href="'.$eventUrl.'">'.$parentEvent->title.'</a>',
];
return $header;
};
$arrDca['list']['label']['format'] = '%s <span style="color:#999;padding-left:3px">[%s]</span>';
$arrDca['list']['label']['fields'] = ['title', 'startDate', 'startTime'];
$arrDca['list']['label']['label_callback'] = static function (array $row, string $label) {
Expand Down
7 changes: 6 additions & 1 deletion languages/de/tl_calendar_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@
/**
* Buttons
*/
$arrLang['showSubEvents'] = ['Unterveranstaltungen anzeigen', 'Unterveranstaltungen von ID %s anzeigen'];
$arrLang['showSubEvents'] = ['Unterveranstaltungen anzeigen', 'Unterveranstaltungen von ID %s anzeigen'];

/**
* References
*/
$arrLang['reference']['archive'] = 'Kalender';
2 changes: 1 addition & 1 deletion models/CalendarPlusEventsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ public static function findPublishedSubEvents($varId, array $arrOptions = [])
$arrColumns = ["($t.parentEvent=?)"];

if (!isset($arrOptions['order'])) {
$arrOptions['order'] = "$t.startTime, $t.sorting ASC";
$arrOptions['order'] = "$t.startTime";
}

if (!BE_USER_LOGGED_IN) {
Expand Down

0 comments on commit 584ec56

Please sign in to comment.