profile.php dynamisch Beiträge anzeigen (unvollständig
This commit is contained in:
+27
-10
@@ -2,7 +2,9 @@
|
||||
Content: Profil
|
||||
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">
|
||||
<div class="flexbox">
|
||||
<!-- Linke Spalte: Profildaten -->
|
||||
@@ -42,18 +44,33 @@
|
||||
<h2 class="section-title">Meine Beiträge</h2>
|
||||
<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-meta">
|
||||
<span class="article-date">29.05.2026</span>
|
||||
<span class="article-category">Technologie</span>
|
||||
<span class="article-date"><?php if (isset($creationDate)) { echo htmlspecialchars($creationDate); } ?></span>
|
||||
<span class="article-category"><?php if (isset($category)) { echo htmlspecialchars($category); } ?></span>
|
||||
</div>
|
||||
<h3 class="article-title">Die Zukunft von CSS Grid</h3>
|
||||
<div class="article-tags">
|
||||
<span class="tag">Webdesign</span>
|
||||
<span class="tag">Frontend</span>
|
||||
</div>
|
||||
<a href="edit-article.php?id=1" class="edit-link-button">Bearbeiten</a>
|
||||
<h3 class="article-title"><?php if (isset($title)) { echo htmlspecialchars($title); } ?></h3>
|
||||
<?php 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
|
||||
// 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>
|
||||
|
||||
<!-- Beispiel-Eintrag 2 -->
|
||||
|
||||
@@ -15,7 +15,6 @@ include_once 'php/controller/showArticle-controller.php';
|
||||
<?php if (isset($category) && !empty($category)): ?>
|
||||
<span class="article-view-category"><?php echo htmlspecialchars($category); ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<h1 class="article-view-title">
|
||||
<?php if (isset($title)) { echo htmlspecialchars($title); } ?>
|
||||
</h1>
|
||||
@@ -28,7 +27,7 @@ include_once 'php/controller/showArticle-controller.php';
|
||||
|
||||
</div>
|
||||
|
||||
<!-- articleikel-Inhalt -->
|
||||
<!-- Beitrags-Inhalt -->
|
||||
<div class="article-view-content">
|
||||
<?php if (isset($content)): ?>
|
||||
<!-- nl2br für Zeilenumbrüche -->
|
||||
@@ -36,7 +35,7 @@ include_once 'php/controller/showArticle-controller.php';
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- articleikel-Endbereich (Tags) -->
|
||||
<!-- Beitrags-Endbereich (Tags) -->
|
||||
<?php if (isset($tags) && !empty($tags)): ?>
|
||||
<div class="article-view-bottom-section">
|
||||
<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";
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user