feat: student name popover preview on /repertoire via htmx

This commit is contained in:
Pontoporeia
2026-04-24 13:13:26 +02:00
parent ede53746ba
commit 53c3127140
6 changed files with 127 additions and 69 deletions

View File

@@ -1,28 +1,42 @@
<?php
/**
* Partial: student popover preview.
* Partial: student popover preview card(s).
*
* Expected variables:
* $theses array rows of [id => int, title => string]
* $theses array rows from Database::getThesesByAuthorName()
* $name string student name
*/
foreach ($theses as $t):
$synopsis = $t['synopsis'] ?? '';
// Truncate synopsis to ~160 chars
if (mb_strlen($synopsis) > 160) {
$synopsis = mb_substr($synopsis, 0, 157) . '…';
}
$meta = array_filter([
$t['year'] ?? null,
$t['orientation'] ?? null,
$t['finality_type'] ?? null,
]);
?>
<?php if (count($theses) === 1): ?>
<iframe
src="/tfe?id=<?= (int)$theses[0]['id'] ?>"
class="student-preview__iframe"
loading="lazy"
title="Aperçu — <?= htmlspecialchars($name) ?>"
></iframe>
<?php else: ?>
<p class="student-preview__name"><?= htmlspecialchars($name) ?></p>
<ul class="student-preview__list">
<?php foreach ($theses as $t): ?>
<li>
<a href="/tfe?id=<?= (int)$t['id'] ?>" class="student-preview__link">
<?= htmlspecialchars($t['title']) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<a href="/tfe?id=<?= (int)$t['id'] ?>" class="student-card">
<?php if (!empty($t['banner_path'])): ?>
<div class="student-card__banner" style="background-image:url('<?= htmlspecialchars($t['banner_path']) ?>')"></div>
<?php else: ?>
<div class="student-card__banner student-card__banner--gradient">
<span class="student-card__gradient-author"><?= htmlspecialchars($t['authors'] ?? '') ?></span>
<span class="student-card__gradient-title"><?= htmlspecialchars($t['title']) ?></span>
</div>
<?php endif; ?>
<div class="student-card__body">
<p class="student-card__meta"><?= htmlspecialchars(implode(' · ', $meta)) ?></p>
<h3 class="student-card__title"><?= htmlspecialchars($t['title']) ?></h3>
<?php if (!empty($t['subtitle'])): ?>
<p class="student-card__subtitle"><?= htmlspecialchars($t['subtitle']) ?></p>
<?php endif; ?>
<?php if ($synopsis !== ''): ?>
<p class="student-card__synopsis"><?= htmlspecialchars($synopsis) ?></p>
<?php endif; ?>
</div>
</a>
<?php endforeach; ?>