From 833c3718cf1965868ac9f8aacb076586a37d201d Mon Sep 17 00:00:00 2001 From: Moritz Weinmann Date: Mon, 22 Jun 2026 11:59:31 +0200 Subject: [PATCH] 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 --- module/knowledgecenter_update/Ajax/Ajax.php | 51 ++++++++++--------- .../Views/post_cardform_edit_aside.php | 8 ++- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/module/knowledgecenter_update/Ajax/Ajax.php b/module/knowledgecenter_update/Ajax/Ajax.php index facdba2..e20969f 100644 --- a/module/knowledgecenter_update/Ajax/Ajax.php +++ b/module/knowledgecenter_update/Ajax/Ajax.php @@ -707,6 +707,7 @@ function update_post_version() $image = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['image'][$langId] ?? ''); $teaser = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['teaser'][$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; $link = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['link'][$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; if ($versionId <= 0) { // INSERT: Ermittle die neue Versionnummer… - $query = "SELECT MAX(version_number) AS max_ver - FROM knowledgecenter_post_versions + $query = "SELECT MAX(version_number) AS max_ver + FROM knowledgecenter_post_versions WHERE post_id = $postId AND language_id = $langId"; $result = mysqli_query($GLOBALS['mysql_con'], $query); $row = mysqli_fetch_assoc($result); @@ -752,12 +753,12 @@ function update_post_version() $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) + 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') + '$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)) { 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 - $query = " + $query = " UPDATE knowledgecenter_post_versions - SET title = '$title', - image = '$image', - link = '$link', - link_label = '$link_label', - teaser = '$teaser', - content = '$content', - author_id = $author_id, - state = $state, - valid_from = $valid_from_sql, - valid_until = $valid_until_sql, - background_color = '$backgroundColor', - text_color = '$textColor'" . ($keepModifiedAt ? "" : ",\n modified_at = NOW()") . " + SET title = '$title', + image = '$image', + link = '$link', + link_label = '$link_label', + teaser = '$teaser', + content = '$content', + summary = '$summary', + author_id = $author_id, + state = $state, + valid_from = $valid_from_sql, + valid_until = $valid_until_sql, + background_color = '$backgroundColor', + text_color = '$textColor'" . ($keepModifiedAt ? "" : ",\n modified_at = NOW()") . " WHERE id = $versionId AND language_id = $langId "; 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] ?? ''); $teaser = mysqli_real_escape_string($GLOBALS['mysql_con'], $_POST['teaser'][$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_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; @@ -867,8 +870,8 @@ function insert_post_version() $valid_from_sql = ($valid_from !== 'NULL' && !empty($valid_from)) ? "'$valid_from'" : "NULL"; $valid_until_sql = ($valid_until !== 'NULL' && !empty($valid_until)) ? "'$valid_until'" : "NULL"; - $query = "SELECT MAX(version_number) AS max_ver - FROM knowledgecenter_post_versions + $query = "SELECT MAX(version_number) AS max_ver + FROM knowledgecenter_post_versions WHERE post_id = $postId AND language_id = $langId"; $result = mysqli_query($GLOBALS['mysql_con'], $query); $row = mysqli_fetch_assoc($result); @@ -890,9 +893,9 @@ function insert_post_version() } } - $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) - VALUES ($postId, $langId, $newVersion, '$title', '$image', '$link', '$link_label', '$teaser', '$content', $author_id, $state, $insertModifiedAtSql, $valid_from_sql, $valid_until_sql, '$backgroundColor', '$textColor')"; + $insertQuery = "INSERT INTO knowledgecenter_post_versions + (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', '$summary', $author_id, $state, $insertModifiedAtSql, $valid_from_sql, $valid_until_sql, '$backgroundColor', '$textColor')"; if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) { echo json_encode(['error' => "Fehler beim Einfügen für Sprache $langId: " . mysqli_error($GLOBALS['mysql_con'])]); exit; diff --git a/module/knowledgecenter_update/Views/post_cardform_edit_aside.php b/module/knowledgecenter_update/Views/post_cardform_edit_aside.php index 8a2320c..ccc7c06 100644 --- a/module/knowledgecenter_update/Views/post_cardform_edit_aside.php +++ b/module/knowledgecenter_update/Views/post_cardform_edit_aside.php @@ -34,7 +34,7 @@
'', 'image' => '', 'teaser' => '', 'content' => '']; + $trans = isset($translations[$langId]) ? $translations[$langId] : ['title' => '', 'image' => '', 'teaser' => '', 'content' => '', 'summary' => '']; ?>
@@ -65,6 +65,10 @@
+
+ +
@@ -80,7 +84,7 @@ '', 'image' => '', 'teaser' => '', 'content' => '']; + $trans = isset($translations[$langId]) ? $translations[$langId] : ['title' => '', 'image' => '', 'teaser' => '', 'content' => '', 'summary' => '']; ?>