Laden von bereits existierenden Themen eingefügen
This commit is contained in:
@@ -5,6 +5,16 @@ require_once("classes/User.php");
|
||||
require_once("classes/SubjectData.php");
|
||||
require_once("classes/TopicData.php");
|
||||
|
||||
$allSubjects = SubjectData::getAll();
|
||||
$editingTopic = null;
|
||||
|
||||
if (isset($_GET['subjectId']) && isset($_GET['topicId'])) {
|
||||
if (isset($allSubjects[$_GET['subjectId']]->getTopics()[$_GET['topicId']])) {
|
||||
$editingTopic = $allSubjects[$_GET['subjectId']]->getTopics()[$_GET['topicId']];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
@@ -16,11 +26,10 @@ require_once("classes/TopicData.php");
|
||||
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
<link href="assets/css/styles.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css" rel="stylesheet" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css" rel="stylesheet"/>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -31,7 +40,12 @@ require_once("classes/TopicData.php");
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<label for="topicNameSelect" class="block text-sm font-medium text-gray-700">Themenname</label>
|
||||
<input id="topicNameSelect" type="text" name="displayName" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" required>
|
||||
<input id="topicNameSelect" type="text" name="displayName"
|
||||
class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" required value="<?php
|
||||
if (isset($editingTopic)) {
|
||||
echo $editingTopic->getDisplayName();
|
||||
}
|
||||
?>">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -39,20 +53,42 @@ require_once("classes/TopicData.php");
|
||||
<select id="topicSubjectSelect" name="subject" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" required>
|
||||
<option value="">Fach auswählen...</option>
|
||||
<?php
|
||||
foreach (SubjectData::getAll() as $subject) {
|
||||
$id = $subject->getID();
|
||||
$name = $subject->getDisplayName();
|
||||
foreach ($allSubjects as $subject) {
|
||||
$selected = "";
|
||||
if (isset($editingTopic)) {
|
||||
if ($editingTopic->getSubjectId() === $subject->getId()) {
|
||||
$selected = "selected";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<option value='$id'>$name</option>";
|
||||
echo "<option $selected value='" . $subject->getID() . "'>" . $subject->getDisplayName() . "</option>";
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="topicDescriptionSelect" class="block text-sm font-medium text-gray-700">Kurzbeschreibung</label>
|
||||
<textarea id="topicDescriptionSelect" name="description" rows="2" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" required></textarea>
|
||||
<textarea id="topicDescriptionSelect" name="description" rows="5"
|
||||
class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" required><?php
|
||||
if (isset($editingTopic)) {
|
||||
echo $editingTopic->getDescription();
|
||||
}
|
||||
?></textarea>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="iconSelect" class="block text-sm font-medium text-gray-700">Icon</label>
|
||||
<input class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" type="text" name="icon" id="iconSelect" value="fa-address-card">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="relatedTopicSelect" class="block text-sm font-medium text-gray-700">Verwandte Themen als IDs und kommagetrennt</label>
|
||||
<input class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" type="text" name="related-topics" id="relatedTopicSelect" value="<?php
|
||||
if(isset($editingTopic)) {
|
||||
echo implode(", ", $editingTopic->getRelatedTopics());
|
||||
}
|
||||
?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -73,7 +109,13 @@ require_once("classes/TopicData.php");
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="quillEditor" style="height: 400px;" class="bg-white border rounded-lg"></div>
|
||||
<div id="quillEditor" style="height: 400px;" class="bg-white border rounded-lg">
|
||||
<?php
|
||||
if(isset($editingTopic)) {
|
||||
echo $editingTopic->getFinishedArticle();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -102,11 +144,11 @@ require_once("classes/TopicData.php");
|
||||
const quill = new Quill('#quillEditor', {
|
||||
modules: {
|
||||
toolbar: [
|
||||
[{ 'size': [] }],
|
||||
[ 'bold', 'italic', 'underline', 'strike' ],
|
||||
[{ 'script': 'super' }, { 'script': 'sub' }],
|
||||
[{ 'list': 'ordered' }, { 'list': 'bullet'}],
|
||||
[ 'link', 'image' ],
|
||||
[{'size': []}],
|
||||
['bold', 'italic', 'underline', 'strike'],
|
||||
[{'script': 'super'}, {'script': 'sub'}],
|
||||
[{'list': 'ordered'}, {'list': 'bullet'}],
|
||||
['link', 'image'],
|
||||
]
|
||||
},
|
||||
theme: 'snow'
|
||||
@@ -118,6 +160,7 @@ require_once("classes/TopicData.php");
|
||||
document.getElementById('article-upload-field').value = html;
|
||||
|
||||
});
|
||||
quill.emitter.emit('text-change');
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user