src/Utilities/Feed.php line 51

Open in your IDE?
  1. <?php
  2. namespace App\Utilities;
  3. use App\Entity\Contact;
  4. use App\Entity\CustomForm;
  5. use App\Entity\EventType;
  6. use App\Entity\Service;
  7. use Exception;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpKernel\KernelInterface;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. class Feed
  12. {
  13.   private KernelInterface $kernel;
  14.   public function __construct(
  15.     KernelInterface $kernel,
  16.     protected EntityManagerInterface $em
  17.   )
  18.   {
  19.     $this->kernel $kernel;
  20.   }
  21.   public function social_posts_detect_links(mixed $posts): mixed
  22.   {
  23.     $i 0;
  24.     foreach ($posts as $post) {
  25.       $text $post->getContent();
  26.       if ($text == null) {
  27.         $text $post->getShortDescription();
  28.       }
  29.       if ($post->getType()->getId() == 5) {
  30.         $text preg_replace('/#([^(\s|\[|\])]+)/'"<span class='color-blue'>#$1</span>"$text);
  31.         $text preg_replace('/@([^\s]+)/'"<span class='color-blue'>@$1</span>"$text);
  32.         $text preg_replace('@((https?://)?([-\\w]+\\.[-\\w\\.]+)+\\w(:\\d+)?(/([-\\w/_\\.]*(\\?\\S+)?)?)*)@'"<span class='color-blue'>$1</span>"$text);
  33.         $post->setShortDescription($text);
  34.         $post->setContent($text);
  35.       }
  36.       $i $i 1;
  37.     }
  38.     return $posts;
  39.   }
  40.   public function social_posts_padding(mixed $postsRequest $request): mixed
  41.   {
  42.     $i 0;
  43.     foreach ($posts as $post) {
  44.       $posts[$i]->padding 0;
  45.       $posts[$i]->paddingImageFocusPub 0;
  46.       $posts[$i]->contenu_ null;
  47.       if ($post->getType()->getId() == '6') {
  48.         //                $path = 'https://nordinfo.spontaneit.fr/upload/images/' . $post->getillustrationfilName();
  49.         $path $request->getSchemeAndHttpHost() . '/upload/images/' $post->getillustrationfilName();
  50.         if (@getimagesize($path)) {
  51.           [$width$height] = getimagesize($path);
  52.           $posts[$i]->paddingImageFocusPub = ($height $width) * 100;
  53.         }
  54.       }
  55.       if ($post->getType()->getId() == && $post->getContent() != null) {
  56.         $posts[$i]->contenu_ $this->jsonToHtml($post->getContent(), $request);
  57.       }
  58.       if ($posts[$i]->getImageUrl() !== null && $posts[$i]->getImageUrl() !== "") {
  59.         try {
  60.           if (@getimagesize($posts[$i]->getImageUrl())) {
  61.             [$width$height] = getimagesize($post->getImageUrl());
  62.             $posts[$i]->padding = ($height $width) * 100;
  63.             if ($posts[$i]->padding 200) {
  64.               $posts[$i]->padding 200;
  65.             }
  66.           }
  67.         } catch (Exception $e) {
  68.         }
  69.       }
  70.       //      $posts[$i]->padding = 200;
  71.       $i $i 1;
  72.     }
  73.     return $posts;
  74.   }
  75.   public function focus_pub_img_dimensions(mixed $postsRequest $request): mixed
  76.   {
  77.     $i 0;
  78.     foreach ($posts as $post) {
  79.       if ($post->getType()->getId() === 6) {
  80.         $posts[$i]->widthImageFocusPub 0;
  81.         $posts[$i]->heightImageFocusPub 0;
  82.         $baseUrl $request->getSchemeAndHttpHost();
  83.         $basePath $this->kernel->getProjectDir() . '/public/upload/images/';
  84.         if (
  85.           $baseUrl === 'https://127.0.0.1:8000' ||
  86.           $baseUrl === 'https://127.0.0.1:8001' ||
  87.           $baseUrl === 'https://127.0.0.1:8002' ||
  88.           $baseUrl === 'https://localhost:8000' ||
  89.           $baseUrl === 'https://localhost:8001' ||
  90.           $baseUrl === 'https://localhost:8002'
  91.         ) {
  92.           $path $basePath $post->getillustrationfilName();
  93.         } else {
  94.           $path $basePath str_replace(' ''%20', (string) $post->getillustrationfilName());
  95.         }
  96.         if (@getimagesize($path)) {
  97.           [$width$height] = getimagesize($path);
  98.           $posts[$i]->widthImageFocusPub $width;
  99.           $posts[$i]->heightImageFocusPub $height;
  100.         }
  101.       }
  102.       ++$i;
  103.     }
  104.     return $posts;
  105.   }
  106.   
  107.   public function jsonToHtml(mixed $jsonRequest $request): mixed
  108.   {
  109.     $htmlArray json_decode((string) $jsontrue512);
  110.     if (!$htmlArray) {
  111.       return $json;
  112.     }
  113.     $html "";
  114.     $count 0;
  115.     foreach ($htmlArray['blocks'] as $item) {
  116.       switch ($item['type']) {
  117.         case "header2":
  118.           $html .= '<h2>' $item["data"]["text"] . '</h2>';
  119.           break;
  120.         case "header3":
  121.           $html .= '<h3>' $item["data"]["text"] . '</h3>';
  122.           break;
  123.         case "header4":
  124.           $html .= '<h4>' $item["data"]["text"] . '</h4>';
  125.           break;
  126.         case "list_ordered":
  127.           if ($item['data']['style'] == 'unordered') {
  128.             $html .= '<ol>';
  129.             foreach ($item['data']['items'] as $list_item) {
  130.               $html .= '<li>' $list_item '</li>';
  131.             }
  132.             $html .= '</ol>';
  133.           } else {
  134.             $html .= '<ol>';
  135.             foreach ($item['data']['items'] as $list_item) {
  136.               $html .= '<li>' $list_item '</li>';
  137.             }
  138.             $html .= '</ol>';
  139.           }
  140.           break;
  141.         case "list_unordered":
  142.           if ($item['data']['style'] == 'unordered') {
  143.             $html .= '<ul>';
  144.             foreach ($item['data']['items'] as $list_item) {
  145.               $html .= '<li>' $list_item '</li>';
  146.             }
  147.             $html .= '</ul>';
  148.           } else {
  149.             $html .= '<ol>';
  150.             foreach ($item['data']['items'] as $list_item) {
  151.               $html .= '<li>' $list_item '</li>';
  152.             }
  153.             $html .= '</ol>';
  154.           }
  155.           break;
  156.         case "paragraph":
  157.           $html .= '<p>' $item["data"]["text"] . '</p>';
  158.           break;
  159.         case "image":
  160.           $alt '';
  161.           if (strlen((string) $item['data']['alt']) > 0) {
  162.             $alt $item['data']['alt'];
  163.           } else if (strlen((string) $item['data']['caption']) > 0) {
  164.             $alt 'Illustration';
  165.           }
  166.           $class_img "";
  167.           if ($item['data']['responsive'] == true) {
  168.             $class_img "img-fluid";
  169.           }
  170.           $html .= (isset($item['data']['file']['url'])) ? '<figure aria-label="' $item['data']['caption'] . '"><img src="' $item['data']['file']['url'] . '" alt="' $alt '" width="100%" height="auto" class="' $class_img '"><figcaption>' $item['data']['caption'] . '</figcaption></figure>' null;
  171.           break;
  172.         case "embed":
  173.           switch ($item['data']['service']) {
  174.             case "youtube":
  175.               $html .= '<p class="py-2 m-0"><a href="#skipmap' $item['data']['embed'] . '" id="backmap' $item['data']['embed'] . '" class="sr-only sr-only-focusable bg-white">Passer la vidéo</a></p>';
  176.               $html .= '<div class="videoWrapper"><iframe width="" height="" src="' $item['data']['embed'] . '" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div><figcaption>' $item['data']['caption'] . '</figcaption>';
  177.               $html .= '<p class="py-2 m-0"><a href="#backmap' $item['data']['embed'] . '" id="skipmap' $item['data']['embed'] . '" class="sr-only sr-only-focusable bg-white no-after">Revenir avant la vidéo</a></p>';
  178.               break;
  179.           }
  180.           break;
  181.         case "description":
  182.           $class_alignment "";
  183.           if ($item['data']['alignment'] == "center") {
  184.             $class_alignment "text-center";
  185.           }
  186.           $html .= '<p class="short-desc ' $class_alignment '">' $item['data']['text'] . '</p>';
  187.           break;
  188.         case "quote":
  189.           $html .= '<blockquote class="blockquote"><p class="mb-0"><strong>' $item['data']['text'] . '</strong></p>';
  190.           if (strlen((string) $item['data']['caption']) > 0) {
  191.             $html .= '<footer class="blockquoteFooter">' $item['data']['caption'] . '</footer>';
  192.           }
  193.           $html .= '</blockquote>';
  194.           break;
  195.         case "box":
  196.           $html .= '<div class="boxText"><h2 class="__title">' $item['data']['caption'] . '</h2>';
  197.           if (strlen((string) $item['data']['text']) > 0) {
  198.             $html .= '<p class="__desc">' $item['data']['text'] . '</p>';
  199.           }
  200.           $html .= '</div>';
  201.           break;
  202.         case "raw":
  203.           $html .= '<div class="rawHtml" style="margin:1em 0;">' $item['data']['html'] . '</div>';
  204.           break;
  205.         case "carousel":
  206.           $htmlImages '';
  207.           $i 0;
  208.           foreach ($item['data']['images'] as $image) {
  209.             $alt '';
  210.             if (strlen((string) $image['alt']) > 0) {
  211.               $alt $image['alt'];
  212.             } else if (strlen((string) $image['caption']) > 0) {
  213.               $alt 'Illustration';
  214.             }
  215.             $filename $image['file'];
  216.             $file_headers = @get_headers($filename);
  217.             if ($file_headers[0] == 'HTTP/1.0 404 Not Found') {
  218.               $image['width'] = '0';
  219.               $image['height'] = '0';
  220.             } else if ($file_headers[0] == 'HTTP/1.0 302 Found' && $file_headers[7] == 'HTTP/1.0 404 Not Found') {
  221.               $image['width'] = '0';
  222.               $image['height'] = '0';
  223.             } else {
  224.               $image['width'] = null;
  225.               $image['height'] = null;
  226.               try {
  227.                 [$width$height] = getimagesize($image['file']);
  228.                 $image['width'] = $width;
  229.                 $image['height'] = $height;
  230.               } catch (Exception) {
  231.               }
  232.             }
  233.             $hyphen '';
  234.             if (strlen((string) $image['caption']) > 0) {
  235.               $hyphen ' - ';
  236.             }
  237.             
  238.             $figcaption '<figcaption>' . ($i 1) . '/' sizeof($item['data']['images']) . $hyphen $image['caption'] . '</figcaption>';
  239.             //$htmlImages .= '<figure aria-label="' . ($i + 1) . '/' . sizeof($item['data']['images']) . $hyphen . $image['caption'] . '"><img src="' . $image['file'] . '" width="100%" height="auto" alt="' . $alt . '">' . $figcaption . '</figure><br><br>';
  240.             $htmlImages .= '<li class="glide__slide" data-pw data-pw-img-src="' $image['file'] . '" data-pw-size="' $image['width'] . 'x' $image['height'] . '"><figure><div class="__img-wrapper" aria-label="' $alt '" data-pw-img-alt="' $alt '" role="img" style="background-image:url(' $image['file'] . ');"></div>' $figcaption '</figure></li>';
  241.             $i++;
  242.           }
  243.           $html .= '
  244.           <div class="glide carouselMain" data-glide-pw>
  245.           <div class="glide__track" data-glide-el="track">
  246.             <ul class="glide__slides">' $htmlImages '</ul>
  247.           </div>
  248.           <div class="glide__arrows" data-glide-el="controls">
  249.             <button class="glide__arrow glide__arrow--left" data-glide-dir="<">
  250.               <svg xmlns="http://www.w3.org/2000/svg" width="15.333" height="8.975" viewBox="0 0 15.333 8.975">
  251.                 <path id="Chevron"
  252.                       d="M7.133,15.021.219,8.187a.729.729,0,0,1,0-1.041L7.133.312a1.089,1.089,0,0,1,1.526,0,1.059,1.059,0,0,1,0,1.508L2.744,7.667,8.66,13.512a1.06,1.06,0,0,1,0,1.509,1.089,1.089,0,0,1-1.526,0"
  253.                       transform="translate(0 8.975) rotate(-90)" fill="#5ac8fa"/>
  254.               </svg>
  255.               </button>
  256.             <button class="glide__arrow glide__arrow--right" data-glide-dir=">">
  257.               <svg xmlns="http://www.w3.org/2000/svg" width="15.333" height="8.975" viewBox="0 0 15.333 8.975">
  258.                 <path id="Chevron"
  259.                       d="M7.133,15.021.219,8.187a.729.729,0,0,1,0-1.041L7.133.312a1.089,1.089,0,0,1,1.526,0,1.059,1.059,0,0,1,0,1.508L2.744,7.667,8.66,13.512a1.06,1.06,0,0,1,0,1.509,1.089,1.089,0,0,1-1.526,0"
  260.                       transform="translate(0 8.975) rotate(-90)" fill="#5ac8fa"/>
  261.               </svg>
  262.             </button>
  263.           </div>
  264.           </div>
  265.           ';
  266.           break;
  267.         case "link_internal":
  268.           $class_link_services '';
  269.           if (
  270.             str_contains((string) $item['data']['url'], 'https://serviceslenord.spontaneit.fr/') ||
  271.             str_contains((string) $item['data']['url'], 'https://serviceslenord.spontaneit.fr') ||
  272.             str_contains((string) $item['data']['url'], 'https://www.serviceslenord.spontaneit.fr/') ||
  273.             str_contains((string) $item['data']['url'], 'https://www.serviceslenord.spontaneit.fr') ||
  274.             str_contains((string) $item['data']['url'], 'https://services.lenord.fr/') ||
  275.             str_contains((string) $item['data']['url'], 'https://services.lenord.fr') ||
  276.             str_contains((string) $item['data']['url'], 'https://www.services.lenord.fr/') ||
  277.             str_contains((string) $item['data']['url'], 'https://www.services.lenord.fr')
  278.           ) {
  279.             $class_link_services 'linkBlock--services';
  280.           }
  281.           $html .= '<a href="' $item['data']['url'] . '" class="linkBlock linkBlock--internal ' $class_link_services '">';
  282.           $html .= '<div class="linkBlock__inner">';
  283.           $html .= '<div>';
  284.           $html .= '<span class="linkBlock__icon"><svg id="ec08912c-f4c9-4607-ad0f-018158ab53da" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 555 442.63"><path d="M560.18,272.36a40.54,40.54,0,0,0,4.14-8.57,29.22,29.22,0,0,0-.63-18.37c-.26-.69-.75-1.22-1.06-1.89-.09-.19-.21-.37-.31-.56a29.16,29.16,0,0,0-10.19-11.82L334.4,41.91a29.48,29.48,0,1,0-38.68,44.5l160.9,139.85H40a29.48,29.48,0,0,0,0,58.95H457.25L295.7,425.59a29.47,29.47,0,0,0,38.66,44.5L555.43,278c.2-.18.31-.41.5-.59.75-.7,1.72-1,2.41-1.79A27.39,27.39,0,0,0,560.18,272.36Z" transform="translate(-10.5 -34.69)"/></svg></span>';
  285.           $html .= '</div>';
  286.           $html .= '<div>';
  287.           $html .= '<span>' $item['data']['text'] . '</span>';
  288.           $html .= '</div>';
  289.           $html .= '</div>';
  290.           $html .= '</a>';
  291.           break;
  292.         case "link_procedure":
  293.           $html .= '<a href="' $item['data']['url'] . '" class="linkBlock linkBlock--procedure">';
  294.           $html .= '<div class="linkBlock__inner">';
  295.           $html .= '<div>';
  296.           $html .= '<span class="linkBlock__icon"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><style>svg{fill:#17323f}</style><path d="M362.7 19.3L314.3 67.7 444.3 197.7l48.4-48.4c25-25 25-65.5 0-90.5L453.3 19.3c-25-25-65.5-25-90.5 0zm-71 71L58.6 323.5c-10.4 10.4-18 23.3-22.2 37.4L1 481.2C-1.5 489.7 .8 498.8 7 505s15.3 8.5 23.7 6.1l120.3-35.4c14.1-4.2 27-11.8 37.4-22.2L421.7 220.3 291.7 90.3z"/></svg></span>';
  297.           $html .= '</div>';
  298.           $html .= '<div>';
  299.           $html .= '<span>' $item['data']['text'] . '</span>';
  300.           $html .= '</div>';
  301.           $html .= '</div>';
  302.           $html .= '</a>';
  303.           break;
  304.         case "link_external":
  305.           $class_link_services '';
  306.           if (
  307.             str_contains((string) $item['data']['url'], 'https://serviceslenord.spontaneit.fr/') ||
  308.             str_contains((string) $item['data']['url'], 'https://serviceslenord.spontaneit.fr') ||
  309.             str_contains((string) $item['data']['url'], 'https://www.serviceslenord.spontaneit.fr/') ||
  310.             str_contains((string) $item['data']['url'], 'https://www.serviceslenord.spontaneit.fr') ||
  311.             str_contains((string) $item['data']['url'], 'https://services.lenord.fr/') ||
  312.             str_contains((string) $item['data']['url'], 'https://services.lenord.fr') ||
  313.             str_contains((string) $item['data']['url'], 'https://www.services.lenord.fr/') ||
  314.             str_contains((string) $item['data']['url'], 'https://www.services.lenord.fr')
  315.           ) {
  316.             $class_link_services 'linkBlock--services';
  317.           }
  318.           $html .= '<a href="' $item['data']['url'] . '" class="linkBlock linkBlock--external ' $class_link_services '">';
  319.           $html .= '<div class="linkBlock__inner">';
  320.           $html .= '<div>';
  321.           $html .= '<span class="linkBlock__icon"><svg id="f2c09b3a-291a-4f9b-af4e-4c54c8628938" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480.62 460.76"><g id="a923b6ed-2241-4971-af5b-20b676d74906" data-name="Path 691"><path d="M193.42,486.38l-4.1-.84-27.54-1.45-4.17-2.26a132.48,132.48,0,0,1-96.85-78.05,279.57,279.57,0,0,1-12.59-46.6l-.48-2.71L49.84,323c1.71-6.51,3.28-12.39,5.21-18.24A137,137,0,0,1,92.4,246.46l28.65-25.78c13.14-12.56,30.74-14.74,44.3-5.17l-27.58,39c6.1,4.28,13.55,3,15.85,1.09l-29,26.15a88.92,88.92,0,0,0-24.11,37.82c-1.45,4.41-2.63,8.78-3.81,13.23l-1,18.58a231.66,231.66,0,0,0,9.5,34.86c10.91,25.29,34.82,44.1,63.41,49l4,1.05c.49.16,1,.35,1.48.54l13.33.7c.5-.12,1-.24,1.51-.33l3.33-.47a89.55,89.55,0,0,0,56.45-25c15.75-14.44,31-28.44,46.57-41.95a88.54,88.54,0,0,0,31.86-55.05c6-32.36-6.12-64.32-31.62-84.07l29.26-37.78a132.88,132.88,0,0,1,49.47,130,135.32,135.32,0,0,1-48.16,83.47c-14.66,12.78-29.64,26.5-44.63,40.22a137,137,0,0,1-83.31,37.69Zm58.16-167.7A134.55,134.55,0,0,1,202.08,187a135.87,135.87,0,0,1,47.17-81.74C259.87,96,270.82,86,281.71,76.1L297.23,62a134.34,134.34,0,0,1,80.41-35.07,30.08,30.08,0,0,1,4.44-1l2.26-.33,30.33,1.59,3.22,1.9A136.7,136.7,0,0,1,525,135.83c.77,3.87,1.35,7.73,1.91,11.58l1.45,9.08-2.52,32.57-4,12.72a128.1,128.1,0,0,1-35.89,60.09c-9.5,9.2-20.86,20-33.11,29.72L423.1,254.15c10.52-8.35,20.88-18.21,29.75-26.8a81.47,81.47,0,0,0,23-38.64l3.52-11.21,1-18.41-.75-4.82c-.42-3-.84-6-1.44-8.88A89.08,89.08,0,0,0,407,75.67a36,36,0,0,1-4.88-1.26L388,73.66a27.36,27.36,0,0,1-3.88.69,87.81,87.81,0,0,0-54.62,22.93l-15.57,14.15c-11.15,10.15-22.37,20.38-33.68,30.23a88.87,88.87,0,0,0-31.09,53.75c-6.24,32.78,6,65.39,31.89,85.61Z" transform="translate(-47.69 -25.62)"/></g></svg></span>';
  322.           $html .= '</div>';
  323.           $html .= '<div>';
  324.           $html .= '<span>' $item['data']['text'] . '</span>';
  325.           $html .= '</div>';
  326.           $html .= '</div>';
  327.           $html .= '</a>';
  328.           break;
  329.         case "img_url":
  330.           $alt '';
  331.           if (strlen((string) $item['data']['alt']) > 0) {
  332.             $alt $item['data']['alt'];
  333.           } else if (strlen((string) $item['data']['caption']) > 0) {
  334.             $alt 'Illustration';
  335.           }
  336.           $class_img "img-fluid";
  337.           $html .= (isset($item['data']['url'])) ? '<figure aria-label="' $item['data']['caption'] . '"><img src="' $item['data']['url'] . '" alt="' $alt '" width="100%" height="auto" class="' $class_img '"><figcaption>' $item['data']['caption'] . '</figcaption></figure>' null;
  338.           break;
  339.         case "mailto":
  340.           //$item['data']['name']
  341.           //$item['data']['email']
  342.           $custom_form $this->em->getRepository(CustomForm::class)->findOneBy(array('email' => $item['data']['email']));
  343.           if ($custom_form == null) {
  344.             $custom_form = new CustomForm;
  345.             $custom_form->setEmail($item['data']['email'])
  346.               ->setDestinataire($item['data']['name'])
  347.               ->setAlias(uniqid(''true));
  348.             $this->em->persist($custom_form);
  349.             $this->em->flush();
  350.           }
  351.           $html .= '<a href="mailto:' $item['data']['email'] . '" class="linkBlock">';
  352.           $html .= '<div class="linkBlock__inner">';
  353.           $html .= '<div>';
  354.           $html .= '<span class="linkBlock__icon"><?xml version="1.0" encoding="utf-8"?>
  355.           <svg version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
  356.             viewBox="0 0 283.5 283.5" style="enable-background:new 0 0 283.5 283.5;" xml:space="preserve">
  357.           <path id="envelope-solid" d="M263.9,109.4c1.2-1,3.1-0.9,4.1,0.4c0.5,0.5,0.7,1.2,0.7,2v101.5
  358.             c0,13.1-10.6,23.8-23.7,23.8H38.5c-13.2,0-23.8-10.7-23.8-23.8V111.8c0-1.6,1.3-2.9,2.9-3c0.7,0,1.4,0.2,1.9,0.7
  359.             c11.1,8.6,25.9,19.6,76.5,56.4c10.5,7.6,28.1,23.7,45.7,23.6c17.7,0.1,35.7-16.3,45.8-23.6C238.2,129,252.9,118,263.9,109.4z
  360.             M141.8,173.5c11.5,0.2,28.1-14.5,36.4-20.5c65.8-47.8,70.8-52,86-63.9c2.9-2.3,4.6-5.7,4.6-9.4v-9.4c0-13.2-10.6-23.8-23.8-23.8
  361.             c0,0,0,0,0,0H38.5c-13.2,0-23.8,10.7-23.8,23.8v9.4c0,3.7,1.7,7.1,4.6,9.4c15.2,11.9,20.2,16.1,86,63.9
  362.             C113.7,159,130.2,173.7,141.8,173.5z"/>
  363.           </svg></span>';
  364.           $html .= '</div>';
  365.           $html .= '<div>';
  366.           $html .= '<span>' $item['data']['name'] . '</span>';
  367.           $html .= '</div>';
  368.           $html .= '</div>';
  369.           $html .= '</a>';
  370.           break;
  371.         case "link_download":
  372.           $stringFileSize $item['data']['file']['fileSize'];
  373.           $stringKB " KB";
  374.           $stringMB " MB";
  375.           if (str_contains((string) $stringFileSize$stringKB)) {
  376.             $stringFileSize str_replace($stringKB"", (string) $stringFileSize);
  377.             $fileSize floatval($stringFileSize);
  378.             $fileSize $fileSize 1024;
  379.             if ($fileSize 0.01) {
  380.               $fileSize number_format($fileSize3);
  381.             }
  382.             if ($fileSize >= 0.01) {
  383.               $fileSize number_format($fileSize2);
  384.             }
  385.             $stringFileSize $fileSize " <abbr title=\"mégaoctet\">Mo</abbr>";
  386.           } else if (str_contains((string) $stringFileSize$stringMB)) {
  387.             $stringFileSize str_replace($stringMB"", (string) $stringFileSize);
  388.             $fileSize floatval($stringFileSize);
  389.             $stringFileSize $fileSize " <abbr title=\"mégaoctet\">Mo</abbr>";
  390.           }
  391.           $html .= '<a href="' $item['data']['file']['url'] . '" class="linkBlock linkBlock--download" download>';
  392.           $html .= '<div class="linkBlock__inner">';
  393.           $html .= '<div>';
  394.           $html .= '<span class="linkBlock__icon"><svg id="f3ce6478-5c65-4999-af52-59a99b9cbf14" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M481.79,453.6H309.33L463.76,275.91a24.2,24.2,0,1,0-36.54-31.74L312.42,376.25V34.2a24.21,24.21,0,0,0-48.41,0V376.78L148.75,244.15a24.2,24.2,0,1,0-36.53,31.74L266.66,453.6H94.21a24.2,24.2,0,1,0,0,48.4H481.79a24.2,24.2,0,0,0,0-48.4Z"/></svg></span>';
  395.           $html .= '</div>';
  396.           $html .= '<div>';
  397.           $html .= '<span>' $item['data']['textButton'] . ' (<span>' strtoupper((string) $item['data']['file']['fileExtension']) . '</span> - ' $stringFileSize ')</span>';
  398.           $html .= '</div>';
  399.           $html .= '</div>';
  400.           $html .= '</a>';
  401.           break;
  402.         case "card_contact":
  403.           $contact $this->em->getRepository(Contact::class)->getContact($item['data']['id']);
  404.           $html .= '<div class="cardContact">';
  405.           $html .= '<div class="cardContact__inner">';
  406.           $html .= '<div>';
  407.           $html .= '<div class="cardContact__img"><img src="/upload/images/' $contact->getPicture() . '" alt=""></div>';
  408.           $html .= '</div>';
  409.           $html .= '<div>';
  410.           $html .= '<div class="cardContact__name">' $contact->getFirstName() . ' ' $contact->getLastName() . '</div>';
  411.           $html .= '<div class="cardContact__desc">' $contact->getShortDescription() . '</div>';
  412.           $html .= '</div>';
  413.           $html .= '<div>';
  414.           $html .= '<a href="https://lenord.fr/l-institution/les-conseillers-departementaux/' $contact->getSlug() . '">Contacter</a>';
  415.           $html .= '</div>';
  416.           $html .= '</div>';
  417.           $html .= '</div>';
  418.           break;
  419.         case "service":
  420.           $service $this->em->getRepository(Service::class)->getService($item['data']['id']);
  421.           if ($service->getStatut() !== null && $service->getStatut()->getId() == 5) {
  422.             $domain "https://services.lenord.fr/";
  423.             if ($request->getSchemeAndHttpHost() == 'https://nordinfo.spontaneit.fr') {
  424.               $domain "https://serviceslenord.spontaneit.fr/";
  425.             }
  426.             $html .= '<a href="' $domain $service->getAliasUrl() . '" class="linkBlock linkBlock--external linkBlock--services" target="_blank">';
  427.             $html .= '<div class="linkBlock__inner">';
  428.             $html .= '<div>';
  429.             $html .= '<span class="linkBlock__icon"><svg id="f2c09b3a-291a-4f9b-af4e-4c54c8628938" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480.62 460.76"><g id="a923b6ed-2241-4971-af5b-20b676d74906" data-name="Path 691"><path d="M193.42,486.38l-4.1-.84-27.54-1.45-4.17-2.26a132.48,132.48,0,0,1-96.85-78.05,279.57,279.57,0,0,1-12.59-46.6l-.48-2.71L49.84,323c1.71-6.51,3.28-12.39,5.21-18.24A137,137,0,0,1,92.4,246.46l28.65-25.78c13.14-12.56,30.74-14.74,44.3-5.17l-27.58,39c6.1,4.28,13.55,3,15.85,1.09l-29,26.15a88.92,88.92,0,0,0-24.11,37.82c-1.45,4.41-2.63,8.78-3.81,13.23l-1,18.58a231.66,231.66,0,0,0,9.5,34.86c10.91,25.29,34.82,44.1,63.41,49l4,1.05c.49.16,1,.35,1.48.54l13.33.7c.5-.12,1-.24,1.51-.33l3.33-.47a89.55,89.55,0,0,0,56.45-25c15.75-14.44,31-28.44,46.57-41.95a88.54,88.54,0,0,0,31.86-55.05c6-32.36-6.12-64.32-31.62-84.07l29.26-37.78a132.88,132.88,0,0,1,49.47,130,135.32,135.32,0,0,1-48.16,83.47c-14.66,12.78-29.64,26.5-44.63,40.22a137,137,0,0,1-83.31,37.69Zm58.16-167.7A134.55,134.55,0,0,1,202.08,187a135.87,135.87,0,0,1,47.17-81.74C259.87,96,270.82,86,281.71,76.1L297.23,62a134.34,134.34,0,0,1,80.41-35.07,30.08,30.08,0,0,1,4.44-1l2.26-.33,30.33,1.59,3.22,1.9A136.7,136.7,0,0,1,525,135.83c.77,3.87,1.35,7.73,1.91,11.58l1.45,9.08-2.52,32.57-4,12.72a128.1,128.1,0,0,1-35.89,60.09c-9.5,9.2-20.86,20-33.11,29.72L423.1,254.15c10.52-8.35,20.88-18.21,29.75-26.8a81.47,81.47,0,0,0,23-38.64l3.52-11.21,1-18.41-.75-4.82c-.42-3-.84-6-1.44-8.88A89.08,89.08,0,0,0,407,75.67a36,36,0,0,1-4.88-1.26L388,73.66a27.36,27.36,0,0,1-3.88.69,87.81,87.81,0,0,0-54.62,22.93l-15.57,14.15c-11.15,10.15-22.37,20.38-33.68,30.23a88.87,88.87,0,0,0-31.09,53.75c-6.24,32.78,6,65.39,31.89,85.61Z" transform="translate(-47.69 -25.62)"/></g></svg></span>';
  430.             $html .= '</div>';
  431.             $html .= '<div>';
  432.             $html .= '<span>' $service->getTitre() . '</span>';
  433.             $html .= '</div>';
  434.             $html .= '</div>';
  435.             $html .= '</a>';
  436.           }
  437.           break;
  438.         case "youtubeEmbed":
  439.           $videoID '';
  440.           if (str_contains((string) $item['data']['url'], '/watch?v=')) {
  441.             $videoID substr((string) $item['data']['url'], strpos((string) $item['data']['url'], '/watch?v=') + 911);
  442.           }
  443.           if (str_contains((string) $item['data']['url'], 'https://youtu.be/')) {
  444.             $videoID substr((string) $item['data']['url'], 1711);
  445.           }
  446.           if (str_contains((string) $item['data']['url'], 'https://www.youtube.com/embed/')) {
  447.             $videoID substr((string) $item['data']['url'], 3011);
  448.           }
  449.           //$title = $this->getVideoTitle($videoID, 'AIzaSyBK8eEKobOxbxp7QubTRnYFDhM0T5F87E0');
  450.           $html .= '<p class="py-2 m-0"><a href="#skipmap' $videoID '" id="backmap' $videoID '" class="sr-only sr-only-focusable bg-white">Passer la vidéo</a></p>';
  451.           $html .= '<div class="videoWrapper">';
  452.           $html .= '<iframe src="https://www.youtube.com/embed/' $videoID '" title="' htmlspecialchars($item['data']['title'], ENT_QUOTES'UTF-8') . '" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>';
  453.           $html .= '</iframe>';
  454.           $html .= '</div>';
  455.           $html .= '<p class="py-2 m-0"><a href="#backmap' $videoID '" id="skipmap' $videoID '" class="sr-only sr-only-focusable bg-white no-after">Revenir avant la vidéo</a></p>';
  456.           break;
  457.         case "wemap":
  458.           $mapID strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/''-'$item['data']['text'])));
  459.           $html .= '<p class="py-2 m-0"><a href="#skip-' $mapID '" id="back-' $mapID '" class="sr-only sr-only-focusable bg-white">Passer la carte</a></p>';
  460.           $html .= '<div class="wemapContainer">';
  461.           $html .= '
  462.               <iframe
  463.                   src="' $item['data']['url'] . '"
  464.                   frameborder="0"
  465.                   allowfullscreen
  466.                   allowtransparency
  467.                   allow="geolocation; camera; accelerometer; gyroscope; magnetometer; fullscreen"
  468.                   title="' htmlspecialchars($item['data']['text'], ENT_QUOTES'UTF-8') . '">
  469.               </iframe>
  470.           ';
  471.           $html .= '</div>';
  472.           $html .= '<p class="py-2 m-0"><a href="#back-' $mapID '" id="skip-' $mapID '" class="sr-only sr-only-focusable bg-white no-after">Revenir avant la carte</a></p>';
  473.           break;
  474.         case "accordion":
  475.           $html .= '<div class="accordion accordionEditorJs" id="accordion-editorjs-'.$count.'">
  476.       <div class="card">
  477.         <a href="#" class="card-header collapsed" data-focus-content-target="verify" data-toggle="collapse" data-target="#collapse'.$count.'" aria-expanded="true" aria-controls="collapseOne">
  478.           <div class="container">
  479.             <div class="__inner">
  480.               <div class="__col-info">
  481.                 <div class="__title" id="headingOne">'.$item['data']['title'].'</div>
  482.               </div>
  483.               <div class="__col-arrow">
  484.                 <svg aria-hidden="true" focusable="false" data-name="Calque 1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 283.5 283.5">
  485.                   <g id="Chevron_horizontal" data-name="Bouton retour">
  486.                     <path id="Chevron" d="M7.09,190.21l125.1-126.6a13.4,13.4,0,0,1,18.9-.2l.2.2,125.1,126.6a19.92,19.92,0,0,1,0,27.9,19.4,19.4,0,0,1-27.4.2l-.2-.2-107-108.3-107,108.3a19.4,19.4,0,0,1-27.4.2l-.2-.2a19.83,19.83,0,0,1-.1-27.9"/>
  487.                   </g>
  488.                 </svg>
  489.               </div>
  490.             </div>
  491.           </div>
  492.         </a>
  493.         <div id="collapse'.$count.'" class="collapse" aria-labelledby="headingOne" data-parent="#accordion-editorjs-'.$count.'">
  494.           <div class="card-body">
  495.             <div class="container pt-2 pb-2">
  496.               '.$item['data']['content'].'
  497.             </div>
  498.           </div>
  499.         </div>
  500.       </div>
  501.     </div>';
  502.           break;
  503.       }
  504.       $count++;
  505.     }
  506.     return $html;
  507.   }
  508.   public function checkboxes_get_description(mixed $postsRequest $request): mixed
  509.   {
  510.     $i 0;
  511.     foreach ($posts as $post) {
  512.       if ($post->getType()->getId() == || $post->getType()->getId() == 7) {
  513.         $post->setContent($this->jsonToHtml($post->getContent(), $request));
  514.       }
  515.       if ($post->getIllustrationFilName() == null && $post->getType()->getId() == 3) {
  516.         $event_type iterator_to_array($this->em->getRepository(EventType::class)->getPostEventType($post->getId()));
  517.         if (!empty($event_type)) {
  518.           switch ($event_type[0]['id']) {
  519.             case 1:
  520.               $posts[$i]->setDefautFil(true);
  521.               $posts[$i]->setIllustrationFilName("/img/images_defauts/spectacle_defaut.jpg");
  522.               break;
  523.             case 3:
  524.               $posts[$i]->setDefautFil(true);
  525.               $posts[$i]->setIllustrationFilName("/img/images_defauts/conference.jpg");
  526.               break;
  527.             case 4:
  528.               $posts[$i]->setDefautFil(true);
  529.               $posts[$i]->setIllustrationFilName("/img/images_defauts/salon.jpg");
  530.               break;
  531.             case 5:
  532.               $posts[$i]->setDefautFil(true);
  533.               $posts[$i]->setIllustrationFilName("/img/images_defauts/sport.jpg");
  534.               break;
  535.             case 6:
  536.             case 12:
  537.               $posts[$i]->setDefautFil(true);
  538.               $posts[$i]->setIllustrationFilName("/img/images_defauts/emploi.jpg");
  539.               break;
  540.             case 7:
  541.               $posts[$i]->setDefautFil(true);
  542.               $posts[$i]->setIllustrationFilName("/img/images_defauts/braderie.jpg");
  543.               break;
  544.             case 8:
  545.               $posts[$i]->setDefautFil(true);
  546.               $posts[$i]->setIllustrationFilName("/img/images_defauts/nature.jpg");
  547.               break;
  548.             case 9:
  549.             case 11:
  550.               $posts[$i]->setDefautFil(true);
  551.               $posts[$i]->setIllustrationFilName("/img/images_defauts/exposition.jpg");
  552.               break;
  553.             case 2:
  554.             case 10:
  555.               $posts[$i]->setDefautFil(true);
  556.               $posts[$i]->setIllustrationFilName("/img/images_defauts/fete.jpg");
  557.               break;
  558.           }
  559.         }
  560.       }
  561.       //Ajouter lieu 
  562.       if($post->getLieuNew() !== null){
  563.         $post->setLieu($post->getLieuNew()->getName());
  564.         $post->setVille($post->getLieuNew()->getVille());
  565.       }
  566.       $i++;
  567.     }
  568.     return $posts;
  569.   }
  570. }