Add editor tip and highlight URLs to newsletter HTML in index.php. Implemented logic to display manual highlights and an optional editor tip section, enhancing content customization and visibility for recipients.
This commit is contained in:
101
index.php
101
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 .= '
|
||||
<tr>
|
||||
<td style="padding:0 0 8px 0;font-family:Arial,Helvetica,sans-serif;font-size:15px;line-height:22px;color:#2f3237;">
|
||||
<span style="display:inline-block;min-width:22px;font-weight:700;color:#ff7d00;">' . ($i + 1) . '.</span>
|
||||
<a href="' . h($articles[$i]['url']) . '" target="_blank" style="color:#2f3237;text-decoration:none;">' . h($articles[$i]['title']) . '</a>
|
||||
<a href="' . h($highlightArticles[$i]['url']) . '" target="_blank" style="color:#2f3237;text-decoration:none;">' . h($highlightArticles[$i]['title']) . '</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
@@ -467,6 +496,27 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
|
||||
$unsubscribeFooter = '<br><a href="' . h($unsubscribeUrl) . '" target="_blank" style="color:#ff7d00;text-decoration:underline;">Abmelden</a>';
|
||||
}
|
||||
|
||||
$editorTipSection = '';
|
||||
if ($editorTip !== '') {
|
||||
$editorTipSection = '
|
||||
<tr>
|
||||
<td style="padding:8px 32px 24px 32px;" class="mobile-padding">
|
||||
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100%;background:#f7f8fa;border:1px solid #e1e5eb;border-radius:12px;">
|
||||
<tr>
|
||||
<td style="padding:16px 18px 8px 18px;font-family:Arial,Helvetica,sans-serif;font-size:11px;line-height:15px;color:#5f6064;font-weight:700;letter-spacing:.8px;text-transform:uppercase;">
|
||||
Redaktionstipp
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0 18px 16px 18px;font-family:Arial,Helvetica,sans-serif;font-size:15px;line-height:24px;color:#32363d;">
|
||||
' . nl2br(h($editorTip)) . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
return '<!doctype html>
|
||||
<html lang="de" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
||||
<head>
|
||||
@@ -532,22 +582,7 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
|
||||
' . $highlightsSection . '
|
||||
' . $testBadge . '
|
||||
' . $articleRows . '
|
||||
<tr>
|
||||
<td style="padding:8px 32px 24px 32px;" class="mobile-padding">
|
||||
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100%;background:#f7f8fa;border:1px solid #e1e5eb;border-radius:12px;">
|
||||
<tr>
|
||||
<td style="padding:16px 18px 8px 18px;font-family:Arial,Helvetica,sans-serif;font-size:11px;line-height:15px;color:#5f6064;font-weight:700;letter-spacing:.8px;text-transform:uppercase;">
|
||||
Redaktionstipp
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0 18px 16px 18px;font-family:Arial,Helvetica,sans-serif;font-size:15px;line-height:24px;color:#32363d;">
|
||||
Priorisieren Sie in dieser Ausgabe die Security- und Plattform-Artikel. Diese bringen in der Regel den groessten Hebel fuer Stabilitaet und Betriebssicherheit.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
' . $editorTipSection . '
|
||||
<tr>
|
||||
<td style="padding:0 32px 28px 32px;" class="mobile-padding">
|
||||
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
@@ -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();
|
||||
<input name="subject" value="<?= h($config['subject']) ?>">
|
||||
<p class="hint">Platzhalter: <code>{MONAT}</code>, <code>{ANZAHL}</code></p>
|
||||
|
||||
<label>Redaktionstipp (optional)</label>
|
||||
<textarea name="editor_tip" placeholder="Optionaler Hinweis fuer den Newsletter..."><?= h((string)($config['editor_tip'] ?? '')) ?></textarea>
|
||||
<p class="hint">Wird nur im Newsletter angezeigt, wenn ein Text hinterlegt ist.</p>
|
||||
|
||||
<label>Top Highlight 1 URL (optional)</label>
|
||||
<input name="highlight_url_1" value="<?= h((string)($config['highlight_url_1'] ?? '')) ?>" placeholder="https://www.thomas-krenn.com/de/wiki/...">
|
||||
|
||||
<label>Top Highlight 2 URL (optional)</label>
|
||||
<input name="highlight_url_2" value="<?= h((string)($config['highlight_url_2'] ?? '')) ?>" placeholder="https://www.thomas-krenn.com/de/wiki/...">
|
||||
|
||||
<label>Top Highlight 3 URL (optional)</label>
|
||||
<input name="highlight_url_3" value="<?= h((string)($config['highlight_url_3'] ?? '')) ?>" placeholder="https://www.thomas-krenn.com/de/wiki/...">
|
||||
<p class="hint">Wenn gesetzt, werden diese 3 Artikel in genau dieser Reihenfolge als Highlights verwendet. Leer = automatische Highlights (erste 3 Artikel).</p>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
|
||||
Reference in New Issue
Block a user