edit.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 1

Code

<?php

declare(strict_types=1);

// @responsibility: View für Stopword bearbeiten mit HTMX-Formular

ob_start();
?>

<nav class="breadcrumb">
    <a href="/">Campus KI</a> &raquo;
    <a href="/semantic-explorer">Semantic Explorer</a> &raquo;
    <a href="/semantic-explorer/stopwords">Stopwords</a> &raquo; <?= htmlspecialchars($stopword['word']) ?>
</nav>

<h1>Stopword: <?= htmlspecialchars($stopword['word']) ?></h1>

<form id="stopword-form" class="form" style="max-width: 600px;"
      hx-post="/semantic-explorer/stopwords/<?= $stopword['id'] ?>"
      hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
      hx-disabled-elt="button[type=submit]">
    <div class="form-group">
        <label for="word">Wort *</label>
        <input type="text" id="word" name="word" class="form-input" required value="<?= htmlspecialchars($stopword['word']) ?>">
    </div>

    <div class="form-group">
        <label for="category">Kategorie</label>
        <select id="category" name="category" class="form-select">
            <option value="generic" <?= $stopword['category'] === 'generic' ? 'selected' : '' ?>>Generisch - Immer ausschliessen</option>
            <option value="domain_specific" <?= $stopword['category'] === 'domain_specific' ? 'selected' : '' ?>>Domain-spezifisch</option>
            <option value="context_dependent" <?= $stopword['category'] === 'context_dependent' ? 'selected' : '' ?>>Kontextabhaengig</option>
        </select>
    </div>

    <div class="form-group">
        <label for="reason">Begruendung</label>
        <input type="text" id="reason" name="reason" class="form-input" value="<?= htmlspecialchars($stopword['reason'] ?? '') ?>">
    </div>

    <div class="form-group">
        <label class="checkbox-inline">
            <input type="checkbox" name="is_active" value="1" <?= $stopword['is_active'] ? 'checked' : '' ?>>
            Aktiv
        </label>
    </div>

    <div class="form-info">
        <p><strong>Canonical Form:</strong> <code><?= htmlspecialchars($stopword['canonical_form']) ?></code></p>
        <p><strong>Erstellt:</strong> <?= htmlspecialchars($stopword['created_at']) ?></p>
        <p><strong>Aktualisiert:</strong> <?= htmlspecialchars($stopword['updated_at']) ?></p>
    </div>

    <div class="form-actions">
        <button type="submit" class="btn btn--primary">Speichern</button>
        <a href="/semantic-explorer/stopwords" class="btn">Abbrechen</a>
        <button type="button"
                class="btn btn--danger"
                style="margin-left: auto;"
                hx-post="/semantic-explorer/stopwords/<?= $stopword['id'] ?>/delete"
                hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
                hx-confirm="Stopword wirklich loeschen?"
                hx-disabled-elt="this">
            Loeschen
        </button>
    </div>
</form>

<?php $content = ob_get_clean(); ?>
<?php require VIEW_PATH . '/layout.php'; ?>
← Übersicht