feat: enrichir l'édition du site public
This commit is contained in:
parent
6e3beea211
commit
1df26401a3
17 changed files with 115 additions and 15 deletions
|
|
@ -47,7 +47,10 @@ trait AnimalBrowseActions
|
|||
];
|
||||
$orderBy = $allowed[$sort] ?? 'a.updated_at';
|
||||
|
||||
$where = ['a.deleted_at IS NULL', 'a.archived_at IS NULL'];
|
||||
$where = ['a.deleted_at IS NULL'];
|
||||
if ($status !== '') {
|
||||
$where[] = 'a.archived_at IS NULL';
|
||||
}
|
||||
$params = [];
|
||||
if (in_array($availability, ['available', 'not_available', 'unknown'], true)) {
|
||||
$where[] = 'a.adoption_availability=:availability';
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ final class DashboardController
|
|||
$agendaDue = PermissionService::can('agenda') ? AgendaService::due() : [];
|
||||
|
||||
render('dashboard.php', [
|
||||
'title' => 'Dashboard',
|
||||
'title' => t('nav.dashboard'),
|
||||
'stats' => $stats,
|
||||
'shelterRoomCounts' => $shelterRoomCounts,
|
||||
'quality' => $quality,
|
||||
|
|
|
|||
|
|
@ -666,13 +666,41 @@ final class SettingsController
|
|||
public static function publicSite(): void
|
||||
{
|
||||
self::admin();
|
||||
$images = [];
|
||||
$mediaDirectory = dirname(__DIR__, 2) . '/public/media/site';
|
||||
foreach (glob($mediaDirectory . '/*.{jpg,jpeg,png,webp,gif}', GLOB_BRACE) ?: [] as $path) {
|
||||
$filename = basename($path);
|
||||
$images[] = ['filename' => $filename, 'url' => '/media/site/' . rawurlencode($filename)];
|
||||
}
|
||||
usort($images, static fn (array $left, array $right): int => strcmp($right['filename'], $left['filename']));
|
||||
render('settings_public_site.php', [
|
||||
'title' => t('public_site.settings_title'),
|
||||
'settings' => AppSettings::all(),
|
||||
'saved' => isset($_GET['saved']),
|
||||
'error' => (string) ($_GET['error'] ?? ''),
|
||||
'images' => $images,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function uploadPublicSiteImage(): void
|
||||
{
|
||||
self::admin();
|
||||
self::postOnly();
|
||||
try {
|
||||
$upload = $_FILES['public_site_image'] ?? null;
|
||||
if (!is_array($upload) || (int) ($upload['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) {
|
||||
throw new RuntimeException(t('public_site.image_invalid'));
|
||||
}
|
||||
$directory = dirname(__DIR__, 2) . '/public/media/site';
|
||||
$filename = ImageService::storeUploaded((string) $upload['tmp_name'], $directory, 'site', 'photo');
|
||||
@chmod($directory, 0755);
|
||||
AuditService::log('public_site_image_uploaded', '/settings/public-site/image', 'Image du site public ajoutée');
|
||||
header('Location: /settings/public-site?image=' . rawurlencode($filename));
|
||||
} catch (Throwable $e) {
|
||||
header('Location: /settings/public-site?error=' . rawurlencode(SecurityService::publicError($e)));
|
||||
}
|
||||
exit();
|
||||
}
|
||||
public static function health(): void
|
||||
{
|
||||
self::admin();
|
||||
|
|
@ -770,7 +798,7 @@ final class SettingsController
|
|||
exit();
|
||||
}
|
||||
$values['public_site_custom_css'] = $customCss;
|
||||
foreach (['public_site_donation_url', 'public_site_facebook_url', 'public_site_instagram_url', 'public_site_mastodon_url', 'public_site_youtube_url', 'public_site_tiktok_url', 'public_site_bluesky_url'] as $key) {
|
||||
foreach (['public_site_donation_url', 'public_site_facebook_url', 'public_site_instagram_url', 'public_site_youtube_url', 'public_site_tiktok_url'] as $key) {
|
||||
$url = trim((string) ($_POST[$key] ?? ''));
|
||||
$scheme = strtolower((string) parse_url($url, PHP_URL_SCHEME));
|
||||
if ($url !== '' && (!filter_var($url, FILTER_VALIDATE_URL) || $scheme !== 'https')) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue