Files
rpigroupplay/config/ui.inc.php
T
alexspeakerandClaude Fable 5.1 24391c49ac vers. 3.0.0 - nuova interfaccia app per mobile e desktop
Nuova UI disegnata sul tema RPIGroup Radio Theme dei siti del gruppo:
guscio unico responsive (sidebar e player in basso da 900px, topbar e
tab bar su telefono), player della radio persistente nel dock con
now playing, HLS/MP3, volume e Media Session; pagine radio, tv,
podcast (copertine e programma dal feed), player e pagine di testo
rifatte; icone SVG inline al posto di Bootstrap, jQuery e Material
Icons; font Bricolage Grotesque e Plus Jakarta Sans in locale;
service worker v5, manifest con orientamento libero, icone PWA 192 e
384 rigenerate.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-06 14:56:08 +01:00

158 lines
8.9 KiB
PHP

<?php
/**
* Pezzi di interfaccia condivisi tra le pagine: icone SVG inline, intestazioni, motivo grafico, link.
* Tutto quello che riguarda l'aspetto e si ripete sta qui, così le pagine restano leggibili.
*/
/** Indirizzo di una pagina dell'app (home = radice) */
function rpi_link(string $page): string
{
global $base_path;
return $page === 'home' ? $base_path . '/' : $base_path . '/' . $page;
}
/** Sezione principale a cui appartiene una pagina (per evidenziare la voce di menu) */
function rpi_section(string $page, string $param = ''): string
{
if ($page === 'play') return 'radio';
if ($page === 'playtv') return 'tv';
if (in_array($page, ['home', 'radio', 'tv', 'podcast'], true)) return $page;
return '';
}
/** Voci del menu principale (sidebar su desktop, tab bar su telefono) */
function rpi_nav_items(): array
{
return [
['page' => 'home', 'label' => 'Home', 'icon' => 'home'],
['page' => 'radio', 'label' => 'Radio', 'icon' => 'radio'],
['page' => 'tv', 'label' => 'TV', 'icon' => 'tv'],
['page' => 'podcast', 'label' => 'Podcast', 'icon' => 'mic'],
];
}
/**
* Icona SVG inline (griglia 24x24, tratto 2px, colore corrente).
* Le icone "piene" (play, pause) usano il riempimento invece del tratto.
*/
function rpi_icon(string $name, int $size = 20, string $class = ''): string
{
static $icons = [
'home' => '<path d="m3 10 9-7 9 7v10a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1V10Z"/>',
'radio' => '<path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"/><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"/><circle cx="12" cy="12" r="2"/><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"/><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"/>',
'tv' => '<rect width="20" height="15" x="2" y="7" rx="2" ry="2"/><path d="m17 2-5 5-5-5"/>',
'mic' => '<rect x="9" y="2" width="6" height="12" rx="3"/><path d="M5 10a7 7 0 0 0 14 0M12 17v5"/>',
'headphones' => '<path d="M3 18v-6a9 9 0 0 1 18 0v6"/><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"/>',
'arrow-left' => '<path d="M19 12H5M11 18l-6-6 6-6"/>',
'arrow-right' => '<path d="M5 12h14M13 6l6 6-6 6"/>',
'external' => '<path d="M7 17 17 7M8 7h9v9"/>',
'volume' => '<path d="M11 5 6 9H2v6h4l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14"/>',
'mute' => '<path d="M11 5 6 9H2v6h4l5 4V5Z"/><path d="m23 9-6 6M17 9l6 6"/>',
'download' => '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5M12 15V3"/>',
'close' => '<path d="M18 6 6 18M6 6l12 12"/>',
'calendar' => '<rect width="18" height="18" x="3" y="4" rx="2" ry="2"/><path d="M16 2v4M8 2v4M3 10h18"/>',
'wifi-off' => '<path d="M2 2 22 22"/><path d="M8.5 16.5a5 5 0 0 1 7 0"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><path d="M16.85 11.25a10 10 0 0 1 2.22 1.68"/><path d="M5 13a10 10 0 0 1 5.24-2.76"/><path d="M12 20h.01"/>',
'refresh' => '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',
'info' => '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/>',
'help' => '<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3M12 17h.01"/>',
'copyright' => '<circle cx="12" cy="12" r="10"/><path d="M14.83 14.83a4 4 0 1 1 0-5.66"/>',
'mail' => '<rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>',
'share' => '<path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><path d="m16 6-4-4-4 4M12 2v13"/>',
'plus-square' => '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M8 12h8M12 8v8"/>',
'more-vertical' => '<circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/>',
'rss' => '<path d="M4 11a9 9 0 0 1 9 9"/><path d="M4 4a16 16 0 0 1 16 16"/><circle cx="5" cy="19" r="1"/>',
'message' => '<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',
'list' => '<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>',
'shield' => '<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/>',
'file-text' => '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8M16 13H8M16 17H8"/>',
'globe' => '<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20M2 12h20"/>',
'clock' => '<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>',
'sparkles' => '<path d="m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3Z"/>',
'maximize' => '<path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M8 21H5a2 2 0 0 1-2-2v-3M16 21h3a2 2 0 0 0 2-2v-3"/>',
// Piene
'play' => '<path d="M7 4.5v15a1 1 0 0 0 1.5.86l12.5-7.5a1 1 0 0 0 0-1.72L8.5 3.64A1 1 0 0 0 7 4.5Z"/>',
'pause' => '<rect x="6" y="4.5" width="4" height="15" rx="1.2"/><rect x="14" y="4.5" width="4" height="15" rx="1.2"/>',
];
if (!isset($icons[$name])) return '';
$filled = in_array($name, ['play', 'pause'], true);
$paint = $filled
? 'fill="currentColor"'
: 'fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';
$cls = trim('icon icon-' . $name . ' ' . $class);
return '<svg class="' . htmlspecialchars($cls) . '" viewBox="0 0 24 24" width="' . $size . '" height="' . $size . '" ' . $paint . ' aria-hidden="true" focusable="false">' . $icons[$name] . '</svg>';
}
/** Figura decorativa delle sezioni scure: anelli concentrici (il "segno" di RPIGroup Play) */
function rpi_motivo(string $class = ''): string
{
$cls = trim('motivo ' . $class);
$out = '<svg class="' . htmlspecialchars($cls) . '" viewBox="0 0 800 800" fill="none" aria-hidden="true" focusable="false">';
foreach ([140, 230, 320, 395] as $r) {
$out .= '<circle cx="400" cy="400" r="' . $r . '"/>';
}
return $out . '</svg>';
}
/**
* Intestazione di una pagina interna: sfondo del brand, pillola "torna a", etichetta, titolo, sottotitolo.
* $o = ['title' => ..., 'eyebrow' => ..., 'subtitle' => ..., 'back' => ['page' => 'home', 'label' => 'Home'], 'class' => ...]
*/
function rpi_page_header(array $o): void
{
$title = $o['title'] ?? '';
$eyebrow = $o['eyebrow'] ?? '';
$subtitle = $o['subtitle'] ?? '';
$back = $o['back'] ?? ['page' => 'home', 'label' => 'Home'];
$class = $o['class'] ?? '';
?>
<header class="page-head <?= htmlspecialchars($class) ?>">
<span class="page-head-glow" aria-hidden="true"></span>
<?= rpi_motivo('page-head-motivo') ?>
<div class="container page-head-inner">
<?php if ($back): ?>
<a href="<?= rpi_link($back['page']) ?>" data-page="<?= htmlspecialchars($back['page']) ?>" class="back-pill">
<?= rpi_icon('arrow-left', 18) ?><?= htmlspecialchars($back['label']) ?>
</a>
<?php endif; ?>
<?php if ($eyebrow): ?><span class="eyebrow"><?= htmlspecialchars($eyebrow) ?></span><?php endif; ?>
<h1><?= htmlspecialchars($title) ?></h1>
<?php if ($subtitle): ?><p class="subtitle"><?= htmlspecialchars($subtitle) ?></p><?php endif; ?>
</div>
</header>
<?php
}
/** Barra in testa alle viste a tutta altezza (player radio, TV, puntata podcast): pillola indietro + titolo */
function rpi_back_pill(string $page, string $label): string
{
return '<a href="' . rpi_link($page) . '" data-page="' . htmlspecialchars($page) . '" class="back-pill">'
. rpi_icon('arrow-left', 18) . htmlspecialchars($label) . '</a>';
}
/** Link legali e versione: nella sidebar (desktop) e in fondo alla home (telefono) */
function rpi_legal_links(): array
{
return [
['page' => 'page/termini-condizioni', 'label' => 'Termini e Condizioni'],
['page' => 'page/policy-privacy', 'label' => 'Policy Privacy'],
['page' => 'page/changelog', 'label' => 'Changelog'],
];
}
/** Dati di una stazione radio per il player (attributo data-station) */
function rpi_station_json($station): string
{
return htmlspecialchars(json_encode([
'id' => (int)$station->id,
'name' => (string)$station->name,
'slogan' => (string)$station->slogan,
'logo' => (string)$station->logo,
'stream' => (string)$station->stream,
'streamhls' => (string)$station->streamhls,
'api' => (string)$station->apiradio,
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), ENT_QUOTES, 'UTF-8');
}