diff --git a/index.php b/index.php index c05f3f5..428862c 100644 --- a/index.php +++ b/index.php @@ -44,6 +44,10 @@ $defaultConfig = [ 'subject' => 'Wiki Newsletter - {MONAT}', 'firstname' => 'zusammen', + 'editor_tip' => '', + 'highlight_url_1' => '', + 'highlight_url_2' => '', + 'highlight_url_3' => '', 'reply_to' => '', 'unsubscribe_url' => '#', 'cron_token' => bin2hex(random_bytes(24)), @@ -347,6 +351,31 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel ? 'In diesem Zeitraum wurde ein neuer Wiki-Artikel veröffentlicht.' : 'In diesem Zeitraum wurden ' . $count . ' neue Wiki-Artikel veröffentlicht.'; $heroHeadline = 'Die wichtigsten Wiki-Updates fuer Ihr Team'; + $editorTip = trim((string)($config['editor_tip'] ?? '')); + + $manualHighlightUrls = []; + foreach (['highlight_url_1', 'highlight_url_2', 'highlight_url_3'] as $highlightField) { + $url = trim((string)($config[$highlightField] ?? '')); + if ($url !== '') { + $manualHighlightUrls[] = $url; + } + } + + $highlightArticles = []; + if (!empty($manualHighlightUrls)) { + foreach ($manualHighlightUrls as $manualUrl) { + foreach ($articles as $article) { + if (($article['url'] ?? '') === $manualUrl) { + $highlightArticles[] = $article; + break; + } + } + } + } + + if (empty($highlightArticles) && !empty($articles)) { + $highlightArticles = array_slice($articles, 0, 3); + } [$periodStart, $periodEnd] = newsletterPeriod((string)$config['period_mode']); $rangeEnd = $periodEnd; @@ -356,14 +385,14 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel $dateRangeText = 'vom ' . $periodStart->format('d.m') . ' bis ' . $rangeEnd->format('d.m'); $highlightsRows = ''; - if ($count > 0) { - $maxHighlights = min(3, $count); + if (!empty($highlightArticles)) { + $maxHighlights = min(3, count($highlightArticles)); for ($i = 0; $i < $maxHighlights; $i++) { $highlightsRows .= ' ' . ($i + 1) . '. - ' . h($articles[$i]['title']) . ' + ' . h($highlightArticles[$i]['title']) . ' '; } @@ -467,6 +496,27 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel $unsubscribeFooter = '
Abmelden'; } + $editorTipSection = ''; + if ($editorTip !== '') { + $editorTipSection = ' + + + + + + + + + +
+ Redaktionstipp +
+ ' . nl2br(h($editorTip)) . ' +
+ + '; + } + return ' @@ -532,22 +582,7 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel ' . $highlightsSection . ' ' . $testBadge . ' ' . $articleRows . ' - - - - - - - - - -
- Redaktionstipp -
- Priorisieren Sie in dieser Ausgabe die Security- und Plattform-Artikel. Diese bringen in der Regel den groessten Hebel fuer Stabilitaet und Betriebssicherheit. -
- - + ' . $editorTipSection . ' @@ -755,7 +790,8 @@ function configFromPost(array $current): array 'wiki_url', 'article_limit', 'article_fetch_limit', 'period_mode', 'smtp_host', 'smtp_port', 'smtp_encryption', 'smtp_user', 'from_email', 'from_name', 'recipient_email', 'test_recipient_email', - 'subject', 'reply_to', 'unsubscribe_url', 'cron_token' + 'subject', 'editor_tip', 'highlight_url_1', 'highlight_url_2', 'highlight_url_3', + 'reply_to', 'unsubscribe_url', 'cron_token' ]; foreach ($fields as $field) { @@ -925,7 +961,7 @@ $isLoggedIn = isAdminLoggedIn(); .card.full { grid-column: 1 / -1; } h2 { margin: 0 0 18px; font-size: 21px; letter-spacing: -.02em; } label { display: block; margin: 14px 0 7px; color: #374151; font-size: 14px; font-weight: 700; } - input, select { + input, select, textarea { width: 100%; height: 42px; padding: 0 12px; @@ -936,7 +972,14 @@ $isLoggedIn = isAdminLoggedIn(); font-size: 14px; outline: none; } - input:focus, select:focus { border-color: rgba(37,99,235,.55); box-shadow: 0 0 0 4px rgba(37,99,235,.08); } + textarea { + min-height: 110px; + height: auto; + padding: 10px 12px; + resize: vertical; + line-height: 1.5; + } + input:focus, select:focus, textarea:focus { border-color: rgba(37,99,235,.55); box-shadow: 0 0 0 4px rgba(37,99,235,.08); } .hint { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; } .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; } button { @@ -1042,6 +1085,20 @@ $isLoggedIn = isAdminLoggedIn();

Platzhalter: {MONAT}, {ANZAHL}

+ + +

Wird nur im Newsletter angezeigt, wenn ein Text hinterlegt ist.

+ + + + + + + + + +

Wenn gesetzt, werden diese 3 Artikel in genau dieser Reihenfolge als Highlights verwendet. Leer = automatische Highlights (erste 3 Artikel).

+