release: promote beta to main (gyms, brand colours, JPEG XL, SEO per gym) #3

Merged
andre merged 74 commits from beta into main 2026-10-26 19:47:48 +00:00
2 changed files with 27 additions and 6 deletions
Showing only changes of commit 49adbd0ae1 - Show all commits

No files matched your search

+25 -4
View File
@@ -29,16 +29,37 @@ function site_info(PDO $pdo, ?int $gym_id = null): array {
return $row; return $row;
} }
/** Whether the home page renders section $sec for $gym (same data checks as site/index.php). */
function site_section_has_content(array $gym, string $sec): bool {
$pdo = $GLOBALS['pdo'] ?? null;
$gid = (int) $gym['id'];
if (!$pdo && $sec !== 'galeria') return true;
return match ($sec) {
'modalidades' => (bool) site_modalidades($pdo, $gid),
'equipa' => (bool) site_team_active($pdo, $gid),
'horario' => (bool) site_horario($pdo, '', $gid),
'mensalidades' => (bool) site_memberships($pdo, $gid),
'galeria' => !empty($gym['gallery_id']) && preg_grep('/\.(jpe?g|png|gif|webp|jxl)$/i',
glob(dirname(__DIR__) . '/uploads/gallery/' . (int) $gym['gallery_id'] . '/*') ?: []),
default => true,
};
}
/** Team members shown on the site (status «ativo»). */
function site_team_active(PDO $pdo, ?int $gym_id = null): array {
return array_values(array_filter(site_team($pdo, $gym_id), fn($d) => ($d['status'] ?? '') === 'ativo'));
}
// Top navigation (label => absolute URL): anchors on the gym's own page, only // Top navigation (label => absolute URL): anchors on the gym's own page, only
// for the sections that gym shows, plus its CrossFit page when it has one. // for the sections that gym shows and has content for, plus its CrossFit page when it has one.
function site_navbar(?array $gym = null): array { function site_navbar(?array $gym = null): array {
$gym = $gym ?? current_gym(); $gym = $gym ?? current_gym();
$items = ['Home' => ['#home', null]]; $items = ['Home' => ['#home', null]];
foreach (['Modalidades' => 'modalidades', 'Equipa' => 'equipa', 'Horário' => 'horario', foreach (['Galeria' => 'galeria', 'Modalidades' => 'modalidades', 'Equipa' => 'equipa', 'Horário' => 'horario',
'Mensalidades' => 'mensalidades', 'Contactos' => 'contactos'] as $label => $sec) { 'Mensalidades' => 'mensalidades', 'Contactos' => 'contactos'] as $label => $sec) {
if (!gym_section_on($gym, $sec)) continue; if (!gym_section_on($gym, $sec)) continue;
// No active plans → the section isn't rendered, so no link to it either. // A section with nothing to show isn't rendered, so no link to it either.
if ($sec === 'mensalidades' && !empty($GLOBALS['pdo']) && !site_memberships($GLOBALS['pdo'], (int) $gym['id'])) continue; if (!site_section_has_content($gym, $sec)) continue;
$items[$label] = ['#' . $sec, $sec]; $items[$label] = ['#' . $sec, $sec];
} }
$nav = []; $nav = [];
+2 -2
View File
@@ -27,7 +27,7 @@ require __DIR__ . '/_open.php'; // resolves $gym (404 if unknown / not visible
$gid = (int) $gym['id']; $gid = (int) $gym['id'];
$on = fn(string $key) => gym_section_on($gym, $key); $on = fn(string $key) => gym_section_on($gym, $key);
$offer = $on('oferta') ? site_offer($pdo, $gid) : []; $offer = $on('oferta') ? site_offer($pdo, $gid) : [];
$team = $on('equipa') ? site_team($pdo, $gid) : []; $team = $on('equipa') ? site_team_active($pdo, $gid) : [];
$modalidades = $on('modalidades') ? site_modalidades($pdo, $gid) : []; $modalidades = $on('modalidades') ? site_modalidades($pdo, $gid) : [];
$horario = $on('horario') ? site_horario($pdo, '', $gid) : []; $horario = $on('horario') ? site_horario($pdo, '', $gid) : [];
$whours = $on('workhours') ? site_work_hours($pdo, $gid) : []; $whours = $on('workhours') ? site_work_hours($pdo, $gid) : [];
@@ -121,7 +121,7 @@ $gallery_files = ($on('galeria') && $gallery_path !== '') ? preg_grep('/\.(jpe?g
if ($gallery_files && count($gallery_files) > 0): if ($gallery_files && count($gallery_files) > 0):
$gallery_h2 = 'Conhece as nossas instalações'; $gallery_h2 = 'Conhece as nossas instalações';
?> ?>
<section id="galeria" class="gallery-section" style="padding:70px 0 0;background:var(--fitme-white)"> <section id="galeria" class="gallery-section" style="padding:70px 0 0;background:color-mix(in srgb, var(--fitme-accent) 7%, #fff)">
<?php include __DIR__ . '/includes/gallery.php'; ?> <?php include __DIR__ . '/includes/gallery.php'; ?>
</section> </section>
<?php endif; ?> <?php endif; ?>