mirror of
git://f0xx.org/android_cast
synced 2026-07-29 03:57:50 +03:00
features
This commit is contained in:
@@ -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>';
|
||||
|
||||
Reference in New Issue
Block a user