Bearbeitung von Übungsblättern eingefügt
This commit is contained in:
@@ -226,7 +226,7 @@ class TopicData
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result->cleanupRelatedTopics();
|
$result->cleanupRelatedTopics();
|
||||||
$result->cleanupFiles();
|
//$result->cleanupFiles();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ class TopicData
|
|||||||
public function save(): bool
|
public function save(): bool
|
||||||
{
|
{
|
||||||
$this->cleanupRelatedTopics();
|
$this->cleanupRelatedTopics();
|
||||||
$this->cleanupFiles();
|
//$this->cleanupFiles();
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data["displayName"] = $this->displayName;
|
$data["displayName"] = $this->displayName;
|
||||||
@@ -316,11 +316,13 @@ class TopicData
|
|||||||
*/
|
*/
|
||||||
public function deleteDownload(string $name): bool
|
public function deleteDownload(string $name): bool
|
||||||
{
|
{
|
||||||
if (!isset($this->files[$name])) {
|
if (!in_array($name, $this->files)) {
|
||||||
|
echo "a";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unlink(Config::getTopicDirectory($this->getSubjectId(), $this->getId()) . "downloads/$name")) {
|
if (!unlink(Config::getTopicDirectory($this->getSubjectId(), $this->getId()) . "downloads/$name")) {
|
||||||
|
echo "b";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ $defaultValues['subjectId'] = "";
|
|||||||
$defaultValues['description'] = "";
|
$defaultValues['description'] = "";
|
||||||
$defaultValues['icon'] = "";
|
$defaultValues['icon'] = "";
|
||||||
$defaultValues['relatedTopics'] = "";
|
$defaultValues['relatedTopics'] = "";
|
||||||
|
$defaultValues['existing_files'] = "";
|
||||||
$defaultValues['article'] = "";
|
$defaultValues['article'] = "";
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
@@ -29,6 +30,7 @@ if (isset($_GET['subject']) && isset($_GET['topic'])) {
|
|||||||
$defaultValues['description'] = $editingTopic->getDescription();
|
$defaultValues['description'] = $editingTopic->getDescription();
|
||||||
$defaultValues['icon'] = $editingTopic->getIcon();
|
$defaultValues['icon'] = $editingTopic->getIcon();
|
||||||
$defaultValues['relatedTopics'] = implode(", ", $editingTopic->getRelatedTopics());
|
$defaultValues['relatedTopics'] = implode(", ", $editingTopic->getRelatedTopics());
|
||||||
|
$defaultValues['existing_files'] = implode(", ", $editingTopic->getFiles());
|
||||||
$defaultValues['article'] = $editingTopic->getFinishedArticle();
|
$defaultValues['article'] = $editingTopic->getFinishedArticle();
|
||||||
}
|
}
|
||||||
} else if(isset($_GET['subject'])) {
|
} else if(isset($_GET['subject'])) {
|
||||||
@@ -80,8 +82,16 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
$relatedTopics[] = $relatedTopic;
|
$relatedTopics[] = $relatedTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
$article = htmlentities($_POST['article'], ENT_HTML401, 'UTF-8');
|
$existingFiles = array();
|
||||||
|
foreach (explode(",", $_POST['existing_files']) as $existingTopic) {
|
||||||
|
$existingTopic = trim($existingTopic);
|
||||||
|
if($existingTopic == "") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$existingFiles[] = trim($existingTopic);
|
||||||
|
}
|
||||||
|
|
||||||
|
$article = htmlentities($_POST['article'], ENT_HTML401, 'UTF-8');
|
||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
$dom->encoding = 'UTF-8';
|
$dom->encoding = 'UTF-8';
|
||||||
$dom->loadHTML($article, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
$dom->loadHTML($article, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||||
@@ -114,6 +124,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
$htmlImage->setAttribute("src", '__TOPICPATH__/' . $imagename);
|
$htmlImage->setAttribute("src", '__TOPICPATH__/' . $imagename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extension=mbstring in php.ini muss aktiviert sein!
|
||||||
$article = mb_convert_encoding($dom->saveHTML(), 'UTF-8', 'HTML-ENTITIES');
|
$article = mb_convert_encoding($dom->saveHTML(), 'UTF-8', 'HTML-ENTITIES');
|
||||||
|
|
||||||
if(isset($allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']])) {
|
if(isset($allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']])) {
|
||||||
@@ -123,8 +134,12 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
$newTopic->setSubjectId($_POST['subjectId']);
|
$newTopic->setSubjectId($_POST['subjectId']);
|
||||||
$newTopic->setDescription($_POST['description']);
|
$newTopic->setDescription($_POST['description']);
|
||||||
$newTopic->setIcon($_POST['icon']);
|
$newTopic->setIcon($_POST['icon']);
|
||||||
|
|
||||||
$newTopic->setRelatedTopics($relatedTopics);
|
$newTopic->setRelatedTopics($relatedTopics);
|
||||||
|
foreach ($newTopic->getFiles() as $file) {
|
||||||
|
if(!in_array($file, $existingFiles)) {
|
||||||
|
$newTopic->deleteDownload($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
$newTopic->setArticle($article);
|
$newTopic->setArticle($article);
|
||||||
} else {
|
} else {
|
||||||
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $relatedTopics, $article);
|
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $relatedTopics, $article);
|
||||||
@@ -133,6 +148,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
if(!$newTopic) {
|
if(!$newTopic) {
|
||||||
$errors["error"] = "Fehler beim Speichern des Themas.";
|
$errors["error"] = "Fehler beim Speichern des Themas.";
|
||||||
} else {
|
} else {
|
||||||
|
for($i = 0; $i < count($_FILES['new_files']['name']); $i++) {
|
||||||
|
!$newTopic->addDownload($_FILES['new_files']['name'][$i], $_FILES['new_files']['tmp_name'][$i]);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($newImages as $name => $image) {
|
foreach ($newImages as $name => $image) {
|
||||||
$newTopic->uploadImage($name, $image);
|
$newTopic->uploadImage($name, $image);
|
||||||
}
|
}
|
||||||
@@ -174,7 +193,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
|
|
||||||
<body class="min-h-screen bg-gray-50">
|
<body class="min-h-screen bg-gray-50">
|
||||||
|
|
||||||
<form id="topicForm" method="post" class="space-y-8">
|
<form id="topicForm" method="post" enctype="multipart/form-data" class="space-y-8">
|
||||||
<div class="grid grid-cols-1 xl:grid-cols-2 gap-8">
|
<div class="grid grid-cols-1 xl:grid-cols-2 gap-8">
|
||||||
<!-- Left column - Topic details -->
|
<!-- Left column - Topic details -->
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
@@ -227,6 +246,29 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
<input class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" type="text"
|
<input class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" type="text"
|
||||||
name="relatedTopics" id="relatedTopicSelect" value="<?php echo $defaultValues['relatedTopics']; ?>">
|
name="relatedTopics" id="relatedTopicSelect" value="<?php echo $defaultValues['relatedTopics']; ?>">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="existing_files" class="block text-sm font-medium text-gray-700">
|
||||||
|
Existierende Übungsblätter</label>
|
||||||
|
<input class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" type="text" name="existing_files" id="existing_files" value="<?php echo $defaultValues['existing_files']; ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-2">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<div class="rounded-md bg-slate-800 py-0.5 px-2.5 border border-transparent text-sm text-white transition-all shadow-sm">
|
||||||
|
|
||||||
|
Chip
|
||||||
|
<button class="pl-1" onclick=""><i class="fa fa-x"></i></button>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="new_files" class="block text-sm font-medium text-gray-700">
|
||||||
|
Übungsblätter hinzufügen</label>
|
||||||
|
<input type="file" name="new_files[]" id="new_files" multiple>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right column - Editor -->
|
<!-- Right column - Editor -->
|
||||||
@@ -246,14 +288,12 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="quillEditor" style="height: 400px;" class="bg-white border rounded-lg">
|
<div id="quillEditor" style="height: 400px;" class="bg-white border rounded-lg"><?php
|
||||||
<?php
|
|
||||||
$article = $defaultValues['article'];
|
$article = $defaultValues['article'];
|
||||||
|
|
||||||
echo $article;
|
echo $article;
|
||||||
|
|
||||||
?>
|
?></div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user