search-results.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 1

Code

<?php

declare(strict_types=1);

// @responsibility: HTMX-Partial für semantische Suchergebnisse

?>
<?php if ($query !== '' && !empty($results)): ?>
<h2>Ergebnisse fuer "<?= htmlspecialchars($query) ?>"</h2>
<p class="text-muted"><?= count($results) ?> Treffer gefunden.</p>

<table data-sortable>
    <thead>
        <tr>
            <th data-sort="rank">#</th>
            <th data-sort="score">Score</th>
            <th data-sort="filename">Dokument</th>
            <th data-sort="tokens">Tokens</th>
            <th data-sort="content">Inhalt</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($results as $i => $r): ?>
        <tr>
            <td><?= $i + 1 ?></td>
            <td><span class="badge badge--success"><?= number_format($r['score'] * \Domain\Constants::PERCENT_FULL, 1) ?>%</span></td>
            <td>
                <a href="/semantic-explorer/chunks/<?= $r['id'] ?>">#<?= $r['id'] ?></a>
                <br><small><a href="/semantic-explorer/dokumente/<?= $r['document_id'] ?>"><?= htmlspecialchars($r['filename']) ?></a></small>
            </td>
            <td><?= $r['token_count'] ?></td>
            <td><?= htmlspecialchars(substr($r['content'], 0, 150)) ?>...</td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php elseif ($query !== ''): ?>
<div class="empty-state empty-state--small">
    <p>Keine Ergebnisse fuer "<?= htmlspecialchars($query) ?>" gefunden.</p>
    <p class="text-muted">Stellen Sie sicher, dass Dokumente mit Embeddings vorliegen.</p>
</div>
<?php endif; ?>
← Übersicht