repository = $repository ?? new SystemExplorerRepository(); } /** * GET /explorer * Dashboard mit Statistiken */ public function index(): void { $this->view('system-explorer.index', [ 'title' => 'Doc2Vector Explorer', 'dokumenteCount' => $this->repository->countDokumente(), 'seitenCount' => $this->repository->countSeiten(), 'chunkStats' => $this->repository->getChunkStats(), 'taxonomyCategories' => $this->repository->getTopTaxonomyCategories(10), 'dokumente' => $this->repository->getDokumenteWithStats(), 'recentChunks' => $this->repository->getRecentChunks(5), ]); } /** * GET /explorer/dokumente * Liste aller Hauptbereiche (depth=0) */ public function dokumente(): void { $this->view('system-explorer.dokumente.index', [ 'title' => 'Dokumente', 'dokumente' => $this->repository->getDokumenteWithFullStats(), ]); } /** * GET /explorer/dokumente/{id} * Dokument-Details mit Seiten und Chunks */ public function dokumentShow(int $id): void { $dokument = $this->repository->getDokumentRoot($id); if ($dokument === null) { $this->notFound('Dokument nicht gefunden'); } $this->view('system-explorer.dokumente.show', [ 'title' => $dokument['title'], 'dokument' => $dokument, 'seiten' => $this->repository->getSeitenWithStatsForParent($id), 'chunks' => $this->repository->getChunksForDokument($id), 'taxonomy' => $this->repository->getTaxonomyForDokumentTree($id), ]); } /** * GET /explorer/seiten * Liste aller Seiten (depth>0) */ public function seiten(): void { $search = $this->getString('search'); $parentId = $this->getString('parent'); $this->view('system-explorer.seiten.index', [ 'title' => 'Seiten', 'seiten' => $this->repository->getSeitenFiltered($search, $parentId), 'dokumente' => $this->repository->getDokumenteForFilter(), 'currentSearch' => $search, 'currentParent' => $parentId, ]); } /** * GET /explorer/seiten/{id} * Seiten-Details mit Chunks */ public function seiteShow(int $id): void { $seite = $this->repository->getSeiteWithParent($id); if ($seite === null) { $this->notFound('Seite nicht gefunden'); } $this->view('system-explorer.seiten.show', [ 'title' => $seite['title'], 'seite' => $seite, 'chunks' => $this->repository->getChunksDetailedForDokument($id), 'unterseiten' => $this->repository->getUnterseiten($id), 'breadcrumb' => $this->repository->buildBreadcrumb($seite), ]); } /** * GET /explorer/chunks * Liste aller Chunks mit Filtern */ public function chunks(): void { $category = $this->getString('category'); $status = $this->getString('status'); $search = $this->getString('search'); $pagination = Pagination::fromRequest(50); $totalCount = $this->repository->countChunksFiltered($category, $status, $search); $pagination = $pagination->withTotal($totalCount); $this->view('system-explorer.chunks.index', [ 'title' => 'Chunks', 'chunks' => $this->repository->getChunksFilteredPaginated( $category, $status, $search, $pagination->limit, $pagination->offset ), 'categories' => $this->repository->getDistinctCategories(), 'currentCategory' => $category, 'currentStatus' => $status, 'currentSearch' => $search, 'currentPage' => $pagination->page, 'totalCount' => $pagination->totalCount, 'totalPages' => $pagination->totalPages(), ]); } /** * GET /explorer/chunks/{id} * Chunk-Details */ public function chunkShow(int $id): void { $chunk = $this->repository->getChunk($id); if ($chunk === null) { $this->notFound('Chunk nicht gefunden'); } // Nachbar-Chunks $prevChunk = $this->repository->getChunkByDokumentAndIndex( $chunk['dokumentation_id'], $chunk['chunk_index'] - 1 ); $nextChunk = $this->repository->getChunkByDokumentAndIndex( $chunk['dokumentation_id'], $chunk['chunk_index'] + 1 ); $this->view('system-explorer.chunks.show', [ 'title' => 'Chunk #' . $chunk['id'], 'chunk' => $chunk, 'prevChunk' => $prevChunk, 'nextChunk' => $nextChunk, ]); } /** * GET /explorer/taxonomie * Taxonomie-Übersicht */ public function taxonomie(): void { $this->view('system-explorer.taxonomie', [ 'title' => 'Taxonomie & Entities', 'categories' => $this->repository->getCategoriesWithStats(), 'topKeywords' => $this->repository->getTopKeywords(30), 'topEntities' => $this->repository->getTopEntitiesRaw(30), ]); } /** * GET /explorer/suche * Suche-Formular */ public function suche(): void { $query = $this->getString('q'); $category = $this->getString('category'); $limit = $this->getLimit(20, 10); $results = []; $suggestions = []; if ($query !== '') { $filters = []; if ($category !== '') { $filters['taxonomy_category'] = $category; } $search = new HybridSearchService(); $results = $search->search($query, $filters, $limit); $suggestions = $search->suggestRelatedSearches($results); } $this->view('system-explorer.suche', [ 'title' => 'Dokumentation durchsuchen', 'query' => $query, 'results' => $results, 'suggestions' => $suggestions, 'categories' => $this->repository->getDistinctCategories(), 'currentCategory' => $category, 'limit' => $limit, ]); } }