1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 06:58:51 +03:00
This commit is contained in:
Anton Afanasyeu
2026-06-20 22:56:48 +02:00
parent 26642f46c6
commit 0d8b06f096
14 changed files with 724 additions and 26 deletions

View File

@@ -20,7 +20,10 @@ return [
'bottom' => null,
// --- Default left column when `left` is null ---
'holder' => '<a href="https://f0xx.org">Anton Afanaasyeu</a>, 2026 - current',
// Use holder_name + holder_url for a safe link (holder HTML is escaped if used alone).
'holder_name' => 'Anton Afanaasyeu',
'holder_url' => 'https://f0xx.org',
'holder' => null,
'copyright_symbol' => "\u{00A9}",
'show_year' => false,
// null = current calendar year at render time (end of range).

View File

@@ -74,13 +74,17 @@ function platform_footer_year_label(array $cfg): string
function platform_footer_default_left(array $cfg): string
{
$symbol = trim((string) ($cfg['copyright_symbol'] ?? "\u{00A9}"));
$holderName = trim((string) ($cfg['holder_name'] ?? ''));
$holderUrl = trim((string) ($cfg['holder_url'] ?? ''));
$holder = trim((string) ($cfg['holder'] ?? ''));
$showYear = (bool) ($cfg['show_year'] ?? true);
$parts = [];
if ($symbol !== '') {
$parts[] = $symbol;
}
if ($holder !== '') {
if ($holderName !== '') {
$parts[] = $holderName;
} elseif ($holder !== '') {
$parts[] = $holder;
}
$line = implode(' ', $parts);
@@ -95,6 +99,41 @@ function platform_footer_default_left(array $cfg): string
return $line . ', ' . $yearLabel;
}
/** Render left footer HTML (holder link when configured). */
function platform_footer_render_left_html(array $cfg, array $opts): ?string
{
$raw = platform_footer_resolve_left($cfg, $opts);
if ($raw === null) {
return null;
}
$holderName = trim((string) ($cfg['holder_name'] ?? ''));
$holderUrl = trim((string) ($cfg['holder_url'] ?? ''));
if (platform_footer_field($cfg, $opts, 'left') === null
&& $holderName !== '' && $holderUrl !== '') {
$text = platform_footer_h($raw);
$name = platform_footer_h($holderName);
$link = '<a href="' . platform_footer_h($holderUrl) . '">' . $name . '</a>';
if (str_contains($text, $name)) {
return substr_replace($text, $link, strpos($text, $name), strlen($name));
}
return $link . ($text !== '' ? ' ' . $text : '');
}
return platform_footer_h($raw);
}
/** True when default left uses holder_name + holder_url (skip i18n text replacement). */
function platform_footer_left_has_link(array $cfg, array $opts): bool
{
if (platform_footer_field($cfg, $opts, 'left') !== null) {
return false;
}
$holderName = trim((string) ($cfg['holder_name'] ?? ''));
$holderUrl = trim((string) ($cfg['holder_url'] ?? ''));
return $holderName !== '' && $holderUrl !== '';
}
/**
* Resolve optional row text (null/empty = omit row). Supports per-render overrides in $opts.
*
@@ -167,7 +206,9 @@ function platform_render_footer(array $opts = []): void
$useI18n = $opts['use_i18n'] ?? (bool) ($cfg['use_i18n'] ?? true);
$i18nKey = (string) ($cfg['i18n_key'] ?? 'footer.copyright');
$leftUsesDefault = platform_footer_field($cfg, $opts, 'left') === null;
$leftHasLink = platform_footer_left_has_link($cfg, $opts);
$yearEnd = platform_footer_year_end($cfg);
$leftHtml = platform_footer_render_left_html($cfg, $opts);
echo '<footer class="' . platform_footer_h($classes) . '">';
@@ -179,12 +220,12 @@ function platform_render_footer(array $opts = []): void
echo '<div class="platform-footer__main">';
if ($left !== null) {
echo '<div class="platform-footer__left"';
if ($useI18n && $i18nKey !== '' && $leftUsesDefault) {
if ($useI18n && $i18nKey !== '' && $leftUsesDefault && !$leftHasLink) {
echo ' data-i18n="' . platform_footer_h($i18nKey) . '"'
. ' data-year="' . platform_footer_h(platform_footer_year_label($cfg)) . '"'
. ' data-year-end="' . $yearEnd . '"';
}
echo '>' . platform_footer_h($left) . '</div>';
echo '>' . ($leftHtml ?? platform_footer_h($left)) . '</div>';
}
if ($right !== null) {
echo '<div class="platform-footer__right">' . platform_footer_h($right) . '</div>';