Compare commits

..

7 Commits

Author SHA1 Message Date
e98f9ad2d9 Update deploy scripts 2026-04-06 08:49:33 +02:00
c1ffbc3f3a Improve date handling for the calendar widget 2026-04-06 08:49:14 +02:00
5c74c2e667 Fix timezone parsing for calendars 2026-04-03 15:40:06 +02:00
1cfd935794 Add zed settings 2026-04-03 15:27:34 +02:00
8a36333883 Add Validation for time imputs 2026-04-03 15:27:26 +02:00
e32d69dcc3 Fix date parsing in event-popup 2026-04-03 15:14:42 +02:00
5c747aaa78 Remove vscode config 2026-04-03 15:12:12 +02:00
9 changed files with 230 additions and 82 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
_agent-data/ _agent-data/
.claude/

26
.vscode/settings.json vendored
View File

@@ -1,26 +0,0 @@
{
// Developer quality-of-life:
// If you add a DokuWiki checkout as ./_dokuwiki (see README), Intelephense will
// index it and resolve DokuWiki base classes (ActionPlugin, SyntaxPlugin, etc.).
"intelephense.environment.includePaths": [
"./_dokuwiki",
"./_dokuwiki/inc",
"./_dokuwiki/lib",
"./_dokuwiki/vendor"
],
// DokuWiki replaces @ini_* placeholders server-side.
// VS Code's CSS validator doesn't understand those tokens, but LESS does.
"files.associations": {
"style.css": "less",
"temp-input-colors.css": "less"
},
// Keep the file explorer tidy when the optional DokuWiki checkout exists.
"files.exclude": {
"**/_dokuwiki/.git": true,
"**/_dokuwiki/data": true,
"**/_dokuwiki/conf": true,
"**/_dokuwiki/cache": true
}
}

5
.zed/settings.json Normal file
View File

@@ -0,0 +1,5 @@
{
"file_types": {
"LESS": ["style.css"],
},
}

View File

@@ -11,7 +11,8 @@ $TARGET = "S:\7-Infrastructure\lib\plugins\luxtools"
$DRY_RUN = $false $DRY_RUN = $false
$DELETE = $true $DELETE = $true
function Resolve-PathUsingExistingCase { function Resolve-PathUsingExistingCase
{
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string]$Path [string]$Path
@@ -20,7 +21,8 @@ function Resolve-PathUsingExistingCase {
$fullPath = [System.IO.Path]::GetFullPath($Path) $fullPath = [System.IO.Path]::GetFullPath($Path)
$root = [System.IO.Path]::GetPathRoot($fullPath).TrimEnd('\\') $root = [System.IO.Path]::GetPathRoot($fullPath).TrimEnd('\\')
if ($fullPath.TrimEnd('\\') -ieq $root) { if ($fullPath.TrimEnd('\\') -ieq $root)
{
return $root return $root
} }
@@ -28,12 +30,14 @@ function Resolve-PathUsingExistingCase {
$leaf = Split-Path -Path $fullPath -Leaf $leaf = Split-Path -Path $fullPath -Leaf
$resolvedParent = Resolve-PathUsingExistingCase -Path $parent $resolvedParent = Resolve-PathUsingExistingCase -Path $parent
if (Test-Path -LiteralPath $resolvedParent) { if (Test-Path -LiteralPath $resolvedParent)
{
$match = Get-ChildItem -LiteralPath $resolvedParent -Force -ErrorAction SilentlyContinue | $match = Get-ChildItem -LiteralPath $resolvedParent -Force -ErrorAction SilentlyContinue |
Where-Object { $_.Name -ieq $leaf } | Where-Object { $_.Name -ieq $leaf } |
Select-Object -First 1 Select-Object -First 1
if ($null -ne $match) { if ($null -ne $match)
{
return (Join-Path -Path $resolvedParent -ChildPath $match.Name) return (Join-Path -Path $resolvedParent -ChildPath $match.Name)
} }
} }
@@ -41,18 +45,22 @@ function Resolve-PathUsingExistingCase {
return (Join-Path -Path $resolvedParent -ChildPath $leaf) return (Join-Path -Path $resolvedParent -ChildPath $leaf)
} }
foreach ($arg in $args) { foreach ($arg in $args)
if ($arg -eq "--dry-run" -or $arg -eq "-n") { {
if ($arg -eq "--dry-run" -or $arg -eq "-n")
{
$DRY_RUN = $true $DRY_RUN = $true
continue continue
} }
if ($arg -eq "--no-delete") { if ($arg -eq "--no-delete")
{
$DELETE = $false $DELETE = $false
continue continue
} }
if ($arg -eq "-h" -or $arg -eq "--help") { if ($arg -eq "-h" -or $arg -eq "--help")
{
Get-Content $PSCommandPath Get-Content $PSCommandPath
exit 0 exit 0
} }
@@ -65,7 +73,8 @@ $TARGET = Resolve-PathUsingExistingCase -Path $TARGET
$SRC_DIR = $PSScriptRoot $SRC_DIR = $PSScriptRoot
# Safety checks: make sure source looks like luxtools plugin # Safety checks: make sure source looks like luxtools plugin
if (-not (Test-Path "$SRC_DIR/plugin.info.txt")) { if (-not (Test-Path "$SRC_DIR/plugin.info.txt"))
{
Write-Error "Error: '$SRC_DIR' doesn't look like luxtools (missing plugin.info.txt)." Write-Error "Error: '$SRC_DIR' doesn't look like luxtools (missing plugin.info.txt)."
exit 1 exit 1
} }
@@ -75,11 +84,14 @@ New-Item -ItemType Directory -Force -Path "$TARGET" | Out-Null
# Safety check: refuse to deploy to an obviously wrong directory. # Safety check: refuse to deploy to an obviously wrong directory.
# Allow empty dir (fresh install) OR existing luxtools plugin dir. # Allow empty dir (fresh install) OR existing luxtools plugin dir.
if (Test-Path "$TARGET/plugin.info.txt") { if (Test-Path "$TARGET/plugin.info.txt")
{
$content = Get-Content "$TARGET/plugin.info.txt" -ErrorAction SilentlyContinue $content = Get-Content "$TARGET/plugin.info.txt" -ErrorAction SilentlyContinue
if ($content -match "^base\s+luxtools" -or $content -match "^base\s+luxtools\s+") { if ($content -match "^base\s+luxtools" -or $content -match "^base\s+luxtools\s+")
{
# It's a luxtools plugin, allow it # It's a luxtools plugin, allow it
} else { } else
{
Write-Error "Error: target '$TARGET' has a plugin.info.txt, but it doesn't look like luxtools." Write-Error "Error: target '$TARGET' has a plugin.info.txt, but it doesn't look like luxtools."
Write-Error "Refusing to deploy." Write-Error "Refusing to deploy."
exit 1 exit 1
@@ -92,6 +104,8 @@ $EXCLUDE_DIRS = @(
"_agent-data", "_agent-data",
".github", ".github",
".vscode", ".vscode",
".zed",
".claude",
"_test" "_test"
) )
@@ -121,21 +135,25 @@ $ROBOCOPY_ARGS = @(
"/Z" # restartable mode "/Z" # restartable mode
) )
if ($EXCLUDE_DIRS.Count -gt 0) { if ($EXCLUDE_DIRS.Count -gt 0)
{
$ROBOCOPY_ARGS += "/XD" $ROBOCOPY_ARGS += "/XD"
$ROBOCOPY_ARGS += $EXCLUDE_DIRS $ROBOCOPY_ARGS += $EXCLUDE_DIRS
} }
if ($EXCLUDE_FILES.Count -gt 0) { if ($EXCLUDE_FILES.Count -gt 0)
{
$ROBOCOPY_ARGS += "/XF" $ROBOCOPY_ARGS += "/XF"
$ROBOCOPY_ARGS += $EXCLUDE_FILES $ROBOCOPY_ARGS += $EXCLUDE_FILES
} }
if ($DRY_RUN) { if ($DRY_RUN)
{
$ROBOCOPY_ARGS += "/L" # list mode $ROBOCOPY_ARGS += "/L" # list mode
} }
if ($DELETE) { if ($DELETE)
{
$ROBOCOPY_ARGS += "/MIR" # mirror $ROBOCOPY_ARGS += "/MIR" # mirror
} }

View File

@@ -72,6 +72,8 @@ RSYNC_ARGS=(
--exclude=_agent-data/ --exclude=_agent-data/
--exclude=.github/ --exclude=.github/
--exclude=.vscode/ --exclude=.vscode/
--exclude=.zed/
--exclude=.claude/
--exclude=_test/ --exclude=_test/
--exclude=deleted.files --exclude=deleted.files
--exclude=*.swp --exclude=*.swp

View File

@@ -51,19 +51,33 @@
function getCalendarStateKey(calendar) { function getCalendarStateKey(calendar) {
var baseNs = calendar.getAttribute('data-base-ns') || 'chronological'; var baseNs = calendar.getAttribute('data-base-ns') || 'chronological';
return 'luxtools.calendar.month.' + baseNs; return 'luxtools_calendar_month_' + baseNs.replace(/[^a-zA-Z0-9]/g, '_');
} }
function shouldPersistCalendarMonth(calendar) { function shouldPersistCalendarMonth(calendar) {
return (calendar.getAttribute('data-luxtools-size') || 'large') === 'small'; return (calendar.getAttribute('data-luxtools-size') || 'large') === 'small';
} }
function getCookieValue(name) {
var match = document.cookie.match('(^|;)\\s*' + name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\s*=\\s*([^;]+)');
return match ? decodeURIComponent(match[2]) : null;
}
function setCookie(name, value) {
var date = new Date();
date.setFullYear(date.getFullYear() + 1);
document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + date.toUTCString() + '; path=/; SameSite=Lax';
}
function deleteCookie(name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax';
}
function readSavedCalendarMonth(calendar) { function readSavedCalendarMonth(calendar) {
if (!shouldPersistCalendarMonth(calendar)) return null; if (!shouldPersistCalendarMonth(calendar)) return null;
if (!window.localStorage) return null;
try { try {
var raw = window.localStorage.getItem(getCalendarStateKey(calendar)); var raw = getCookieValue(getCalendarStateKey(calendar));
if (!raw) return null; if (!raw) return null;
var parsed = JSON.parse(raw); var parsed = JSON.parse(raw);
@@ -79,31 +93,17 @@
function saveCalendarMonth(calendar) { function saveCalendarMonth(calendar) {
if (!shouldPersistCalendarMonth(calendar)) return; if (!shouldPersistCalendarMonth(calendar)) return;
if (!window.localStorage) return;
var year = parseInt(calendar.getAttribute('data-current-year') || '', 10); var year = parseInt(calendar.getAttribute('data-current-year') || '', 10);
var month = parseInt(calendar.getAttribute('data-current-month') || '', 10); var month = parseInt(calendar.getAttribute('data-current-month') || '', 10);
if (!year || month < 1 || month > 12) return; if (!year || month < 1 || month > 12) return;
try { setCookie(getCalendarStateKey(calendar), JSON.stringify({ year: year, month: month }));
window.localStorage.setItem(getCalendarStateKey(calendar), JSON.stringify({
year: year,
month: month
}));
} catch (e) {
// ignore storage failures
}
} }
function clearSavedCalendarMonth(calendar) { function clearSavedCalendarMonth(calendar) {
if (!shouldPersistCalendarMonth(calendar)) return; if (!shouldPersistCalendarMonth(calendar)) return;
if (!window.localStorage) return; deleteCookie(getCalendarStateKey(calendar));
try {
window.localStorage.removeItem(getCalendarStateKey(calendar));
} catch (e) {
// ignore storage failures
}
} }
function fetchCalendarMonth(calendar, year, month) { function fetchCalendarMonth(calendar, year, month) {
@@ -227,11 +227,22 @@
function restoreCalendarMonth(calendar) { function restoreCalendarMonth(calendar) {
if (!shouldPersistCalendarMonth(calendar)) return; if (!shouldPersistCalendarMonth(calendar)) return;
var saved = readSavedCalendarMonth(calendar);
if (!saved) return;
var year = parseInt(calendar.getAttribute('data-current-year') || '', 10); var year = parseInt(calendar.getAttribute('data-current-year') || '', 10);
var month = parseInt(calendar.getAttribute('data-current-month') || '', 10); var month = parseInt(calendar.getAttribute('data-current-month') || '', 10);
if (!year || !month) return;
var saved = readSavedCalendarMonth(calendar);
if (!saved) {
var now = new Date();
var todayYear = now.getFullYear();
var todayMonth = now.getMonth() + 1;
if (year !== todayYear || month !== todayMonth) {
loadCalendarMonth(calendar, todayYear, todayMonth, false);
}
return;
}
if (saved.year === year && saved.month === month) return; if (saved.year === year && saved.month === month) return;
loadCalendarMonth(calendar, saved.year, saved.month, true); loadCalendarMonth(calendar, saved.year, saved.month, true);
@@ -258,7 +269,17 @@
navigateCalendarMonth(calendar, direction, true); navigateCalendarMonth(calendar, direction, true);
} }
function updateClientDateCookie() {
var now = new Date();
setCookie('luxtools_client_month', JSON.stringify({
year: now.getFullYear(),
month: now.getMonth() + 1
}));
}
function initCalendarWidgets() { function initCalendarWidgets() {
updateClientDateCookie();
var calendars = document.querySelectorAll('div.luxtools-calendar[data-luxtools-calendar="1"]'); var calendars = document.querySelectorAll('div.luxtools-calendar[data-luxtools-calendar="1"]');
for (var i = 0; i < calendars.length; i++) { for (var i = 0; i < calendars.length; i++) {
syncCalendarToday(calendars[i]); syncCalendarToday(calendars[i]);

View File

@@ -31,17 +31,13 @@
function formatDate(isoStr) { function formatDate(isoStr) {
if (!isoStr) return ""; if (!isoStr) return "";
var d = new Date(isoStr); var match = isoStr.match(/^(\d{4})-(\d{2})-(\d{2})/);
if (isNaN(d.getTime())) return isoStr; if (!match) return isoStr;
return ( return match[3] + "." + match[2] + "." + match[1];
pad2(d.getDate()) + "." + pad2(d.getMonth() + 1) + "." + d.getFullYear()
);
} }
function formatDateTime(isoStr) { function formatDateTime(isoStr) {
if (!isoStr) return ""; if (!isoStr) return "";
var d = new Date(isoStr);
if (isNaN(d.getTime())) return isoStr;
return formatDate(isoStr) + " " + formatTimeOnly(isoStr); return formatDate(isoStr) + " " + formatTimeOnly(isoStr);
} }
@@ -435,14 +431,12 @@
var startTime = ""; var startTime = "";
var endTime = ""; var endTime = "";
if (!data.allDay && data.start) { if (!data.allDay && data.start) {
var sd = new Date(data.start); startTime = formatTimeOnly(data.start);
if (!isNaN(sd.getTime())) if (startTime === data.start) startTime = "";
startTime = pad2(sd.getHours()) + ":" + pad2(sd.getMinutes());
} }
if (!data.allDay && data.end) { if (!data.allDay && data.end) {
var ed = new Date(data.end); endTime = formatTimeOnly(data.end);
if (!isNaN(ed.getTime())) if (endTime === data.end) endTime = "";
endTime = pad2(ed.getHours()) + ":" + pad2(ed.getMinutes());
} }
renderForm( renderForm(
@@ -464,6 +458,39 @@
}); });
} }
function setupTimeInputNormalization(input) {
// Track digits typed into the hours sub-field so we can reconstruct
// "HH:00" when the user fills hours but leaves minutes as "--".
var typedDigits = "";
input.addEventListener("keydown", function (e) {
if (this.value) {
// Field already has a valid complete value — reset tracking.
typedDigits = "";
return;
}
if (/^\d$/.test(e.key)) {
typedDigits = (typedDigits + e.key).slice(-2);
} else if (e.key === "Backspace" || e.key === "Delete") {
typedDigits = "";
}
});
input.addEventListener("change", function () {
typedDigits = "";
});
input.addEventListener("blur", function () {
if (!this.value && this.validity && this.validity.badInput) {
var h = parseInt(typedDigits, 10);
if (!isNaN(h) && h >= 0 && h <= 23) {
this.value = pad2(h) + ":00";
}
typedDigits = "";
}
});
}
function renderForm(data, slots) { function renderForm(data, slots) {
var isEdit = data.mode === "edit"; var isEdit = data.mode === "edit";
var title = isEdit ? "Edit Event" : "Create Event"; var title = isEdit ? "Edit Event" : "Create Event";
@@ -571,6 +598,12 @@
timeFields.style.display = allDayCheckbox.checked ? "none" : ""; timeFields.style.display = allDayCheckbox.checked ? "none" : "";
}); });
} }
// Wire up time normalization: auto-substitute :00 for missing minutes
var startTimeInput = popup.querySelector(".luxtools-form-start-time");
var endTimeInput = popup.querySelector(".luxtools-form-end-time");
if (startTimeInput) setupTimeInputNormalization(startTimeInput);
if (endTimeInput) setupTimeInputNormalization(endTimeInput);
} }
function collectFormData() { function collectFormData() {
@@ -606,6 +639,22 @@
return; return;
} }
if (!formData.allDay) {
var popup = getDialog().getContainer();
var startInput = popup.querySelector(".luxtools-form-start-time");
var endInput = popup.querySelector(".luxtools-form-end-time");
if (
(startInput && startInput.validity && startInput.validity.badInput) ||
(endInput && endInput.validity && endInput.validity.badInput)
) {
showNotification(
"Please complete the time fields or clear them.",
"error",
);
return;
}
}
// For recurring event edits, ask about scope first // For recurring event edits, ask about scope first
if (mode === "edit") { if (mode === "edit") {
var recurrence = saveBtn.getAttribute("data-recurrence") || ""; var recurrence = saveBtn.getAttribute("data-recurrence") || "";

View File

@@ -138,12 +138,13 @@ class CalendarService
if ($calendar === null) continue; if ($calendar === null) continue;
try { try {
$uidTimezones = self::buildUidTimezoneMap($calendar);
$expanded = $calendar->expand($rangeStart, $rangeEnd); $expanded = $calendar->expand($rangeStart, $rangeEnd);
if (!($expanded instanceof VCalendar)) continue; if (!($expanded instanceof VCalendar)) continue;
for ($day = 1; $day <= $daysInMonth; $day++) { for ($day = 1; $day <= $daysInMonth; $day++) {
$dateIso = sprintf('%04d-%02d-%02d', $year, $month, $day); $dateIso = sprintf('%04d-%02d-%02d', $year, $month, $day);
$events = self::collectFromCalendar($expanded, $slot->getKey(), $dateIso); $events = self::collectFromCalendar($expanded, $slot->getKey(), $dateIso, $uidTimezones);
$cacheKey = $slot->getKey() . '|' . $dateIso; $cacheKey = $slot->getKey() . '|' . $dateIso;
self::$dayCache[$cacheKey] = $events; self::$dayCache[$cacheKey] = $events;
@@ -222,6 +223,28 @@ class CalendarService
} }
} }
/**
* Build a UID → TZID map from the original (non-expanded) calendar.
*
* VCalendar::expand() normalizes all timezone-aware datetimes to UTC, losing
* the original TZID. This map lets us restore the correct timezone afterwards.
*
* @param VCalendar $calendar
* @return array<string,string> uid => tzid
*/
protected static function buildUidTimezoneMap(VCalendar $calendar): array
{
$map = [];
foreach ($calendar->select('VEVENT') as $vevent) {
if (!isset($vevent->DTSTART)) continue;
$uid = trim((string)($vevent->UID ?? ''));
if ($uid === '' || isset($map[$uid])) continue;
$tzid = (string)($vevent->DTSTART['TZID'] ?? '');
if ($tzid !== '') $map[$uid] = $tzid;
}
return $map;
}
/** /**
* Parse events from a local ICS file for a specific date. * Parse events from a local ICS file for a specific date.
* *
@@ -236,6 +259,8 @@ class CalendarService
if ($calendar === null) return []; if ($calendar === null) return [];
try { try {
$uidTimezones = self::buildUidTimezoneMap($calendar);
$utc = new DateTimeZone('UTC'); $utc = new DateTimeZone('UTC');
$rangeStart = new DateTimeImmutable($dateIso . ' 00:00:00', $utc); $rangeStart = new DateTimeImmutable($dateIso . ' 00:00:00', $utc);
$rangeStart = $rangeStart->sub(new DateInterval('P1D')); $rangeStart = $rangeStart->sub(new DateInterval('P1D'));
@@ -244,7 +269,7 @@ class CalendarService
$expanded = $calendar->expand($rangeStart, $rangeEnd); $expanded = $calendar->expand($rangeStart, $rangeEnd);
if (!($expanded instanceof VCalendar)) return []; if (!($expanded instanceof VCalendar)) return [];
return self::collectFromCalendar($expanded, $slotKey, $dateIso); return self::collectFromCalendar($expanded, $slotKey, $dateIso, $uidTimezones);
} catch (Throwable $e) { } catch (Throwable $e) {
return []; return [];
} }
@@ -256,9 +281,10 @@ class CalendarService
* @param VCalendar $calendar * @param VCalendar $calendar
* @param string $slotKey * @param string $slotKey
* @param string $dateIso * @param string $dateIso
* @param array<string,string> $uidTimezones uid => tzid, for restoring timezone after expand()
* @return CalendarEvent[] * @return CalendarEvent[]
*/ */
protected static function collectFromCalendar(VCalendar $calendar, string $slotKey, string $dateIso): array protected static function collectFromCalendar(VCalendar $calendar, string $slotKey, string $dateIso, array $uidTimezones = []): array
{ {
$result = []; $result = [];
$seen = []; $seen = [];
@@ -266,7 +292,7 @@ class CalendarService
// VEVENTs // VEVENTs
foreach ($calendar->select('VEVENT') as $vevent) { foreach ($calendar->select('VEVENT') as $vevent) {
if (!($vevent instanceof VEvent)) continue; if (!($vevent instanceof VEvent)) continue;
$event = self::normalizeVEventForDay($vevent, $slotKey, $dateIso); $event = self::normalizeVEventForDay($vevent, $slotKey, $dateIso, $uidTimezones);
if ($event === null) continue; if ($event === null) continue;
$dedupeKey = $event->uid . '|' . $event->recurrenceId . '|' . $event->startIso . '|' . $event->summary; $dedupeKey = $event->uid . '|' . $event->recurrenceId . '|' . $event->startIso . '|' . $event->summary;
@@ -285,9 +311,10 @@ class CalendarService
* @param VEvent $vevent * @param VEvent $vevent
* @param string $slotKey * @param string $slotKey
* @param string $dateIso * @param string $dateIso
* @param array<string,string> $uidTimezones uid => tzid, for restoring timezone after expand()
* @return CalendarEvent|null * @return CalendarEvent|null
*/ */
protected static function normalizeVEventForDay(VEvent $vevent, string $slotKey, string $dateIso): ?CalendarEvent protected static function normalizeVEventForDay(VEvent $vevent, string $slotKey, string $dateIso, array $uidTimezones = []): ?CalendarEvent
{ {
if (!isset($vevent->DTSTART)) return null; if (!isset($vevent->DTSTART)) return null;
@@ -295,8 +322,30 @@ class CalendarService
$start = self::toImmutable($vevent->DTSTART->getDateTime()); $start = self::toImmutable($vevent->DTSTART->getDateTime());
if ($start === null) return null; if ($start === null) return null;
// VCalendar::expand() normalizes all timezone-aware datetimes to UTC, losing
// the original TZID. Restore it using the pre-expansion UID→TZID map so that
// display times and day-boundary checks use the event's original timezone.
$restoredTz = null;
if (!$isAllDay && $uidTimezones !== [] && $start->getTimezone()->getName() === 'UTC') {
$uid = trim((string)($vevent->UID ?? ''));
$tzid = $uidTimezones[$uid] ?? '';
if ($tzid !== '') {
try {
$restoredTz = new DateTimeZone($tzid);
$start = $start->setTimezone($restoredTz);
} catch (Throwable $e) {
$restoredTz = null;
}
}
}
$end = self::resolveEnd($vevent, $start, $isAllDay); $end = self::resolveEnd($vevent, $start, $isAllDay);
// Apply the same timezone restoration to the end datetime.
if ($restoredTz !== null && $end->getTimezone()->getName() === 'UTC') {
$end = $end->setTimezone($restoredTz);
}
if (!self::intersectsDay($start, $end, $isAllDay, $dateIso)) return null; if (!self::intersectsDay($start, $end, $isAllDay, $dateIso)) return null;
$event = new CalendarEvent(); $event = new CalendarEvent();

View File

@@ -91,6 +91,16 @@ class syntax_plugin_luxtools_calendar extends SyntaxPlugin
$size = ChronologicalCalendarWidget::normalizeSize((string)($data['size'] ?? 'large')); $size = ChronologicalCalendarWidget::normalizeSize((string)($data['size'] ?? 'large'));
$showTimes = (bool)($data['show_times'] ?? true); $showTimes = (bool)($data['show_times'] ?? true);
if ($size === 'small') {
$resolved = $this->resolveMonthFromCookie(
'luxtools_calendar_month_' . preg_replace('/[^a-zA-Z0-9]/', '_', $baseNs)
) ?? $this->resolveMonthFromCookie('luxtools_client_month');
if ($resolved !== null) {
$year = $resolved['year'];
$month = $resolved['month'];
}
}
$slots = CalendarSlot::loadEnabled($this); $slots = CalendarSlot::loadEnabled($this);
$widgetSlots = CalendarSlot::filterWidgetVisible($slots); $widgetSlots = CalendarSlot::filterWidgetVisible($slots);
$indicators = []; $indicators = [];
@@ -122,6 +132,25 @@ class syntax_plugin_luxtools_calendar extends SyntaxPlugin
return true; return true;
} }
/**
* @param string $cookieName
* @return array{year:int,month:int}|null
*/
protected function resolveMonthFromCookie(string $cookieName): ?array
{
$raw = $_COOKIE[$cookieName] ?? null;
if ($raw === null) return null;
$decoded = json_decode($raw, true);
if (!is_array($decoded)) return null;
$year = (int)($decoded['year'] ?? 0);
$month = (int)($decoded['month'] ?? 0);
if ($year < 1 || $month < 1 || $month > 12) return null;
return ['year' => $year, 'month' => $month];
}
/** /**
* @param string $flags * @param string $flags
* @return array<string,string> * @return array<string,string>