Add summary field to knowledgecenter posts
- ALTER TABLE knowledgecenter_post_versions ADD COLUMN summary TEXT NULL AFTER content - Add summary textarea to post edit form (after Quill editor) - Include summary in insert_post_version() and update_post_version() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -707,6 +707,7 @@ function update_post_version()
|
|||||||
$image = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['image'][$langId] ?? '');
|
$image = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['image'][$langId] ?? '');
|
||||||
$teaser = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['teaser'][$langId] ?? '');
|
$teaser = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['teaser'][$langId] ?? '');
|
||||||
$content = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['content'][$langId] ?? '');
|
$content = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['content'][$langId] ?? '');
|
||||||
|
$summary = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['summary'][$langId] ?? '');
|
||||||
$author_id = isset($_POST['author_id'][$langId]) ? (int) $_POST['author_id'][$langId] : 0;
|
$author_id = isset($_POST['author_id'][$langId]) ? (int) $_POST['author_id'][$langId] : 0;
|
||||||
$link = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link'][$langId] ?? '');
|
$link = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link'][$langId] ?? '');
|
||||||
$link_label = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link_label'][$langId] ?? '');
|
$link_label = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link_label'][$langId] ?? '');
|
||||||
@@ -726,8 +727,8 @@ function update_post_version()
|
|||||||
$versionId = isset($_POST['version_id'][$langId]) ? (int) $_POST['version_id'][$langId] : 0;
|
$versionId = isset($_POST['version_id'][$langId]) ? (int) $_POST['version_id'][$langId] : 0;
|
||||||
if ($versionId <= 0) {
|
if ($versionId <= 0) {
|
||||||
// INSERT: Ermittle die neue Versionnummer…
|
// INSERT: Ermittle die neue Versionnummer…
|
||||||
$query = "SELECT MAX(version_number) AS max_ver
|
$query = "SELECT MAX(version_number) AS max_ver
|
||||||
FROM knowledgecenter_post_versions
|
FROM knowledgecenter_post_versions
|
||||||
WHERE post_id = $postId AND language_id = $langId";
|
WHERE post_id = $postId AND language_id = $langId";
|
||||||
$result = mysqli_query($GLOBALS['mysql_con'], $query);
|
$result = mysqli_query($GLOBALS['mysql_con'], $query);
|
||||||
$row = mysqli_fetch_assoc($result);
|
$row = mysqli_fetch_assoc($result);
|
||||||
@@ -752,12 +753,12 @@ function update_post_version()
|
|||||||
$insertQuery = "
|
$insertQuery = "
|
||||||
INSERT INTO knowledgecenter_post_versions
|
INSERT INTO knowledgecenter_post_versions
|
||||||
(post_id, language_id, version_number,
|
(post_id, language_id, version_number,
|
||||||
title, image, link, link_label, teaser, content, author_id, state,
|
title, image, link, link_label, teaser, content, summary, author_id, state,
|
||||||
modified_at, valid_from, valid_until, background_color, text_color)
|
modified_at, valid_from, valid_until, background_color, text_color)
|
||||||
VALUES
|
VALUES
|
||||||
($postId, $langId, $newVersion,
|
($postId, $langId, $newVersion,
|
||||||
'$title', '$image', '$link', '$link_label', '$teaser', '$content', $author_id, $state,
|
'$title', '$image', '$link', '$link_label', '$teaser', '$content', '$summary', $author_id, $state,
|
||||||
$insertModifiedAtSql, $valid_from_sql, $valid_until_sql, '$backgroundColor', '$textColor')
|
$insertModifiedAtSql, $valid_from_sql, $valid_until_sql, '$backgroundColor', '$textColor')
|
||||||
";
|
";
|
||||||
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
|
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
|
||||||
echo json_encode(['error' => 'Fehler beim Einfügen für Sprache ' . $langId . ': ' . mysqli_error($GLOBALS['mysql_con'])]);
|
echo json_encode(['error' => 'Fehler beim Einfügen für Sprache ' . $langId . ': ' . mysqli_error($GLOBALS['mysql_con'])]);
|
||||||
@@ -767,20 +768,21 @@ function update_post_version()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UPDATE: Aktualisiere auch die Datumsfelder
|
// UPDATE: Aktualisiere auch die Datumsfelder
|
||||||
$query = "
|
$query = "
|
||||||
UPDATE knowledgecenter_post_versions
|
UPDATE knowledgecenter_post_versions
|
||||||
SET title = '$title',
|
SET title = '$title',
|
||||||
image = '$image',
|
image = '$image',
|
||||||
link = '$link',
|
link = '$link',
|
||||||
link_label = '$link_label',
|
link_label = '$link_label',
|
||||||
teaser = '$teaser',
|
teaser = '$teaser',
|
||||||
content = '$content',
|
content = '$content',
|
||||||
author_id = $author_id,
|
summary = '$summary',
|
||||||
state = $state,
|
author_id = $author_id,
|
||||||
valid_from = $valid_from_sql,
|
state = $state,
|
||||||
valid_until = $valid_until_sql,
|
valid_from = $valid_from_sql,
|
||||||
background_color = '$backgroundColor',
|
valid_until = $valid_until_sql,
|
||||||
text_color = '$textColor'" . ($keepModifiedAt ? "" : ",\n modified_at = NOW()") . "
|
background_color = '$backgroundColor',
|
||||||
|
text_color = '$textColor'" . ($keepModifiedAt ? "" : ",\n modified_at = NOW()") . "
|
||||||
WHERE id = $versionId AND language_id = $langId
|
WHERE id = $versionId AND language_id = $langId
|
||||||
";
|
";
|
||||||
if (!mysqli_query($GLOBALS['mysql_con'], $query)) {
|
if (!mysqli_query($GLOBALS['mysql_con'], $query)) {
|
||||||
@@ -855,6 +857,7 @@ function insert_post_version()
|
|||||||
$image = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['image'][$langId] ?? '');
|
$image = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['image'][$langId] ?? '');
|
||||||
$teaser = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['teaser'][$langId] ?? '');
|
$teaser = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['teaser'][$langId] ?? '');
|
||||||
$content = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['content'][$langId] ?? '');
|
$content = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['content'][$langId] ?? '');
|
||||||
|
$summary = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['summary'][$langId] ?? '');
|
||||||
$link = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link'][$langId] ?? '');
|
$link = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link'][$langId] ?? '');
|
||||||
$link_label = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link_label'][$langId] ?? '');
|
$link_label = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link_label'][$langId] ?? '');
|
||||||
$author_id = isset($_POST['author_id'][$langId]) ? (int) $_POST['author_id'][$langId] : 0;
|
$author_id = isset($_POST['author_id'][$langId]) ? (int) $_POST['author_id'][$langId] : 0;
|
||||||
@@ -867,8 +870,8 @@ function insert_post_version()
|
|||||||
$valid_from_sql = ($valid_from !== 'NULL' && !empty($valid_from)) ? "'$valid_from'" : "NULL";
|
$valid_from_sql = ($valid_from !== 'NULL' && !empty($valid_from)) ? "'$valid_from'" : "NULL";
|
||||||
$valid_until_sql = ($valid_until !== 'NULL' && !empty($valid_until)) ? "'$valid_until'" : "NULL";
|
$valid_until_sql = ($valid_until !== 'NULL' && !empty($valid_until)) ? "'$valid_until'" : "NULL";
|
||||||
|
|
||||||
$query = "SELECT MAX(version_number) AS max_ver
|
$query = "SELECT MAX(version_number) AS max_ver
|
||||||
FROM knowledgecenter_post_versions
|
FROM knowledgecenter_post_versions
|
||||||
WHERE post_id = $postId AND language_id = $langId";
|
WHERE post_id = $postId AND language_id = $langId";
|
||||||
$result = mysqli_query($GLOBALS['mysql_con'], $query);
|
$result = mysqli_query($GLOBALS['mysql_con'], $query);
|
||||||
$row = mysqli_fetch_assoc($result);
|
$row = mysqli_fetch_assoc($result);
|
||||||
@@ -890,9 +893,9 @@ function insert_post_version()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$insertQuery = "INSERT INTO knowledgecenter_post_versions
|
$insertQuery = "INSERT INTO knowledgecenter_post_versions
|
||||||
(post_id, language_id, version_number, title, image, link, link_label, teaser, content, author_id, state, modified_at, valid_from, valid_until, background_color, text_color)
|
(post_id, language_id, version_number, title, image, link, link_label, teaser, content, summary, author_id, state, modified_at, valid_from, valid_until, background_color, text_color)
|
||||||
VALUES ($postId, $langId, $newVersion, '$title', '$image', '$link', '$link_label', '$teaser', '$content', $author_id, $state, $insertModifiedAtSql, $valid_from_sql, $valid_until_sql, '$backgroundColor', '$textColor')";
|
VALUES ($postId, $langId, $newVersion, '$title', '$image', '$link', '$link_label', '$teaser', '$content', '$summary', $author_id, $state, $insertModifiedAtSql, $valid_from_sql, $valid_until_sql, '$backgroundColor', '$textColor')";
|
||||||
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
|
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
|
||||||
echo json_encode(['error' => "Fehler beim Einfügen für Sprache $langId: " . mysqli_error($GLOBALS['mysql_con'])]);
|
echo json_encode(['error' => "Fehler beim Einfügen für Sprache $langId: " . mysqli_error($GLOBALS['mysql_con'])]);
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<div class="edit-main">
|
<div class="edit-main">
|
||||||
<?php foreach ($allLanguages as $lang):
|
<?php foreach ($allLanguages as $lang):
|
||||||
$langId = $lang['id'];
|
$langId = $lang['id'];
|
||||||
$trans = isset($translations[$langId]) ? $translations[$langId] : ['title' => '', 'image' => '', 'teaser' => '', 'content' => ''];
|
$trans = isset($translations[$langId]) ? $translations[$langId] : ['title' => '', 'image' => '', 'teaser' => '', 'content' => '', 'summary' => ''];
|
||||||
?>
|
?>
|
||||||
<div class="lang-form" id="lang_<?= $langId ?>" data-lang="<?= $langId ?>"
|
<div class="lang-form" id="lang_<?= $langId ?>" data-lang="<?= $langId ?>"
|
||||||
style="<?= ($langId == $languageId) ? '' : 'display: none;' ?>">
|
style="<?= ($langId == $languageId) ? '' : 'display: none;' ?>">
|
||||||
@@ -65,6 +65,10 @@
|
|||||||
<div id="editor_<?= $langId ?>" class="editor">
|
<div id="editor_<?= $langId ?>" class="editor">
|
||||||
<?= $translations[$langId]['content'] ?>
|
<?= $translations[$langId]['content'] ?>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
<label for="summary_<?= $langId ?>">Zusammenfassung (Summary)</label>
|
||||||
|
<textarea id="summary_<?= $langId ?>" name="summary[<?= $langId ?>]" rows="4"
|
||||||
|
placeholder="Kurze Zusammenfassung des Artikelinhalts..."><?= htmlspecialchars($trans['summary'] ?? '') ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,7 +84,7 @@
|
|||||||
|
|
||||||
<?php foreach ($allLanguages as $lang):
|
<?php foreach ($allLanguages as $lang):
|
||||||
$langId = $lang['id'];
|
$langId = $lang['id'];
|
||||||
$trans = isset($translations[$langId]) ? $translations[$langId] : ['title' => '', 'image' => '', 'teaser' => '', 'content' => ''];
|
$trans = isset($translations[$langId]) ? $translations[$langId] : ['title' => '', 'image' => '', 'teaser' => '', 'content' => '', 'summary' => ''];
|
||||||
?>
|
?>
|
||||||
<div class="lang-form-meta" data-lang="<?= $langId ?>"
|
<div class="lang-form-meta" data-lang="<?= $langId ?>"
|
||||||
style="<?= ($langId == $languageId) ? '' : 'display: none;' ?>">
|
style="<?= ($langId == $languageId) ? '' : 'display: none;' ?>">
|
||||||
|
|||||||
Reference in New Issue
Block a user