Calendar Refinement

This commit is contained in:
2026-03-11 13:31:49 +01:00
parent 94215fdd65
commit 6162ff595f
8 changed files with 371 additions and 49 deletions

View File

@@ -64,6 +64,8 @@ class syntax_plugin_luxtools_calendar extends SyntaxPlugin
'year' => $resolved['year'],
'month' => $resolved['month'],
'base' => $baseNs,
'size' => ChronologicalCalendarWidget::normalizeSize((string)($params['size'] ?? 'large')),
'show_times' => ChronologicalCalendarWidget::normalizeShowTimes($params['show_times'] ?? null),
];
}
@@ -86,13 +88,24 @@ class syntax_plugin_luxtools_calendar extends SyntaxPlugin
$year = (int)$data['year'];
$month = (int)$data['month'];
$baseNs = (string)$data['base'];
$size = ChronologicalCalendarWidget::normalizeSize((string)($data['size'] ?? 'large'));
$showTimes = (bool)($data['show_times'] ?? true);
// Load slot indicators and colors for the calendar widget
$slots = CalendarSlot::loadEnabled($this);
$indicators = CalendarService::monthIndicators($slots, $year, $month);
$widgetSlots = CalendarSlot::filterWidgetVisible($slots);
$indicators = [];
$dayEvents = [];
if ($size === 'large') {
$widgetData = CalendarService::monthWidgetData($widgetSlots, $year, $month);
$indicators = $widgetData['indicators'];
$dayEvents = $widgetData['events'];
} else {
$indicators = CalendarService::monthIndicators($widgetSlots, $year, $month);
}
$slotColors = [];
$slotDisplays = [];
foreach ($slots as $slot) {
foreach ($widgetSlots as $slot) {
$color = $slot->getColor();
if ($color !== '') {
$slotColors[$slot->getKey()] = $color;
@@ -100,7 +113,11 @@ class syntax_plugin_luxtools_calendar extends SyntaxPlugin
$slotDisplays[$slot->getKey()] = $slot->getDisplay();
}
$renderer->doc .= ChronologicalCalendarWidget::render($year, $month, $baseNs, $indicators, $slotColors, $slotDisplays);
$renderer->doc .= ChronologicalCalendarWidget::render($year, $month, $baseNs, $indicators, $slotColors, $slotDisplays, [
'size' => $size,
'showTimes' => $showTimes,
'dayEvents' => $dayEvents,
]);
return true;
}