docsRepo = new DokumentationRepository(); } public function index(): void { $this->view('docs.index', [ 'title' => 'Dokumentation', 'hierarchy' => $this->docsRepo->getHierarchy(), ]); } public function redirectBySlug(string $slug): void { $doc = $this->docsRepo->findDocBySlug($slug); if ($doc === null) { http_response_code(404); echo '404 - Dokumentation nicht gefunden: ' . htmlspecialchars($slug); return; } header('Location: /docs' . $doc['path'], true, 301); exit; } public function show(string $path): void { $path = '/' . ltrim($path, '/'); $doc = $this->docsRepo->findByPath($path); if ($doc === null) { http_response_code(404); echo '404 - Dokumentation nicht gefunden: ' . htmlspecialchars($path); return; } $data = [ 'title' => $doc['title'], 'doc' => $doc, 'breadcrumb' => $this->docsRepo->getBreadcrumb((int) $doc['id']), 'children' => $this->docsRepo->findChildren((int) $doc['id']), 'siblings' => $this->docsRepo->getSiblings((int) $doc['id']), ]; // Modul-spezifische Daten laden if ($doc['slug'] === 'ki-protokoll') { $repository = new KiProtokollRepository(); $data['entries'] = $repository->findLatest(20); } $this->view('docs.show', $data); } public function tasksIndex(): void { $taskRepo = new TaskRepository(); $data = [ 'title' => 'Tasks', 'stats' => $taskRepo->getStatistics(), 'tasks' => array_map(fn ($t) => $t->toArray(), $taskRepo->findAll([], 50, 0)), ]; $this->view('tasks.index', $data); } public function tasksNew(): void { $this->view('tasks.new', [ 'title' => 'Neuer Task', ]); } public function tasksEdit(string $id): void { $taskRepo = new TaskRepository(); $task = $taskRepo->findById((int) $id); if ($task === null) { http_response_code(404); echo '404 - Task nicht gefunden'; return; } $this->view('tasks.edit', [ 'title' => 'Task bearbeiten', 'task' => $task->toArray(), ]); } public function taskShow(string $id): void { $taskRepo = new TaskRepository(); $task = $taskRepo->findById((int) $id); if ($task === null) { http_response_code(404); echo '404 - Task nicht gefunden'; return; } $assignmentRepo = new TaskAssignmentRepository(); $resultRepo = new TaskResultRepository(); $commentRepo = new TaskCommentRepository(); $this->view('tasks.show', [ 'title' => 'Task #' . $id, 'task' => $task->toArray(), 'assignments' => array_map(fn ($a) => $a->toArray(), $assignmentRepo->findByTaskId((int) $id)), 'results' => array_map(fn ($r) => $r->toArray(), $resultRepo->findByTaskId((int) $id)), 'comments' => array_map(fn ($c) => $c->toArray(), $commentRepo->findByTaskId((int) $id)), ]); } }