form.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 2

Code

<?php ob_start(); ?>

<h1><?= $pipeline ? 'Pipeline bearbeiten' : 'Neue Pipeline' ?></h1>

<form action="<?= $pipeline ? '/content-pipeline/' . $pipeline['id'] : '/content-pipeline' ?>" method="POST" class="form">
    <input type="hidden" name="_csrf_token" value="<?= htmlspecialchars($csrfToken ?? '') ?>">

    <div class="form-group">
        <label for="name" class="form-label">Name *</label>
        <input type="text" id="name" name="name" class="form-input" required
               value="<?= htmlspecialchars($pipeline['name'] ?? '') ?>"
               placeholder="z.B. Standard, Nur-Embedding, Test">
    </div>

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

    <div class="form-group">
        <label for="source_path" class="form-label">Quell-Pfad</label>
        <input type="text" id="source_path" name="source_path" class="form-input"
               value="<?= htmlspecialchars($pipeline['source_path'] ?? '/var/www/nextcloud/data/root/files/Documents') ?>"
               placeholder="/var/www/nextcloud/data/root/files/Documents">
        <small class="form-hint">Pfad zum Nextcloud-Ordner mit den zu verarbeitenden Dokumenten</small>
    </div>

    <div class="form-group">
        <label for="extensions" class="form-label">Dateitypen</label>
        <input type="text" id="extensions" name="extensions" class="form-input"
               value="<?= htmlspecialchars(implode(', ', $pipeline['extensions'] ?? ['.pdf', '.docx', '.pptx', '.md', '.txt'])) ?>"
               placeholder=".pdf, .docx, .pptx, .md, .txt">
        <small class="form-hint">Komma-getrennte Liste der Dateiendungen (mit oder ohne Punkt)</small>
    </div>

    <div class="form-group">
        <label class="form-checkbox">
            <input type="checkbox" name="is_default" value="1" <?= ($pipeline['is_default'] ?? 0) ? 'checked' : '' ?>>
            <span>Als Standard-Pipeline markieren</span>
        </label>
    </div>

    <div class="form-actions">
        <button type="submit" class="btn btn--primary"><?= $pipeline ? 'Speichern' : 'Erstellen' ?></button>
        <a href="<?= $pipeline ? '/content-pipeline/' . $pipeline['id'] : '/content-pipeline' ?>" class="btn btn--secondary">Abbrechen</a>
    </div>
</form>

<?php if (!$pipeline): ?>
<div class="info-box">
    <h3>Pipeline-Schritte</h3>
    <p>Nach dem Erstellen werden automatisch die Standard-Schritte hinzugefuegt:</p>
    <ol>
        <?php foreach ($stepTypes as $type => $meta): ?>
        <li><strong><?= $meta['label'] ?></strong> - <?= $meta['description'] ?></li>
        <?php endforeach; ?>
    </ol>
    <p>Die Schritte koennen danach einzeln aktiviert/deaktiviert und konfiguriert werden.</p>
</div>
<?php endif; ?>

<p class="links-bar">
    <a href="/content-pipeline">Zurueck zur Uebersicht</a>
</p>

<style>
.info-box {
    background: var(--info-bg, #e7f3ff);
    border: 1px solid var(--info-color, #0066cc);
    border-radius: 6px;
    padding: 1rem;
    margin-top: 2rem;
}
.info-box h3 {
    margin-top: 0;
    color: var(--info-color, #0066cc);
}
</style>

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