erste article-Implementation

article-Interface & -Klasse
+ createArticle.php mit article.css (Editor)
+ neuer "Beitrag erstellen"-Button in Navbar
This commit is contained in:
NOrtmann1
2026-05-26 10:36:56 +02:00
parent c41302d046
commit a1184299b1
6 changed files with 187 additions and 4 deletions
+45 -2
View File
@@ -1,10 +1,53 @@
<?php
require_once articleDAO::class;
/*
* Klasse: Artikel
* TODO Beschreibung hinzufügen
*/
class article
{
class article implements articleDAO {
public function newArticle($title, $content, $author) {
$newData = array(
"title" => $title,
"content" => $content,
"author" => $author,
"email" => $_POST["Email"],
"date" => date("d.m.Y, H:i")
);
$newData = base64_encode(serialize($newData));
if (!file_exists("articles.txt")) {
$newData = fopen("articles.txt", "xb");
fclose($newData);
}
$previousData = file_get_contents("gaestebuch.txt");
if (file_put_contents("gaestebuch.txt", "$newData\n$previousData")) {
// TODO: Vernünftige Rückmeldung implementieren.
echo "Artikel erfolgreich gespeichert!";
} else {
// TODO: passende Exceptions werfen.
echo "Fehler!";
}
}
public function updateArticle($id, $title, $content, $author)
{
// TODO: Implement updateArticle() method.
}
public function deleteArticle($id)
{
// TODO: Implement deleteArticle() method.
}
public function getArticle($id)
{
// TODO: Implement getArticle() method.
}
public function getAllArticles()
{
// TODO: Implement getAllArticles() method.
}
}
?>
+3
View File
@@ -1,4 +1,7 @@
<?php
/*
* Die Klasse binhaltet alle Methoden für die Beiträge.
*/
interface articleDAO
{