Globinours/app/Views/public_site_contact.php

49 lines
3.1 KiB
PHP

<?php $lat = is_numeric($settings['association_latitude'] ?? null) ? (float)$settings['association_latitude'] : null;
$lng = is_numeric($settings['association_longitude'] ?? null) ? (float)$settings['association_longitude'] : null;
$obfuscate = static fn (string$value): string => implode('', array_reverse(mb_str_split($value))); ?>
<section class="section">
<div class="wrap">
<div class="content-card">
<h1 class="page-title"><?= h(t('public_site.contact')) ?></h1>
<div><?= PublicContentFormatter::render($settings['public_site_contact_text']) ?></div>
<div class="contact-list"><?php if ($fullAddress !== ''): ?><div class="contact-item">📍
<?= h($fullAddress) ?></div><?php endif; ?><?php if ($settings['association_phone']): ?><div
class="contact-item">☎ <span
class="contact-obfuscated"><?= h($obfuscate($settings['association_phone'])) ?></span></div>
<?php endif; ?><?php if ($settings['association_email']): ?><div class="contact-item">✉ <span
class="contact-obfuscated"><?= h($obfuscate($settings['association_email'])) ?></span></div>
<?php endif; ?></div>
<div class="social-links">
<?php foreach ($socialNetworks as $network => [$label,$icon]):
$url = trim((string)($settings['public_site_' . $network . '_url'] ?? ''));
if ($url === '') continue; ?>
<a class="social-link social-<?= h($network) ?>" href="<?= h($url) ?>" target="_blank" rel="noopener noreferrer"><span class="social-icon" aria-hidden="true"><?= h($icon) ?></span><span><?= h($label) ?></span></a>
<?php endforeach; ?>
</div>
<?php if ($lat !== null && $lng !== null): ?><h2 style="margin-top:35px">
<?= h(t('public_site.map_title')) ?></h2>
<div id="association-map" class="contact-map" aria-label="<?= h(t('public_site.map_title')) ?>"></div>
<?php endif; ?>
</div>
</div>
</section>
<?php if ($lat !== null && $lng !== null): ?><script src="/assets/vendor/leaflet/leaflet.js"></script>
<script>
(() => {
const map = L.map('association-map', {
scrollWheelZoom: false
}).setView([ <?= json_encode($lat) ?> , <?= json_encode($lng) ?> ], 15);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; OpenStreetMap'
}).addTo(map);
const popup = document.createElement('div');
const name = document.createElement('strong');
name.textContent = <?= json_encode($association, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?> ;
popup.append(name, document.createElement('br'), document.createTextNode( <?= json_encode($fullAddress,
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?> ));
L.marker([ <?= json_encode($lat) ?> , <?= json_encode($lng) ?> ]).addTo(map).bindPopup(popup)
.openPopup();
})();
</script><?php endif; ?>