<?php
require_once __DIR__ . '/../includes/functions.php';
requireAdmin();
require __DIR__ . '/includes/ui.php';
$pageTitle = 'About Page Content';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && csrfVerify($_POST['csrf_token'] ?? null)) {
$valuePoints = array_values(array_filter(array_map('trim', explode("\n", $_POST['value_points'] ?? ''))));
$statLabels = $_POST['stat_label'] ?? [];
$statValues = $_POST['stat_value'] ?? [];
$stats = [];
foreach ($statLabels as $idx => $label) {
$label = trim($label);
$value = trim($statValues[$idx] ?? '');
if ($label !== '' && $value !== '') {
$stats[] = ['label' => $label, 'value' => $value];
}
}
db()->prepare('UPDATE about_content SET heading=?, intro=?, mission=?, vision=?, value_points=?, stats=? WHERE id = 1')->execute([
trim($_POST['heading'] ?? ''),
trim($_POST['intro'] ?? ''),
trim($_POST['mission'] ?? ''),
trim($_POST['vision'] ?? ''),
json_encode($valuePoints),
json_encode($stats),
]);
flash('success', 'About page content updated.');
redirect('about-content.php');
}
require __DIR__ . '/includes/admin-header.php';
adminFlashBox();
$about = db()->query('SELECT * FROM about_content WHERE id = 1')->fetch() ?: [];
$valuePointsText = implode("\n", jdecode($about['value_points'] ?? null));
$stats = jdecode($about['stats'] ?? null);
while (count($stats) < 3) { $stats[] = ['label' => '', 'value' => '']; }
?>
<form method="post" class="bg-white rounded-2xl border border-gray-100 p-6 max-w-3xl">
<input type="hidden" name="csrf_token" value="<?= e(csrfToken()) ?>" />
<?php inputField('Heading', 'heading', $about['heading'] ?? '', 'text', true); ?>
<?php textareaField('Intro / Who We Are', 'intro', $about['intro'] ?? '', 4, true); ?>
<?php textareaField('Mission', 'mission', $about['mission'] ?? '', 3); ?>
<?php textareaField('Vision', 'vision', $about['vision'] ?? '', 3); ?>
<?php textareaField('Core Strengths / Value Points (one per line)', 'value_points', $valuePointsText, 5); ?>
<h2 class="font-heading font-semibold mb-3 mt-6">Stats (shown as counters)</h2>
<div class="grid sm:grid-cols-3 gap-4 mb-4">
<?php foreach ($stats as $idx => $stat): ?>
<div class="border border-gray-200 rounded-lg p-3">
<label class="block mb-2"><span class="block text-xs text-gray-500 mb-1">Value (e.g. 500+)</span>
<input type="text" name="stat_value[]" value="<?= e($stat['value'] ?? '') ?>" class="w-full px-3 py-2 rounded-lg border border-gray-200 text-sm" /></label>
<label class="block"><span class="block text-xs text-gray-500 mb-1">Label</span>
<input type="text" name="stat_label[]" value="<?= e($stat['label'] ?? '') ?>" class="w-full px-3 py-2 rounded-lg border border-gray-200 text-sm" /></label>
</div>
<?php endforeach; ?>
</div>
<button class="btn-primary-brand bg-primary text-white px-6 py-3 rounded-lg font-semibold mt-2">Save About Content</button>
</form>
<?php require __DIR__ . '/includes/admin-footer.php'; ?>