index.php
- Pfad:
src/View/chat/index.php
- Namespace: -
- Zeilen: 188 | Größe: 10,808 Bytes
- Geändert: 2025-12-28 03:01:10 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 98
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 80 (10%)
Issues 2
| Zeile |
Typ |
Beschreibung |
| 74 |
magic_number |
Magic Number gefunden: 24 |
| 74 |
magic_number |
Magic Number gefunden: 24 |
Versionen 58
-
v58
2025-12-28 03:01 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v57
2025-12-28 02:49 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Write-Operation
-
v56
2025-12-28 01:19 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v55
2025-12-27 14:01 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v54
2025-12-27 12:46 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v53
2025-12-27 12:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v52
2025-12-27 12:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v51
2025-12-27 12:43 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v50
2025-12-27 12:43 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v49
2025-12-27 11:25 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v48
2025-12-27 11:07 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v47
2025-12-27 11:07 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v46
2025-12-27 11:07 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v45
2025-12-27 11:05 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v44
2025-12-27 11:04 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v43
2025-12-27 11:03 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v42
2025-12-27 10:58 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v41
2025-12-27 10:55 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v40
2025-12-27 10:28 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v39
2025-12-27 10:28 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v38
2025-12-27 10:27 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v37
2025-12-26 21:09 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v36
2025-12-26 21:03 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v35
2025-12-26 21:01 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v34
2025-12-26 20:55 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v33
2025-12-26 20:48 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v32
2025-12-26 20:36 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v31
2025-12-26 20:36 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v30
2025-12-26 20:34 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v29
2025-12-26 20:30 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v28
2025-12-26 20:30 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v27
2025-12-26 20:18 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Write-Operation
-
v26
2025-12-26 20:06 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v25
2025-12-26 20:06 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v24
2025-12-26 20:06 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v23
2025-12-26 20:05 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v22
2025-12-26 19:54 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Write-Operation
-
v21
2025-12-23 03:36 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v20
2025-12-23 02:39 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v19
2025-12-22 22:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v18
2025-12-22 22:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v17
2025-12-22 22:27 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v16
2025-12-21 16:21 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v15
2025-12-21 14:44 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v14
2025-12-21 14:16 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v13
2025-12-21 04:13 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v12
2025-12-20 19:27 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v11
2025-12-20 19:27 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v10
2025-12-20 19:27 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v9
2025-12-20 19:27 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v8
2025-12-20 19:16 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v7
2025-12-20 19:16 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v6
2025-12-20 19:04 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v5
2025-12-20 19:00 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v4
2025-12-20 18:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v3
2025-12-20 18:49 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v2
2025-12-20 18:33 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v1
2025-12-20 18:32 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
/**
* Chat - Redesign
* Clean, minimalist, professional
*/
$currentModel = $session['model'] ?? $defaultModel ?? 'claude-opus-4-5-20251101';
$selected = json_decode($session['collections'] ?? '["documents"]', true) ?: ['documents'];
$currentLimit = (int) ($session['context_limit'] ?? 5);
$currentProfileId = (int) ($session['author_profile_id'] ?? 0);
$currentPromptId = (int) ($session['system_prompt_id'] ?? 1);
$currentTemperature = (float) ($session['temperature'] ?? 0.5);
$currentMaxTokens = (int) ($session['max_tokens'] ?? 4096);
?>
<!DOCTYPE html>
<html lang="de" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($session['title'] ?? 'KI-Chat') ?> - Campus</title>
<link rel="icon" type="image/png" href="https://campus-am-see.de/wp-content/uploads/menu-logo.png">
<link rel="stylesheet" href="/css/chat-redesign.css">
<script src="/js/htmx.min.js"></script>
</head>
<body>
<div class="chat-layout">
<!-- Sidebar -->
<aside class="chat-sidebar" id="sidebar">
<div class="chat-sidebar__header">
<a href="/chat" class="chat-sidebar__new">+ Neuer Chat</a>
<button class="chat-sidebar__delete-all" hx-delete="/chat" hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}' hx-confirm="Alle <?= count($sessions ?? []) ?> Chats löschen?" title="Alle löschen">× Alle</button>
</div>
<div class="chat-sidebar__list" id="session-list">
<?php foreach ($sessions ?? [] as $s):
$totalTokens = (int) ($s['total_input_tokens'] ?? 0) + (int) ($s['total_output_tokens'] ?? 0);
$totalCost = ((int) ($s['total_input_tokens'] ?? 0) * 0.000015) + ((int) ($s['total_output_tokens'] ?? 0) * 0.000075);
$isOllama = str_starts_with($s['model'] ?? '', 'ollama:');
$createdAt = $s['created_at'] ?? null;
$dateStr = $createdAt ? (new DateTime($createdAt))->format('d.m. H:i') : '';
?>
<a href="/chat/<?= $s['uuid'] ?>"
class="chat-session <?= ($session['uuid'] ?? '') === $s['uuid'] ? 'chat-session--active' : '' ?>"
data-uuid="<?= $s['uuid'] ?>">
<div class="chat-session__title" id="title-<?= $s['uuid'] ?>"><?= htmlspecialchars($s['title'] ?? 'Neuer Chat') ?></div>
<div class="chat-session__meta">
<span class="chat-session__date"><?= $dateStr ?></span>
<span><?= $s['message_count'] ?? 0 ?> Nachr.</span>
<?php if (!$isOllama && $totalTokens > 0): ?>
<span class="chat-session__cost">~$<?= number_format($totalCost, 2) ?></span>
<?php elseif ($isOllama): ?>
<span class="chat-session__local">lokal</span>
<?php endif; ?>
</div>
<div class="chat-session__actions">
<button class="chat-session__edit" onclick="event.preventDefault(); event.stopPropagation(); editTitle('<?= $s['uuid'] ?>');" title="Bearbeiten">✎</button>
<button class="chat-session__delete" hx-delete="/chat/<?= $s['uuid'] ?>" hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}' hx-confirm="Session löschen?" onclick="event.preventDefault(); event.stopPropagation();">×</button>
</div>
</a>
<?php endforeach; ?>
<?php if (empty($sessions)): ?>
<div class="chat-session chat-session--empty">Keine Sessions</div>
<?php endif; ?>
</div>
</aside>
<?php include __DIR__ . '/partials/_config_panel.php'; ?>
<div class="chat-overlay" id="overlay"></div>
<!-- Main -->
<main class="chat-main">
<!-- Header -->
<header class="chat-header">
<button class="chat-toggle" id="toggle" title="Sidebar">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 12h18M3 6h18M3 18h18"/></svg>
</button>
<a href="/" class="chat-header__logo" title="Zur Startseite">
<img src="https://campus-am-see.de/wp-content/uploads/menu-logo.png" alt="Campus">
</a>
<div class="chat-header__title">
<h1 id="page-title"><?= htmlspecialchars($session['title'] ?? 'KI-Chat') ?></h1>
</div>
</header>
<!-- Messages -->
<div class="chat-messages" id="messages">
<div class="chat-messages__inner">
<?php if (empty($messages)): ?>
<div class="chat-welcome">
<img src="https://campus-am-see.de/wp-content/uploads/menu-logo.png" alt="Campus am See" class="chat-welcome__logo">
<h2 class="chat-welcome__title">Campus am See KI</h2>
<p class="chat-welcome__subtitle">Wie kann ich dir helfen?</p>
</div>
<?php endif; ?>
<?php foreach ($messages ?? [] as $msg): ?>
<div class="chat-msg chat-msg--<?= $msg['role'] ?>">
<div class="chat-msg__content">
<?php if ($msg['role'] === 'user'): ?>
<?= htmlspecialchars($msg['content']) ?>
<?php else: ?>
<?= nl2br(htmlspecialchars($msg['content'])) ?>
<?php if (!empty($msg['sources'])): ?>
<?php $sources = json_decode($msg['sources'], true) ?: []; ?>
<?php if (!empty($sources)): ?>
<div class="chat-sources" id="sources-<?= $msg['id'] ?>">
<button type="button" class="chat-sources__toggle" onclick="this.parentElement.classList.toggle('chat-sources--open')">
<?= count($sources) ?> Quelle<?= count($sources) > 1 ? 'n' : '' ?> ▾
</button>
<div class="chat-sources__list">
<?php foreach ($sources as $source): ?>
<div class="chat-source">
<div class="chat-source__header">
<?php if (!empty($source['collection'])): ?>
<span class="chat-source__collection">[<?= htmlspecialchars($source['collection']) ?>]</span>
<?php endif; ?>
<span class="chat-source__title"><?= htmlspecialchars($source['title'] ?? 'Unbekannt') ?></span>
<span class="chat-source__score"><?= round(($source['score'] ?? 0) * \Domain\Constants::PERCENT_FULL) ?>%</span>
</div>
<?php if (!empty($source['content'])): ?>
<div class="chat-source__content">"<?= htmlspecialchars(mb_substr($source['content'], 0, 200)) ?><?= mb_strlen($source['content']) > 200 ? '...' : '' ?>"</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php
$inputTokens = (int) ($msg['tokens_input'] ?? 0);
$outputTokens = (int) ($msg['tokens_output'] ?? 0);
$msgCost = ($inputTokens * 0.000015) + ($outputTokens * 0.000075);
$msgModel = $msg['model'] ?? 'claude-opus-4-5-20251101';
$msgIsOllama = str_starts_with($msgModel, 'ollama:');
?>
<div class="chat-msg__meta">
<span><?= $msgIsOllama ? substr($msgModel, 7) : $msgModel ?></span>
<?php if (!$msgIsOllama && ($inputTokens > 0 || $outputTokens > 0)): ?>
<span class="chat-msg__tokens">↓<?= number_format($inputTokens) ?> ↑<?= number_format($outputTokens) ?></span>
<span class="chat-msg__cost">~$<?= number_format($msgCost, 4) ?></span>
<?php elseif ($msgIsOllama): ?>
<span class="chat-msg__local">lokal</span>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<!-- Input Area -->
<div class="chat-input-area">
<div class="chat-input-wrapper">
<form class="chat-form" id="chatForm">
<!-- Hidden inputs (synced from Config Panel) -->
<input type="hidden" name="model" id="hiddenModel" value="<?= $currentModel ?>">
<input type="hidden" name="context_limit" id="hiddenContextLimit" value="<?= $currentLimit ?>">
<input type="hidden" name="temperature" id="hiddenTemperature" value="<?= $currentTemperature ?>">
<input type="hidden" name="max_tokens" id="hiddenMaxTokens" value="<?= $currentMaxTokens ?>">
<input type="hidden" name="author_profile_id" id="hiddenAuthorProfile" value="<?= $currentProfileId ?>">
<input type="hidden" name="system_prompt_id" id="hiddenSystemPrompt" value="<?= $currentPromptId ?>">
<input type="hidden" name="structure_id" id="hiddenStructure" value="0">
<div id="hiddenCollections"></div>
<div class="chat-input-row">
<input type="text" name="message" class="chat-input" placeholder="Nachricht eingeben..." autocomplete="off" required>
<button type="submit" class="chat-send" id="sendBtn">
<span class="chat-send__text">Senden</span>
<span class="chat-send__loading"><span></span><span></span><span></span></span>
</button>
</div>
</form>
</div>
</div>
</main>
</div>
<script src="/js/chat.js"></script>
<script>
initChatForm('<?= $session['uuid'] ?? '' ?>', '<?= $csrfToken ?>');
initConfigEditors('<?= $csrfToken ?>');
</script>
</body>
</html>