edit.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 1

Code

<?php

declare(strict_types=1);

// @responsibility: View für Ontologie-Klasse 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/ontologie">Ontologie</a> &raquo; <?= htmlspecialchars($class['name']) ?> &raquo; Bearbeiten
</nav>

<h1>Ontologie-Klasse bearbeiten</h1>

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

    <div class="form-group">
        <label for="parent_class_id">Uebergeordnete Klasse</label>
        <select id="parent_class_id" name="parent_class_id" class="form-select">
            <option value="">-- Keine (Root-Klasse) --</option>
            <?php foreach ($classes as $c): ?>
            <?php if ($c['id'] !== $class['id']): ?>
            <option value="<?= $c['id'] ?>"
                <?= ($class['parent_class_id'] ?? '') == $c['id'] ? 'selected' : '' ?>><?= htmlspecialchars($c['name']) ?></option>
            <?php endif; ?>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="form-group">
        <label for="description">Beschreibung</label>
        <textarea id="description" name="description" class="form-textarea" rows="3"><?= htmlspecialchars($class['description'] ?? '') ?></textarea>
    </div>

    <div class="form-group">
        <label for="properties">Properties (JSON)</label>
        <textarea id="properties" name="properties" class="form-textarea" rows="4"><?= htmlspecialchars($class['properties'] ?? '{}') ?></textarea>
        <small>z.B. {"color": "string", "count": "integer"}</small>
    </div>

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

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