3a1433b71e
Every photo upload (session setup, novena group, Rosary Builder title photo) gets shown two ways: full-size on the presentation cover slide (unaffected, stays untouched), and cropped to a fixed box everywhere else — home page cards, profile cards, the novena day-picker's circular hero photo, and each admin form's own preview thumbnail. All of those crops used to just take the image's dead center, with no way to control what part of the photo that was — cropping out people's heads on portrait photos. - New sessions/novena_groups columns: photo_focal_x, photo_focal_y (0-100%), photo_zoom (1-3x), defaulting to 50/50/1 — today's exact centered/ unzoomed behavior, so this is fully backward compatible until someone actively repositions a photo. - New assets/js/photo-crop.js: a reusable drag-to-pan + zoom modal editor. The crop frame renders with the *exact* CSS recipe used at final render time (object-position + transform:scale/transform-origin), so the editor is a truthful live preview, not an approximation. A reference thumbnail shows the full photo dimmed outside a rectangle marking the current crop. All math reads actual rendered box dimensions rather than assuming fixed pixel sizes, so it holds up responsively at any viewport width — caught and fixed a real mismatch bug here by testing the widget standalone in a browser before wiring it into any PHP form. - New includes/photo.php: photo_crop_style() builds the inline style="..." from a session/group row, used everywhere a crop is displayed. - Wired into all three upload locations (admin/setup.php, admin/novena_group.php, admin/builder.php) with a "Reposition" button, and persisted through api/save_session.php, admin/novena_group.php's save handler, and api/builder_session.php. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
148 lines
5.1 KiB
PHP
148 lines
5.1 KiB
PHP
<?php
|
|
/**
|
|
* novena_public.php — Public day-picker for a 9-day novena group.
|
|
* Linked from index.php when a visitor clicks a novena card.
|
|
*/
|
|
require_once __DIR__ . '/config/db.php';
|
|
require_once __DIR__ . '/includes/auth.php';
|
|
require_once __DIR__ . '/includes/donate.php';
|
|
require_once __DIR__ . '/includes/photo.php';
|
|
|
|
_auth_start();
|
|
$pdo = get_pdo();
|
|
$site_name = get_setting('site_name', APP_NAME);
|
|
$logged_in = !empty($_SESSION['user_id']);
|
|
|
|
// Resolve group: ?group_id=X OR ?username=X&slug=Y
|
|
$group = null;
|
|
if (isset($_GET['group_id'])) {
|
|
$stmt = $pdo->prepare('
|
|
SELECT ng.*, u.username, u.display_name
|
|
FROM novena_groups ng
|
|
JOIN users u ON u.id = ng.user_id
|
|
WHERE ng.id = ? AND ng.is_public = 1
|
|
');
|
|
$stmt->execute([(int)$_GET['group_id']]);
|
|
$group = $stmt->fetch();
|
|
} elseif (isset($_GET['username'], $_GET['slug'])) {
|
|
$stmt = $pdo->prepare('
|
|
SELECT ng.*, u.username, u.display_name
|
|
FROM novena_groups ng
|
|
JOIN users u ON u.id = ng.user_id
|
|
WHERE u.username = ? AND ng.slug = ? AND ng.is_public = 1
|
|
');
|
|
$stmt->execute([$_GET['username'], $_GET['slug']]);
|
|
$group = $stmt->fetch();
|
|
}
|
|
|
|
if (!$group) {
|
|
http_response_code(404);
|
|
die('Novena not found.');
|
|
}
|
|
|
|
// Load all available days
|
|
$days_stmt = $pdo->prepare('
|
|
SELECT id, novena_day, mystery_set, slug
|
|
FROM sessions
|
|
WHERE novena_group_id = ?
|
|
ORDER BY novena_day
|
|
');
|
|
$days_stmt->execute([$group['id']]);
|
|
$days_rows = $days_stmt->fetchAll();
|
|
|
|
$days_by_num = [];
|
|
foreach ($days_rows as $d) {
|
|
$days_by_num[(int)$d['novena_day']] = $d;
|
|
}
|
|
|
|
$mystery_labels = [
|
|
'sorrowful' => 'Sorrowful Mysteries',
|
|
'joyful' => 'Joyful Mysteries',
|
|
'glorious' => 'Glorious Mysteries',
|
|
'luminous' => 'Luminous Mysteries',
|
|
'by_day_of_week' => 'By Day of Week',
|
|
'chaplet' => 'Chaplet of Divine Mercy',
|
|
];
|
|
|
|
$disp_name = $group['display_name'] ?: $group['username'];
|
|
$photo_src = $group['photo_path'] ? ('/' . ltrim($group['photo_path'], '/')) : '';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="icon" type="image/svg+xml" href="<?= BASE_URL ?>/favicon.svg">
|
|
<title><?= htmlspecialchars($group['name']) ?> — <?= htmlspecialchars($site_name) ?></title>
|
|
<link rel="stylesheet" href="<?= BASE_URL ?>/assets/css/public.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="pub-nav">
|
|
<a href="<?= BASE_URL ?>/" class="pub-nav-brand">✝ <span><?= htmlspecialchars($site_name) ?></span></a>
|
|
<div class="pub-nav-links">
|
|
<?php if ($logged_in): ?>
|
|
<a href="<?= BASE_URL ?>/admin/">Dashboard</a>
|
|
<a href="<?= BASE_URL ?>/logout">Logout</a>
|
|
<?php else: ?>
|
|
<a href="<?= BASE_URL ?>/login">Sign In</a>
|
|
<a href="<?= BASE_URL ?>/register" class="btn-nav">Get Started</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="novena-hero">
|
|
<?php if ($photo_src): ?>
|
|
<div class="novena-hero-photo-wrap">
|
|
<img class="novena-hero-photo" src="<?= htmlspecialchars($photo_src) ?>" alt=""
|
|
style="<?= htmlspecialchars(photo_crop_style($group)) ?>">
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="novena-hero-cross">✝</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="novena-hero-text">
|
|
<p class="novena-hero-label"><?= $group['mystery_set'] === 'chaplet' ? 'Divine Mercy Novena' : '9-Day Novena' ?></p>
|
|
<h1 class="novena-hero-title"><?= htmlspecialchars($group['name']) ?></h1>
|
|
<?php if ($group['subject_name']): ?>
|
|
<p class="novena-hero-subject">For <?= htmlspecialchars($group['subject_name']) ?></p>
|
|
<?php endif; ?>
|
|
<?php if ($group['subject_dates']): ?>
|
|
<p class="novena-hero-dates"><?= htmlspecialchars($group['subject_dates']) ?></p>
|
|
<?php endif; ?>
|
|
<p class="novena-hero-by">By <?= htmlspecialchars($disp_name) ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="pub-section">
|
|
<h2>Select a Day</h2>
|
|
<div class="novena-days-grid">
|
|
<?php for ($d = 1; $d <= 9; $d++):
|
|
$ses = $days_by_num[$d] ?? null;
|
|
$mysteries = $ses ? ($mystery_labels[$ses['mystery_set']] ?? $ses['mystery_set']) : null;
|
|
$url = $ses ? (BASE_URL . '/present.php?id=' . (int)$ses['id']) : null;
|
|
?>
|
|
<div class="novena-day-card <?= $ses ? '' : 'novena-day-missing' ?>">
|
|
<div class="novena-day-number">Day <?= $d ?></div>
|
|
<?php if ($ses): ?>
|
|
<div class="novena-day-mysteries"><?= htmlspecialchars($mysteries) ?></div>
|
|
<a href="<?= htmlspecialchars($url) ?>" class="novena-day-link">Pray →</a>
|
|
<?php else: ?>
|
|
<div class="novena-day-mysteries">Not yet added</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endfor; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php render_donate_strip(); ?>
|
|
|
|
<footer class="pub-footer">
|
|
<a href="<?= BASE_URL ?>/" style="color:inherit">← All Rosaries</a>
|
|
•
|
|
© <?= date('Y') ?> <?= htmlspecialchars($site_name) ?>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|