Backup #450
| ID | 450 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Controller/PromptsController.php |
| Version | 2 |
| Typ |
modified |
| Größe | 4.6 KB |
| Hash | 5a809a9b51f76735422247686b23b20888634ace2aa403668402ac9dfa9fc1aa |
| Datum | 2025-12-22 10:24:46 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace Controller;
use Framework\Controller;
use Infrastructure\Persistence\PromptsRepository;
class PromptsController extends Controller
{
private PromptsRepository $promptsRepo;
private const PROMPT_TYPES = [
'critic' => 'Critic-Prompt',
'generate' => 'Generierungs-Prompt',
'revise' => 'Revisions-Prompt',
'system' => 'System-Prompt',
'other' => 'Sonstiges',
];
public function __construct(?PromptsRepository $promptsRepo = null)
{
$this->promptsRepo = $promptsRepo ?? new PromptsRepository();
}
public function index(): void
{
$this->view('prompts.index', [
'title' => 'Prompts verwalten',
'prompts' => $this->promptsRepo->findAll(),
'stats' => $this->promptsRepo->getStatistics(),
'promptTypes' => self::PROMPT_TYPES,
]);
}
public function promptsNew(): void
{
$this->view('prompts.form', [
'title' => 'Neuer Prompt',
'prompt' => null,
'promptTypes' => self::PROMPT_TYPES,
'isEdit' => false,
]);
}
public function store(): void
{
$this->requireCsrf();
$name = trim($_POST['name'] ?? '');
$version = trim($_POST['version'] ?? '1.0');
$content = $_POST['content'] ?? '';
$isActive = isset($_POST['is_active']) ? 1 : 0;
if ($name === '' || $content === '') {
$_SESSION['error'] = 'Name und Inhalt sind erforderlich.';
header('Location: /prompts/new');
exit;
}
$id = $this->promptsRepo->create($name, $version, $content, $isActive);
$_SESSION['success'] = 'Prompt erfolgreich erstellt.';
header('Location: /prompts/' . $id);
exit;
}
public function show(string $id): void
{
$prompt = $this->promptsRepo->findById((int) $id);
if ($prompt === null) {
$this->notFound('Prompt nicht gefunden');
}
$this->view('prompts.show', [
'title' => $prompt['name'],
'prompt' => $prompt,
'linkedCritics' => $this->promptsRepo->findLinkedCritics((int) $id),
'promptTypes' => self::PROMPT_TYPES,
]);
}
public function edit(string $id): void
{
$prompt = $this->promptsRepo->findById((int) $id);
if ($prompt === null) {
$this->notFound('Prompt nicht gefunden');
}
$this->view('prompts.form', [
'title' => 'Bearbeiten: ' . $prompt['name'],
'prompt' => $prompt,
'promptTypes' => self::PROMPT_TYPES,
'isEdit' => true,
]);
}
public function update(string $id): void
{
$this->requireCsrf();
$prompt = $this->promptsRepo->findById((int) $id);
if ($prompt === null) {
$this->notFound('Prompt nicht gefunden');
}
$name = trim($_POST['name'] ?? '');
$version = trim($_POST['version'] ?? $prompt['version']);
$content = $_POST['content'] ?? '';
$isActive = isset($_POST['is_active']) ? 1 : 0;
if ($name === '' || $content === '') {
$_SESSION['error'] = 'Name und Inhalt sind erforderlich.';
header('Location: /prompts/' . $id . '/edit');
exit;
}
$this->promptsRepo->update((int) $id, $name, $version, $content, $isActive);
$_SESSION['success'] = 'Prompt aktualisiert.';
header('Location: /prompts/' . $id);
exit;
}
public function delete(string $id): void
{
$this->requireCsrf();
$prompt = $this->promptsRepo->findById((int) $id);
if ($prompt === null) {
$this->notFound('Prompt nicht gefunden');
}
$criticCount = $this->promptsRepo->countLinkedCritics((int) $id);
if ($criticCount > 0) {
$_SESSION['error'] = "Kann nicht gelöscht werden: {$criticCount} Critics verknüpft.";
header('Location: /prompts/' . $id);
exit;
}
$this->promptsRepo->delete((int) $id);
$_SESSION['success'] = 'Prompt gelöscht.';
header('Location: /prompts');
exit;
}
public function duplicate(string $id): void
{
$this->requireCsrf();
$prompt = $this->promptsRepo->findById((int) $id);
if ($prompt === null) {
$this->notFound('Prompt nicht gefunden');
}
$newName = $prompt['name'] . ' (Kopie)';
$newId = $this->promptsRepo->duplicate((int) $id, $newName, '1.0');
$_SESSION['success'] = 'Prompt dupliziert.';
header('Location: /prompts/' . $newId . '/edit');
exit;
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1752 |
17 |
modified |
5.3 KB |
2025-12-27 12:46 |
| 1749 |
16 |
modified |
4.9 KB |
2025-12-27 12:45 |
| 1670 |
15 |
modified |
4.6 KB |
2025-12-27 11:29 |
| 865 |
14 |
modified |
4.6 KB |
2025-12-23 08:50 |
| 689 |
13 |
modified |
4.5 KB |
2025-12-23 07:52 |
| 507 |
12 |
modified |
4.6 KB |
2025-12-22 15:42 |
| 506 |
11 |
modified |
4.6 KB |
2025-12-22 15:42 |
| 505 |
10 |
modified |
4.7 KB |
2025-12-22 15:42 |
| 486 |
9 |
modified |
4.4 KB |
2025-12-22 15:26 |
| 485 |
8 |
modified |
4.2 KB |
2025-12-22 15:26 |
| 484 |
7 |
modified |
4.1 KB |
2025-12-22 15:26 |
| 462 |
6 |
modified |
4.1 KB |
2025-12-22 10:30 |
| 461 |
5 |
modified |
4.1 KB |
2025-12-22 10:30 |
| 460 |
4 |
modified |
4.1 KB |
2025-12-22 10:30 |
| 451 |
3 |
modified |
4.7 KB |
2025-12-22 10:25 |
| 450 |
2 |
modified |
4.6 KB |
2025-12-22 10:24 |
| 444 |
1 |
modified |
7.0 KB |
2025-12-22 10:16 |
← Zurück zur Übersicht