This commit is contained in:
2026-07-19 20:10:51 +02:00
parent d7d121b541
commit 5eca2f162b
4 changed files with 56 additions and 28 deletions
+16 -15
View File
@@ -123,9 +123,9 @@ $categories = [
</select>
</div>
<noscript>
<button type="submit" class="nav__search-button">Filter anwenden</button>
</noscript>
<button type="submit" class="nav__search-button">
Filter anwenden
</button>
</form>
</aside>
@@ -189,21 +189,22 @@ $categories = [
<option value="50" <?php echo $limit === 50 ? 'selected' : ''; ?>>50</option>
<option value="100" <?php echo $limit === 100 ? 'selected' : ''; ?>>100</option>
</select>
<noscript><button type="submit" form="s-res-filter-form" class="nav__search-button">Übernehmen</button></noscript>
<button type="submit"
form="s-res-filter-form"
class="nav__search-button">
Übernehmen
</button>
</div>
<nav class="s-res-page-navigation" aria-label="Seitennavigation">
<!-- No-JS-Fallback: -->
<noscript>
<?php echo renderNoJsPagination($currentPage, $totalPages, $query, $currentSort, $currentCategory, $limit); ?>
</noscript>
<!-- JS-Version: wird per search-results.js befüllt/eingeblendet: -->
<div id="js-page-navigation" style="display:none;">
<button type="button" class="s-res-page-btn" id="prev-page-btn">«</button>
<span id="dynamic-page-numbers"></span>
<button type="button" class="s-res-page-btn" id="next-page-btn">»</button>
</div>
<?php echo renderNoJsPagination(
$currentPage,
$totalPages,
$query,
$currentSort,
$currentCategory,
$limit
); ?>
</nav>
</div>
+20 -10
View File
@@ -251,11 +251,23 @@ if ($replyAuthor === null) {
(string) $comment->getArticleId()
); ?>">
<button type="submit"
class="delete-comment-button"
onclick="return confirm('Möchtest du diesen Kommentar wirklich löschen?');">
Kommentar löschen
</button>
<form method="post"
action="index.php?pfad=deleteComment"
class="delete-comment-form confirm-delete-comment">
<input type="hidden"
name="comment_id"
value="<?php echo htmlspecialchars((string) $comment->getId()); ?>">
<input type="hidden"
name="article_id"
value="<?php echo htmlspecialchars((string) $comment->getArticleId()); ?>">
<button type="submit"
class="delete-comment-button">
Kommentar löschen
</button>
</form>
</form>
<?php endif; ?>
@@ -383,11 +395,9 @@ if ($replyAuthor === null) {
(string) $reply->getArticleId()
); ?>">
<button type="submit"
class="delete-comment-button"
onclick="return confirm('Möchtest du diesen Kommentar wirklich löschen?');">
Kommentar löschen
</button>
<form method="post"
action="index.php?pfad=deleteComment"
class="delete-comment-form confirm-delete-comment">
</form>
<?php endif; ?>
-1
View File
@@ -26,7 +26,6 @@ include_once "php/controller/index-controller.php";
<script src="js/comments.js" defer></script>
<script src="js/profile.js" defer></script>
<script src="js/editor.js" async></script>
<script src="js/search-results.js" async></script>
<script src="js/showCategory.js" async></script>
+20 -2
View File
@@ -11,6 +11,26 @@ document.addEventListener("DOMContentLoaded", function () {
const parentCommentInput = document.getElementById("parent-comment-id");
const replyInfo = document.getElementById("reply-info");
/**
* Fragt vor dem Löschen eines Kommentars nach einer Bestätigung.
*
* Der Listener funktioniert auch für Kommentare,
* die später per AJAX eingefügt werden.
*/
document.addEventListener("submit", function (event) {
if (!event.target.classList.contains("delete-comment-form")) {
return;
}
const confirmed = confirm(
"Möchtest du diesen Kommentar wirklich löschen?"
);
if (!confirmed) {
event.preventDefault();
}
});
if (!form || !commentsList || !commentContent || !parentCommentInput) {
return;
}
@@ -152,7 +172,6 @@ document.addEventListener("DOMContentLoaded", function () {
<button
type="submit"
class="delete-comment-button"
onclick="return confirm('Möchtest du diesen Kommentar wirklich löschen?');"
>
Kommentar löschen
</button>
@@ -230,7 +249,6 @@ document.addEventListener("DOMContentLoaded", function () {
<button
type="submit"
class="delete-comment-button"
onclick="return confirm('Möchtest du diesen Kommentar wirklich löschen?');"
>
Kommentar löschen
</button>