or platform_render_footer(['use_i18n' => false]); */ function platform_footer_h(mixed $value): string { return htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } /** @return array */ function platform_footer_config(): array { static $loaded = null; if ($loaded !== null) { return $loaded; } $path = __DIR__ . '/footer.config.php'; if (!is_file($path)) { $path = __DIR__ . '/footer.config.example.php'; } $loaded = require $path; return is_array($loaded) ? $loaded : []; } function platform_footer_year(array $cfg): int { if (array_key_exists('year', $cfg) && $cfg['year'] !== null) { return (int) $cfg['year']; } return (int) date('Y'); } function platform_footer_plain_text(array $cfg, int $year): string { $symbol = trim((string) ($cfg['copyright_symbol'] ?? '(c)')); $holder = trim((string) ($cfg['holder'] ?? '')); $showYear = (bool) ($cfg['show_year'] ?? true); $parts = []; if ($symbol !== '') { $parts[] = $symbol; } if ($holder !== '') { $parts[] = $holder; } $line = implode(' ', $parts); if ($showYear && $line !== '') { return $line . ', ' . $year; } if ($showYear && $line === '') { return (string) $year; } return $line; } /** * @param array{use_i18n?: bool, extra_class?: string} $opts */ function platform_render_footer(array $opts = []): void { $cfg = platform_footer_config(); $year = platform_footer_year($cfg); $text = platform_footer_plain_text($cfg, $year); $class = (string) ($opts['extra_class'] ?? ($cfg['footer_class'] ?? 'bottom-bar')); $useI18n = $opts['use_i18n'] ?? (bool) ($cfg['use_i18n'] ?? true); $i18nKey = (string) ($cfg['i18n_key'] ?? 'footer.copyright'); if ($useI18n && $i18nKey !== '') { echo ''; return; } echo ''; }