{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/SystemExplorerController.php",
"oldString": " $sql .= ' ORDER BY c.created_at DESC LIMIT ' . $limit . ' OFFSET ' . $offset;\n\n $stmt = $this->db->prepare($sql);\n $stmt->execute($params);\n $chunks = $stmt->fetchAll();",
"newString": " $sql .= ' ORDER BY c.created_at DESC LIMIT :limit OFFSET :offset';\n\n $stmt = $this->db->prepare($sql);\n foreach ($params as $key => $value) {\n $stmt->bindValue(':' . $key, $value);\n }\n $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);\n $stmt->bindValue(':offset', $offset, \\PDO::PARAM_INT);\n $stmt->execute();\n $chunks = $stmt->fetchAll();",
"originalFile": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse Infrastructure\\Config\\DatabaseFactory;\nuse Infrastructure\\Docs\\HybridSearchService;\n\n\/**\n * SystemExplorerController - Interne System-Dokumentation\n *\n * Zeigt Code-Dokumentation, Seiten und Chunks aus der dokumentation_chunks Pipeline.\n * Für Admin\/Entwickler - System-Wissen.\n *\/\nclass SystemExplorerController extends Controller\n{\n private \\PDO $db;\n\n public function __construct()\n {\n $this->db = DatabaseFactory::dev();\n }\n\n \/**\n * GET \/explorer\n * Dashboard mit Statistiken\n *\/\n public function index(): void\n {\n \/\/ Dokumente (depth=0) = Hauptbereiche\n $dokumenteCount = $this->db->query(\n 'SELECT COUNT(*) FROM dokumentation WHERE depth = 0'\n )->fetchColumn();\n\n \/\/ Seiten (depth>0) = Unterseiten\n $seitenCount = $this->db->query(\n 'SELECT COUNT(*) FROM dokumentation WHERE depth > 0'\n )->fetchColumn();\n\n \/\/ Chunk-Statistiken\n $chunkStats = $this->db->query(\n 'SELECT\n COUNT(*) as total,\n COALESCE(SUM(token_count), 0) as tokens,\n SUM(CASE WHEN analysis_status = \"completed\" THEN 1 ELSE 0 END) as analyzed,\n SUM(CASE WHEN qdrant_id IS NOT NULL THEN 1 ELSE 0 END) as synced\n FROM dokumentation_chunks'\n )->fetch();\n\n \/\/ Taxonomie-Kategorien\n $taxonomyCategories = $this->db->query(\n 'SELECT taxonomy_category, COUNT(*) as count\n FROM dokumentation_chunks\n WHERE taxonomy_category IS NOT NULL\n GROUP BY taxonomy_category\n ORDER BY count DESC\n LIMIT 10'\n )->fetchAll();\n\n \/\/ Dokumente (Hauptbereiche)\n $dokumente = $this->db->query(\n 'SELECT d.id, d.title, d.path,\n (SELECT COUNT(*) FROM dokumentation WHERE parent_id = d.id) as seiten_count,\n (SELECT COUNT(*) FROM dokumentation_chunks WHERE dokumentation_id = d.id) as chunks_count\n FROM dokumentation d\n WHERE d.depth = 0\n ORDER BY d.title'\n )->fetchAll();\n\n \/\/ Neueste Chunks\n $recentChunks = $this->db->query(\n 'SELECT c.id, c.content, c.taxonomy_category, c.token_count, c.created_at,\n d.title as dokument_title, d.path as dokument_path\n FROM dokumentation_chunks c\n JOIN dokumentation d ON c.dokumentation_id = d.id\n ORDER BY c.created_at DESC\n LIMIT 5'\n )->fetchAll();\n\n $this->view('system-explorer.index', [\n 'title' => 'Doc2Vector Explorer',\n 'dokumenteCount' => $dokumenteCount,\n 'seitenCount' => $seitenCount,\n 'chunkStats' => $chunkStats,\n 'taxonomyCategories' => $taxonomyCategories,\n 'dokumente' => $dokumente,\n 'recentChunks' => $recentChunks,\n ]);\n }\n\n \/**\n * GET \/explorer\/dokumente\n * Liste aller Hauptbereiche (depth=0)\n *\/\n public function dokumente(): void\n {\n $dokumente = $this->db->query(\n 'SELECT d.id, d.title, d.path, d.content, d.created_at, d.updated_at,\n (SELECT COUNT(*) FROM dokumentation WHERE parent_id = d.id) as seiten_count,\n (SELECT COUNT(*) FROM dokumentation_chunks WHERE dokumentation_id IN\n (SELECT id FROM dokumentation WHERE parent_id = d.id OR id = d.id)) as total_chunks,\n (SELECT COALESCE(SUM(token_count), 0) FROM dokumentation_chunks WHERE dokumentation_id IN\n (SELECT id FROM dokumentation WHERE parent_id = d.id OR id = d.id)) as total_tokens\n FROM dokumentation d\n WHERE d.depth = 0\n ORDER BY d.title'\n )->fetchAll();\n\n $this->view('system-explorer.dokumente.index', [\n 'title' => 'Dokumente',\n 'dokumente' => $dokumente,\n ]);\n }\n\n \/**\n * GET \/explorer\/dokumente\/{id}\n * Dokument-Details mit Seiten und Chunks\n *\/\n public function dokumentShow(int $id): void\n {\n $stmt = $this->db->prepare(\n 'SELECT * FROM dokumentation WHERE id = :id AND depth = 0'\n );\n $stmt->execute(['id' => $id]);\n $dokument = $stmt->fetch();\n\n if ($dokument === false) {\n http_response_code(404);\n echo '404 - Dokument nicht gefunden';\n\n return;\n }\n\n \/\/ Direkte Seiten (depth=1)\n $stmt = $this->db->prepare(\n 'SELECT s.id, s.title, s.path, s.depth,\n (SELECT COUNT(*) FROM dokumentation_chunks WHERE dokumentation_id = s.id) as chunks_count,\n (SELECT COALESCE(SUM(token_count), 0) FROM dokumentation_chunks WHERE dokumentation_id = s.id) as token_count\n FROM dokumentation s\n WHERE s.parent_id = :id\n ORDER BY s.title'\n );\n $stmt->execute(['id' => $id]);\n $seiten = $stmt->fetchAll();\n\n \/\/ Chunks direkt am Dokument\n $stmt = $this->db->prepare(\n 'SELECT c.id, c.chunk_index, c.content, c.token_count, c.taxonomy_category,\n c.entities, c.keywords, c.analysis_status, c.qdrant_id\n FROM dokumentation_chunks c\n WHERE c.dokumentation_id = :id\n ORDER BY c.chunk_index'\n );\n $stmt->execute(['id' => $id]);\n $chunks = $stmt->fetchAll();\n\n \/\/ Taxonomie-Aggregation für dieses Dokument (inkl. Seiten)\n $stmt = $this->db->prepare(\n 'SELECT taxonomy_category, COUNT(*) as count\n FROM dokumentation_chunks\n WHERE dokumentation_id IN (\n SELECT id FROM dokumentation WHERE id = :id OR parent_id = :id2\n )\n AND taxonomy_category IS NOT NULL\n GROUP BY taxonomy_category\n ORDER BY count DESC'\n );\n $stmt->execute(['id' => $id, 'id2' => $id]);\n $taxonomy = $stmt->fetchAll();\n\n $this->view('system-explorer.dokumente.show', [\n 'title' => $dokument['title'],\n 'dokument' => $dokument,\n 'seiten' => $seiten,\n 'chunks' => $chunks,\n 'taxonomy' => $taxonomy,\n ]);\n }\n\n \/**\n * GET \/explorer\/seiten\n * Liste aller Seiten (depth>0)\n *\/\n public function seiten(): void\n {\n $search = $_GET['search'] ?? '';\n $parentId = $_GET['parent'] ?? '';\n\n $sql = 'SELECT s.id, s.title, s.path, s.depth, s.parent_id,\n p.title as parent_title,\n (SELECT COUNT(*) FROM dokumentation_chunks WHERE dokumentation_id = s.id) as chunks_count,\n (SELECT COALESCE(SUM(token_count), 0) FROM dokumentation_chunks WHERE dokumentation_id = s.id) as token_count\n FROM dokumentation s\n LEFT JOIN dokumentation p ON s.parent_id = p.id\n WHERE s.depth > 0';\n\n $params = [];\n\n if ($search !== '') {\n $sql .= ' AND (s.title LIKE :search OR s.path LIKE :search2)';\n $params['search'] = '%' . $search . '%';\n $params['search2'] = '%' . $search . '%';\n }\n\n if ($parentId !== '') {\n $sql .= ' AND s.parent_id = :parent';\n $params['parent'] = (int) $parentId;\n }\n\n $sql .= ' ORDER BY p.title, s.depth, s.title';\n\n $stmt = $this->db->prepare($sql);\n $stmt->execute($params);\n $seiten = $stmt->fetchAll();\n\n \/\/ Dokumente für Filter\n $dokumente = $this->db->query(\n 'SELECT id, title FROM dokumentation WHERE depth = 0 ORDER BY title'\n )->fetchAll();\n\n $this->view('system-explorer.seiten.index', [\n 'title' => 'Seiten',\n 'seiten' => $seiten,\n 'dokumente' => $dokumente,\n 'currentSearch' => $search,\n 'currentParent' => $parentId,\n ]);\n }\n\n \/**\n * GET \/explorer\/seiten\/{id}\n * Seiten-Details mit Chunks\n *\/\n public function seiteShow(int $id): void\n {\n $stmt = $this->db->prepare(\n 'SELECT s.*, p.title as parent_title, p.path as parent_path\n FROM dokumentation s\n LEFT JOIN dokumentation p ON s.parent_id = p.id\n WHERE s.id = :id'\n );\n $stmt->execute(['id' => $id]);\n $seite = $stmt->fetch();\n\n if ($seite === false) {\n http_response_code(404);\n echo '404 - Seite nicht gefunden';\n\n return;\n }\n\n \/\/ Chunks dieser Seite\n $stmt = $this->db->prepare(\n 'SELECT c.id, c.chunk_index, c.content, c.token_count, c.taxonomy_category,\n c.taxonomy_path, c.entities, c.keywords, c.analysis_status, c.qdrant_id,\n c.heading_path, c.analyzed_at\n FROM dokumentation_chunks c\n WHERE c.dokumentation_id = :id\n ORDER BY c.chunk_index'\n );\n $stmt->execute(['id' => $id]);\n $chunks = $stmt->fetchAll();\n\n \/\/ Unterseiten (falls depth=1)\n $stmt = $this->db->prepare(\n 'SELECT id, title, path, depth FROM dokumentation WHERE parent_id = :id ORDER BY title'\n );\n $stmt->execute(['id' => $id]);\n $unterseiten = $stmt->fetchAll();\n\n \/\/ Breadcrumb aufbauen\n $breadcrumb = $this->buildBreadcrumb($seite);\n\n $this->view('system-explorer.seiten.show', [\n 'title' => $seite['title'],\n 'seite' => $seite,\n 'chunks' => $chunks,\n 'unterseiten' => $unterseiten,\n 'breadcrumb' => $breadcrumb,\n ]);\n }\n\n \/**\n * GET \/explorer\/chunks\n * Liste aller Chunks mit Filtern\n *\/\n public function chunks(): void\n {\n $category = $_GET['category'] ?? '';\n $status = $_GET['status'] ?? '';\n $search = $_GET['s... [TRUNCATED-3de89823d770433b]",
"structuredPatch": [
{
"oldStart": 330,
"oldLines": 10,
"newStart": 330,
"newLines": 15,
"lines": [
" $countStmt->execute($params);",
" $totalCount = $countStmt->fetchColumn();",
" ",
"- $sql .= ' ORDER BY c.created_at DESC LIMIT ' . $limit . ' OFFSET ' . $offset;",
"+ $sql .= ' ORDER BY c.created_at DESC LIMIT :limit OFFSET :offset';",
" ",
" $stmt = $this->db->prepare($sql);",
"- $stmt->execute($params);",
"+ foreach ($params as $key => $value) {",
"+ $stmt->bindValue(':' . $key, $value);",
"+ }",
"+ $stmt->bindValue(':limit', $limit, \\PDO::PARAM_INT);",
"+ $stmt->bindValue(':offset', $offset, \\PDO::PARAM_INT);",
"+ $stmt->execute();",
" $chunks = $stmt->fetchAll();",
" ",
" \/\/ Kategorien für Filter"
]
}
],
"userModified": false,
"replaceAll": false
}
}