Feat: Language support via json files in the locales folder + Feat: Popup with title, channel, schedule, duration, season, episode, synopsis, Watch button (if M3U provided) and IMDb link + Fix: Date added to the timebar

This commit is contained in:
Johnnybegood90
2026-03-12 13:11:49 +01:00
parent 8d223359f4
commit 8826926168
13 changed files with 289 additions and 31 deletions
+51
View File
@@ -0,0 +1,51 @@
<?php
// GridTV — index.php
$config_path = __DIR__ . "/../config.json";
if (!file_exists($config_path)) {
header("Location: ../setup.php");
exit;
}
$config = json_decode(file_get_contents($config_path), true);
// ── Migration automatique ancien format → nouveau ─────────────────────────────
if (isset($config['epg_url']) && !isset($config['epg_sources'])) {
$config['epg_sources'] = [[
'name' => 'Main',
'epg_url' => $config['epg_url'],
'm3u_url' => $config['m3u_url'] ?? '',
]];
$config['allow_personal_epg'] = false;
unset($config['epg_url'], $config['m3u_url']);
file_put_contents($config_path, json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
// ─────────────────────────────────────────────────────────────────────────────
$group_name = htmlspecialchars($config['group_name'] ?? 'GridTV');
$epg_sources = $config['epg_sources'] ?? [];
$allow_personal_epg = !empty($config['allow_personal_epg']);
// Première source par défaut (pour compatibilité avec le reste du code)
$first_source = $epg_sources[0] ?? [];
$epg_url = htmlspecialchars($first_source['epg_url'] ?? '');
$m3u_url = htmlspecialchars($first_source['m3u_url'] ?? '');
// ── Locale detection ─────────────────────────────────────────────────────────
$supported_locales = ['en', 'fr', 'es'];
$locale = 'en';
$accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'en';
foreach (explode(',', $accept) as $lang) {
$code = strtolower(substr(trim($lang), 0, 2));
if (in_array($code, $supported_locales)) { $locale = $code; break; }
}
$locale_path = __DIR__ . "/../locales/{$locale}.json";
$L = json_decode(file_get_contents($locale_path), true);
// ─────────────────────────────────────────────────────────────────────────────
?>
<!DOCTYPE html>
<html lang="<?= $locale ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GridTV — <?= $group_name ?></title>
+1 -1
View File
@@ -3,7 +3,7 @@
<?php
$js_dir = __DIR__ . '/../js/';
include $js_dir . 'config.js';
$js_modules = ['utils', 'epg', 'mobile', 'tooltip', 'sources', 'm3u', 'player', 'themes', 'search', 'live'];
$js_modules = ['utils', 'epg', 'mobile', 'tooltip', 'sources', 'm3u', 'player', 'themes', 'search', 'program', 'live'];
foreach ($js_modules as $mod) {
echo file_get_contents($js_dir . $mod . '.js');
}
+5 -5
View File
@@ -1,14 +1,14 @@
<div class="loading" id="loading">
<div class="loading-text">Chargement du guide</div>
<div class="loading-text"><?= htmlspecialchars($L["loading"]) ?></div>
<div class="loading-bar"></div>
</div>
<div class="error-msg" id="errorMsg">
<div class="err-title">&#9888; Impossible de charger l'EPG</div>
<div class="err-sub" id="errorDetail">Vérifiez l'URL de votre flux XMLTV.</div>
<div class="err-title">&#9888; <?= htmlspecialchars($L["epg_error"]) ?></div>
<div class="err-sub" id="errorDetail"><?= htmlspecialchars($L["epg_error_sub"]) ?></div>
<div class="epg-input-bar">
<input class="epg-input" id="epgInput" type="text" placeholder="<?= $epg_url ?>" />
<button class="epg-btn" onclick="loadFromInput()">Charger</button>
<button class="epg-btn" onclick="loadFromInput()"><?= htmlspecialchars($L["load"]) ?></button>
</div>
</div>
@@ -32,7 +32,7 @@
<!-- GRID (desktop/tablet) -->
<div class="grid-wrapper">
<div class="channels-col">
<div class="channels-col-header"><span>Chaînes</span></div>
<div class="channels-col-header"><span><?= htmlspecialchars($L["channels"]) ?></span></div>
<div class="channels-list" id="channelsList"></div>
</div>
<div class="timeline-area" id="timelineArea">
+51
View File
@@ -800,6 +800,57 @@
border-left: 3px solid var(--accent);
}
/* ── PROGRAM MODAL ───────────────────────────────────────────────────────── */
.program-card {
max-width: 520px; padding: 28px; position: relative;
}
.pm-close {
position: absolute; top: 14px; right: 14px;
background: none; border: none; color: var(--text-muted);
cursor: pointer; font-size: 18px; line-height: 1;
transition: color .2s;
}
.pm-close:hover { color: var(--accent); }
.pm-channel {
font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
color: var(--accent); margin-bottom: 6px;
}
.pm-title {
font-size: 20px; font-weight: 700; color: var(--text);
margin-bottom: 8px; line-height: 1.2;
}
.pm-time {
font-size: 12px; color: var(--accent); margin-bottom: 14px;
}
.pm-desc {
font-size: 13px; color: var(--text-muted); line-height: 1.6;
margin-bottom: 20px; max-height: 140px; overflow-y: auto;
}
.pm-actions {
display: flex; gap: 10px; flex-wrap: wrap;
}
.pm-btn {
border-radius: 4px; cursor: pointer; font-family: inherit;
font-size: 13px; font-weight: 600; padding: 8px 16px;
text-decoration: none; transition: opacity .2s;
display: inline-flex; align-items: center; gap: 6px;
border: none;
}
.pm-btn:hover { opacity: .8; }
.pm-watch { background: var(--accent); color: var(--bg); }
.pm-imdb { background: #f5c518; color: #000; }
.pm-cancel { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
/* Date midnight dans la timebar */
.time-tick-label.midnight {
color: var(--accent); font-weight: 700; font-size: 11px;
white-space: nowrap;
}
.time-tick-line.midnight {
background: var(--accent); opacity: .4; width: 2px;
}
</style>
<link id="themeStylesheet" rel="stylesheet" href="themes/default.css">
</head>
+22 -6
View File
@@ -1,19 +1,35 @@
<!-- MODAL PROGRAMME -->
<div class="modal-overlay" id="programModal">
<div class="modal-card program-card">
<button class="pm-close" onclick="closeProgramModal()">&#10005;</button>
<div class="pm-channel" id="pm-channel"></div>
<div class="pm-title" id="pm-title"></div>
<div class="pm-time" id="pm-time"></div>
<div class="pm-desc" id="pm-desc"></div>
<div class="pm-actions">
<button class="pm-btn pm-watch" id="pm-watch">&#9654; <?= htmlspecialchars($L["watch_now"]) ?></button>
<a class="pm-btn pm-imdb" id="pm-imdb" href="#" target="_blank" rel="noopener">&#127909; <?= htmlspecialchars($L["imdb_search"]) ?></a>
<button class="pm-btn pm-cancel" onclick="closeProgramModal()"><?= htmlspecialchars($L["close"]) ?></button>
</div>
</div>
</div>
<!-- MODAL PERSONAL EPG -->
<div class="modal-overlay" id="personalEpgModal">
<div class="modal-card">
<div class="modal-title"> Personal EPG</div>
<div class="modal-subtitle">Utilisez votre propre source EPG/M3U sur cette instance.</div>
<div class="modal-title">✏ <?= htmlspecialchars($L["personal_epg_title"]) ?></div>
<div class="modal-subtitle"><?= htmlspecialchars($L["personal_epg_subtitle"]) ?></div>
<div class="modal-field">
<label>URL EPG (XMLTV) *</label>
<label><?= htmlspecialchars($L["personal_epg_label"]) ?></label>
<input type="url" id="personalEpgInput" placeholder="http://mon-serveur/xmltv.xml">
</div>
<div class="modal-field">
<label>URL M3U <span style="opacity:.5;font-size:10px">(optionnel)</span></label>
<label><?= htmlspecialchars($L["personal_epg_m3u_label"]) ?> <span style="opacity:.5;font-size:10px">(<?= htmlspecialchars($L["personal_epg_optional"]) ?>)</span></label>
<input type="url" id="personalM3uInput" placeholder="http://mon-serveur/channels.m3u">
</div>
<div class="modal-actions">
<button class="modal-btn-cancel" onclick="closePersonalEpgModal()">Annuler</button>
<button class="modal-btn-apply" onclick="applyPersonalEpg()">Appliquer</button>
<button class="modal-btn-cancel" onclick="closePersonalEpgModal()"><?= htmlspecialchars($L["cancel"]) ?></button>
<button class="modal-btn-apply" onclick="applyPersonalEpg()"><?= htmlspecialchars($L["apply"]) ?></button>
</div>
</div>
</div>
+7 -7
View File
@@ -3,14 +3,14 @@
<div class="date-label" id="dateLabel"></div>
<div class="clock" id="clock">00:00:00</div>
<div class="nav-btns" id="navBtns">
<button class="nav-btn" onclick="shiftView(-60)">◀ 1h</button>
<button class="nav-btn active" onclick="centerNow()">Maintenant</button>
<button class="nav-btn" onclick="shiftView(60)">1h ▶</button>
<button class="nav-btn" onclick="shiftView(-60)"><?= htmlspecialchars($L["shift_back"]) ?></button>
<button class="nav-btn active" onclick="centerNow()"><?= htmlspecialchars($L["now"]) ?></button>
<button class="nav-btn" onclick="shiftView(60)"><?= htmlspecialchars($L["shift_fwd"]) ?></button>
</div>
<div class="copy-btns">
<button class="copy-btn" onclick="copyUrl('epg')" title="Copier l'URL EPG">EPG</button>
<button class="copy-btn" onclick="copyUrl('epg')" title="<?= htmlspecialchars($L["copy_epg"]) ?>"><?= htmlspecialchars($L["copy_epg"]) ?></button>
<?php if (!empty($m3u_url)): ?>
<button class="copy-btn" onclick="copyUrl('m3u')" title="Copier l'URL M3U">M3U</button>
<button class="copy-btn" onclick="copyUrl('m3u')" title="<?= htmlspecialchars($L["copy_m3u"]) ?>"><?= htmlspecialchars($L["copy_m3u"]) ?></button>
<?php endif; ?>
</div>
<?php if (count($epg_sources) > 1 || $allow_personal_epg): ?>
@@ -48,10 +48,10 @@ foreach ($theme_files as $file) {
?>
</select>
<button class="search-btn" onclick="toggleSearch()" title="Search">&#128269;</button>
<div class="live-dot">LIVE</div>
<div class="live-dot"><?= htmlspecialchars($L["live"]) ?></div>
</div>
<div class="search-bar" id="searchBar">
<input class="search-input" id="searchInput" type="text" placeholder="Search channel or program..." oninput="onSearchInput(this.value)" />
<input class="search-input" id="searchInput" type="text" placeholder="<?= htmlspecialchars($L["search_placeholder"]) ?>" oninput="onSearchInput(this.value)" />
<button class="search-clear" onclick="clearSearch()">&#10005;</button>
</div>