profile.php dynamisch Beiträge anzeigen (unvollständig

This commit is contained in:
2026-05-29 16:00:31 +02:00
parent 52a34cd9b4
commit 88c369de32
3 changed files with 63 additions and 13 deletions
+27 -10
View File
@@ -2,7 +2,9 @@
Content: Profil Content: Profil
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern. Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
--> -->
<?php
include_once 'php/controller/profileArticles-controller.php';
?>
<main class="form-page"> <main class="form-page">
<div class="flexbox"> <div class="flexbox">
<!-- Linke Spalte: Profildaten --> <!-- Linke Spalte: Profildaten -->
@@ -42,18 +44,33 @@
<h2 class="section-title">Meine Beiträge</h2> <h2 class="section-title">Meine Beiträge</h2>
<div class="articles-list"> <div class="articles-list">
<!-- Beispiel-Eintrag 1 (Wird spaeter per PHP wiederholt) --> <!-- Beispiel-Eintrag 1 (Wird später per PHP wiederholt) -->
<div class="article-item"> <div class="article-item">
<div class="article-meta"> <div class="article-meta">
<span class="article-date">29.05.2026</span> <span class="article-date"><?php if (isset($creationDate)) { echo htmlspecialchars($creationDate); } ?></span>
<span class="article-category">Technologie</span> <span class="article-category"><?php if (isset($category)) { echo htmlspecialchars($category); } ?></span>
</div> </div>
<h3 class="article-title">Die Zukunft von CSS Grid</h3> <h3 class="article-title"><?php if (isset($title)) { echo htmlspecialchars($title); } ?></h3>
<div class="article-tags"> <?php if (isset($tags) && !empty($tags)): ?>
<span class="tag">Webdesign</span> <div class="article-view-bottom-section">
<span class="tag">Frontend</span> <div class="article-view-tags-label">Tags:</div>
</div> <div class="article-view-tags-list">
<a href="edit-article.php?id=1" class="edit-link-button">Bearbeiten</a> <?php
// Falls $tags ein String ist (z.B. "Web, CSS"), in ein Array umwandeln
$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="" <!-- TODO --> class="edit-link-button">Bearbeiten</a>
</div> </div>
<!-- Beispiel-Eintrag 2 --> <!-- Beispiel-Eintrag 2 -->
+2 -3
View File
@@ -15,7 +15,6 @@ include_once 'php/controller/showArticle-controller.php';
<?php if (isset($category) && !empty($category)): ?> <?php if (isset($category) && !empty($category)): ?>
<span class="article-view-category"><?php echo htmlspecialchars($category); ?></span> <span class="article-view-category"><?php echo htmlspecialchars($category); ?></span>
<?php endif; ?> <?php endif; ?>
<h1 class="article-view-title"> <h1 class="article-view-title">
<?php if (isset($title)) { echo htmlspecialchars($title); } ?> <?php if (isset($title)) { echo htmlspecialchars($title); } ?>
</h1> </h1>
@@ -28,7 +27,7 @@ include_once 'php/controller/showArticle-controller.php';
</div> </div>
<!-- articleikel-Inhalt --> <!-- Beitrags-Inhalt -->
<div class="article-view-content"> <div class="article-view-content">
<?php if (isset($content)): ?> <?php if (isset($content)): ?>
<!-- nl2br für Zeilenumbrüche --> <!-- nl2br für Zeilenumbrüche -->
@@ -36,7 +35,7 @@ include_once 'php/controller/showArticle-controller.php';
<?php endif; ?> <?php endif; ?>
</div> </div>
<!-- articleikel-Endbereich (Tags) --> <!-- Beitrags-Endbereich (Tags) -->
<?php if (isset($tags) && !empty($tags)): ?> <?php if (isset($tags) && !empty($tags)): ?>
<div class="article-view-bottom-section"> <div class="article-view-bottom-section">
<div class="article-view-tags-label">Tags:</div> <div class="article-view-tags-label">Tags:</div>
@@ -0,0 +1,34 @@
<?php
/*
* Controller für die Liste der eigenen Beiträge eines Nutzers auf der eigenen Profilseite
*/
session_start();
require_once 'php/model/Article.php';
require_once 'php/model/ArticleManager.php';
if (isset($_GET["id"])){
try {
$articleManager = ArticleManager::getInstance();
$article = $articleManager->getArticle($_GET["id"]);
if($article != null){
$title = $article->getTitle();
$content = $article->getContent();
$category = $article->getCategory();
$author = $article->getAuthor();
$tags = $article->getTags();
$creationDate = $article->getCreationDate();
}else{
$_SESSION["message"] = "article_not_found";
echo "article_not_found";
}
} catch (Exception $e){
$_SESSION["message"] = "internal_error";
echo "Fehler aufgetreten: " . $e->getMessage();
}
}else{
$_SESSION["message"] = "article_not_found";
echo "article_not_found";
}
?>