src/Controller/AdminController.php line 69

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Repository\SectionsRepository;
  7. use App\Repository\LignesRepository;
  8. use App\Repository\PagesRepository;
  9. use App\Repository\BlocsRepository;
  10. use App\Repository\ContenusRepository;
  11. use App\Repository\CarouselsRepository;
  12. use App\Repository\TypesContenusRepository;
  13. use App\Repository\AccordeonsRepository;
  14. use App\Repository\ActualitesRepository;
  15. use App\Repository\DictionnaireRepository;
  16. use App\Entity\Sections;
  17. use App\Entity\Lignes;
  18. use App\Entity\Blocs;
  19. use App\Entity\Contenus;
  20. use Symfony\Component\Form\Extension\Core\Type\FileType;
  21. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  22. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  23. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  24. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  25. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  26. use Symfony\Component\Form\Extension\Core\Type\TextType;
  27. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  28. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  29. use Symfony\Component\HttpFoundation\File\UploadedFile;
  30. use Symfony\Component\HttpFoundation\Request;
  31. class AdminController extends AbstractController
  32. {
  33.     
  34.     /**
  35.      * @Route("/changer-locale/{locale}", name="changerLocale")
  36.      */
  37.     public function changerLocale($localeRequest $request)
  38.     {
  39.         $loc $request->getSession()->get('_locale');
  40.         $referer $request->headers->get('referer');
  41.       
  42.         if($locale == 'fr')
  43.         {
  44.             
  45.             $temp str_replace('/en/','/fr/',$referer);
  46.         }
  47.         if($locale == 'en')
  48.         {
  49.           
  50.             $temp str_replace('/fr/','/en/',$referer);
  51.            
  52.         }
  53.       
  54.         // On stocke la langue demandée dans la session
  55.         $request->getSession()->set('_locale'$locale);
  56.         
  57.       
  58.             if(!empty($temp))
  59.             {
  60.                 return $this->redirect($temp);
  61.             }
  62.             else
  63.             {
  64.                 return $this->redirect($this->generateUrl('app_industrialisation'));
  65.             }
  66.        
  67.     }
  68.      /**
  69.      * @Route("/maj-fichiers-translation", name="majFichiersTranslation")
  70.      */
  71.     public function majFichiersTranslation(DictionnaireRepository $dicoRepo)
  72.     {
  73.         $em $this->getDoctrine()->getManager();
  74.         $dictionnaire $dicoRepo->findAll();
  75.         /*$TabLang = ['en'];
  76.         foreach ($TabLang as $lang){
  77.          }*/
  78.         $contenuEn "<?php".PHP_EOL.
  79.             "return array(".PHP_EOL;
  80.         foreach ($dictionnaire as $ligne) {
  81.             $contenuEn .= '"'.$ligne->getCle().'"=>"'.$ligne->getEn().'",'.PHP_EOL;
  82.         }
  83.         $contenuEn .= ");".PHP_EOL.
  84.             "?>";
  85.         $document_root '../translations/';
  86.         // Création du fichier en.php
  87.         $e fopen($document_root."messages.en.php""a");
  88.         file_put_contents($document_root."messages.en.php"$contenuEn);
  89.         fclose($e);
  90.       
  91.         $contenuFr "<?php".PHP_EOL.
  92.             "return array(".PHP_EOL;
  93.         foreach ($dictionnaire as $ligne) {
  94.             $contenuFr .= '"'.$ligne->getCle().'"=>"'.$ligne->getFr().'",'.PHP_EOL;
  95.         }
  96.         $contenuFr .= ");".PHP_EOL.
  97.             "?>";
  98.         $document_root '../translations/';
  99.         // Création du fichier en.php
  100.         $e fopen($document_root."messages.fr.php""a");
  101.         file_put_contents($document_root."messages.fr.php"$contenuFr);
  102.         fclose($e);
  103.         return $this->redirect($this->generateUrl('adminDictionnaire'));
  104.     }
  105.     /**
  106.      * @Route("/admin", name="app_admin")
  107.      */
  108.     public function index(): Response
  109.     {
  110.         return $this->render('admin/index.html.twig', [
  111.             'controller_name' => 'AdminController',
  112.         ]);
  113.     }
  114.     /**
  115.      * @Route("/admin/addSection", name="app_addSection")
  116.      */
  117.     public function addSection(SectionsRepository $sectionsRepositoryLignesRepository $lignesRepositoryPagesRepository $pagesRepository,ActualitesRepository $actualitesRepositoryRequest $request): Response
  118.     {
  119.         
  120.         if(isset($_POST['page']))
  121.         {
  122.             $page $pagesRepository->findOneById($_POST['page']);
  123.         }
  124.         if(isset($_POST['actualite']))
  125.         {
  126.             $actu $actualitesRepository->findOneById($_POST['actualite']);
  127.         }
  128.         
  129.         $section = new Sections();
  130.        
  131.         if(!empty($_FILES))
  132.         {
  133.             if(!empty($_FILES['imageSection']['tmp_name']))
  134.             {
  135.                 $tmpName $_FILES['imageSection']['tmp_name'];
  136.                 $fileNameParts explode('.'$_FILES['imageSection']['name']);
  137.                 $ext end($fileNameParts);
  138.                 
  139.                 if(!empty($ext))
  140.                 {
  141.                     $name uniqid().'.'.$ext;
  142.                 $size $_FILES['imageSection']['size'];
  143.                 $error $_FILES['imageSection']['error'];
  144.                 move_uploaded_file($tmpName'../public/uploads/sections/'.$name);
  145.                 $section->setImage($name);
  146.                 }
  147.             }
  148.             if(!empty($_FILES['imageRond']['tmp_name']))
  149.             {
  150.                 $tmpName $_FILES['imageRond']['tmp_name'];
  151.                 $fileNameParts explode('.'$_FILES['imageRond']['name']);
  152.                 $ext end($fileNameParts);
  153.                 
  154.                 if(!empty($ext))
  155.                 {
  156.                     $name uniqid().'.'.$ext;
  157.                 $size $_FILES['imageRond']['size'];
  158.                 $error $_FILES['imageRond']['error'];
  159.                 move_uploaded_file($tmpName'../public/uploads/sections/'.$name);
  160.                 $section->setRond($name);
  161.                 }
  162.             }
  163.         }
  164.       
  165.         $section->setColor($_POST['couleurSection']);
  166.         $section->setOrdre($_POST['ordreSection']);
  167.         if(isset($_POST['page']))
  168.         {
  169.             $section->setPages($page);
  170.         }
  171.         if(isset($_POST['actualite']))
  172.         {
  173.             $section->setActualites($actu);
  174.         }
  175.       
  176.         $sectionsRepository->add($sectiontrue);
  177.         $ligne = new Lignes();
  178.         $ligne->setOrdre(1);
  179.         $ligne->setSections($section);
  180.         $lignesRepository->add($lignetrue);
  181.         $referer $request->headers->get('referer').'#section'.$section->getId();
  182.            return $this->redirect($referer);
  183.     }
  184.       /**
  185.      * @Route("/admin/addBloc/{ligne}/{type}", name="app_addBloc")
  186.      */
  187.     public function addBloc(SectionsRepository $sectionsRepositoryLignesRepository $lignesRepositoryBlocsRepository $blocsRepositoryRequest $request$ligne$type): Response
  188.     {
  189.         
  190.         $ligneT $lignesRepository->findOneById($ligne);
  191.         
  192.         $ligne = new Lignes();
  193.         $ligne->setSections($ligneT->getSections());
  194.         $ligne->setOrdre(1);
  195.         $lignesRepository->add($lignetrue);
  196.         if($type == 12)
  197.         {
  198.             $bloc = new Blocs();
  199.             $bloc->setLignes($ligne);
  200.             $bloc->SetType($type);
  201.             $blocsRepository->add($bloctrue);
  202.         }
  203.         if($type == 66)
  204.         {
  205.             $bloc = new Blocs();
  206.             $bloc->setLignes($ligne);
  207.             $bloc->SetType(6);
  208.             $blocsRepository->add($bloctrue);
  209.             
  210.             $bloc = new Blocs();
  211.             $bloc->setLignes($ligne);
  212.             $bloc->SetType(6);
  213.             $blocsRepository->add($bloctrue);
  214.         }
  215.         if($type == 444)
  216.         {
  217.             $bloc = new Blocs();
  218.             $bloc->setLignes($ligne);
  219.             $bloc->SetType(4);
  220.             $blocsRepository->add($bloctrue);
  221.             
  222.             $bloc = new Blocs();
  223.             $bloc->setLignes($ligne);
  224.             $bloc->SetType(4);
  225.             $blocsRepository->add($bloctrue);
  226.             $bloc = new Blocs();
  227.             $bloc->setLignes($ligne);
  228.             $bloc->SetType(4);
  229.             $blocsRepository->add($bloctrue);
  230.         }
  231.         if($type == 84)
  232.         {
  233.             $bloc = new Blocs();
  234.             $bloc->setLignes($ligne);
  235.             $bloc->SetType(8);
  236.             $blocsRepository->add($bloctrue);
  237.             
  238.             $bloc = new Blocs();
  239.             $bloc->setLignes($ligne);
  240.             $bloc->SetType(4);
  241.             $blocsRepository->add($bloctrue);
  242.         }
  243.         if($type == 48)
  244.         {
  245.             $bloc = new Blocs();
  246.             $bloc->setLignes($ligne);
  247.             $bloc->SetType(4);
  248.             $blocsRepository->add($bloctrue);
  249.             
  250.             $bloc = new Blocs();
  251.             $bloc->setLignes($ligne);
  252.             $bloc->SetType(8);
  253.             $blocsRepository->add($bloctrue);
  254.         }
  255.         if($type == 3333)
  256.         {
  257.             $bloc = new Blocs();
  258.             $bloc->setLignes($ligne);
  259.             $bloc->SetType(3);
  260.             $blocsRepository->add($bloctrue);
  261.             $bloc = new Blocs();
  262.             $bloc->setLignes($ligne);
  263.             $bloc->SetType(3);
  264.             $blocsRepository->add($bloctrue);
  265.             
  266.             $bloc = new Blocs();
  267.             $bloc->setLignes($ligne);
  268.             $bloc->SetType(3);
  269.             $blocsRepository->add($bloctrue);
  270.             
  271.             $bloc = new Blocs();
  272.             $bloc->setLignes($ligne);
  273.             $bloc->SetType(3);
  274.             $blocsRepository->add($bloctrue);       
  275.         }
  276.         $referer $request->headers->get('referer').'#bloc'.$bloc->getId();
  277.         return $this->redirect($referer);
  278.     }
  279.      /**
  280.      * @Route("/admin/addContent/{bloc}/{type}", name="app_addContent")
  281.      */
  282.     public function app_addContent(BlocsRepository $blocsRepository,ContenusRepository $contenusRepository,TypesContenusRepository $typesContenusRepositoryRequest $request$bloc$type): Response
  283.     {
  284.         
  285.         function replaceSpecialChar($str) {
  286.             $ch0 = array( 
  287.                 " "=>"_",
  288.                 "é"=>"e",
  289.                 "è"=>"e",
  290.                 "ê"=>"e",
  291.                 "ë"=>"e",
  292.                 "à"=>"a",
  293.                 "ç"=>"c",
  294.                 "("=>"_",
  295.                 ")"=>"_",
  296.                 "'"=>"_",
  297.                 "&"=>"_",
  298.                 "ù"=>"u",
  299.                     
  300.                     );
  301.                 $str strtr($str,$ch0);
  302.                 return $str;
  303.             }
  304.         $block $blocsRepository->findOneById($bloc);
  305.         $referer $request->headers->get('referer');
  306.        
  307.         if(isset($_POST['page']))
  308.         {
  309.             $page $pagesRepository->findOneById($_POST['page']);
  310.         }
  311.         if(isset($_POST['actualite']))
  312.         {
  313.             $actu $actualitesRepository->findOneById($_POST['actualite']);
  314.         }
  315.      
  316.        
  317.         
  318.         $contenu = new Contenus();
  319.         if($type == 'accordeon')
  320.         {
  321.             $typeCon $typesContenusRepository->findOneById(8);
  322.             $contenu->setBlocs($block);
  323.             $contenu->setTypesContenus($typeCon);
  324.             $contenusRepository->add($contenu,true);
  325.             return $this->redirectToRoute('app_accordeons_index', ['contenu'=>$contenu->getId()]);
  326.         }
  327.         if($type == 'carousel')
  328.         {
  329.             $typeCon $typesContenusRepository->findOneById(9);
  330.             $contenu->setBlocs($block);
  331.             $contenu->setTypesContenus($typeCon);
  332.             $contenusRepository->add($contenu,true);
  333.             return $this->redirectToRoute('app_carousels_index', ['contenu'=>$contenu->getId()]);
  334.         }
  335.         if($type == 'boxpictocarousel')
  336.         {
  337.             $typeCon $typesContenusRepository->findOneById(10);
  338.             $contenu->setBlocs($block);
  339.             $contenu->setTypesContenus($typeCon);
  340.             $contenusRepository->add($contenu,true);
  341.             return $this->redirectToRoute('app_carousels_index', ['contenu'=>$contenu->getId()]);
  342.         }
  343.         if($type == 'temoignage')
  344.         {
  345.             $typeCon $typesContenusRepository->findOneById(11);
  346.             $contenu->setBlocs($block);
  347.             $contenu->setTypesContenus($typeCon);
  348.             $contenusRepository->add($contenu,true);
  349.             return $this->redirectToRoute('app_temoignages_index', []);
  350.         }
  351.         if($type == 'chiffrescles' || $type == 'chiffrescles2' )
  352.         {
  353.            
  354.             if($type == 'chiffrescles')
  355.             {
  356.             $typeCon $typesContenusRepository->findOneById(5);
  357.             }
  358.             if($type == 'chiffrescles2')
  359.             {
  360.             $typeCon $typesContenusRepository->findOneById(6);
  361.             }
  362.             
  363.            
  364.             $form $this->createFormBuilder($contenu)
  365.             ->add('titreFr',TextareaType::class, [
  366.                 'attr' => ['class' => 'attached-input'],
  367.     
  368.                 'label' => false,
  369.                 'required' => false
  370.             ])
  371.         
  372.             ->add('titreEn',TextareaType::class, [
  373.                 'attr' => ['class' => 'attached-input'],
  374.     
  375.                 'label' => false,
  376.                 'required' => false
  377.             ])
  378.             ->add('texteFr',TextareaType::class, [
  379.                 'attr' => ['class' => 'attached-input'],
  380.     
  381.                 'label' => false,
  382.                 'required' => false
  383.             ])
  384.             ->add('texteEn',TextareaType::class, [
  385.                 'attr' => ['class' => 'attached-input'],
  386.     
  387.                 'label' => false,
  388.                 'required' => false
  389.             ])
  390.            
  391.     
  392.                 ->getForm();
  393.         
  394.         }
  395.         if($type == 'texte'  )
  396.         {
  397.             if($type == 'texte')
  398.             {
  399.             $typeCon $typesContenusRepository->findOneById(1);
  400.             }
  401.             
  402.             
  403.            
  404.             $form $this->createFormBuilder($contenu)
  405.             ->add('texteFr',TextareaType::class, [
  406.                 'attr' => ['class' => 'attached-input'],
  407.     
  408.                 'label' => false,
  409.                 'required' => false
  410.             ])
  411.             ->add('texteEn',TextareaType::class, [
  412.                 'attr' => ['class' => 'attached-input'],
  413.     
  414.                 'label' => false,
  415.                 'required' => false
  416.             ])
  417.             ->add('document',TextType::class, [
  418.                 'attr' => ['class' => 'attached-input'],
  419.     
  420.                 'label' => false,
  421.                 'required' => false
  422.             ])
  423.             ->add('titreFr',TextareaType::class, [
  424.                 'attr' => ['class' => 'attached-input'],
  425.     
  426.                 'label' => false,
  427.                 'required' => false
  428.             ])
  429.         
  430.             ->add('titreEn',TextareaType::class, [
  431.                 'attr' => ['class' => 'attached-input'],
  432.     
  433.                 'label' => false,
  434.                 'required' => false
  435.             ])
  436.     
  437.                 ->getForm();
  438.         
  439.         }
  440.         if($type == 'image')
  441.         {
  442.             $typeCon $typesContenusRepository->findOneById(2);
  443.             $form $this->createFormBuilder($contenu)
  444.             ->add('image'FileType::class, array('data_class' => null'required' => true'label' => false'empty_data' => 'ok'))
  445.           
  446.             ->add('lien',TextType::class, [
  447.                 'attr' => ['class' => 'attached-input'],
  448.     
  449.                 'label' => false,
  450.                 'required' => false
  451.             ])
  452.             ->add('titreFr',TextType::class, [
  453.                 'attr' => ['class' => 'attached-input'],
  454.     
  455.                 'label' => false,
  456.                 'required' => false
  457.             ])
  458.             ->add('titreEn',TextType::class, [
  459.                 'attr' => ['class' => 'attached-input'],
  460.     
  461.                 'label' => false,
  462.                 'required' => false
  463.             ])
  464.     
  465.                 ->getForm();
  466.         }
  467.         if($type == 'video')
  468.         {
  469.             $typeCon $typesContenusRepository->findOneById(3);
  470.             $form $this->createFormBuilder($contenu)
  471.             ->add('titreFr',TextareaType::class, [
  472.                 'attr' => ['class' => 'attached-input'],
  473.     
  474.                 'label' => false,
  475.                 'required' => false
  476.             ])
  477.             ->add('titreEn',TextareaType::class, [
  478.                 'attr' => ['class' => 'attached-input'],
  479.     
  480.                 'label' => false,
  481.                 'required' => false
  482.             ])
  483.             ->add('video',TextType::class, [
  484.                 'attr' => ['class' => 'attached-input'],
  485.     
  486.                 'label' => false,
  487.                 'required' => false
  488.             ])
  489.            
  490.                 ->getForm();
  491.         }
  492.         if($type == 'document')
  493.         {
  494.             $typeCon $typesContenusRepository->findOneById(14);
  495.             $modaltypeDoc $request->request->get('modal_select_doc');
  496.             $form $this->createFormBuilder($contenu)
  497.             ->add('document'FileType::class, array('data_class' => null'required' => true'label' => false'empty_data' => 'ok'))
  498.             ->add('image'FileType::class, array('data_class' => null'required' => true'label' => false'empty_data' => 'ok'))
  499.             ->add('titreFr',TextareaType::class, [
  500.                 'attr' => ['class' => 'attached-input'],
  501.     
  502.                 'label' => false,
  503.                 'required' => false
  504.             ])
  505.             ->add('titreEn',TextareaType::class, [
  506.                 'attr' => ['class' => 'attached-input'],
  507.     
  508.                 'label' => false,
  509.                 'required' => false
  510.             ])
  511.             ->add('modal',TextType::class, [
  512.                 'attr' => ['class' => 'attached-input'],
  513.     
  514.                 'label' => false,
  515.                 'required' => false,
  516.                 'data' => $modaltypeDoc
  517.             ])
  518.            
  519.         
  520.            
  521.                 ->getForm();
  522.         }
  523.         
  524.         if($type == 'avantage')
  525.         {
  526.          
  527.             if($type == 'avantage')
  528.             {
  529.             $typeCon $typesContenusRepository->findOneById(7);
  530.             }
  531.             $form $this->createFormBuilder($contenu)
  532.             ->add('image'FileType::class, array('data_class' => null'required' => false'label' => false'empty_data' => 'ok'))
  533.             ->add('titreFr',TextType::class, [
  534.                 'attr' => ['class' => 'attached-input'],
  535.     
  536.                 'label' => false,
  537.                 'required' => false
  538.             ])
  539.             
  540.             ->add('titreEn',TextType::class, [
  541.                 'attr' => ['class' => 'attached-input'],
  542.     
  543.                 'label' => false,
  544.                 'required' => false
  545.             ])
  546.             ->add('texteFr',TextareaType::class, [
  547.                 'attr' => ['class' => 'attached-input'],
  548.     
  549.                 'label' => false,
  550.                 'required' => false
  551.             ])
  552.             ->add('texteEn',TextareaType::class, [
  553.                 'attr' => ['class' => 'attached-input'],
  554.     
  555.                 'label' => false,
  556.                 'required' => false
  557.             ])
  558.     
  559.                 ->getForm();
  560.         }
  561.         if($type == 'button')
  562.         {
  563.          
  564.             if($type == 'button')
  565.             {
  566.                 $typeCon $typesContenusRepository->findOneById(12);
  567.                 $modaltype $request->request->get('modal_select');
  568.             }
  569.             $form $this->createFormBuilder($contenu)
  570.             
  571.             ->add('lien',TextType::class, [
  572.                 'attr' => ['class' => 'attached-input'],
  573.     
  574.                 'label' => false,
  575.                 'required' => false
  576.             ])
  577.             ->add('modal',TextType::class, [
  578.                 'attr' => ['class' => 'attached-input'],
  579.     
  580.                 'label' => false,
  581.                 'required' => false,
  582.                 'data' => $modaltype 
  583.             ])
  584.           
  585.             ->add('texteFr',TextareaType::class, [
  586.                 'attr' => ['class' => 'attached-input'],
  587.     
  588.                 'label' => false,
  589.                 'required' => false
  590.             ])
  591.             ->add('texteEn',TextareaType::class, [
  592.                 'attr' => ['class' => 'attached-input'],
  593.     
  594.                 'label' => false,
  595.                 'required' => false
  596.             ])
  597.                 ->getForm();
  598.         }
  599.         if($type == 'boxpicto')
  600.         {
  601.             if($type == 'boxpicto')
  602.             {
  603.             $typeCon $typesContenusRepository->findOneById(4);
  604.             }
  605.             if($type == 'avantage')
  606.             {
  607.             $typeCon $typesContenusRepository->findOneById(7);
  608.             }
  609.             $form $this->createFormBuilder($contenu)
  610.             ->add('image'FileType::class, array('data_class' => null'required' => false'label' => false'empty_data' => 'ok'))
  611.             ->add('titreFr',TextareaType::class, [
  612.                 'attr' => ['class' => 'attached-input'],
  613.     
  614.                 'label' => false,
  615.                 'required' => false
  616.             ])
  617.             ->add('titreEn',TextareaType::class, [
  618.                 'attr' => ['class' => 'attached-input'],
  619.     
  620.                 'label' => false,
  621.                 'required' => false
  622.             ])
  623.             ->add('texteFr',TextareaType::class, [
  624.                 'attr' => ['class' => 'attached-input'],
  625.     
  626.                 'label' => false,
  627.                 'required' => false
  628.             ])
  629.             ->add('texteEn',TextareaType::class, [
  630.                 'attr' => ['class' => 'attached-input'],
  631.     
  632.                 'label' => false,
  633.                 'required' => false
  634.             ])
  635.             
  636.             
  637.             ->add('video',TextType::class, [
  638.                 'attr' => ['class' => 'attached-input'],
  639.     
  640.                 'label' => false,
  641.                 'required' => false
  642.             ])
  643.     
  644.                 ->getForm();
  645.         }
  646.     
  647.             $form->handleRequest($request);
  648.             if ($form->isSubmitted()) {
  649.                 
  650.                 if($type == 'image' || $type == 'boxpicto' || $type == 'avantage' || $type == 'boutton')
  651.                 {
  652.                     $file $form->get('image')->getData();
  653.                     if($file != 'ok') {
  654.                         $path '/';
  655.                         $fileName str_replace(' ','_',$file->getClientOriginalName());
  656.                    
  657.                         $file->move(
  658.                             $this->getParameter('contenus_directory').$path,
  659.                             $fileName
  660.                         );
  661.                         $contenu->setImage($fileName);
  662.                     }
  663.                 }   
  664.                 if( $type == 'document' )
  665.                 {
  666.                     $file $form->get('document')->getData();
  667.                     if($file != 'ok') {
  668.                         $path '/';
  669.                         
  670.                         $fileName str_replace(' ','_',$file->getClientOriginalName());
  671.                         $file->move(
  672.                             $this->getParameter('contenus_directory').$path,
  673.                             $fileName
  674.                         );
  675.                         $contenu->setDocument($fileName);
  676.                     }
  677.                     $fileImage $form->get('image')->getData();
  678.                     
  679.                     if($fileImage != 'ok') {
  680.                         $path '/';
  681.                         $name $fileImage->getClientOriginalName();
  682.                         $fileNameImage $name.'.'.$fileImage->guessExtension();
  683.                         $fileImage->move(
  684.                             $this->getParameter('contenus_directory').$path,
  685.                             $fileNameImage
  686.                         );
  687.                         $contenu->setImage($fileNameImage);
  688.                     }
  689.                     else
  690.                     {
  691.                         $contenu->setImage($oldImg);
  692.                     } 
  693.                 }   
  694.                 if(isset($_POST['background']))
  695.                 {
  696.                     $contenu->setBackground($_POST['background']);
  697.                 }
  698.                 if(isset($_POST['couleur1']))
  699.                 {
  700.                     $contenu->setCouleur1($_POST['couleur1']);
  701.                 }
  702.                 $contenu->setBlocs($block);
  703.                 $contenu->setTypesContenus($typeCon);
  704.                 $contenusRepository->add($contenu,true);
  705.                 $urlReferer $_POST['redirection'].'#bloc'.$contenu->getBlocs()->getId();
  706.                 return $this->redirect($urlReferer);
  707.                 
  708.             }
  709.         
  710.         return $this->render('admin/addContenu.html.twig', [
  711.             'form' => $form->createView(),
  712.             'typeCon'=>$typeCon->getLibelle(),
  713.             'contenu'=>$contenu,
  714.             'referer' =>$referer
  715.            
  716.         ]);
  717.     }
  718.      /**
  719.      * @Route("/admin/editContent/{id}/{type}", name="app_editContent")
  720.      */
  721.     public function app_editContent(BlocsRepository $blocsRepository,ContenusRepository $contenusRepository,TypesContenusRepository $typesContenusRepositoryRequest $request$id$type): Response
  722.     {
  723.         
  724.         $contenu $contenusRepository->findOneById($id);
  725.         $oldImg $contenu->getImage();
  726.         $oldDoc $contenu->getDocument();
  727.        // $page = $contenu->getBlocs()->getLignes()->getSections()->getPages()->getRoute();
  728.         $referer $request->headers->get('referer');
  729.         
  730.        
  731.    
  732.     
  733.         if($type == 'button')
  734.         {
  735.          
  736.             if($type == 'button')
  737.             {
  738.                 $modaltype $request->request->get('modal_select');
  739.                 $typeCon $typesContenusRepository->findOneById(12);
  740.             }
  741.             $form $this->createFormBuilder($contenu)
  742.             ->add('lien',TextType::class, [
  743.                 'attr' => ['class' => 'attached-input'],
  744.     
  745.                 'label' => false,
  746.                 'required' => false
  747.             ])
  748.             ->add('modal',TextType::class, [
  749.                 'attr' => ['class' => 'attached-input'],
  750.     
  751.                 'label' => false,
  752.                 'required' => false,
  753.                 'data' => $modaltype
  754.             ])
  755.            
  756.             ->add('texteFr',TextareaType::class, [
  757.                 'attr' => ['class' => 'attached-input'],
  758.     
  759.                 'label' => false,
  760.                 'required' => false
  761.             ])
  762.             ->add('texteEn',TextareaType::class, [
  763.                 'attr' => ['class' => 'attached-input'],
  764.     
  765.                 'label' => false,
  766.                 'required' => false
  767.             ])
  768.                 ->getForm();
  769.         }
  770.         
  771.         if($type == 'document')
  772.         {
  773.             $typeCon $typesContenusRepository->findOneById(14);
  774.             $modaltypeDoc $request->request->get('modal_select_doc');
  775.             
  776.             $form $this->createFormBuilder($contenu)
  777.             ->add('document'FileType::class, array('data_class' => null'required' => true'label' => false'empty_data' => 'ok'))
  778.             ->add('image'FileType::class, array('data_class' => null'required' => true'label' => false'empty_data' => 'ok'))
  779.             ->add('titreFr',TextareaType::class, [
  780.                 'attr' => ['class' => 'attached-input'],
  781.     
  782.                 'label' => false,
  783.                 'required' => false
  784.             ])
  785.             ->add('titreEn',TextareaType::class, [
  786.                 'attr' => ['class' => 'attached-input'],
  787.     
  788.                 'label' => false,
  789.                 'required' => false
  790.             ])
  791.             ->add('modal',TextType::class, [
  792.                 'attr' => ['class' => 'attached-input'],
  793.     
  794.                 'label' => false,
  795.                 'required' => false,
  796.                 'data' => $modaltypeDoc
  797.             ])
  798.             
  799.         
  800.            
  801.                 ->getForm();
  802.         }
  803.         if($type == 'chiffrescles' || $type == 'chiffrescles2' )
  804.         {
  805.            
  806.             if($type == 'chiffrescles')
  807.             {
  808.             $typeCon $typesContenusRepository->findOneById(5);
  809.             }
  810.             if($type == 'chiffrescles2')
  811.             {
  812.             $typeCon $typesContenusRepository->findOneById(6);
  813.             }
  814.             
  815.            
  816.             $form $this->createFormBuilder($contenu)
  817.             ->add('titreFr',TextareaType::class, [
  818.                 'attr' => ['class' => 'attached-input'],
  819.     
  820.                 'label' => false,
  821.                 'required' => false
  822.             ])
  823.         
  824.             ->add('titreEn',TextareaType::class, [
  825.                 'attr' => ['class' => 'attached-input'],
  826.     
  827.                 'label' => false,
  828.                 'required' => false
  829.             ])
  830.             ->add('texteFr',TextareaType::class, [
  831.                 'attr' => ['class' => 'attached-input'],
  832.     
  833.                 'label' => false,
  834.                 'required' => false
  835.             ])
  836.             ->add('texteEn',TextareaType::class, [
  837.                 'attr' => ['class' => 'attached-input'],
  838.     
  839.                 'label' => false,
  840.                 'required' => false
  841.             ])
  842.            
  843.                 ->getForm();
  844.         
  845.         }
  846.         
  847.         if($type == 'texte'  )
  848.         {
  849.             if($type == 'texte')
  850.             {
  851.             $typeCon $typesContenusRepository->findOneById(1);
  852.             }
  853.             
  854.             
  855.            
  856.             $form $this->createFormBuilder($contenu)
  857.             ->add('texteFr',TextareaType::class, [
  858.                 'attr' => ['class' => 'attached-input'],
  859.     
  860.                 'label' => false,
  861.                 'required' => false
  862.             ])
  863.             ->add('texteEn',TextareaType::class, [
  864.                 'attr' => ['class' => 'attached-input'],
  865.     
  866.                 'label' => false,
  867.                 'required' => false
  868.             ])
  869.             ->add('document',TextType::class, [
  870.                 'attr' => ['class' => 'attached-input'],
  871.     
  872.                 'label' => false,
  873.                 'required' => false
  874.             ])
  875.             ->add('titreFr',TextareaType::class, [
  876.                 'attr' => ['class' => 'attached-input'],
  877.     
  878.                 'label' => false,
  879.                 'required' => false
  880.             ])
  881.         
  882.             ->add('titreEn',TextareaType::class, [
  883.                 'attr' => ['class' => 'attached-input'],
  884.     
  885.                 'label' => false,
  886.                 'required' => false
  887.             ])
  888.     
  889.                 ->getForm();
  890.         
  891.         }
  892.         if($type == 'accordeon')
  893.         {
  894.             $typeCon $typesContenusRepository->findOneById(8);
  895.             $form $this->createFormBuilder($contenu)
  896.            
  897.             ->add('titreFr',TextareaType::class, [
  898.                 'attr' => ['class' => 'attached-input'],
  899.     
  900.                 'label' => false,
  901.                 'required' => false
  902.             ])
  903.             ->add('titreEn',TextareaType::class, [
  904.                 'attr' => ['class' => 'attached-input'],
  905.     
  906.                 'label' => false,
  907.                 'required' => false
  908.             ])
  909.     
  910.                 ->getForm();
  911.         }
  912.         if($type == 'image')
  913.         {
  914.             $typeCon $typesContenusRepository->findOneById(2);
  915.             $form $this->createFormBuilder($contenu)
  916.             ->add('image'FileType::class, array('data_class' => null'required' => false'label' => false'empty_data' => 'ok'))
  917.             ->add('lien',TextType::class, [
  918.                 'attr' => ['class' => 'attached-input'],
  919.     
  920.                 'label' => false,
  921.                 'required' => false
  922.             ])
  923.             ->add('titreFr',TextareaType::class, [
  924.                 'attr' => ['class' => 'attached-input'],
  925.     
  926.                 'label' => false,
  927.                 'required' => false
  928.             ])
  929.             ->add('titreEn',TextareaType::class, [
  930.                 'attr' => ['class' => 'attached-input'],
  931.     
  932.                 'label' => false,
  933.                 'required' => false
  934.             ])
  935.     
  936.                 ->getForm();
  937.         }
  938.        
  939.         if($type == 'video')
  940.         {
  941.             $typeCon $typesContenusRepository->findOneById(3);
  942.             $form $this->createFormBuilder($contenu)
  943.             ->add('titreFr',TextareaType::class, [
  944.                 'attr' => ['class' => 'attached-input'],
  945.     
  946.                 'label' => false,
  947.                 'required' => false
  948.             ])
  949.             ->add('titreEn',TextareaType::class, [
  950.                 'attr' => ['class' => 'attached-input'],
  951.     
  952.                 'label' => false,
  953.                 'required' => false
  954.             ])
  955.             ->add('video',TextType::class, [
  956.                 'attr' => ['class' => 'attached-input'],
  957.     
  958.                 'label' => false,
  959.                 'required' => false
  960.             ])
  961.            
  962.                 ->getForm();
  963.         }
  964.         if($type == 'boxpicto')
  965.         {
  966.             if($type == 'boxpicto')
  967.             {
  968.             $typeCon $typesContenusRepository->findOneById(4);
  969.             }
  970.             if($type == 'avantage')
  971.             {
  972.             $typeCon $typesContenusRepository->findOneById(7);
  973.             }
  974.             $form $this->createFormBuilder($contenu)
  975.             ->add('image'FileType::class, array('data_class' => null'required' => false'label' => false'empty_data' => 'ok'))
  976.             ->add('titreFr',TextareaType::class, [
  977.                 'attr' => ['class' => 'attached-input'],
  978.     
  979.                 'label' => false,
  980.                 'required' => false
  981.             ])
  982.             ->add('titreEn',TextareaType::class, [
  983.                 'attr' => ['class' => 'attached-input'],
  984.     
  985.                 'label' => false,
  986.                 'required' => false
  987.             ])
  988.             ->add('texteFr',TextareaType::class, [
  989.                 'attr' => ['class' => 'attached-input'],
  990.     
  991.                 'label' => false,
  992.                 'required' => false
  993.             ])
  994.             ->add('texteEn',TextareaType::class, [
  995.                 'attr' => ['class' => 'attached-input'],
  996.     
  997.                 'label' => false,
  998.                 'required' => false
  999.             ])
  1000.             
  1001.             ->add('video',TextType::class, [
  1002.                 'attr' => ['class' => 'attached-input'],
  1003.     
  1004.                 'label' => false,
  1005.                 'required' => false
  1006.             ])
  1007.     
  1008.                 
  1009.             
  1010.            
  1011.     
  1012.                 ->getForm();
  1013.         }
  1014.         if($type == 'boxmodal')
  1015.         {
  1016.             if($type == 'boxmodal')
  1017.             {
  1018.             $typeCon $typesContenusRepository->findOneById(13);
  1019.             }
  1020.             if($type == 'boxpict')
  1021.             {
  1022.             $typeCon $typesContenusRepository->findOneById(4);
  1023.             }
  1024.             if($type == 'avantage')
  1025.             {
  1026.             $typeCon $typesContenusRepository->findOneById(7);
  1027.             }
  1028.             $form $this->createFormBuilder($contenu)
  1029.            
  1030.             ->add('titreFr',TextType::class, [
  1031.                 'attr' => ['class' => 'attached-input'],
  1032.     
  1033.                 'label' => false,
  1034.                 'required' => false
  1035.             ])
  1036.             ->add('titreEn',TextType::class, [
  1037.                 'attr' => ['class' => 'attached-input'],
  1038.     
  1039.                 'label' => false,
  1040.                 'required' => false
  1041.             ])
  1042.             ->add('texteFr',TextareaType::class, [
  1043.                 'attr' => ['class' => 'attached-input'],
  1044.     
  1045.                 'label' => false,
  1046.                 'required' => false
  1047.             ])
  1048.             ->add('texteEn',TextareaType::class, [
  1049.                 'attr' => ['class' => 'attached-input'],
  1050.     
  1051.                 'label' => false,
  1052.                 'required' => false
  1053.             ])
  1054.             
  1055.            
  1056.     
  1057.                 ->getForm();
  1058.         }
  1059.         if($type == 'avantage')
  1060.         {
  1061.           
  1062.             if($type == 'avantage')
  1063.             {
  1064.             $typeCon $typesContenusRepository->findOneById(7);
  1065.             }
  1066.             $form $this->createFormBuilder($contenu)
  1067.             ->add('image'FileType::class, array('data_class' => null'required' => false'label' => false'empty_data' => 'ok'))
  1068.             ->add('titreFr',TextareaType::class, [
  1069.                 'attr' => ['class' => 'attached-input'],
  1070.     
  1071.                 'label' => false,
  1072.                 'required' => false
  1073.             ])
  1074.             ->add('titreEn',TextareaType::class, [
  1075.                 'attr' => ['class' => 'attached-input'],
  1076.     
  1077.                 'label' => false,
  1078.                 'required' => false
  1079.             ])
  1080.             ->add('texteFr',TextareaType::class, [
  1081.                 'attr' => ['class' => 'attached-input'],
  1082.     
  1083.                 'label' => false,
  1084.                 'required' => false
  1085.             ])
  1086.             ->add('texteEn',TextareaType::class, [
  1087.                 'attr' => ['class' => 'attached-input'],
  1088.     
  1089.                 'label' => false,
  1090.                 'required' => false
  1091.             ])
  1092.        
  1093.             
  1094.     
  1095.                 ->getForm();
  1096.         }
  1097.     
  1098.             $form->handleRequest($request);
  1099.             if ($form->isSubmitted()) {
  1100.                 
  1101.                 if($type == 'image' || $type == 'boxpicto' || $type == 'avantage')
  1102.                 {
  1103.                     
  1104.                     $file $form->get('image')->getData();
  1105.                     
  1106.                     if($file != 'ok') {
  1107.                         $path '/';
  1108.                         $fileName md5(uniqid()).'.'.$file->guessExtension();
  1109.                         $file->move(
  1110.                             $this->getParameter('contenus_directory').$path,
  1111.                             $fileName
  1112.                         );
  1113.                         $contenu->setImage($fileName);
  1114.                     }
  1115.                     else
  1116.                     {
  1117.                         $contenu->setImage($oldImg);
  1118.                     } 
  1119.                 }  
  1120.                 if( $type == 'document' )
  1121.                 {
  1122.                     $file $form->get('document')->getData();
  1123.                     if($file != 'ok') {
  1124.                         $path '/';
  1125.                         $origine str_replace(' ','_',$file->getClientOriginalName());
  1126.                 $fileName md5(uniqid()).'-'.$origine.'.'.$file->guessExtension();
  1127.                         $file->move(
  1128.                             $this->getParameter('contenus_directory').$path,
  1129.                             $fileName
  1130.                         );
  1131.                         $contenu->setDocument($fileName);
  1132.                     }
  1133.                     else
  1134.                     {
  1135.                         $contenu->setDocument($oldDoc);
  1136.                     }
  1137.                     $fileImage $form->get('image')->getData();
  1138.                     
  1139.                     if($fileImage != 'ok') {
  1140.                         $path '/';
  1141.                         $fileNameImage md5(uniqid()).'.'.$fileImage->guessExtension();
  1142.                         $fileImage->move(
  1143.                             $this->getParameter('contenus_directory').$path,
  1144.                             $fileNameImage
  1145.                         );
  1146.                         $contenu->setImage($fileNameImage);
  1147.                     }
  1148.                     else
  1149.                     {
  1150.                         $contenu->setImage($oldImg);
  1151.                     } 
  1152.                 }   
  1153.            
  1154.                 if(isset($_POST['background']))
  1155.                 {
  1156.                     $contenu->setBackground($_POST['background']);
  1157.                 }
  1158.                 if(isset($_POST['couleur1']))
  1159.                 {
  1160.                     $contenu->setCouleur1($_POST['couleur1']);
  1161.                 }
  1162.                
  1163.                
  1164.                 $contenusRepository->add($contenu,true);
  1165.                $urlReferer $_POST['redirection'].'#bloc'.$contenu->getBlocs()->getId();
  1166.                 return $this->redirect($urlReferer);
  1167.             }
  1168.         
  1169.         return $this->render('admin/editContenu.html.twig', [
  1170.             'form' => $form->createView(),
  1171.             'typeCon'=>$typeCon->getLibelle(),
  1172.             'contenu'=>$contenu,
  1173.             'referer' =>$referer
  1174.            
  1175.         ]);
  1176.     }
  1177.       /**
  1178.      * @Route("/admin/deleteContent/{id}", name="app_deleteContent")
  1179.      */
  1180.     public function app_deleteContent(BlocsRepository $blocsRepository,ContenusRepository $contenusRepository,TypesContenusRepository $typesContenusRepositoryRequest $request$id): Response
  1181.     {
  1182.         
  1183.         $contenu $contenusRepository->findOneById($id);
  1184.         $page $contenu->getBlocs()->getLignes()->getSections()->getPages()->getRoute();
  1185.         $loc $request->getLocale();
  1186.         if(!empty($contenu->getImage()))
  1187.             {
  1188.                 $lien '../public/uploads/contenus/'.$contenu->getImage();
  1189.                 unlink($lien);
  1190.             }
  1191.             $contenusRepository->remove($contenutrue);
  1192.  
  1193.             $referer $this->generateUrl($page, ['locale'=>$loc]).'#bloc'.$contenu->getBlocs()->getId();
  1194.             return $this->redirect($referer);
  1195.     }
  1196.     
  1197.      /**
  1198.      * @Route("/admin/app_deleteLigne/{id}/{pages}", name="app_deleteLigne")
  1199.      */
  1200.     public function app_deleteLigne(LignesRepository $lignesRepoBlocsRepository $blocsRepository,ContenusRepository $contenusRepository,PagesRepository $pagesRepository,AccordeonsRepository $accordeonsRepositoryCarouselsRepository $carouselsRepositoryRequest $request$id$pages): Response
  1201.     {
  1202.         
  1203.         $pageR $pagesRepository->findOneById($pages);
  1204.         $page $pageR->getRoute();
  1205.       
  1206.         $ligne $lignesRepo->findOneById($id);
  1207.        
  1208.         $blocks $blocsRepository->findBy(['Lignes'=>$ligne]);
  1209.                 foreach($blocks as $block)
  1210.                 {
  1211.                         $section $block->getLignes()->getSections()->getId();
  1212.                         $contenu $contenusRepository->findBy(['Blocs'=>$block]);
  1213.                         $idsContenu = array();
  1214.                         foreach($contenu as $res)
  1215.                         {
  1216.                             array_push($idsContenu,$res->getId());
  1217.                             if($res->getImage() != "ok")
  1218.                             {
  1219.                                 $lien '../public/uploads/contenus/'.$res->getImage();
  1220.                                 unlink($lien);
  1221.                             }
  1222.                     
  1223.                             
  1224.                     
  1225.                         }
  1226.                         $accordeons $accordeonsRepository->findBy(['Contenus'=>$idsContenu]);       
  1227.                         // SUPPRESSION DES ACCORDEONS
  1228.                         foreach($accordeons as $resA)
  1229.                         {
  1230.                             $accordeonsRepository->remove($resAtrue);
  1231.                     
  1232.                         }
  1233.                         $carousels $carouselsRepository->findBy(['Contenus'=>$idsContenu]);   
  1234.                         // SUPPRESSION DES CAROUSELS
  1235.                         foreach($carousels as $resC)
  1236.                         {
  1237.                             if(!empty($resC->getImage()))
  1238.                             {
  1239.                                 $lien '../public/uploads/carousels/'.$resC->getImage();
  1240.                                 unlink($lien);
  1241.                             }
  1242.                             $carouselsRepository->remove($resCtrue);
  1243.                         }
  1244.                         foreach($contenu as $res)
  1245.                         {
  1246.                             
  1247.                     
  1248.                             $contenusRepository->remove($restrue);
  1249.                     
  1250.                         }
  1251.                         $blocsRepository->remove($blocktrue);
  1252.             }
  1253.           $lignesRepo->remove($lignetrue);
  1254.            // return $this->redirectToRoute($page, []);
  1255.            $referer $request->headers->get('referer').'#section'.$section;
  1256.            return $this->redirect($referer);
  1257.     }
  1258.       /**
  1259.      * @Route("/admin/app_deleteBlock/{id}/{pages}", name="app_deleteBlock")
  1260.      */
  1261.     public function app_deleteBlock(BlocsRepository $blocsRepository,ContenusRepository $contenusRepository,PagesRepository $pagesRepository,AccordeonsRepository $accordeonsRepositoryCarouselsRepository $carouselsRepositoryRequest $request$id$pages): Response
  1262.     {
  1263.         
  1264.         $pageR $pagesRepository->findOneById($pages);
  1265.         $page $pageR->getRoute();
  1266.       
  1267.         $block $blocsRepository->findOneBy(['id'=>$id]);
  1268.         $section $block->getLignes()->getSections()->getId();
  1269.         $contenu $contenusRepository->findBy(['Blocs'=>$block]);
  1270.         $idsContenu = array();
  1271.         foreach($contenu as $res)
  1272.         {
  1273.             array_push($idsContenu,$res->getId());
  1274.             if(!empty($res->getImage()))
  1275.             {
  1276.                 $lien '../public/uploads/contenus/'.$res->getImage();
  1277.                 unlink($lien);
  1278.             }
  1279.        
  1280.             
  1281.        
  1282.         }
  1283.         $accordeons $accordeonsRepository->findBy(['Contenus'=>$idsContenu]);       
  1284.         // SUPPRESSION DES ACCORDEONS
  1285.         foreach($accordeons as $resA)
  1286.         {
  1287.             $accordeonsRepository->remove($resAtrue);
  1288.        
  1289.         }
  1290.         $carousels $carouselsRepository->findBy(['Contenus'=>$idsContenu]);   
  1291.         // SUPPRESSION DES CAROUSELS
  1292.         foreach($carousels as $resC)
  1293.         {
  1294.             if(!empty($resC->getImage()))
  1295.             {
  1296.                 $lien '../public/uploads/carousels/'.$resC->getImage();
  1297.                 unlink($lien);
  1298.             }
  1299.             $carouselsRepository->remove($resCtrue);
  1300.         }
  1301.         foreach($contenu as $res)
  1302.         {
  1303.             
  1304.        
  1305.             $contenusRepository->remove($restrue);
  1306.        
  1307.         }
  1308.         $blocsRepository->remove($blocktrue);
  1309.            // return $this->redirectToRoute($page, []);
  1310.            $referer $request->headers->get('referer').'#section'.$section;
  1311.            return $this->redirect($referer);
  1312.     }
  1313.      /**
  1314.      * @Route("/admin/deleteSection/{id}/{pages}", name="app_deleteSection")
  1315.      */
  1316.     public function app_deleteSection(BlocsRepository $blocsRepositoryLignesRepository $lignesRepository,SectionsRepository $sectionsRepository,ContenusRepository $contenusRepository,PagesRepository $pagesRepository,AccordeonsRepository $accordeonsRepositoryCarouselsRepository $carouselsRepositoryRequest $request$id$pages): Response
  1317.     {
  1318.         $pageR $pagesRepository->findOneById($pages);
  1319.         if(!empty($pageR))
  1320.         {
  1321.         $page $pageR->getRoute();
  1322.         }
  1323.         //SECTION, LIGNES, BLOCS, CONTENUS, ACCORDEONS, CAROUSELS
  1324.         $sections $sectionsRepository->findOneById($id);
  1325.         $oldSection $sections->getId();
  1326.         
  1327.         $lignes $lignesRepository->findBy(array('Sections'=>$sections));
  1328.         foreach($lignes as $ligne)
  1329.         {
  1330.            
  1331.             $block $blocsRepository->findBy(array('Lignes'=>$ligne));
  1332.            
  1333.             foreach($block as $res)
  1334.             {
  1335.                 $contenus $contenusRepository->findBy(array('Blocs'=>$res));
  1336.                 
  1337.                 foreach($contenus as $res2)
  1338.                 {
  1339.                     // SUPPRIMER LES ACCORDEONS
  1340.                     $accordeons $accordeonsRepository->findBy(array('Contenus'=>$res2));
  1341.                     
  1342.                     foreach($accordeons as $res4)
  1343.                     {
  1344.                         $accordeonsRepository->remove($res4true);
  1345.                     }
  1346.                     // SUPPRIMER LES CAROIUSELS
  1347.                     $carousels $carouselsRepository->findBy(array('Contenus'=>$res2));
  1348.                     foreach($carousels as $res5)
  1349.                     {
  1350.                         $carouselsRepository->remove($res5true);
  1351.                     }
  1352.                     $contenusRepository->remove($res2true);
  1353.                 }
  1354.                 $blocsRepository->remove($restrue);
  1355.             }
  1356.         
  1357.             $lignesRepository->remove($lignetrue);
  1358.         }
  1359.         $sectionsRepository->remove($sectionstrue);
  1360.         //return $this->redirectToRoute($page, []);
  1361.         $referer $request->headers->get('referer').'#section'.$oldSection;
  1362.         return $this->redirect($referer);
  1363.         if(!empty($pageR))
  1364.         {
  1365.         //return $this->redirectToRoute($page, []);
  1366.         $referer $request->headers->get('referer').'#section'.$oldSection;
  1367.         return $this->redirect($referer);
  1368.         }
  1369.         else
  1370.         {
  1371.             $titre str_replace(' ','_',$sections->getActualites()->getTitreFr());
  1372.             $titre str_replace("'",'_',$sections->getActualites()->getTitreFr());
  1373.             $url $this->generateUrl('actualitesD', array('id' => $sections->getActualites()->getId(), 'titre' => $titre));
  1374.             $referer $url.'#section'.$oldSection;
  1375.             return $this->redirect($referer);
  1376.         
  1377.         }
  1378.         
  1379.     } 
  1380.     
  1381.      /**
  1382.      * @Route("/admin/updateSection/{id}/{pages}", name="app_updateSection")
  1383.      */
  1384.     public function app_updateSection(BlocsRepository $blocsRepositoryLignesRepository $lignesRepository,SectionsRepository $sectionsRepository,ContenusRepository $contenusRepository,PagesRepository $pagesRepository,AccordeonsRepository $accordeonsRepositoryCarouselsRepository $carouselsRepositoryRequest $request$id$pages): Response
  1385.     {
  1386.         $loc $request->getLocale();
  1387.         
  1388.         $pageR $pagesRepository->findOneById($pages);
  1389.         if(!empty($pageR))
  1390.         {
  1391.         $page $pageR->getRoute();
  1392.         }
  1393.         //SECTION, LIGNES, BLOCS, CONTENUS, ACCORDEONS, CAROUSELS
  1394.         $sections $sectionsRepository->findOneById($id);
  1395.         $oldImg $sections->getImage();
  1396.         $oldRond $sections->getRond();
  1397.         $form $this->createFormBuilder($sections)
  1398.         ->add('image'FileType::class, array('data_class' => null'required' => false'label' => false'empty_data' => 'ok'))
  1399.         ->add('rond'FileType::class, array('data_class' => null'required' => false'label' => false'empty_data' => 'ok'))
  1400.         ->add('ordre',NumberType::class, [
  1401.             'attr' => ['class' => 'attached-input'],
  1402.             'label' => false,
  1403.             'required' => false
  1404.         ])
  1405.         
  1406.    
  1407.         
  1408.             ->getForm();
  1409.     
  1410.         $form->handleRequest($request);
  1411.         if ($form->isSubmitted()) {
  1412.             $file $form->get('image')->getData();
  1413.             if($file != 'ok') {
  1414.                 
  1415.                 $path '/';
  1416.                 $fileName md5(uniqid()).'.'.$file->guessExtension();
  1417.                 $file->move(
  1418.                     $this->getParameter('sections_directory').$path,
  1419.                     $fileName
  1420.                 );
  1421.                 $sections->setImage($fileName);
  1422.             }
  1423.             else
  1424.             {
  1425.                 $sections->setImage($oldImg);
  1426.             }
  1427.             $file $form->get('rond')->getData();
  1428.             if($file != 'ok') {
  1429.                 
  1430.                 $path '/';
  1431.                 $fileName md5(uniqid()).'.'.$file->guessExtension();
  1432.                 $file->move(
  1433.                     $this->getParameter('sections_directory').$path,
  1434.                     $fileName
  1435.                 );
  1436.                 $sections->setRond($fileName);
  1437.             }
  1438.             else
  1439.             {
  1440.                 $sections->setRond($oldRond);
  1441.             }
  1442.             $sections->setColor($_POST['background']);
  1443.             
  1444.             
  1445.             
  1446.             
  1447.             
  1448.             $sectionsRepository->add($sectionstrue);
  1449.         
  1450.             if(!empty($pageR))
  1451.             {
  1452.               
  1453.                 $url $this->generateUrl($page, array('locale'=>$loc));
  1454.                 $referer $url.'#section'.$sections->getId();
  1455.             //$referer = $request->headers->get('referer').'#section'.$sections->getId();
  1456.             return $this->redirect($referer);
  1457.             }
  1458.             else
  1459.             {
  1460.                 $titre str_replace(' ','_',$sections->getActualites()->getTitreFr());
  1461.                 $titre str_replace("'",'_',$sections->getActualites()->getTitreFr());
  1462.                 $url $this->generateUrl('actualitesD', array('id' => $sections->getActualites()->getId(), 'titre' => $titre,'locale'=>$loc));
  1463.                 $referer $url.'#section'.$sections->getId();
  1464.                 return $this->redirect($referer);
  1465.             
  1466.             }
  1467.         }
  1468.         return $this->render('admin/updateSection.html.twig', [
  1469.             'form' => $form->createView(),
  1470.             'section'=>$sections
  1471.            
  1472.         ]);
  1473.     }
  1474.      /**
  1475.      * @Route("/admin/updateSectionActu/{id}/{pages}", name="app_updateSectionActu")
  1476.      */
  1477.     public function app_updateSectionActu(BlocsRepository $blocsRepositoryLignesRepository $lignesRepository,SectionsRepository $sectionsRepository,ContenusRepository $contenusRepository,PagesRepository $pagesRepository,AccordeonsRepository $accordeonsRepositoryCarouselsRepository $carouselsRepositoryRequest $request$id$pages): Response
  1478.     {
  1479.         $pageR $pagesRepository->findOneById($pages);
  1480.         if(!empty($pageR))
  1481.         {
  1482.         $page $pageR->getRoute();
  1483.         }
  1484.         //SECTION, LIGNES, BLOCS, CONTENUS, ACCORDEONS, CAROUSELS
  1485.         $sections $sectionsRepository->findOneById($id);
  1486.         $oldImg $sections->getImage();
  1487.         $oldRond $sections->getRond();
  1488.         $form $this->createFormBuilder($sections)
  1489.        
  1490.         ->add('ordre',NumberType::class, [
  1491.             'attr' => ['class' => 'attached-input'],
  1492.             'label' => false,
  1493.             'required' => false
  1494.         ])
  1495.         
  1496.    
  1497.         
  1498.             ->getForm();
  1499.     
  1500.         $form->handleRequest($request);
  1501.         if ($form->isSubmitted()) {
  1502.           
  1503.             
  1504.            
  1505.             
  1506.             
  1507.             $sectionsRepository->add($sectionstrue);
  1508.           
  1509.                 $titre1 str_replace(' ','_',$sections->getActualites()->getTitreFr());
  1510.                 $titre str_replace("'",'_',$titre1);
  1511.                 $url $this->generateUrl('actualitesD', array('id' => $sections->getActualites()->getId(), 'titre' => $titre));
  1512.                 $referer $url.'#section'.$sections->getId();
  1513.               
  1514.                 return $this->redirectToRoute('actualitesD', array('id' => $sections->getActualites()->getId(), 'titre' => $titre));
  1515.             
  1516.            
  1517.         }
  1518.         return $this->render('admin/updateSectionActu.html.twig', [
  1519.             'form' => $form->createView(),
  1520.             'section'=>$sections
  1521.            
  1522.         ]);
  1523.     }
  1524.     
  1525.     
  1526. }