Kommentare löschen
This commit is contained in:
+149
-28
@@ -153,43 +153,164 @@ if ($replyAuthor === null) {
|
||||
<div id="comments-list">
|
||||
<?php if (!empty($mainComments)): ?>
|
||||
<?php foreach ($mainComments as $comment): ?>
|
||||
<div class="comment-item" data-comment-id="<?php echo htmlspecialchars($comment->getId()); ?>">
|
||||
<p>
|
||||
<strong><?php echo htmlspecialchars($comment->getAuthor()); ?></strong>
|
||||
<span><?php echo htmlspecialchars($comment->getCreated()); ?></span>
|
||||
</p>
|
||||
<div class="comment-item"
|
||||
data-comment-id="<?php echo htmlspecialchars(
|
||||
(string) $comment->getId()
|
||||
); ?>">
|
||||
|
||||
<p><?php echo nl2br(htmlspecialchars($comment->getContent())); ?></p>
|
||||
<?php
|
||||
$isDeleted = $comment->getContent()
|
||||
=== "Dieser Kommentar wurde gelöscht.";
|
||||
?>
|
||||
|
||||
<?php if ($isDeleted): ?>
|
||||
|
||||
<p class="deleted-comment">
|
||||
Dieser Kommentar wurde gelöscht.
|
||||
</p>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p>
|
||||
<strong>
|
||||
<?php echo htmlspecialchars($comment->getAuthor()); ?>
|
||||
</strong>
|
||||
|
||||
<span>
|
||||
<?php echo htmlspecialchars($comment->getCreated()); ?>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
echo nl2br(
|
||||
htmlspecialchars($comment->getContent())
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php if (
|
||||
isset($_SESSION["user_email"])
|
||||
&& $_SESSION["user_email"] === $comment->getAuthor()
|
||||
): ?>
|
||||
|
||||
<form method="post"
|
||||
action="php/controller/deleteComment-controller.php"
|
||||
class="delete-comment-form">
|
||||
|
||||
<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"
|
||||
onclick="return confirm('Möchtest du diesen Kommentar wirklich löschen?');">
|
||||
Kommentar löschen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($_SESSION["user_email"])): ?>
|
||||
|
||||
<a href="index.php?pfad=<?php
|
||||
echo urlencode($_GET["pfad"] ?? "showArticle");
|
||||
?>&id=<?php
|
||||
echo urlencode((string) $comment->getArticleId());
|
||||
?>&reply_to=<?php
|
||||
echo urlencode((string) $comment->getId());
|
||||
?>#comment-form"
|
||||
class="reply-button"
|
||||
data-comment-id="<?php echo htmlspecialchars(
|
||||
(string) $comment->getId()
|
||||
); ?>"
|
||||
data-author="<?php echo htmlspecialchars(
|
||||
$comment->getAuthor()
|
||||
); ?>">
|
||||
|
||||
Antworten
|
||||
</a>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($_SESSION["user_email"])): ?>
|
||||
<a href="index.php?pfad=<?php
|
||||
echo urlencode($_GET["pfad"] ?? "showArticle");
|
||||
?>&id=<?php
|
||||
echo urlencode((string) ($_GET["id"] ?? ""));
|
||||
?>&reply_to=<?php
|
||||
echo urlencode((string) $comment->getId());
|
||||
?>#comment-form"
|
||||
class="reply-button"
|
||||
data-comment-id="<?php echo htmlspecialchars(
|
||||
(string) $comment->getId()
|
||||
); ?>"
|
||||
data-author="<?php echo htmlspecialchars(
|
||||
$comment->getAuthor()
|
||||
); ?>">
|
||||
Antworten
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="comment-replies">
|
||||
<?php if (isset($repliesByParent[$comment->getId()])): ?>
|
||||
<?php foreach ($repliesByParent[$comment->getId()] as $reply): ?>
|
||||
<div class="comment-item comment-reply">
|
||||
<p>
|
||||
<strong><?php echo htmlspecialchars($reply->getAuthor()); ?></strong>
|
||||
<span><?php echo htmlspecialchars($reply->getCreated()); ?></span>
|
||||
</p>
|
||||
|
||||
<p><?php echo nl2br(htmlspecialchars($reply->getContent())); ?></p>
|
||||
<?php
|
||||
$isReplyDeleted = $reply->getContent()
|
||||
=== "Dieser Kommentar wurde gelöscht.";
|
||||
?>
|
||||
|
||||
<?php if ($isReplyDeleted): ?>
|
||||
|
||||
<p class="deleted-comment">
|
||||
Dieser Kommentar wurde gelöscht.
|
||||
</p>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p>
|
||||
<strong>
|
||||
<?php echo htmlspecialchars($reply->getAuthor()); ?>
|
||||
</strong>
|
||||
|
||||
<span>
|
||||
<?php echo htmlspecialchars($reply->getCreated()); ?>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
echo nl2br(
|
||||
htmlspecialchars($reply->getContent())
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php if (
|
||||
isset($_SESSION["user_email"])
|
||||
&& $_SESSION["user_email"] === $reply->getAuthor()
|
||||
): ?>
|
||||
|
||||
<form method="post"
|
||||
action="php/controller/deleteComment-controller.php"
|
||||
class="delete-comment-form">
|
||||
|
||||
<input type="hidden"
|
||||
name="comment_id"
|
||||
value="<?php echo htmlspecialchars(
|
||||
(string) $reply->getId()
|
||||
); ?>">
|
||||
|
||||
<input type="hidden"
|
||||
name="article_id"
|
||||
value="<?php echo htmlspecialchars(
|
||||
(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>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user