src/Services/QueriesV2Manager.php line 213

Open in your IDE?
  1. <?php
  2. namespace App\Services;
  3. use App\Entity\Actuv2ElectronicInvoice;
  4. use App\Entity\Actuv2ElectronicInvoiceAnswer;
  5. use App\Entity\Actuv2ElectronicInvoiceVote;
  6. use App\Entity\Actuv2Help;
  7. use App\Entity\Actuv2Journal;
  8. use App\Entity\Actuv2Quiz;
  9. use App\Entity\Actuv2Podcast;
  10. use App\Entity\Actuv2Sondage;
  11. use App\Entity\Actuv2Bienetre;
  12. use App\Entity\Actuv2Citation;
  13. use App\Entity\Actuv2QuizVote;
  14. use App\Entity\Actuv2Actualite;
  15. use App\Entity\Actualitecabinet;
  16. use App\Entity\Actuv2Calendrier;
  17. use App\Entity\Actuv2Infographie;
  18. use App\Entity\Actuv2Sondagevote;
  19. use App\Entity\Actuv2Chiffredumois;
  20. use App\Entity\Actuv2InfographieRse;
  21. use App\Entity\Actuv2NewYear;
  22. use App\Entity\Actuv2QuizAnswer;
  23. use App\Entity\NewsletterProspect;
  24. use App\Entity\PodcastPrivate;
  25. use App\Services\HelpersFirmsService;
  26. use Doctrine\ORM\EntityManagerInterface;
  27. use App\Entity\Actuv2Transformationdigitale;
  28. use App\Entity\Actuv2VoteUseful;
  29. use GuzzleHttp\Client;
  30. use Symfony\Component\HttpFoundation\RequestStack;
  31. use Symfony\Component\String\Slugger\AsciiSlugger;
  32. class QueriesV2Manager
  33. {
  34.   protected $entityManager;
  35.   protected $em;
  36.     private $request;
  37.     private HelpersFirmsService $helperFirmsService;
  38.     private \App\Services\HelpersFirmsService $helpersFirmsService;
  39.     public function __construct(EntityManagerInterface $entityManagerRequestStack $requestStacktHelpersFirmsService $helperFirmsServiceHelpersFirmsService $helpersFirmsService)
  40.   {
  41.     $this->entityManager $entityManager->getConnection();
  42.     $this->slugger = new AsciiSlugger();
  43.     $this->em $entityManager;
  44.     $this->request $requestStackt->getCurrentRequest();
  45.     $this->helperFirmsService $helperFirmsService;
  46.       $this->helpersFirmsService $helpersFirmsService;
  47.   }
  48.   /**
  49.    * Renvoie les bornes d'une période passée en paramètre
  50.    * Si pas de période en paramètre, on se basera la période en cours
  51.    *
  52.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  53.    * @return array "dateMin" et "dateMax", ex: 2021-03-01 et 2021-04-01
  54.    */
  55.   public function getPeriodFromDate($date '')
  56.   {
  57.     //$date = "2024-06-01";
  58.     // si pas de date fournie, on prend la date du jour
  59.     if ($date == '') {
  60.       $date = (new \DateTime())->format('Y-m-d');
  61.     }
  62.     // Calcul de la période
  63.     try {
  64.       $dateMin = (new \DateTime($date))->format('Y-m-01');
  65.       $dateMax = (new \DateTime($dateMin))->modify('last day of this month')->format('Y-m-d');
  66.     } catch (\Throwable $th) {
  67.       die;
  68.     }
  69.     return [
  70.       //'dateMin' => "2021-01-01",
  71.       'dateMin' => $dateMin,
  72.       'dateMax' => $dateMax
  73.     ];
  74.   }
  75.   public function getPeriodFromDatePalec($date '')
  76.   {
  77.     // si pas de date fournie, on prend la date du jour
  78.     if ($date == '') {
  79.       $date = (new \DateTime())->format('Y-m-d');
  80.     }
  81.     // Calcul de la période
  82.     try {
  83.       $dateInput = new \DateTime($date);  // On initialise la date donnée
  84.       // Si le jour du mois est avant le 15, on passe au mois précédent
  85.       if ($dateInput->format('d') < 15) {
  86.         $dateInput->modify('-1 month')->format("Y-m-15");  // Reculer d'un mois
  87.       }
  88.       // On fixe les limites en fonction de la date ajustée
  89.       $dateMin = new \DateTime($dateInput->format('Y-m-15'));  // Création de l'objet DateTime pour le 15 du mois ajusté
  90.       $dateMax = (clone $dateMin)->modify('+1 month')->modify('-1 day');  // Date max est le 14 du mois suivant
  91.     } catch (\Throwable $th) {
  92.       // Log l'erreur ici si nécessaire, puis gérer l'exception
  93.       die;  // à éviter en production, préférer un retour d'erreur géré
  94.     }
  95.     return [
  96.       'dateMin' => $dateMin->format('Y-m-d'),  // Formatage en chaîne
  97.       'dateMax' => $dateMax->format('Y-m-d')   // Formatage en chaîne
  98.     ];
  99.   }
  100.   /**
  101.    * Récupère les 6 articles de la table actuv2_actualite pour une période donnée
  102.    *
  103.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  104.    * @return array $tabData image1 => format paysage (image principale page de détail), image2 => format portrait (homepage), image3 => format panoramique (homepage + footer)
  105.    */
  106.   public function getActualites(?string $date null)
  107.   {
  108.     $date $this->getPeriodFromDate($date);
  109.     $res $this->em->getRepository(Actuv2Actualite::class)->findArrayResultBy($date);
  110.     // dd($res);
  111.     if (count($res) > 0) {
  112.       foreach ($res as $key => $value) {
  113.         $res[$key]['new_slug'] = $value['id'] . '-' $this->slugger->slug($value['titre']);
  114.         $res[$key]['new_slug'] = strtolower($res[$key]['new_slug']);
  115.       }
  116.     }
  117.     return $res;
  118.   }
  119.   public function getHistoActualites()
  120.   {
  121.     $date $this->getPeriodFromDate();
  122.     $date['dateMin'] = (new \DateTime())->setDate(20000101)->format('Y-m-d');
  123.     $res $this->em->getRepository(Actuv2Actualite::class)->findArrayResultBy($date20);
  124.     //dd($res);
  125.     if (count($res) > 0) {
  126.       foreach ($res as $key => $value) {
  127.         $res[$key]['new_slug'] = $value['id'] . '-' $this->slugger->slug($value['titre']);
  128.         $res[$key]['new_slug'] = strtolower($res[$key]['new_slug']);
  129.       }
  130.     }
  131.     return $res;
  132.   }
  133.   public function getHistoTransfo()
  134.   {
  135.     $date $this->getPeriodFromDate();
  136.     $date['dateMin'] = (new \DateTime())->setDate(20000101)->format('Y-m-d');
  137.     $res $this->em->getRepository(Actuv2Transformationdigitale::class)->findArrayResultBy($date1000);
  138.     //dd($res);
  139.     if (count($res) > 0) {
  140.       foreach ($res as $key => $value) {
  141.         $res[$key]['new_slug'] = $value['id'] . '-' $this->slugger->slug($value['titre']);
  142.         $res[$key]['new_slug'] = strtolower($res[$key]['new_slug']);
  143.       }
  144.     }
  145.     return $res;
  146.   }
  147.   public function getHistoBienEtre()
  148.   {
  149.     $date $this->getPeriodFromDate();
  150.     $date['dateMin'] = (new \DateTime())->setDate(20000101)->format('Y-m-d');
  151.     $res $this->em->getRepository(Actuv2Bienetre::class)->findArrayResultBy($date1000);
  152.     //dd($res);
  153.     if (count($res) > 0) {
  154.       foreach ($res as $key => $value) {
  155.         $res[$key]['new_slug'] = $value['id'] . '-' $this->slugger->slug($value['titre']);
  156.         $res[$key]['new_slug'] = strtolower($res[$key]['new_slug']);
  157.       }
  158.     }
  159.     return $res;
  160.   }
  161.   /**
  162.    * Récupère l'article de la table actuv2_bienEtre pour une période donnée
  163.    *
  164.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  165.    * @return array $tabData image1 => format carré, image2 => format panoramique
  166.    */
  167.   public function getBienEtre(?string $date null$archive false)
  168.   {
  169.     if ($archive) {
  170.       $reult $this->em->getRepository(Actuv2Bienetre::class)->findArrayResultBy([], 6);
  171.     } else {
  172.       $date $this->getPeriodFromDate($date);
  173.       $reult $this->em->getRepository(Actuv2Bienetre::class)->findArrayResultBy($date);
  174.     }
  175.     if (count($reult) == 1) {
  176.       return $reult[0];
  177.     } else {
  178.       return null;
  179.     }
  180.   }
  181.   public function getActualiteCabinet(?string $date null$cabinet)
  182.   {
  183.     $date $this->getPeriodFromDate($date);
  184.     $params = [
  185.       'dateMin' => $date['dateMin'],
  186.       'dateMax' => $date['dateMax'],
  187.       'cabinet' => $cabinet
  188.     ];
  189.     $res $this->em->getRepository(Actualitecabinet::class)->findArrayResultBy($params);
  190.     if (count($res) == 1) {
  191.       return $res[0];
  192.     } else {
  193.       return null;
  194.     }
  195.   }
  196.   public function getActualiteCabinetDetails(int $id)
  197.   {
  198.     if (is_null($id) || !is_numeric($id)) {
  199.       return false;
  200.     }
  201.     $res $this->em->getRepository(Actualitecabinet::class)->findAllArrayResult($id);
  202.     return $res && $res[0] ? $res[0] : null;
  203.   }
  204.   public function getBienEtreList(?string $date null)
  205.   {
  206.     $date $this->getPeriodFromDate($date);
  207.     return $this->em->getRepository(Actuv2Bienetre::class)->findArrayResultBy($date6'actualite.php');
  208.   }
  209.   public function getTransformationDigitaleList(?string $date null)
  210.   {
  211.     $date $this->getPeriodFromDate($date);
  212.     return $this->em->getRepository(Actuv2Transformationdigitale::class)->findArrayResultBy($date6'actualite.php');
  213.   }
  214.   /**
  215.    * Récupère l'article de la table actuv2_chiffreDuMois pour une période donnée
  216.    *
  217.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  218.    * @return array $tabData
  219.    */
  220.   public function getChiffreDuMois(?string $date null)
  221.   {
  222.     $date $this->getPeriodFromDate($date);
  223.     return $this->em->getRepository(Actuv2Chiffredumois::class)->findArrayResultBy($date);
  224.   }
  225.   /**
  226.    * Récupère l'article de la table actuv2_citation pour une période donnée
  227.    *
  228.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  229.    * @return array $tabData
  230.    */
  231.   public function getCitation(?string $date null)
  232.   {
  233.     $date $this->getPeriodFromDate($date);
  234.     return $this->em->getRepository(Actuv2Citation::class)->findArrayResultBy($date);
  235.   }
  236.     public function getHelp(?string $date null)
  237.     {
  238.         $date $this->getPeriodFromDate($date);
  239.         $actuv2Help $this->em->getRepository(Actuv2Help::class)->findArrayResultBy($date);
  240.         if ($actuv2Help) {
  241.             $help $this->helpersFirmsService->getHelperById($actuv2Help->getIdHelp());
  242.             return [
  243.                 'id' => $actuv2Help->getId(),
  244.                 'help' => $help,
  245.             ];
  246.         } else {
  247.             return null;
  248.         }
  249.     }
  250.     public function getHelpById(?string $id null)
  251.     {
  252.         $actuv2Help $this->em->getRepository(Actuv2Help::class)->find($id);
  253.         if ($actuv2Help) {
  254.             $help $this->helpersFirmsService->getHelperById($actuv2Help->getIdHelp());
  255.             return [
  256.                 'id' => $actuv2Help->getId(),
  257.                 'help' => $help,
  258.             ];
  259.         } else {
  260.             return null;
  261.         }
  262.     }
  263.     public function getHelpWithId(?string $date null)
  264.     {
  265.         $date $this->getPeriodFromDate($date);
  266.         $actuv2Help $this->em->getRepository(Actuv2Help::class)->findArrayResultBy($date);
  267.         if ($actuv2Help) {
  268.             $help $this->helpersFirmsService->getHelperById($actuv2Help->getIdHelp());
  269.             return [
  270.                 'id' => $actuv2Help->getId(),
  271.                 'help' => $help,
  272.             ];
  273.         } else {
  274.             return null;
  275.         }
  276.     }
  277.   /**
  278.    * Récupère l'article de la table actuv2_infographie pour une période donnée
  279.    *
  280.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  281.    * @return array $tabData image1 => format panoramique (homepage + footer),
  282.    *                        image2 => format lightbox paysage
  283.    *                        image3 => format mobile portrait
  284.    *                        image4 => format mobile portrait
  285.    *                        image5 => format mobile portrait (facultatif)
  286.    *                        image6 => format mobile portrait (facultatif)
  287.    *                        image7 => format mobile portrait (facultatif)
  288.    *                        image8 => format mobile portrait (facultatif)
  289.    *                        image9 => format mobile portrait (facultatif)
  290.    *                        image10 => format mobile portrait (facultatif)
  291.    * @throws Exception
  292.    */
  293.   public function getInfographie(?string $date null)
  294.   {
  295.     $date $this->getPeriodFromDate($date);
  296.     $infographie $this->em->getRepository(Actuv2InfographieRse::class)->findArrayResultBy($date);
  297.     if ($infographie) {
  298.       usort($infographie[0]['actuv2InfographieRseCarouselMobileFiles'], function ($a$b) {
  299.         return $a['orderDisplay'] - $b['orderDisplay'];
  300.       });
  301.       return $infographie[0];
  302.     }
  303.     return null;
  304.   }
  305.   /**
  306.    * Récupère l'article de la table actuv2_transformationDigitale pour une période donnée
  307.    *
  308.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  309.    * @return array $tabData
  310.    */
  311.   public function getTransformationDigitale(?string $date null$archive false)
  312.   {
  313.     if ($archive) {
  314.       $result $this->em->getRepository(Actuv2Transformationdigitale::class)->findArrayResultBy([], 6);
  315.     } else {
  316.       $date $this->getPeriodFromDate($date);
  317.       $result $this->em->getRepository(Actuv2Transformationdigitale::class)->findArrayResultBy($date);
  318.     }
  319.     if (count($result) == 1) {
  320.       return $result[0];
  321.     } else {
  322.       return null;
  323.     }
  324.   }
  325.   /**
  326.    * Récupère l'article de la table actuv2_journal pour une période donnée
  327.    *
  328.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  329.    * @return array $tabData
  330.    */
  331.   public function getJournal(?string $date null$archive false)
  332.   {
  333.     if ($archive) {
  334.       $result $this->em->getRepository(Actuv2Journal::class)->findArrayResultBy([], 6);
  335.     } else {
  336.       $date $this->getPeriodFromDate($date);
  337.       $result $this->em->getRepository(Actuv2Journal::class)->findArrayResultBy($date);
  338.     }
  339.     if (count($result) == 1) {
  340.       return $result[0];
  341.     } else {
  342.       return null;
  343.     }
  344.   }
  345.   /**
  346.    * Récupère le sondage du mois, table actuv2_sondage pour une période donnée
  347.    *
  348.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  349.    * @return array $tabData
  350.    */
  351.   public function getSondage(?string $date null)
  352.   {
  353.     $date $this->getPeriodFromDate($date);
  354.     $date['ip'] = $this->request->getClientIp();
  355.     $result $this->em->getRepository(Actuv2Sondage::class)->findSondageBy($date);
  356.     if (!$result) {
  357.       $result $this->em->getRepository(Actuv2Sondage::class)->findSimpleSondageBy($date);
  358.       $result[0]['nbVote'] = 0;
  359.     }
  360.     $result[0]['date'] = ($result[0]['date'])->format('Y-m-d');
  361.     $result[0]['ip'] = $this->request->getClientIp();
  362.     if (!empty($result)) {
  363.       return $result[0];
  364.     } else {
  365.       return null;
  366.     }
  367.   }
  368.   /**
  369.    * Récupère le sondage du mois, table actuv2_sondage pour une période donnée
  370.    *
  371.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  372.    * @return array $tabData
  373.    */
  374.   public function hasVoteUseful(?string $idActu, ?string $type)
  375.   {
  376.     $ip $this->request->getClientIp();
  377.     $alreadyVote $this->em->getRepository(Actuv2VoteUseful::class)->findOneBy(['actuId' => $idActu'ip' => $ip'typeActu' => $type]);
  378.     if (!empty($alreadyVote)) {
  379.       return true;
  380.     } else {
  381.       return false;
  382.     }
  383.   }
  384.   /**
  385.    * Récupère le podcast (format mp3), table actuv2_podcast pour une période donnée
  386.    *
  387.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  388.    * @return object $tabData
  389.    */
  390.   public function getPodcast(?string $date null)
  391.   {
  392.     $date $this->getPeriodFromDate($date);
  393.     return $this->em->getRepository(PodcastPrivate::class)->findOneByDates($date);
  394.   }
  395.   public function getPodcastLatest()
  396.   {
  397.       return $this->em->getRepository(PodcastPrivate::class)->findLastEpisodes(1, ['dateMax' => (new \DateTime())->format('Y-m-d')]);
  398.   }
  399.   public function getNewsletterProspect(?string $date null)
  400.   {
  401.     if ($date == '') {
  402.       $date = (new \DateTime())->format('Y-m-d');
  403.     }
  404.     // Calcul de la période
  405.     try {
  406.       $dateMin = (new \DateTime($date))->modify('first day of this month')->modify('+4 days')->format('Y-m-d');
  407.       $dateMax = (new \DateTime($dateMin))->modify('first day of next month')->modify('+3 days')->format('Y-m-d');
  408.     } catch (\Throwable $th) {
  409.       die;
  410.     }
  411.     $date = [
  412.       'dateMin' => $dateMin,
  413.       'dateMax' => $dateMax
  414.     ];
  415.     return $this->em->getRepository(NewsletterProspect::class)->findOneByDates($date);
  416.   }
  417.   public function getSondageMailing(?string $date null)
  418.   {
  419.     $date $this->getPeriodFromDate($date);
  420.     $result $this->em->getRepository(Actuv2Sondage::class)->findSimpleSondageBy($date);
  421.     if (!empty($result)) {
  422.       $result[0]['nbVote'] = 0;
  423.       $result[0]['date'] = ($result[0]['date'])->format('Y-m-d');
  424.       return $result[0];
  425.     } else {
  426.       return null;
  427.     }
  428.   }
  429.   /**
  430.    * Récupère les podcasts ausha, table actuv2_podcast
  431.    *
  432.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  433.    * @return array $tabData
  434.    */
  435.   public function getPodcasts(?string $date null)
  436.   {
  437.     $date $this->getPeriodFromDate($date);
  438.     return $this->em->getRepository(Actuv2Podcast::class)->findByDatesArrayResult(['dateMin' => $date['dateMin'], 'dateMax' => (new \DateTime())->format('Y-m-d')]);
  439.   }
  440.   /**
  441.    * Récupère les podcasts ausha sous forme d'objet, table actuv2_podcast
  442.    *
  443.    * @param string $date "aaaa-mm-01", ex: "2021-03-01" pour la période mars 2021
  444.    */
  445.   public function getPodcastsObjects(?string $date null)
  446.   {
  447.     $date $this->getPeriodFromDate($date);
  448.     // remove 1 month to dateMax to doesnt get last episode published
  449.     $dateMax = new \DateTime($date['dateMax']);
  450.     $date['dateMax'] = $dateMax->format('Y-m-d');
  451.     return $this->em->getRepository(PodcastPrivate::class)->findByDates(['dateMin' => $date['dateMin'], 'dateMax' => $date['dateMax']]);
  452.   }
  453.   /**
  454.    * @return array
  455.    */
  456.   public function getDates()
  457.   {
  458.     $datas $this->em->getRepository(Actuv2Calendrier::class)->findAllArrayResult();
  459.     $arr = array();
  460.     foreach ($datas as $item) {
  461.       $item['date'] = $item['date'] ? ($item['date'])->format('Y-m-d') : null;
  462.       $arr[$item['date']][] = $item;
  463.     }
  464.     return $arr;
  465.   }
  466.   /**
  467.    * Récupère le résultat d'un sondage
  468.    *
  469.    * @param int $idSondage
  470.    *
  471.    * @return array $tabData pourcentage de réponses (1=oui 2=non) ou FALSE si idSondage introuvable
  472.    */
  473.   public function getSondageResult($idSondage)
  474.   {
  475.     if (!is_numeric($idSondage)) {
  476.       return false;
  477.     }
  478.     $tabResult = [
  479.       => 0,
  480.       => 0,
  481.     ];
  482.     $res $this->em->getRepository(Actuv2Sondage::class)->findSondageById($idSondage);
  483.     // le sondage n'existe pas
  484.     if (count($res) == 0) {
  485.       return false;
  486.     }
  487.     if (count($res) == 1) {
  488.       // personne n'a encore voté
  489.       if (is_null($res[0]['reponse'])) {
  490.         // rien à faire
  491.       } else {
  492.         // 1 seul type de réponse (que des oui ou que des non), donc forcément 100%
  493.         $tabResult[$res[0]['reponse']] = 100;
  494.       }
  495.     } else {
  496.       // on a 2 résultats et on calcule les %
  497.       $nbOui = ($res[0]['reponse'] == 1) ? $res[0]['nbVote'] : $res[1]['nbVote'];
  498.       $nbNon = ($res[0]['reponse'] == 2) ? $res[0]['nbVote'] : $res[1]['nbVote'];
  499.       $total $nbOui $nbNon;
  500.       $pourcentageOui round($nbOui 100 $total);
  501.       $pourcentageNon 100 $pourcentageOui;
  502.       $tabResult[1] = $pourcentageOui;
  503.       $tabResult[2] = $pourcentageNon;
  504.     }
  505.     return $tabResult;
  506.   }
  507.   /**
  508.    * Récupère les données d'une actualité
  509.    *
  510.    * @param int $id
  511.    * @return array $tabData
  512.    */
  513.   public function getActualitesDetails(int $id)
  514.   {
  515.     if (is_null($id) || !is_numeric($id)) {
  516.       return false;
  517.     }
  518.     $res $this->em->getRepository(Actuv2Actualite::class)->findAllArrayResult($id);
  519.     if (!empty($res)) {
  520.       $res[0]['new_slug'] = $res[0]['id'] . '-' $this->slugger->slug($res[0]['titre']);
  521.       $res[0]['new_slug'] = strtolower($res[0]['new_slug']);
  522.       $res[0]['date'] = $res[0]['date'] ? ($res[0]['date'])->format('Y-m-d') : null;
  523.       $objDate $res[0]['date'] ? new DateTimeFrench($res[0]['date']) : null;
  524.       $res[0]['dateFormated'] = $objDate $objDate->format('F Y') : null;
  525.     }
  526.     return $res && $res[0] ? $res[0] : null;
  527.   }
  528.   /**
  529.    * Récupère les données d'un article de transformation digitale
  530.    *
  531.    * @param int $id
  532.    * @return Actuv2Transformationdigitale
  533.    */
  534.   public function getTransformationDigitaleDetails(int $id)
  535.   {
  536.     if (is_null($id) || !is_numeric($id)) {
  537.       return false;
  538.     }
  539.     return $this->em->getRepository(Actuv2Transformationdigitale::class)->find($id);
  540.   }
  541.   /**
  542.    * Récupère les données d'un journal
  543.    *
  544.    * @param int $id
  545.    * @return Actuv2Journal
  546.    */
  547.   public function getJournalDetails(int $id)
  548.   {
  549.     if (is_null($id) || !is_numeric($id)) {
  550.       return false;
  551.     }
  552.     return $this->em->getRepository(Actuv2Journal::class)->find($id);
  553.   }
  554.   /**
  555.    * Récupère les données d'un article de bien-être
  556.    *
  557.    * @param int $id
  558.    * @return Actuv2Bienetre
  559.    */
  560.   public function getBienEtreDetails(int $id)
  561.   {
  562.     if (is_null($id) || !is_numeric($id)) {
  563.       return false;
  564.     }
  565.     return $this->em->getRepository(Actuv2Bienetre::class)->find($id);
  566.   }
  567.   /**
  568.    * Récupère les données d'un article du calendrier fiscal
  569.    *
  570.    * @param int $id
  571.    * @return Actuv2Calendrier
  572.    */
  573.   public function getCalendrierDetails(int $id)
  574.   {
  575.     if (is_null($id) || !is_numeric($id)) {
  576.       return false;
  577.     }
  578.     return $this->em->getRepository(Actuv2Calendrier::class)->find($id);
  579.   }
  580.   /**
  581.    * Récupère la liste des articles du calendrier fiscal à une date donnée
  582.    *
  583.    * @param string $date "aaaa-mm-dd"
  584.    * @return array $tabData
  585.    */
  586.   public function getCalendrierListe(?string $date null)
  587.   {
  588.     if (is_null($date) || !is_string($date)) {
  589.       return false;
  590.     }
  591.     $objDate = new \DateTime($date);
  592.     $okDate $objDate->format('Y-m-d');
  593.     return $this->em->getRepository(Actuv2Calendrier::class)->findResultBy($okDate'calendrier-fiscal.php');
  594.   }
  595.   /**
  596.    * Renvoie les données nécéssaires au footer
  597.    */
  598.   public function getFooterData(?string $date null)
  599.   {
  600.     $sondage $this->getSondage($date);
  601.     $aushaToken "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjczOTY4MjQ2MjU3NzJkYzA2M2ZkMTgyMzVlYzY4ZmFkZWE4MDNhMGI2NzI1NjQ1YzJkODEwM2E2YWYyMTMxZTJkZDZkYjU1NTMyMWQzM2NkIn0.eyJhdWQiOiIxIiwianRpIjoiNzM5NjgyNDYyNTc3MmRjMDYzZmQxODIzNWVjNjhmYWRlYTgwM2EwYjY3MjU2NDVjMmQ4MTAzYTZhZjIxMzFlMmRkNmRiNTU1MzIxZDMzY2QiLCJpYXQiOjE2NjMxNTQ4MTUsIm5iZiI6MTY2MzE1NDgxNSwiZXhwIjo3OTUyNDI4Nzk5LCJzdWIiOiIxMTMwNzEiLCJzY29wZXMiOlsic2hvd3MuaW5kZXhXaXRoR3JhbnRlZCIsInNob3dzLnNob3ciLCJzaG93cy5zaG93LmJ5X3B1YmxpY2lkIiwicGxheWxpc3RzLmluZGV4IiwicGxheWxpc3RzLnN0b3JlIiwicGxheWxpc3RzLnNob3ciLCJwbGF5bGlzdHMudXBkYXRlIiwicGxheWxpc3RzLmRlc3Ryb3kiLCJwbGF5bGlzdHMucG9kY2FzdC5zdG9yZSIsInBsYXlsaXN0cy5wb2RjYXN0LmRlc3Ryb3kiLCJwbGF5bGlzdHMucG9kY2FzdC5tb3ZlIiwicGxheWxpc3RzLmltYWdlLnN0b3JlIiwicGxheWxpc3RzLmltYWdlLmRlc3Ryb3kiLCJwb2RjYXN0cy52aWRlby5pbmRleCIsInBvZGNhc3RzLnZpZGVvLnNob3ciLCJzZWFzb25zLmluZGV4Iiwic2Vhc29ucy5zdG9yZSIsInNlYXNvbnMuc2hvdyIsInNlYXNvbnMuZGVzdHJveSIsInNob3dzLnBvZGNhc3RzLnNlYXNvbi51cGRhdGUiLCJjYW1wYWlnbnMuaW5kZXgiLCJjYW1wYWlnbnMuc2hvdyIsInBvZGNhc3RzLmluZGV4IiwicG9kY2FzdHMuc2hvdyIsInBvZGNhc3RzLnNob3cuYnlfcHVibGljaWQiLCJwb2RjYXN0cy5zdG9yZSIsInBvZGNhc3RzLnVwZGF0ZSIsInBvZGNhc3RzLmRlc3Ryb3kiLCJwb2RjYXN0cy5pbWFnZS5zdG9yZSIsInBvZGNhc3RzLmZpbGUuc3RvcmUiXX0.uWgOLN2_5LAKL9gB0Ij8V5PJjKrwRqAO_wVZ4l0vV73QPPF4MUDUzsYU-1hL4iFFPWanhg018EH_AGZvGdSdrZXqkzBPnqv6TxhL9aCVeayVwvgD-BQwPMJ3E7z27xREEhXH_r6f0d2t_J6SJexVh3AoT8fD2kUyFXh9B95ziWV-vULeHOqtWEZk01YctUyHLFWhIFzajgn8nSHb3hMYfbV4phapZqaegwCBSIxVPJz4yS3Ox0tbI5g-P6fAK5PlE1pKiPXabekYyUN4tPEmpMAQVURM3xcutBXUTMX0H6GCs0ih7KH3cI8SICVrldo3LkbAh8x4uuJJu2aNmv9qHpyxLi9wfmklyWMt0ROuf4dHPiDVLUfwmqnt9UEE4H5jP7hHcrMNCIRzerBgW0cCfKj0wJBtOuYpsqqBou2YTEyYja8uNEQbHpOQT4gT7CJxa575kqKsrTr9tS2k19BPdlxtBoIPQHcVpY9tQ1_TJro72kbE1ooJICZyFYTdHHPX77H4LClYcN4TxHxp8jTp6hXt_BjZbwU7Kl2PIxFV1diK62idKCtBjd_tvnUIuh7sKZeGn-YwCYVZVWRblYmZQ3tmPyje1ZJsgnY_nZIZ1TBwzZf3ucuPRxJJ4vPc3dXkxvLtWUs3bLWnACHCjhRA7LfMNDIlAZoRKHKQI6UNuiE";
  602.     $client = new Client(['base_uri' => 'https://developers.ausha.co/v1/podcasts/']);
  603.     $headers = [
  604.       'Authorization' => 'Bearer ' $aushaToken,
  605.       'accept' => 'application/json',
  606.       'content-type' => 'application/json',
  607.     ];
  608.     $podcast $this->getPodcast($date);
  609.     $idAusha null;
  610.     if ($podcast->getIdAushaEpisodeEc()) {
  611.       $idAusha $podcast->getIdAushaEpisodeEc();
  612.     }
  613.     return [
  614.       'actus' => $this->getActualites($date),
  615.       'transformationDigitale' => $this->getTransformationDigitale($date),
  616.       'infographie' => $this->getInfographie($date),
  617.       'chiffreDuMois' => $this->getChiffreDuMois($date),
  618.       'citation' => $this->getCitation($date),
  619.       'bienEtre' => $this->getBienEtre($date),
  620.       'podcast' => $podcast,
  621.       'idAusha' => $idAusha,
  622.       'sondage' => [
  623.         'details' => $sondage,
  624.         'results' => is_null($sondage) ? null $this->getSondageResult($sondage['id']),
  625.       ],
  626.       'origin' => "actu_mois",
  627.     ];
  628.   }
  629.   /**
  630.    * Renvoie les données nécéssaires au quiz RH
  631.    */
  632.   public function getQuizRh(?string $date null)
  633.   {
  634.     $date $this->getPeriodFromDate($date);
  635.     $result $this->em->getRepository(Actuv2Quiz::class)->findResultBy($date);
  636.     //dd($date, $result);
  637.     if (!empty($result)) {
  638.       return $result;
  639.     } else {
  640.       return null;
  641.     }
  642.   }
  643.   public function getQuizRhVote(?string $date null)
  644.   {
  645.     $date $this->getPeriodFromDate($date);
  646.     //$result = $this->em->getRepository(Actuv2QuizVote::class)->findResultBy($date);
  647.     // dd($date, $result);
  648.     $questions $this->em->getRepository(Actuv2Quiz::class)->findResultBy($date);
  649.     $nbVotes = array();
  650.     foreach ($questions as $question) {
  651.       foreach ($question['answers'] as $answer) {
  652.         $nbVotes[$answer['id']] = $this->em->getRepository(Actuv2QuizVote::class)->countVoteById($answer['id']);
  653.       }
  654.     }
  655.     if (!empty($nbVotes)) {
  656.       return $nbVotes;
  657.     } else {
  658.       return null;
  659.     }
  660.   }
  661.     public function getQuizElectronicInvoice(?string $date null)
  662.     {
  663.         $date $this->getPeriodFromDate($date);
  664.         $result $this->em->getRepository(Actuv2ElectronicInvoice::class)->findResultBy($date);
  665.         //dd($date, $result);
  666.         if (!empty($result)) {
  667.             return $result;
  668.         } else {
  669.             return null;
  670.         }
  671.     }
  672.     public function getQuizElectronicInvoiceVote(?string $date null)
  673.     {
  674.         $date $this->getPeriodFromDate($date);
  675.         //$result = $this->em->getRepository(Actuv2QuizVote::class)->findResultBy($date);
  676.         // dd($date, $result);
  677.         $question $this->em->getRepository(Actuv2ElectronicInvoice::class)->findResultBy($date);
  678.         $nbVotes = array();
  679.         if (empty($question)) {
  680.             return null;
  681.         }
  682.         foreach ($question->getAnswers() as $answer) {
  683.             $nbVotes[$answer->getId()] = $this->em->getRepository(Actuv2ElectronicInvoiceVote::class)->countVoteById($answer->getId());
  684.         }
  685.         if (!empty($nbVotes)) {
  686.             return $nbVotes;
  687.         } else {
  688.             return null;
  689.         }
  690.     }
  691.   public function getNewYear(?string $date null)
  692.   {
  693.     $date $this->getPeriodFromDate($date);
  694.     $newYear $this->em->getRepository(Actuv2NewYear::class)->findOneByDates($date);
  695.     if (empty($newYear)) {
  696.       return null;
  697.     }
  698.     return $newYear;
  699.   }
  700.   public function getNextEvent()
  701.   {
  702.     $res $this->em->getRepository(Actuv2Calendrier::class)->findNextEvent(true);
  703.     if (empty($res)) {
  704.       $res $this->em->getRepository(Actuv2Calendrier::class)->findNextEvent(false);
  705.     }
  706.     // Ajout du jour et du mois
  707.     if (count($res) > 0) {
  708.       $res $res[0];
  709.       $res['jour'] = ($res['date'])->format('d');
  710.       $res['mois'] = ($res['date'])->format('m');
  711.       $res['annee'] = ($res['date'])->format('Y');
  712.     } else {
  713.       $res = [];
  714.     }
  715.     return $res;
  716.   }
  717.   public function getPreviousPeriods(): array
  718.   {
  719.     $tabPeriodes = [];
  720.     $res $this->em->getRepository(Actuv2Actualite::class)->findPreviousPeriods();
  721.     foreach ($res as $ligne) {
  722.       //$objDate = new DateTimeFrench($ligne['date']);
  723.       $date $ligne['date']->format('Y-m-01');
  724.       if (!array_key_exists($date$tabPeriodes)) {
  725.         $tabPeriodes[$date] = [
  726.           "periode" => $date,
  727.           "periodeLibelle" => $ligne['date']->format('F Y')
  728.         ];
  729.       }
  730.     }
  731.     return $tabPeriodes;
  732.   }
  733.   public function setSondageVote($idSondage$reponse$ip$idCabinet 0)
  734.   {
  735.     if (!is_numeric($idSondage) || ($reponse != '1' && $reponse != '2') || trim($ip) == "") {
  736.       return false;
  737.     }
  738.     $sExist $this->em->getRepository(Actuv2Sondage::class)->find($idSondage);
  739.     $svExist $this->em->getRepository(Actuv2Sondagevote::class)->findOneBy(['fkSondage' => $idSondage'ip' => $ip]);
  740.     $svNew = new Actuv2Sondagevote();
  741.     $svNew
  742.       ->setFkSondage($idSondage)
  743.       ->setFkCabinet($idCabinet)
  744.       ->setReponse($reponse)
  745.       ->setIp($ip);
  746.     // On check si le sondage existe
  747.     if (!$sExist instanceof Actuv2Sondage) {
  748.       return false;
  749.     }
  750.     // On check si l'internaute a déjà voté
  751.     if ($svExist instanceof Actuv2Sondagevote) {
  752.       return false;
  753.     }
  754.     // On ajoute le vote
  755.     $this->em->persist($svNew);
  756.     $this->em->flush();
  757.     return true;
  758.   }
  759.   public function setUsefulVote($idActu$ip$type$value)
  760.   {
  761.     $idActu = (int)$idActu;
  762.     if (!is_numeric($idActu) || trim($ip) == "") {
  763.       return false;
  764.     }
  765.     $svExist $this->em->getRepository(Actuv2VoteUseful::class)->findOneBy(['actuId' => $idActu'ip' => $ip'typeActu' => $type]);
  766.     // On check si l'internaute a déjà voté
  767.     if ($svExist instanceof Actuv2VoteUseful) {
  768.       return false;
  769.     }
  770.     $svNew = new Actuv2VoteUseful();
  771.     $svNew
  772.       ->setActuId($idActu)
  773.       ->setDate(new \DateTime())
  774.       ->setIp($ip)
  775.       ->setTypeActu($type)
  776.         ->setCategory($value);
  777.     // On ajoute le vote
  778.     $this->em->persist($svNew);
  779.     $this->em->flush();
  780.     return true;
  781.   }
  782.   public function setQuizVote($idQuiz$reponse$ip)
  783.   {
  784.     // if (!is_numeric($idQuiz) || ($reponse != '1' && $reponse != '2') || trim($ip) == "") {
  785.     //     return false;
  786.     // }
  787.     $date = (new \DateTime());
  788.     $sExist $this->em->getRepository(Actuv2Quiz::class)->find($idQuiz);
  789.     $res $this->em->getRepository(Actuv2QuizAnswer::class)->find($reponse);
  790.     $svExist $this->em->getRepository(Actuv2QuizVote::class)->findOneBy(['quiz' => $idQuiz'ip' => $ip]);
  791.     $svNew = new Actuv2QuizVote();
  792.     $svNew
  793.       ->setAnswer($res)
  794.       ->setquiz($sExist)
  795.       ->setDate($date)
  796.       ->setIp($ip);
  797.     // On check si le sondage existe
  798.     if (!$sExist instanceof Actuv2Quiz) {
  799.       return false;
  800.     }
  801.     if (!$res instanceof Actuv2QuizAnswer) {
  802.       return false;
  803.     }
  804.     // On check si l'internaute a déjà voté
  805.     if ($svExist instanceof Actuv2QuizVote) {
  806.       return false;
  807.     }
  808.     // On ajoute le vote
  809.     $this->em->persist($svNew);
  810.     $this->em->flush();
  811.     return true;
  812.   }
  813.     public function setElectronicInvoiceVote($idElectronicInvoice$reponse$ip)
  814.     {
  815.         // if (!is_numeric($idElectronicInvoice) || ($reponse != '1' && $reponse != '2') || trim($ip) == "") {
  816.         //     return false;
  817.         // }
  818.         $date = (new \DateTime());
  819.         $sExist $this->em->getRepository(Actuv2ElectronicInvoice::class)->find($idElectronicInvoice);
  820.         $res $this->em->getRepository(Actuv2ElectronicInvoiceAnswer::class)->find($reponse);
  821.         $svExist $this->em->getRepository(Actuv2ElectronicInvoiceVote::class)->findOneBy(['electronicInvoice' => $idElectronicInvoice'ip' => $ip]);
  822.         $svNew = new Actuv2ElectronicInvoiceVote();
  823.         $svNew
  824.             ->setAnswer($res)
  825.             ->setElectronicInvoice($sExist)
  826.             ->setDate($date)
  827.             ->setIp($ip);
  828.         // On check si le sondage existe
  829.         if (!$sExist instanceof Actuv2ElectronicInvoice) {
  830.             return false;
  831.         }
  832.         if (!$res instanceof Actuv2ElectronicInvoiceAnswer) {
  833.             return false;
  834.         }
  835.         // On check si l'internaute a déjà voté
  836.         if ($svExist instanceof Actuv2ElectronicInvoiceVote) {
  837.             return false;
  838.         }
  839.         // On ajoute le vote
  840.         $this->em->persist($svNew);
  841.         $this->em->flush();
  842.         return true;
  843.     }
  844.   // ---------------------------------------------------
  845.   //                      RECHERCHE
  846.   // ---------------------------------------------------
  847.   public function search($query)
  848.   {
  849.     if (trim($query) == '') return false;
  850.     $tabWords $this->sanitizeQuery2array($query);
  851.     if (count($tabWords) == 0) return false;
  852.     $result1 $this->em->getRepository(Actuv2Actualite::class)->getQuerySearch($tabWords);
  853.     $result2 $this->em->getRepository(Actuv2Bienetre::class)->getQuerySearch($tabWords);
  854.     $result3 $this->em->getRepository(Actuv2Calendrier::class)->getQuerySearch($tabWords);
  855.     $result4 $this->em->getRepository(Actuv2Transformationdigitale::class)->getQuerySearch($tabWords);
  856.     $resultAll array_merge($result1$result2$result3$result4);
  857.     $host $this->request->get('host');
  858.     $prefix null;
  859.     //$prefix = $host ? '/preview/' . $host : null;
  860.     $results = [];
  861.     foreach ($resultAll as $key => $value) {
  862.       if ($key == 50) {
  863.         break;
  864.       }
  865.       if ($value["categorie"] != "Calendrier fiscal") {
  866.         $slug $this->slugger->slug($value['titre']);
  867.         $value['url'] = $prefix $value['url'] . '-' $slug;
  868.       }
  869.       $value['dateFormated'] = ($value['date'])->format('Y-m-d');
  870.       $results[] = $value;
  871.     }
  872.     return $results;
  873.   }
  874.   public function generateDiapo(array $tabActu): array
  875.   {
  876.     $tabActuCarousel = [];
  877.     foreach ($tabActu as $index => $tab) {
  878.       $tabActuCarousel[$this->getTabActuCarouselIndex($index)]['image' $this->getElementIndex($index 1)] = $tab['image1'];
  879.       $tabActuCarousel[$this->getTabActuCarouselIndex($index)]['titre' $this->getElementIndex($index 1)] = $tab['titre'];
  880.       $tabActuCarousel[$this->getTabActuCarouselIndex($index)]['url' $this->getElementIndex($index 1)] = $tab['url'];
  881.     }
  882.     return $tabActuCarousel;
  883.   }
  884.   private function getTabActuCarouselIndex(int $index): int
  885.   {
  886.     return $index <= 1;
  887.   }
  888.   private function getElementIndex(int $index): int
  889.   {
  890.     if ($index <= 3) {
  891.       return $index;
  892.     }
  893.     return $index ?: $index 2;
  894.   }
  895.   private function sanitizeQuery2array($query)
  896.   {
  897.     $tabWords = array();
  898.     //stop words
  899.     $query str_replace(array("'""’"), ' '$query);
  900.     $tabWords explode(' '$query);
  901.     $tabWords $this->StopWords($tabWords);
  902.     //suppression chaines vides
  903.     foreach ($tabWords as $key => $word) {
  904.       if ($word == '') unset($tabWords[$key]);
  905.     }
  906.     return $tabWords;
  907.   }
  908.   private function stopWords($tWord)
  909.   {
  910.     $stopword = array(
  911.       'à',
  912.       'allô',
  913.       'aucuns',
  914.       'auriez',
  915.       'auxdits',
  916.       'aviez',
  917.       'ayons',
  918.       'bof',
  919.       'çà ',
  920.       'certaines',
  921.       'chez',
  922.       'comment',
  923.       'da',
  924.       'desquels',
  925.       'deviez',
  926.       'devras',
  927.       'doit',
  928.       'dues',
  929.       'dût',
  930.       'es',
  931.       'êtes',
  932.       'eurêka',
  933.       'excepté',
  934.       'fouchtra',
  935.       'fûmes',
  936.       'ho',
  937.       'hurrah',
  938.       'laquelle',
  939.       'leur',
  940.       'mazette',
  941.       'mâtin',
  942.       'ne',
  943.       'nulle',
  944.       'or',
  945.       'outre',
  946.       'pas',
  947.       'plein',
  948.       'pourraient',
  949.       'pourvu',
  950.       'pouviez',
  951.       'puis',
  952.       'pussent',
  953.       'que',
  954.       'quoi',
  955.       'saperlipopette',
  956.       'serait',
  957.       'sien',
  958.       'sommes',
  959.       'ta',
  960.       'telles',
  961.       'touchant',
  962.       'une',
  963.       'veuillez',
  964.       'voilà',
  965.       'voudrez',
  966.       'voulante',
  967.       'voulue',
  968.       'vôtre',
  969.       'afin',
  970.       'alors',
  971.       'auquel',
  972.       'aurions',
  973.       'auxquelles',
  974.       'avions',
  975.       'aïe',
  976.       'boum',
  977.       'car',
  978.       'certains',
  979.       'chic',
  980.       'concernant',
  981.       'dans',
  982.       'devaient',
  983.       'devions',
  984.       'devrez',
  985.       'doive',
  986.       'duquel',
  987.       'eh',
  988.       'et',
  989.       'étiez',
  990.       'eus',
  991.       'eûmes',
  992.       'furent',
  993.       'fût',
  994.       'holà',
  995.       'hé',
  996.       'le',
  997.       'leurs',
  998.       'me',
  999.       'miséricorde',
  1000.       'ni',
  1001.       'nulles',
  1002.       'ôté',
  1003.       'palsambleu',
  1004.       'patatras',
  1005.       'plouf',
  1006.       'pourrais',
  1007.       'pouvaient',
  1008.       'pouvions',
  1009.       'puisque',
  1010.       'put',
  1011.       'quel',
  1012.       'quoique',
  1013.       'sapristi',
  1014.       'seras',
  1015.       'sienne',
  1016.       'son',
  1017.       'tandis',
  1018.       'tels',
  1019.       'tous',
  1020.       'unième',
  1021.       'veuillons',
  1022.       'vos',
  1023.       'voudriez',
  1024.       'voulantes',
  1025.       'voulues',
  1026.       'vôtres',
  1027.       'ah',
  1028.       'apr.',
  1029.       'aura',
  1030.       'aurons',
  1031.       'auxquels',
  1032.       'avoir',
  1033.       'bah',
  1034.       'bravissimo',
  1035.       'ce',
  1036.       'ces',
  1037.       'chiche',
  1038.       'contre',
  1039.       'de',
  1040.       'devais',
  1041.       'devoir',
  1042.       'devriez',
  1043.       'doivent',
  1044.       'durant',
  1045.       'elle',
  1046.       'étaient',
  1047.       'étions',
  1048.       'eusse',
  1049.       'eût',
  1050.       'fus',
  1051.       'fûtes',
  1052.       'hop',
  1053.       'il',
  1054.       'ledit',
  1055.       'lorsque',
  1056.       'merci',
  1057.       'moi',
  1058.       'nonobstant',
  1059.       'nuls',
  1060.       'ou',
  1061.       'pan',
  1062.       'pechère',
  1063.       'plus',
  1064.       'pourrait',
  1065.       'pouvais',
  1066.       'pouvoir',
  1067.       'puisse',
  1068.       'pécaïre',
  1069.       'quelle',
  1070.       'rataplan',
  1071.       'sauf',
  1072.       'serez',
  1073.       'siennes',
  1074.       'sont',
  1075.       'tant',
  1076.       'tes',
  1077.       'tout',
  1078.       'unièmes',
  1079.       'veulent',
  1080.       'votre',
  1081.       'voudrions',
  1082.       'voulants',
  1083.       'voulurent',
  1084.       'zut',
  1085.       'ai',
  1086.       'as',
  1087.       'aurai',
  1088.       'auront',
  1089.       'avaient',
  1090.       'avons',
  1091.       'basta',
  1092.       'bravo',
  1093.       'ceci',
  1094.       'cet',
  1095.       'chouette',
  1096.       'corbleu',
  1097.       'debout',
  1098.       'devait',
  1099.       'devons',
  1100.       'devrions',
  1101.       'doives',
  1102.       'durent',
  1103.       'elles',
  1104.       'étais',
  1105.       'être',
  1106.       'eussent',
  1107.       'eûtes',
  1108.       'fusse',
  1109.       'grâce',
  1110.       'hormis',
  1111.       'ils',
  1112.       'lequel',
  1113.       'lui',
  1114.       'merde',
  1115.       'moins',
  1116.       'nos',
  1117.       'ô',
  1118.       'où',
  1119.       'par',
  1120.       'pendant',
  1121.       'plusieurs',
  1122.       'pourras',
  1123.       'pouvait',
  1124.       'pouvons',
  1125.       'puissent',
  1126.       'pût',
  1127.       'quelles',
  1128.       'revoici',
  1129.       'se',
  1130.       'seriez',
  1131.       'siens',
  1132.       'sous',
  1133.       'taratata',
  1134.       'tien',
  1135.       'toute',
  1136.       'v\'lan',
  1137.       'veut',
  1138.       'voudra',
  1139.       'voudrons',
  1140.       'voulez',
  1141.       'voulus',
  1142.       'aie',
  1143.       'attendu',
  1144.       'auraient',
  1145.       'autant',
  1146.       'avais',
  1147.       'ayant',
  1148.       'beaucoup',
  1149.       'ç\'a',
  1150.       'cela',
  1151.       'cette',
  1152.       'chut',
  1153.       'coucou',
  1154.       'depuis',
  1155.       'devant',
  1156.       'devra',
  1157.       'devrons',
  1158.       'donc',
  1159.       'dus',
  1160.       'en',
  1161.       'était',
  1162.       'eu',
  1163.       'eusses',
  1164.       'évohé',
  1165.       'fussent',
  1166.       'ha',
  1167.       'hors',
  1168.       'jarnicoton',
  1169.       'les',
  1170.       'là',
  1171.       'mes',
  1172.       'mon',
  1173.       'notre',
  1174.       'oh',
  1175.       'ouais',
  1176.       'parbleu',
  1177.       'peu',
  1178.       'pouah',
  1179.       'pourrez',
  1180.       'pouvant',
  1181.       'psitt',
  1182.       'puisses',
  1183.       'qq.',
  1184.       'quelqu\'un',
  1185.       'revoilà',
  1186.       'selon',
  1187.       'serions',
  1188.       'sinon',
  1189.       'soyez',
  1190.       'tayaut',
  1191.       'tienne',
  1192.       'toutes',
  1193.       'va',
  1194.       'veux',
  1195.       'voudrai',
  1196.       'voudront',
  1197.       'vouliez',
  1198.       'voulussent',
  1199.       'aient',
  1200.       'au',
  1201.       'aurais',
  1202.       'autre',
  1203.       'avait',
  1204.       'ayante',
  1205.       'bernique',
  1206.       'ç\'aura',
  1207.       'celle',
  1208.       'ceux',
  1209.       'ciao',
  1210.       'couic',
  1211.       'des',
  1212.       'devante',
  1213.       'devrai',
  1214.       'devront',
  1215.       'dont',
  1216.       'dussent',
  1217.       'encontre',
  1218.       'étant',
  1219.       'eue',
  1220.       'eussiez',
  1221.       'évoé',
  1222.       'fusses',
  1223.       'hein',
  1224.       'hou',
  1225.       'je',
  1226.       'lesdites',
  1227.       'ma',
  1228.       'mien',
  1229.       'morbleu',
  1230.       'nôtre',
  1231.       'ohé',
  1232.       'ouf',
  1233.       'parce',
  1234.       'peuchère',
  1235.       'pour',
  1236.       'pourriez',
  1237.       'pouvante',
  1238.       'pst',
  1239.       'puissiez',
  1240.       'qqch.',
  1241.       'quelqu\'une',
  1242.       'rien',
  1243.       'sera',
  1244.       'serons',
  1245.       'soi',
  1246.       'soyons',
  1247.       'taïaut',
  1248.       'tiennes',
  1249.       'tu',
  1250.       'vers',
  1251.       'via',
  1252.       'voudraient',
  1253.       'voulaient',
  1254.       'voulions',
  1255.       'voulut',
  1256.       'aies',
  1257.       'aucun',
  1258.       'aurait',
  1259.       'autres',
  1260.       'avant',
  1261.       'ayantes',
  1262.       'bien',
  1263.       'ç\'aurait',
  1264.       'celles',
  1265.       'chacun',
  1266.       'clic',
  1267.       'crac',
  1268.       'desdites',
  1269.       'devantes',
  1270.       'devraient',
  1271.       'dia',
  1272.       'du',
  1273.       'dut',
  1274.       'endéans',
  1275.       'étante',
  1276.       'eues',
  1277.       'eussions',
  1278.       'fi',
  1279.       'fussiez',
  1280.       'hem',
  1281.       'hourra',
  1282.       'jusque',
  1283.       'lesdits',
  1284.       'made',
  1285.       'mienne',
  1286.       'motus',
  1287.       'nôtres',
  1288.       'olé',
  1289.       'ouille',
  1290.       'pardi',
  1291.       'peut',
  1292.       'pourquoi',
  1293.       'pourrions',
  1294.       'pouvantes',
  1295.       'pu',
  1296.       'puissions',
  1297.       'qqn',
  1298.       'quels',
  1299.       'sa',
  1300.       'serai',
  1301.       'seront',
  1302.       'soient',
  1303.       'stop',
  1304.       'te',
  1305.       'tiens',
  1306.       'tudieu',
  1307.       'veuille',
  1308.       'vivement',
  1309.       'voudrais',
  1310.       'voulais',
  1311.       'vouloir',
  1312.       'voulût',
  1313.       'ait',
  1314.       'aucune',
  1315.       'auras',
  1316.       'aux',
  1317.       'avec',
  1318.       'ayants',
  1319.       'bigre',
  1320.       'ç\'avait',
  1321.       'celui',
  1322.       'chacune',
  1323.       'clac',
  1324.       'cric',
  1325.       'desdits',
  1326.       'devants',
  1327.       'devrais',
  1328.       'diantre',
  1329.       'dudit',
  1330.       'dès',
  1331.       'entre',
  1332.       'étantes',
  1333.       'euh',
  1334.       'eut',
  1335.       'fichtre',
  1336.       'fussions',
  1337.       'hep',
  1338.       'hue',
  1339.       'la',
  1340.       'lesquelles',
  1341.       'mais',
  1342.       'miennes',
  1343.       'moyennant',
  1344.       'nous',
  1345.       'on',
  1346.       'oust',
  1347.       'pardieu',
  1348.       'peuvent',
  1349.       'pourra',
  1350.       'pourrons',
  1351.       'pouvants',
  1352.       'pue',
  1353.       'purent',
  1354.       'quand',
  1355.       'qui',
  1356.       'sacristi',
  1357.       'seraient',
  1358.       'ses',
  1359.       'sois',
  1360.       'suis',
  1361.       'tel',
  1362.       'toi',
  1363.       'turlututu',
  1364.       'veuillent',
  1365.       'vlan',
  1366.       'voudrait',
  1367.       'voulait',
  1368.       'voulons',
  1369.       'vous',
  1370.       'al.',
  1371.       'aucunes',
  1372.       'aurez',
  1373.       'auxdites',
  1374.       'avez',
  1375.       'ayez',
  1376.       'bis',
  1377.       'ça',
  1378.       'cependant',
  1379.       'chaque',
  1380.       'comme',
  1381.       'crénom',
  1382.       'desquelles',
  1383.       'devez',
  1384.       'devrait',
  1385.       'dois',
  1386.       'due',
  1387.       'dû',
  1388.       'envers',
  1389.       'étants',
  1390.       'eurent',
  1391.       'eux',
  1392.       'fors',
  1393.       'fut',
  1394.       'heu',
  1395.       'hum',
  1396.       'ladite',
  1397.       'lesquels',
  1398.       'malgré',
  1399.       'miens',
  1400.       'na',
  1401.       'nul',
  1402.       'ont',
  1403.       'ouste',
  1404.       'parmi',
  1405.       'peux',
  1406.       'pourrai',
  1407.       'pourront',
  1408.       'pouvez',
  1409.       'pues',
  1410.       'pus',
  1411.       'quant',
  1412.       'quiconque',
  1413.       'sans',
  1414.       'serais',
  1415.       'si',
  1416.       'soit',
  1417.       'sur',
  1418.       'telle',
  1419.       'ton',
  1420.       'un',
  1421.       'veuilles',
  1422.       'voici',
  1423.       'voudras',
  1424.       'voulant',
  1425.       'voulu',
  1426.       'vu'
  1427.     );
  1428.     $result array_diff($tWord$stopword);
  1429.     return $result;
  1430.   }
  1431. }