collections-select.php
- Pfad:
src/View/partials/form/collections-select.php - Namespace: -
- Zeilen: 71 | Größe: 2,453 Bytes
- Geändert: 2025-12-22 08:32:48 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Versionen 2
-
v2
2025-12-21 14:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-21 14:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
/**
* Collections Select Partial
*
* Einheitliches Dropdown für RAG-Collection-Auswahl.
* Verwendet in: Chat, Content Studio
*
* @param array $collections Array von Collection-Daten aus CollectionRepository
* @param array $selected Array von ausgewählten collection_ids
* @param string $name Form-Feldname (default: 'collections[]')
* @param string $variant 'default', 'inline' oder 'checkbox'
* @param bool $multiple Multi-Select (default: true)
* @param bool $required Mindestens eine Auswahl erforderlich
*/
$collections ??= [];
$selected ??= [];
// JSON-String zu Array konvertieren (Abwärtskompatibilität)
if (is_string($selected)) {
$selected = json_decode($selected, true) ?: [];
}
$name ??= 'collections[]';
$variant ??= 'default';
$multiple ??= true;
$required ??= false;
$class = match ($variant) {
'inline' => 'form-select form-select--inline',
'checkbox' => '', // Für Checkbox-Variante
default => 'form-select',
};
?>
<?php if ($variant === 'checkbox'): ?>
<div class="checkbox-group collections-select">
<?php foreach ($collections as $col):
$colId = $col['collection_id'];
$isSelected = in_array($colId, $selected, true);
$points = (int) ($col['points_count'] ?? 0);
?>
<label class="checkbox-label" title="<?= number_format($points) ?> Dokumente">
<input type="checkbox" name="<?= htmlspecialchars($name) ?>"
value="<?= htmlspecialchars($colId) ?>"
<?= $isSelected ? 'checked' : '' ?>>
<?= htmlspecialchars($col['display_name']) ?>
<span class="checkbox-meta">(<?= number_format($points) ?>)</span>
</label>
<?php endforeach; ?>
</div>
<?php else: ?>
<select name="<?= htmlspecialchars($name) ?>"
<?= $multiple ? 'multiple' : '' ?>
class="<?= $class ?> collections-select"
title="Collections für RAG auswählen"
<?= $required ? 'required' : '' ?>>
<?php foreach ($collections as $col):
$colId = $col['collection_id'];
$isSelected = in_array($colId, $selected, true);
$points = (int) ($col['points_count'] ?? 0);
?>
<option value="<?= htmlspecialchars($colId) ?>"
<?= $isSelected ? 'selected' : '' ?>
title="<?= number_format($points) ?> Dokumente">
<?= htmlspecialchars($col['display_name']) ?>
</option>
<?php endforeach; ?>
</select>
<?php endif; ?>