feat: vários ginásios (/3070/ e /<código postal>/), CRUD de ginásios, modalidades após a galeria
Estrutura multi-ginásio: as mesmas secções do site, conteúdo próprio por ginásio, e cada um numa pasta da URL com o código postal da zona. - migration_20260926_gyms: tabela gyms (pasta, nome, localidade, publicado, principal, secções visíveis, título/imagem do header, SEO, galeria, Place ID, página CrossFit) com o FitMe 3070 como ginásio 1 em /3070/; gym_id em team, modalidades (o horário segue a modalidade), work_hours, memberships, membership_leads e website_offer (tudo o existente → ginásio 1); events com gym_id NULL = todos; fitme3070_info passa a uma linha por ginásio (id = gym). - Site: /<pasta>/, /<pasta>/crossfit, /<pasta>/agendar|inscricao. Ginásio por publicar → 404 para o público, pré-visualização (com faixa) para a equipa. / e /home → 301 para o ginásio principal (a manter a query); com mais de um ginásio publicado, a raiz passa a uma página para escolher. Secções desligadas não aparecem nem no menu; menu, canonical, JSON-LD, sitemap, formulários, e-mails e reviews (Place ID e cache) são do ginásio. - Backoffice: Gestão → Ginásios (criar/editar/apagar, secções, e «começar com o conteúdo de» outro ginásio — cópias independentes) e o seletor «A editar» no topo; equipa, modalidades, horários, horário de funcionamento, mensalidades, pedidos, contactos e reviews trabalham sobre o ginásio escolhido, e um registo de outro ginásio não abre. - Modalidades passam para logo a seguir à galeria das instalações. - Galeria sem cantos arredondados (raio da marca). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f8f68c61a
commit
5e300fc341
33 files changed
+1146
-197
No files matched your search
@@ -27,10 +27,26 @@
|
||||
|
||||
const REVIEWS_FIELD_MASK = 'displayName,rating,userRatingCount,googleMapsUri,reviews';
|
||||
|
||||
// Multi-gym: the API key and display options are shared; the Place ID (and so
|
||||
// the cache) belongs to a gym (gyms.google_place_id). Which gym is taken from
|
||||
// reviews_gym(): the gym the public page renders, or — on the backoffice
|
||||
// Reviews page — the gym being edited (set with reviews_use_gym()).
|
||||
function reviews_use_gym(array $gym): void {
|
||||
$GLOBALS['_reviews_gym'] = $gym;
|
||||
}
|
||||
|
||||
function reviews_gym(): array {
|
||||
return $GLOBALS['_reviews_gym'] ?? current_gym();
|
||||
}
|
||||
|
||||
function reviews_config(): array {
|
||||
$gym = reviews_gym();
|
||||
$place = trim((string) ($gym['google_place_id'] ?? ''));
|
||||
// Pre-multi-gym installs kept the Place ID in settings (gym 1 only).
|
||||
if ($place === '' && (int) ($gym['id'] ?? 1) === 1) $place = trim((string) setting('google_place_id', ''));
|
||||
return [
|
||||
'api_key' => setting_secret('google_places_api_key', 'GOOGLE_PLACES_API_KEY'),
|
||||
'place_id' => trim((string) setting('google_place_id', '')),
|
||||
'place_id' => $place,
|
||||
'min_rating' => max(1, min(5, (int) setting('google_reviews_min_rating', 4))),
|
||||
'max' => max(1, min(5, (int) setting('google_reviews_max', 3))),
|
||||
'cache_hours' => max(1, (int) setting('google_reviews_cache_hours', 24)),
|
||||
@@ -50,7 +66,7 @@ function reviews_configured(): bool {
|
||||
}
|
||||
|
||||
function _reviews_cache_path(): string {
|
||||
return __DIR__ . '/cache/google_reviews.cache.php';
|
||||
return __DIR__ . '/cache/google_reviews_' . (int) (reviews_gym()['id'] ?? 1) . '.cache.php';
|
||||
}
|
||||
|
||||
function reviews_cache_read(): ?array {
|
||||
@@ -170,7 +186,8 @@ function reviews_get(): array {
|
||||
|
||||
// What the homepage renders: summary + the best qualifying reviews, or null
|
||||
// when there is nothing worth showing (not configured, no qualifying review).
|
||||
function site_reviews(): ?array {
|
||||
function site_reviews(?array $gym = null): ?array {
|
||||
if ($gym !== null) reviews_use_gym($gym);
|
||||
try { $data = reviews_get(); } catch (Throwable $e) { error_log('[reviews] ' . $e->getMessage()); return null; }
|
||||
if (!$data || empty($data['reviews'])) return null;
|
||||
$c = reviews_config();
|
||||
|
||||
Reference in new issue
Block a user