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.

This commit is contained in:
smueller
2026-07-07 10:56:59 +02:00
parent 3dc07b9fb2
commit 69ba3f1595
2 changed files with 44 additions and 6 deletions

View File

@@ -344,8 +344,26 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
$replyEmail = trim((string)($config['reply_to'] ?: $config['from_email'])); $replyEmail = trim((string)($config['reply_to'] ?: $config['from_email']));
$replyHref = 'mailto:' . $replyEmail; $replyHref = 'mailto:' . $replyEmail;
$summaryText = $count === 1 $summaryText = $count === 1
? 'Im ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.' ? 'Im Zeitraum ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.'
: 'Im ' . h($periodLabel) . ' wurden ' . $count . ' neue 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 = ''; $articleRows = '';
if ($count === 0) { if ($count === 0) {
@@ -470,10 +488,11 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
<tr> <tr>
<td class="mobile-intro" style="font-family:Arial,Helvetica,sans-serif;font-size:17px;line-height:27px;color:#1e2530;"> <td class="mobile-intro" style="font-family:Arial,Helvetica,sans-serif;font-size:17px;line-height:27px;color:#1e2530;">
Guten Tag,<br><br> Guten Tag,<br><br>
hier ist Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki.<br> hier erhalten Sie Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki, ' . $dateRangeText . '.<br>
' . $summaryText . '<br><br> ' . $summaryText . '<br><br>
Viel Spaß beim Lesen wünscht<br>Ihr Team von Thomas-Krenn Viel Spaß beim Lesen wünscht<br>Ihr Team von Thomas-Krenn
</td> </td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@@ -344,8 +344,26 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
$replyEmail = trim((string)($config['reply_to'] ?: $config['from_email'])); $replyEmail = trim((string)($config['reply_to'] ?: $config['from_email']));
$replyHref = 'mailto:' . $replyEmail; $replyHref = 'mailto:' . $replyEmail;
$summaryText = $count === 1 $summaryText = $count === 1
? 'Im ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.' ? 'Im Zeitraum ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.'
: 'Im ' . h($periodLabel) . ' wurden ' . $count . ' neue 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 = ''; $articleRows = '';
if ($count === 0) { if ($count === 0) {
@@ -470,10 +488,11 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
<tr> <tr>
<td class="mobile-intro" style="font-family:Arial,Helvetica,sans-serif;font-size:17px;line-height:27px;color:#1e2530;"> <td class="mobile-intro" style="font-family:Arial,Helvetica,sans-serif;font-size:17px;line-height:27px;color:#1e2530;">
Guten Tag,<br><br> Guten Tag,<br><br>
hier ist Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki.<br> hier erhalten Sie Ihre aktuelle Übersicht aus dem Thomas-Krenn-Wiki, ' . $dateRangeText . '.<br>
' . $summaryText . '<br><br> ' . $summaryText . '<br><br>
Viel Spaß beim Lesen wünscht<br>Ihr Team von Thomas-Krenn Viel Spaß beim Lesen wünscht<br>Ihr Team von Thomas-Krenn
</td> </td>
</tr> </tr>
</table> </table>
</td> </td>