2026-06-11 22:20:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Visitenkarte für eine Person. Props:
|
|
|
|
|
* $person array{department, name, phone?, email?, image?}
|
2026-06-11 22:24:45 +02:00
|
|
|
* Ohne image rendert die Karte einen geschlechtsneutralen Initialen-Avatar
|
|
|
|
|
* (Coolvetica-Initialen + Logo-Wasserzeichen) — keinen Foto-Platzhalter.
|
2026-06-11 22:20:14 +02:00
|
|
|
* Kontakt-Link: phone → tel:, sonst email → mailto:.
|
|
|
|
|
*/
|
|
|
|
|
$image = $person['image'] ?? null;
|
2026-06-11 22:24:45 +02:00
|
|
|
|
|
|
|
|
$initials = implode('', array_map(
|
|
|
|
|
static fn (string $word): string => mb_substr($word, 0, 1),
|
|
|
|
|
array_slice(preg_split('/\s+/', trim($person['name'])) ?: [], 0, 2)
|
|
|
|
|
));
|
2026-06-11 22:20:14 +02:00
|
|
|
|
|
|
|
|
if (!empty($person['phone'])) {
|
|
|
|
|
$contactHref = 'tel:' . preg_replace('/[^+\d]/', '', $person['phone']);
|
|
|
|
|
$contactLabel = $person['phone'];
|
|
|
|
|
$contactIcon = 'telephone';
|
|
|
|
|
} elseif (!empty($person['email'])) {
|
|
|
|
|
$contactHref = 'mailto:' . $person['email'];
|
|
|
|
|
$contactLabel = $person['email'];
|
|
|
|
|
$contactIcon = 'envelope';
|
|
|
|
|
} else {
|
|
|
|
|
$contactHref = null;
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<article class="person-card">
|
|
|
|
|
<div class="person-card__media">
|
2026-06-11 22:24:45 +02:00
|
|
|
<?php if ($image): ?>
|
|
|
|
|
<img src="<?= e(asset($image)) ?>"
|
|
|
|
|
alt="<?= e($person['name']) ?>"
|
2026-06-11 22:20:14 +02:00
|
|
|
width="480" height="600" loading="lazy" decoding="async">
|
2026-06-11 22:24:45 +02:00
|
|
|
<?php else: ?>
|
|
|
|
|
<div class="person-card__initials" aria-hidden="true">
|
|
|
|
|
<span><?= e($initials) ?></span>
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif; ?>
|
2026-06-11 22:20:14 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="person-card__body">
|
|
|
|
|
<h3 class="person-card__department"><?= e($person['department']) ?></h3>
|
|
|
|
|
<p class="person-card__name"><?= e($person['name']) ?></p>
|
|
|
|
|
<?php if ($contactHref !== null): ?>
|
|
|
|
|
<a class="person-card__contact" href="<?= e($contactHref) ?>">
|
|
|
|
|
<?= icon($contactIcon) ?><span><?= e($contactLabel) ?></span>
|
|
|
|
|
</a>
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
</div>
|
|
|
|
|
</article>
|