197 lines
6.6 KiB
PHP
197 lines
6.6 KiB
PHP
<!DOCTYPE html>
|
|
|
|
<?php
|
|
require_once("classes/SubjectData.php");
|
|
require_once("classes/TopicData.php");
|
|
|
|
if (!isset($_GET["subject"])) {
|
|
die("Ungültige Seite");
|
|
}
|
|
$subjectData = SubjectData::fromName($_GET["subject"]);
|
|
if (!isset($subjectData)) {
|
|
die("Ungültige Seite");
|
|
}
|
|
if (!isset($_GET["topic"])) {
|
|
die("Ungültige Seite");
|
|
}
|
|
$topicData = TopicData::fromName($_GET["subject"], $_GET["topic"]);
|
|
if (!isset($topicData)) {
|
|
die("Ungültige Seite");
|
|
}
|
|
|
|
?>
|
|
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo($topicData->displayName); ?> - <?php echo($subjectData->displayName); ?></title>
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
|
<link href="assets/css/topic.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>
|
|
</head>
|
|
<body>
|
|
<button class="menu-toggle fixed top-4 left-4 z-50 bg-white h-12 w-12 border-2 p-1 hover:border-[<?php echo($subjectData->color); ?>]">
|
|
<i class="fas fa-bars"></i>
|
|
</button>
|
|
<!-- Left Sidebar -->
|
|
<nav class="sidebar bg-[<?php echo($subjectData->color); ?>]">
|
|
<div class="sidebar-header">
|
|
<i class="fas fa-graduation-cap"></i>
|
|
<h2><?php echo($subjectData->displayName); ?></h2>
|
|
</div>
|
|
<a href="homepage.php" class="nav-link">
|
|
<i class="fas fa-home"></i> Startseite
|
|
</a>
|
|
<a href="subject.php?subject=<?php echo($subjectData->id); ?>" class="nav-link">
|
|
<i class="fas fa-book"></i> <?php echo($subjectData->displayName); ?> Übersicht
|
|
</a>
|
|
<a href="#" class="nav-link active">
|
|
<i class="fas fa-calculator"></i> <?php echo($topicData->displayName); ?>
|
|
</a>
|
|
</nav>
|
|
|
|
<!-- Main Content -->
|
|
<main class="main-content max-w-7xl">
|
|
|
|
<div class="content-card">
|
|
<h1 class="content-title"><?php echo($topicData->displayName); ?></h1>
|
|
<p class="content-text">
|
|
<?php echo($topicData->description); ?>
|
|
</p>
|
|
<p class="content-text article-section">
|
|
<?php echo($topicData->article); ?>
|
|
</p>
|
|
|
|
<div class="exercise-section bg-[<?php echo($subjectData->color); ?>]">
|
|
<h3 style="margin-bottom: 1rem;">Übungen herunterladen:</h3>
|
|
<div style="display: flex; flex-wrap: wrap; gap: 0.5rem;">
|
|
<?php
|
|
foreach ($topicData->files as $fileName) {
|
|
?>
|
|
|
|
<a href='<?php echo("config/subjects/$subjectData->id/topics/$topicData->id/$fileName") ?>'
|
|
target="_blank" download class="download-btn">
|
|
<i class="fas fa-file-pdf"></i>
|
|
<?php echo($fileName); ?>
|
|
</a>
|
|
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="related-topics bg-gray-100 p-4 rounded-lg">
|
|
<h4>Verwandte Themen:</h4>
|
|
<ul class="flex flex-wrap gap-2">
|
|
<?php
|
|
foreach ($topicData->relatedTopics as $relatedTopicName) {
|
|
$relatedTopic = $subjectData->topics[$relatedTopicName];
|
|
if (!isset($relatedTopic)) {
|
|
continue;
|
|
}
|
|
?>
|
|
<li onclick="event.stopPropagation();" class="border-[<?php echo($subjectData->color); ?>] border-2">
|
|
<a href='<?php echo("topic.php?subject=$subjectData->id&topic=$relatedTopic->id") ?>' class="block">
|
|
<?php echo($relatedTopic->displayName); ?>
|
|
</a>
|
|
</li>
|
|
<?php
|
|
}
|
|
?>
|
|
</ul>
|
|
</div>
|
|
</main>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const menuToggle = document.querySelector('.menu-toggle');
|
|
const sidebar = document.querySelector('.sidebar');
|
|
|
|
// Function to handle sidebar toggle
|
|
function toggleSidebar() {
|
|
sidebar.classList.toggle('active');
|
|
|
|
// Add overlay when sidebar is active on mobile/tablet
|
|
if (window.innerWidth <= 1024) {
|
|
if (sidebar.classList.contains('active')) {
|
|
addOverlay();
|
|
} else {
|
|
removeOverlay();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Function to add overlay
|
|
function addOverlay() {
|
|
const overlay = document.createElement('div');
|
|
overlay.className = 'sidebar-overlay';
|
|
overlay.style.cssText = `
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
z-index: 45;
|
|
transition: opacity 0.3s ease;
|
|
`;
|
|
document.body.appendChild(overlay);
|
|
|
|
// Close sidebar when clicking overlay
|
|
overlay.addEventListener('click', () => {
|
|
sidebar.classList.remove('active');
|
|
removeOverlay();
|
|
});
|
|
|
|
// Fade in
|
|
requestAnimationFrame(() => {
|
|
overlay.style.opacity = '1';
|
|
});
|
|
}
|
|
|
|
// Function to remove overlay
|
|
function removeOverlay() {
|
|
const overlay = document.querySelector('.sidebar-overlay');
|
|
if (overlay) {
|
|
overlay.style.opacity = '0';
|
|
setTimeout(() => overlay.remove(), 300);
|
|
}
|
|
}
|
|
|
|
// Add click event to menu toggle
|
|
menuToggle.addEventListener('click', toggleSidebar);
|
|
|
|
// Handle window resize
|
|
let resizeTimer;
|
|
window.addEventListener('resize', () => {
|
|
clearTimeout(resizeTimer);
|
|
resizeTimer = setTimeout(() => {
|
|
if (window.innerWidth > 1024) {
|
|
sidebar.classList.remove('active');
|
|
removeOverlay();
|
|
}
|
|
}, 250);
|
|
});
|
|
});
|
|
|
|
// Add this right after your existing toggleSidebar function
|
|
function updateMenuVisibility() {
|
|
const menuToggle = document.querySelector('.menu-toggle');
|
|
if (window.innerWidth <= 768) { // Smartphone breakpoint
|
|
menuToggle.style.display = 'flex';
|
|
} else {
|
|
menuToggle.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Add event listeners
|
|
window.addEventListener('resize', updateMenuVisibility);
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|