feat(brand): adopt platform-tools Brand feed; logo path convention in emails

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andreandClaude Sonnet 5.5 committed 2026-10-09 15:37:31 +01:00
1 parent f2a9c5181b
commit 79a0047f29
5 files changed
+50 -3

No files matched your search

+9
View File
@@ -117,6 +117,15 @@ platform_connect($pdo, [
],
'remember' => true, // «Manter sessão iniciada» — agora auth_remember_*
// do platform-tools; ver views/auth/login.php.
// Brand feed público (api/brand.php): nome, logos e cores para o hub.
// Cores = tokens :root de site/assets/css/style.css. logo_light = logo de
// cor clara (fundos escuros), logo_dark = logo escuro (fundos claros).
// name: omitido de propósito (APP_NAME ainda não existe aqui; o default é hub_app_name()).
'brand' => [
'logo_light' => fn() => site_logo_rel('logo_light_filename', 'site/assets/img/logos/logo_crossfit_white.svg'),
'logo_dark' => fn() => site_logo_rel('logo_dark_filename', 'site/assets/img/logos/logo_crossfit.svg'),
'colors' => ['primary' => '#c2d500', 'secondary' => '#0b0b0d', 'accent' => '#a6b600'],
],
'guard' => 'require_sysadmin',
'router' => true,
'conformance' => 'report', // nunca recusa — só reporta no health endpoint
+21 -3
View File
@@ -122,6 +122,24 @@ function csv_export(string $type, string $filename, string $summary, array $head
exit;
}
// ─── Logo path (platform convention + static fallback) ───────────────────────
// Setting <key> holds a file name. Convention: uploads/public/logo/<file>; the
// settings page still stores uploads in assets/img/logo/ (legacy), so that is
// accepted too. Empty setting / missing file -> $fallback (site-relative, no
// leading slash), or '' when that file is missing as well.
function site_logo_rel(string $settingKey, string $fallback): string {
$file = basename((string) setting($settingKey, ''));
$root = dirname(__DIR__) . '/';
if ($file !== '') {
foreach (['uploads/public/logo/', 'assets/img/logo/'] as $dir) {
if (is_file($root . $dir . $file)) {
return $dir . rawurlencode($file);
}
}
}
return is_file($root . $fallback) ? $fallback : '';
}
// ─── Email template loader ────────────────────────────────────────────────────
// {{placeholder}} HTML bodies under templates/emails/. Built locally, delivered
// by id.andmore.pt via the enqueue_email()/flush_message() façade.
@@ -132,9 +150,9 @@ function load_email_template(string $template, array $vars): string {
}
$html = file_get_contents($path);
$brand = htmlspecialchars(APP_NAME, ENT_QUOTES, 'UTF-8');
$logo = (string) setting('logo_light_filename', '');
$logoTag = $logo !== ''
? '<img src="' . htmlspecialchars(base_url('assets/img/logo/' . rawurlencode($logo)), ENT_QUOTES, 'UTF-8')
$rel = site_logo_rel('logo_light_filename', 'site/assets/img/logos/logo_crossfit_white.svg');
$logoTag = $rel !== ''
? '<img src="' . htmlspecialchars(base_url($rel), ENT_QUOTES, 'UTF-8')
. '" alt="' . $brand . '" style="max-height:60px;border:0;">'
: '<p style="margin:0;color:#fff;font-size:22px;font-weight:bold;letter-spacing:1px;">' . $brand . '</p>';
$html = str_replace('{{logo_html}}', $logoTag, $html);