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
|
|
@ -37,10 +37,8 @@ final class AppSettings
|
|||
'public_site_contact_text' => 'Une question sur une adoption ou sur l’association ? Contactez-nous.',
|
||||
'public_site_facebook_url' => '',
|
||||
'public_site_instagram_url' => '',
|
||||
'public_site_mastodon_url' => '',
|
||||
'public_site_youtube_url' => '',
|
||||
'public_site_tiktok_url' => '',
|
||||
'public_site_bluesky_url' => '',
|
||||
'notification_email_enabled' => '0',
|
||||
'notification_email_frequency' => 'weekly',
|
||||
'notification_email_recipient' => '',
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ final class PermissionService
|
|||
'lecture' => 'Lecture seule',
|
||||
];
|
||||
public const MODULES = [
|
||||
'dashboard' => ['Dashboard', 'Priorités et situation quotidienne'],
|
||||
'dashboard' => ['Tableau de bord', 'Priorités et situation quotidienne'],
|
||||
'animals' => ['Animaux', 'Fiches, portées, liens, médias et adoptions'],
|
||||
'medical' => ['Médical', 'Notes, traitements, vaccinations et décès'],
|
||||
'care' => ['Tournées', 'Passages tablette et configuration des box'],
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ final class PublicContentFormatter
|
|||
|
||||
private static function inline(string $text): string
|
||||
{
|
||||
$images = [];
|
||||
$text = preg_replace_callback('/!\[([^\]]*)\]\((\/media\/site\/[A-Za-z0-9._%-]+)\)/u', static function (array $match) use (&$images): string {
|
||||
$token = "\x1B" . count($images) . "\x1B";
|
||||
$images[] = '<img class="public-content-image" src="' .
|
||||
htmlspecialchars($match[2], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '" alt="' .
|
||||
htmlspecialchars($match[1], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '" loading="lazy">';
|
||||
return $token;
|
||||
}, $text) ?? $text;
|
||||
$links = [];
|
||||
$text = preg_replace_callback('/\[([^\]]+)\]\((https:\/\/[^\s)]+)\)/u', static function (array $match) use (&$links): string {
|
||||
if (!filter_var($match[2], FILTER_VALIDATE_URL)) {
|
||||
|
|
@ -62,6 +70,9 @@ final class PublicContentFormatter
|
|||
foreach ($links as $index => $link) {
|
||||
$text = str_replace("\x1A" . $index . "\x1A", $link, $text);
|
||||
}
|
||||
foreach ($images as $index => $image) {
|
||||
$text = str_replace("\x1B" . $index . "\x1B", $image, $text);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue