From 69ba3f15954ece4c395235ca695b4b3e3ad9154d Mon Sep 17 00:00:00 2001 From: smueller Date: Tue, 7 Jul 2026 10:56:59 +0200 Subject: [PATCH] Enhance newsletter HTML in index.php and wiki.php by updating article count messages to include date ranges. Added logic to calculate and display the date range of articles, improving clarity for recipients. --- index.php | 25 ++++++++++++++++++++++--- wiki.php | 25 ++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 64c2c32..2733deb 100644 --- a/index.php +++ b/index.php @@ -344,8 +344,26 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel $replyEmail = trim((string)($config['reply_to'] ?: $config['from_email'])); $replyHref = 'mailto:' . $replyEmail; $summaryText = $count === 1 - ? 'Im ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.' - : 'Im ' . h($periodLabel) . ' wurden ' . $count . ' neue Wiki-Artikel veröffentlicht.'; + ? 'Im Zeitraum ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.' + : 'Im Zeitraum ' . h($periodLabel) . ' wurden ' . $count . ' neue Wiki-Artikel veröffentlicht.'; + + $dateRangeText = 'für den Zeitraum ' . h($periodLabel); + if (!empty($articles)) { + $timestamps = []; + foreach ($articles as $article) { + $date = DateTimeImmutable::createFromFormat('Y-m-d', (string)($article['date'] ?? '')); + if ($date instanceof DateTimeImmutable) { + $timestamps[] = $date->getTimestamp(); + } + } + + if (!empty($timestamps)) { + sort($timestamps); + $from = (new DateTimeImmutable('@' . (string)$timestamps[0]))->setTimezone(new DateTimeZone(date_default_timezone_get())); + $to = (new DateTimeImmutable('@' . (string)$timestamps[count($timestamps) - 1]))->setTimezone(new DateTimeZone(date_default_timezone_get())); + $dateRangeText = 'vom ' . $from->format('d.m.Y') . ' bis ' . $to->format('d.m.Y'); + } + } $articleRows = ''; if ($count === 0) { @@ -470,10 +488,11 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel Guten Tag,

- hier ist Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki.
+ hier erhalten Sie Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki, ' . $dateRangeText . '.
' . $summaryText . '

Viel Spaß beim Lesen wünscht
Ihr Team von Thomas-Krenn + diff --git a/wiki.php b/wiki.php index 44106a8..f30e226 100644 --- a/wiki.php +++ b/wiki.php @@ -344,8 +344,26 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel $replyEmail = trim((string)($config['reply_to'] ?: $config['from_email'])); $replyHref = 'mailto:' . $replyEmail; $summaryText = $count === 1 - ? 'Im ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.' - : 'Im ' . h($periodLabel) . ' wurden ' . $count . ' neue Wiki-Artikel veröffentlicht.'; + ? 'Im Zeitraum ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.' + : 'Im Zeitraum ' . h($periodLabel) . ' wurden ' . $count . ' neue Wiki-Artikel veröffentlicht.'; + + $dateRangeText = 'für den Zeitraum ' . h($periodLabel); + if (!empty($articles)) { + $timestamps = []; + foreach ($articles as $article) { + $date = DateTimeImmutable::createFromFormat('Y-m-d', (string)($article['date'] ?? '')); + if ($date instanceof DateTimeImmutable) { + $timestamps[] = $date->getTimestamp(); + } + } + + if (!empty($timestamps)) { + sort($timestamps); + $from = (new DateTimeImmutable('@' . (string)$timestamps[0]))->setTimezone(new DateTimeZone(date_default_timezone_get())); + $to = (new DateTimeImmutable('@' . (string)$timestamps[count($timestamps) - 1]))->setTimezone(new DateTimeZone(date_default_timezone_get())); + $dateRangeText = 'vom ' . $from->format('d.m.Y') . ' bis ' . $to->format('d.m.Y'); + } + } $articleRows = ''; if ($count === 0) { @@ -470,10 +488,11 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel Guten Tag,

- hier ist Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki.
+ hier erhalten Sie Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki, ' . $dateRangeText . '.
' . $summaryText . '

Viel Spaß beim Lesen wünscht
Ihr Team von Thomas-Krenn +