Josh's Changes

This commit is contained in:
2026-04-03 20:43:00 -04:00
parent df06dcc0d7
commit 03825c1048
16 changed files with 216 additions and 54 deletions
+38 -31
View File
@@ -11,7 +11,7 @@ $calId = defined('GOOGLE_CALENDAR_ID') ? trim((string) GOOGLE_CALENDAR_ID) : '';
*/
function familyHub_google_calendar_embed_url(string $raw): ?string {
$raw = trim($raw);
if ($raw === '') {
if ($raw === '' || strcasecmp($raw, 'your_embed_code_here') === 0) {
return null;
}
$allowed = static function (string $u): bool {
@@ -34,7 +34,8 @@ function familyHub_google_calendar_embed_url(string $raw): ?string {
if ($allowed($raw)) {
return $raw;
}
if (preg_match('#<iframe\s[^>]*\ssrc\s*=\s*["\']([^"\']+)["\']#i', $raw, $m)) {
// Match iframe with src first or after other attributes (previous pattern required \s before src and failed on <iframe src="...">).
if (preg_match('#<iframe\s[^>]*\s*src\s*=\s*["\']([^"\']+)["\']#i', $raw, $m)) {
$u = html_entity_decode($m[1], ENT_QUOTES | ENT_HTML5, 'UTF-8');
return $allowed($u) ? $u : null;
}
@@ -56,7 +57,6 @@ $twoWayMerge = !empty($familySettings['calendar_two_way_google']);
$isTvView = isset($_GET['view']) && (string) $_GET['view'] === 'tv';
$calendarBaseUrl = '?tab=calendar';
$calendarTvUrl = '?tab=calendar&view=tv';
$lastRefreshedStamp = gmdate('Y-m-d H:i') . ' UTC';
$eventsByDate = [];
foreach ($events as $ev) {
@@ -82,43 +82,40 @@ $iconByType = [
?>
<div id="calendar" class="tab-content<?= $isTvView ? ' calendar-tv-view' : '' ?>">
<?php if ($isTvView): ?>
<div class="d-flex flex-wrap justify-content-end align-items-center gap-2 mb-2 calendar-tv-toolbar">
<a href="<?= htmlspecialchars($calendarBaseUrl, ENT_QUOTES, 'UTF-8') ?>" class="btn btn-outline-secondary btn-sm" title="Exit TV view">
<i class="fa fa-xmark me-1" aria-hidden="true"></i>
Exit TV view
</a>
</div>
<?php else: ?>
<div class="d-flex flex-wrap justify-content-between align-items-center gap-2 mb-2">
<h2 class="mb-0">Calendar</h2>
<?php if ($isTvView): ?>
<a href="<?= htmlspecialchars($calendarBaseUrl, ENT_QUOTES, 'UTF-8') ?>" class="btn btn-outline-secondary btn-sm" title="Exit TV view">
<i class="fa fa-xmark me-1" aria-hidden="true"></i>
Exit TV view
</a>
<?php else: ?>
<a href="<?= htmlspecialchars($calendarTvUrl, ENT_QUOTES, 'UTF-8') ?>" class="btn btn-outline-secondary btn-sm" title="Open TV view dashboard">
<i class="fa fa-tv me-1" aria-hidden="true"></i>
Open TV view
</a>
<?php endif; ?>
<a href="<?= htmlspecialchars($calendarTvUrl, ENT_QUOTES, 'UTF-8') ?>" class="btn btn-outline-secondary btn-sm" title="Open TV view dashboard">
<i class="fa fa-tv me-1" aria-hidden="true"></i>
Open TV view
</a>
</div>
<p class="text-muted small mb-3">
<?php if ($isTvView): ?>
TV view auto-refreshes every 10 minutes.
<?php else: ?>
Open TV view for a dedicated dashboard URL that refreshes every 10 minutes.
<?php endif; ?>
</p>
<?php if ($isTvView): ?>
<p class="small text-muted mb-3">Last refreshed: <strong><?= htmlspecialchars($lastRefreshedStamp, ENT_QUOTES, 'UTF-8') ?></strong></p>
<?php endif; ?>
<p class="text-muted small mb-3">Open TV view for a full-width dashboard without site chrome.</p>
<?php if ($twoWayMerge): ?>
<div class="alert alert-info mb-3" role="status">
<strong>Two-way Google Calendar sync</strong> is enabled in Family settings. OAuth connection is not available in this version yet. Your Google view below (if configured) and the Family Hub agenda still work; full sync will require signing in with Google when supported.
<div class="alert alert-secondary mb-3" role="status">
<strong>Google Calendar is not synced into Family Hub data.</strong>
The Google panel below is an embedded view from Google (live in your browser). The <strong>Family Hub agenda</strong> lists chores, meals, groceries, expenses, bill reminders, and birthdays from this app only—Google events never appear there until a future API connection exists.
<?php if ($twoWayMerge): ?>
<span class="d-block mt-1 small">You turned on “two-way sync” in settings; OAuth with Google is <strong>not implemented yet</strong>, so that option does not change behavior today.</span>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="row g-4 calendar-tab-layout<?= $embedUrl !== null ? ' calendar-tab-layout-split' : '' ?>">
<div class="row <?= $isTvView ? 'g-3' : 'g-4' ?> calendar-tab-layout<?= $embedUrl !== null ? ' calendar-tab-layout-split' : '' ?>">
<div class="col-12 calendar-tab-google">
<h3 class="h5 mb-3">Google Calendar</h3>
<h3 class="h5 mb-3"><?= $isTvView ? 'Calendar' : 'Google Calendar' ?></h3>
<?php if ($embedUrl === null): ?>
<?php if (!$isTvView): ?>
<p class="text-muted">Connect a shared family calendar by setting <strong>GOOGLE_CALENDAR_EMBED_CODE</strong> (embed URL or full <code>&lt;iframe&gt;</code> from Google Calendar) or <strong>GOOGLE_CALENDAR_ID</strong> in <code>.env</code>. See <a href="https://calendar.google.com/">Google Calendar</a> → calendar menu → <strong>Settings and sharing</strong> → <strong>Integrate calendar</strong>.</p>
<?php else: ?>
<p class="text-muted small mb-0">Google Calendar not configured (set <code class="small">.env</code>).</p>
<?php endif; ?>
<?php else: ?>
<?php if ($fromIdOnly && !$isTvView): ?>
@@ -137,8 +134,11 @@ $iconByType = [
<?php endif; ?>
</div>
<div class="col-12 calendar-tab-agenda">
<h3 class="h5 mb-3">Family Hub agenda</h3>
<p class="text-muted small mb-3">
<h3 class="h5 mb-3"><?= $isTvView ? 'Weekly hub' : 'Family Hub agenda' ?></h3>
<?php if (!$isTvView): ?>
<p class="text-muted small mb-2">Hub data only (not Google Calendar).</p>
<?php endif; ?>
<p class="text-muted small mb-3 hide hidden" style="display: none;">
<?= htmlspecialchars($rangeStart, ENT_QUOTES, 'UTF-8') ?> to <?= htmlspecialchars($rangeEnd, ENT_QUOTES, 'UTF-8') ?>
· Times use <strong><?= htmlspecialchars(str_replace('_', ' ', (string) ($familySettings['timezone'] ?? '')), ENT_QUOTES, 'UTF-8') ?></strong>
</p>
@@ -188,3 +188,10 @@ $iconByType = [
}, 10 * 60 * 1000);
</script>
<?php endif; ?>
<?php if ($isTvView): ?>
<script>
window.setTimeout(function () {
window.location.reload();
}, 10 * 60 * 1000);
</script>
<?php endif; ?>
+1 -1
View File
@@ -213,7 +213,7 @@ $activeCharityDonated = is_numeric($activeBankPerson['charity_donated_total'] ??
</div>
</div>
<div class="card-body p-0">
<script type="application/json" id="currencyLeaderboardPeriodData"><?= json_encode($leaderboardRowsByPeriod, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) ?></script>
<script type="application/json" id="currencyLeaderboardPeriodData"><?= json_encode($leaderboardRowsByPeriod, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | familyHubJsonEncodeShellFlags()) ?></script>
<div class="table-responsive">
<table class="table table-striped mb-0 leaderboard-table">
<thead>
+1 -1
View File
@@ -492,6 +492,6 @@ $mealEditorForbidden = $editMealId !== '' && !$showMealEditorPage;
'title' => (string) ($m['title'] ?? ''),
'tags' => array_values($m['tags'] ?? []),
];
}, $meals), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE) ?></script>
}, $meals), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | familyHubJsonEncodeShellFlags()) ?></script>
<?php endif; ?>
+5 -4
View File
@@ -102,13 +102,14 @@ $permanenceOptions = [
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6 d-flex align-items-end">
<div class="form-check mb-2">
<div class="col-12">
<div class="form-check mb-1">
<input class="form-check-input" type="checkbox" id="calendar_two_way_google" name="calendar_two_way_google" value="1"
<?= !empty($familySettings['calendar_two_way_google']) ? 'checked' : '' ?>
<?= !$canManage ? 'disabled' : '' ?>>
<label class="form-check-label" for="calendar_two_way_google">Enable two-way Google Calendar sync</label>
<label class="form-check-label" for="calendar_two_way_google">Notify me when two-way Google Calendar sync is available</label>
</div>
<p class="small text-muted mb-0">Family Hub does not call Googles API yet. Your calendar appears on the Calendar tab only via <code class="small">.env</code> (<code>GOOGLE_CALENDAR_ID</code> or <code>GOOGLE_CALENDAR_EMBED_CODE</code>). This checkbox only stores a preference; it does not enable sync today.</p>
</div>
<div class="col-12">
<label class="form-label">Monthly bill reminders</label>
@@ -368,7 +369,7 @@ $permanenceOptions = [
];
}
?>
<script type="application/json" id="settingsPeopleEditPayload"><?= json_encode($peopleEditPayload, JSON_HEX_TAG | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE) ?></script>
<script type="application/json" id="settingsPeopleEditPayload"><?= json_encode($peopleEditPayload, JSON_HEX_TAG | JSON_HEX_AMP | familyHubJsonEncodeShellFlags()) ?></script>
<div class="modal fade" id="editPersonModal" tabindex="-1" aria-labelledby="editPersonModalLabel" aria-hidden="true" data-bs-backdrop="false">
<div class="modal-dialog modal-dialog-scrollable">