Files
xamxam/app/templates/partials/student-preview.php

43 lines
1.6 KiB
PHP

<?php
/**
* Partial: student popover preview card(s).
*
* Expected variables:
* $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,
]);
?>
<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; ?>