235 lines
9.3 KiB
PHP
235 lines
9.3 KiB
PHP
<?php
|
|
include_once 'php/controller/profile-controller.php';
|
|
|
|
$user = $user ?? null;
|
|
$isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
|
?>
|
|
|
|
<main class="form-page">
|
|
<div class="flexbox">
|
|
<?php include_once "includes/alertMessages.php" ?>
|
|
<div class="container">
|
|
|
|
<?php if (!empty($error)): ?>
|
|
<p class="alert-message is-error">
|
|
<?php echo htmlspecialchars($error); ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
|
|
<form method="post" action="index.php?pfad=profile">
|
|
|
|
<label class="input-label">Vorname</label>
|
|
<input type="text"
|
|
name="vorname"
|
|
class="login-input"
|
|
value="<?php echo htmlspecialchars($_POST["vorname"] ?? $user["vorname"] ?? ""); ?>"
|
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
|
required>
|
|
|
|
<label class="input-label">Nachname</label>
|
|
<input type="text"
|
|
name="nachname"
|
|
class="login-input"
|
|
value="<?php echo htmlspecialchars($_POST["nachname"] ?? $user["nachname"] ?? ""); ?>"
|
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
|
required>
|
|
|
|
<label class="input-label">Email-Adresse</label>
|
|
<input type="email"
|
|
name="email"
|
|
class="login-input"
|
|
value="<?php echo htmlspecialchars($_POST["email"] ?? $user["email"] ?? ""); ?>"
|
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
|
required>
|
|
|
|
<label class="input-label">
|
|
<?php echo $isEditMode ? "Neues Passwort" : "Passwort"; ?>
|
|
</label>
|
|
|
|
<?php if ($isEditMode): ?>
|
|
<input type="password"
|
|
name="password"
|
|
class="login-input"
|
|
placeholder="Leer lassen, wenn es gleich bleiben soll">
|
|
<?php else: ?>
|
|
<input type="password"
|
|
name="password"
|
|
class="login-input"
|
|
value="********"
|
|
readonly>
|
|
<?php endif; ?>
|
|
|
|
<br><br>
|
|
|
|
<?php if ($isEditMode): ?>
|
|
<button type="submit"
|
|
name="saveProfile"
|
|
class="button">
|
|
Speichern
|
|
</button>
|
|
|
|
<a href="index.php?pfad=profile" class="button">
|
|
Abbrechen
|
|
</a>
|
|
<?php else: ?>
|
|
<a href="index.php?pfad=profile&edit=1" class="button">
|
|
Bearbeiten
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
</form>
|
|
|
|
<br>
|
|
|
|
<form action="php/controller/deleteAccount-controller.php" method="POST">
|
|
<button type="submit"
|
|
class="button"
|
|
onclick="return confirm('Möchtest du deinen Account wirklich unwiderruflich löschen?');">
|
|
Account löschen
|
|
</button>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="container">
|
|
|
|
<h2 class="section-title">Meine Beiträge</h2>
|
|
|
|
<div class="articles-list">
|
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
|
|
|
<p class="alert-message is-error">
|
|
Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.
|
|
</p>
|
|
|
|
<?php elseif (isset($userArticles) && count($userArticles) > 0): ?>
|
|
|
|
<?php foreach ($userArticles as $userArticle): ?>
|
|
<div class="article-item">
|
|
<div class="article-meta">
|
|
<span class="article-date">
|
|
<?php echo htmlspecialchars($userArticle->getCreationDate()); ?>
|
|
</span>
|
|
|
|
<span class="article-category">
|
|
<?php echo htmlspecialchars($userArticle->getCategory()); ?>
|
|
</span>
|
|
</div>
|
|
|
|
<h3 class="article-title">
|
|
<a href="index.php?pfad=showArticle&id=<?php echo $userArticle->getID(); ?>">
|
|
<?php echo htmlspecialchars($userArticle->getTitle()); ?>
|
|
</a>
|
|
</h3>
|
|
|
|
<?php
|
|
$tags = $userArticle->getTags();
|
|
if (isset($tags) && !empty($tags)):
|
|
?>
|
|
<div class="article-view-bottom-section">
|
|
<div class="article-view-tags-label">Tags:</div>
|
|
|
|
<div class="article-view-tags-list">
|
|
<?php
|
|
$tagArray = is_array($tags) ? $tags : explode(',', $tags);
|
|
|
|
foreach ($tagArray as $tag):
|
|
$trimmedTag = trim($tag);
|
|
|
|
if (!empty($trimmedTag)):
|
|
?>
|
|
<span class="article-view-tag-item">
|
|
<?php echo htmlspecialchars($trimmedTag); ?>
|
|
</span>
|
|
<?php
|
|
endif;
|
|
endforeach;
|
|
?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<a href="index.php?pfad=updateArticle&id=<?php echo $userArticle->getID(); ?>"
|
|
class="edit-link-button">
|
|
Bearbeiten
|
|
</a>
|
|
|
|
<form action="php/controller/deleteArticle-controller.php" method="POST">
|
|
<input type="hidden"
|
|
name="id"
|
|
value="<?php echo htmlspecialchars($userArticle->getID()); ?>">
|
|
|
|
<button type="submit"
|
|
class="button"
|
|
onclick="return confirm('Möchtest du diesen Artikel wirklich löschen?');">
|
|
Löschen
|
|
</button>
|
|
</form>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<p>Du hast noch keine Beiträge erstellt.</p>
|
|
|
|
<button type="button"
|
|
class="button"
|
|
onclick="window.location.href='index.php?pfad=createArticle';">
|
|
Beitrag erstellen!
|
|
</button>
|
|
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<!-- Eigener Bereich für die Kommentare des Nutzers -->
|
|
<div class="comments-section">
|
|
|
|
<h2 class="section-title">Meine Kommentare</h2>
|
|
|
|
<!-- Liste aller Kommentare des Nutzers -->
|
|
<div class="comments-list">
|
|
|
|
<?php if (isset($userComments) && count($userComments) > 0): ?>
|
|
|
|
<?php foreach ($userComments as $comment): ?>
|
|
<div class="article-item">
|
|
|
|
<!-- Erstellungsdatum des Kommentars -->
|
|
<div class="article-meta">
|
|
<span class="article-date">
|
|
<?php echo htmlspecialchars($comment->getCreated()); ?>
|
|
</span>
|
|
</div>
|
|
|
|
<!-- Inhalt des Kommentars -->
|
|
<p>
|
|
<?php echo nl2br(htmlspecialchars($comment->getContent())); ?>
|
|
</p>
|
|
|
|
<!-- Link zum Beitrag, unter dem der Kommentar geschrieben wurde -->
|
|
<a href="index.php?pfad=showArticle&id=<?php echo htmlspecialchars($comment->getArticleId()); ?>"
|
|
class="edit-link-button">
|
|
Zum Beitrag
|
|
</a>
|
|
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<p>Du hast noch keine Kommentare geschrieben.</p>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php unset($_SESSION["message"]); ?>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|