src/Controller/IndexController.php line 510

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\ClassTheatre\asides;
  4. use App\ClassTheatre\TheatreController;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Component\Cache\Adapter\AdapterInterface;
  7. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  11. use Symfony\Contracts\Translation\TranslatorInterface;
  12. use TheatreCore\Classes\Stats\Stats;
  13. use TheatreCore\Entity\AnnAnnonces;
  14. use TheatreCore\Entity\Classifications;
  15. use TheatreCore\Entity\Contacts;
  16. use TheatreCore\Entity\Contents;
  17. use TheatreCore\Entity\Multimedias;
  18. use TheatreCore\Entity\News;
  19. use TheatreCore\Entity\Persons;
  20. use TheatreCore\Entity\Playlists;
  21. use TheatreCore\Entity\Podcasts;
  22. use TheatreCore\Entity\Spectacles;
  23. use TheatreCore\Entity\Texts;
  24. class IndexController extends TheatreController
  25. {
  26.     public function __construct(
  27.         EntityManagerInterface $em,
  28.         TranslatorInterface    $translator,
  29.         TokenStorageInterface  $tokenStorage,
  30.         ParameterBagInterface  $parameterBag
  31.     )
  32.     {
  33.         parent::__construct($translator$tokenStorage);
  34.         $this->em $em;
  35.         $this->parameterBag $parameterBag;
  36.         $GLOBALS['rub_courante'] = 'actualites';
  37.         $this->view->controller $GLOBALS['rub_courante'];
  38.     }
  39.     /**
  40.      * @Route("/", name="index")
  41.      */
  42.     public function index(TextesController $textesControllerAdapterInterface $cacheStats $globalstatsRequest $request)
  43.     {
  44.         // old process from legacy
  45.         $forceCacheRefresh $request->query->get('calcul_wget') === 'doit';
  46.         $this->view->action $this->context['action'] = 'view';
  47.         $spectacles $this->em->getRepository(Spectacles::class);
  48.         $multimedias $this->em->getRepository(Multimedias::class);
  49.         $contacts $this->em->getRepository(Contacts::class);
  50.         $persons $this->em->getRepository(Persons::class);
  51.         $podcasts $this->em->getRepository(Podcasts::class);
  52.         if ($forceCacheRefresh) {
  53.             $cache->deleteItem('dernieres_critiques_lists_home');
  54.             $cache->deleteItem('culturebox_lists_home');
  55.             $cache->deleteItem('persons_lists_home');
  56.             $cache->deleteItem('spectacles_partenaires_lists_home');
  57.             $cache->deleteItem('spectacles_jtn_lists_home');
  58.             $cache->deleteItem('video_tete_lists_home');
  59.             $cache->deleteItem('videos_affiche_lists_home');
  60.             $cache->deleteItem('derniers_texts_lists_home');
  61.             $cache->deleteItem('next_news_lists_home');
  62.             $cache->deleteItem('asides_cache_lists_home');
  63.             $cache->deleteItem('recommanded_spectacles_all_infos');
  64.         }
  65.         $item $cache->getItem('dernieres_critiques_lists_home');
  66.         if ($item->isHit()) {
  67.             $this->context['view']->dernieres_critiques $item->get();
  68.         } else {
  69.             // trouver les contenus associés aux critiques (101) et les classer par date
  70.             $params_sql_critiques = array(
  71.                 'sql' => array(
  72.                     'select' => 'ct.deck,ct.writer,ct.writer_group,ct.link,ct.writer_group_url,ct.idspectacle,ct.dateinsert,ct.date_article',
  73.                     'order' => ' ct.date_article DESC',
  74.                     // 'groupby' => 'ct.idspectacle',
  75.                     'limit' => array(04),
  76.                 ),
  77.                 'special' => array(
  78.                     'by_classification' => array(101),
  79.                     'get_extranetuser' => true,
  80.                     'publish' => 1,
  81.                     'valid' => 1,
  82.                 ),
  83.                 'dbg' => array('critiques''Liste des critiques'),
  84.             );
  85.             $this->context['view']->dernieres_critiques $this->em->getRepository(Contents::class)->getListContents($params_sql_critiques, array('get_critiques' => true'shorten_title' => true));
  86.             $item->set($this->context['view']->dernieres_critiques)
  87.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  88.             $cache->save($item);
  89.         }
  90.         // Culturebox => les derniers référencés*
  91.         $item $cache->getItem('culturebox_lists_home');
  92.         if (! $item->isHit()) {
  93.             $culturebox_params = array(
  94.                 'limit' => array(01),
  95.                 'random' => ' ',
  96.                 'special' => array(
  97.                     'type_podcast' => 'culturebox',
  98.                     'current' => true,
  99.                 ),
  100.                 'dbg' => array('derniers_culturebox''Les derniers replay culturebox référencés'),
  101.             );
  102.             $format_vignette = array('width' => 480'direction' => 'thumb');
  103.             $this->context['view']->derniers_culturebox $podcasts->getListPodcasts($culturebox_params$format_vignette);
  104.             $item->set($this->context['view']->derniers_culturebox)
  105.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  106.             $cache->save($item);
  107.         } else {
  108.             $this->context['view']->derniers_culturebox $item->get();
  109.         }
  110.         // dernières annonces => stage et offre d'emploi
  111.         $ann_annonces $this->em->getRepository(AnnAnnonces::class);
  112.         $this->context['view']->dernieres_annonces_emploi $ann_annonces->getLastAnnonces(array(03), array(3), 65);
  113.         $this->context['view']->dernieres_annonces_stages $ann_annonces->getLastAnnonces(array(03), array(1), 65);
  114.         $item $cache->getItem('persons_lists_home');
  115.         if ($item->isHit()) {
  116.             $this->context['view']->persons $item->get();
  117.         } else {
  118.             $params_sql = array(
  119.                 'special' => array(
  120.                     'with_photo' => true,
  121.                     'spectacle' => array(
  122.                         'type' => 'author',
  123.                         'prochains' => '90D',
  124.                         'person_periode' => 'contemporain',
  125.                         'text_edite' => true,
  126.                     ),
  127.                     'random' => '',
  128.                 ),
  129.                 'params' => array(
  130.                     'limit' => array(04)
  131.                 ),
  132.                 'dbg' => array('affiche_persons''Les auteurs contemporaines édités à l\'affiche')
  133.             );
  134.             $params_display['vignette_format'] = array('width' => $_ENV['VIGN_PERSONS_WIDTH'], 'height' => $_ENV['VIGN_PERSONS_HEIGHT'], 'direction' => 'crop');
  135.             $this->context['view']->persons $persons->getListPersons($params_sql$params_display);
  136.             $item->set($this->context['view']->persons)
  137.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  138.             $cache->save($item);
  139.         }
  140.         $nb_spectacles 2;
  141.         $item $cache->getItem('spectacles_partenaires_lists_home');
  142.         if ($item->isHit()) {
  143.             $this->context['view']->spectacles_affiche $item->get();
  144.         } else {
  145.             // trouver les contacts correspondants TN/CDN/Autres théare
  146.             $groupe_contacts = array(128129130131);
  147.             $partenaires $contacts->getContactsByClassification($groupe_contacts);// idgroupclassification = 10
  148.             // grouper par type de partenaires
  149.             foreach ($partenaires as $k => $v) {
  150.                 $spectacles_affiche_order[$v['idtypestructure']]['contacts'][$v['idcontact']] = $v;
  151.                 $spectacles_affiche_order[$v['idtypestructure']]['idcontacts'][$v['idcontact']] = $v['idcontact'];
  152.                 if ($v['idtypestructure'] == 'THIN') {
  153.                     $spectacles_affiche_order[$v['idtypestructure']]['classification'] = 'Autres théâtres partenaires';
  154.                     $spectacles_affiche_order[$v['idtypestructure']]['no_link'] = true;
  155.                     $spectacles_affiche_order[$v['idtypestructure']]['classification_nomaj'] = strtolower($spectacles_affiche_order[$v['idtypestructure']]['classification']);
  156.                 } elseif ($v['idtypestructure'] == 'CDN') {
  157.                     $spectacles_affiche_order[$v['idtypestructure']]['classification'] = 'Centres dramatiques';
  158.                     $spectacles_affiche_order[$v['idtypestructure']]['classification_nomaj'] = 'centres dramatiques';
  159.                 } else {
  160.                     $spectacles_affiche_order[$v['idtypestructure']]['classification_nomaj'] = strtolower($this->context['tr']->trans($v['classification']));
  161.                     $spectacles_affiche_order[$v['idtypestructure']]['classification'] = $this->context['tr']->trans($v['classification']);
  162.                 }
  163.                 $spectacles_affiche_order[$v['idtypestructure']]['idclassification'] = $v['idclassification'];
  164.                 $spectacles_affiche_order[$v['idtypestructure']]['idtypestructure'] = $v['idtypestructure'];
  165.             }
  166.             foreach ($spectacles_affiche_order as $k => $v) {
  167.                 // pour les scènes nationales, rechercher dans toutes les scènes
  168.                 if ($v['idclassification'] == 130) {
  169.                     $v['idcontacts'] = array();
  170.                     $contacts_sn $this->em->getRepository(Contacts::class)->getListContacts(array(
  171.                         'idtypestructure' => 'SN',
  172.                         'limit' => array(0100),
  173.                         'dbg' => array('liste_sn''liste des scènes nationales'),
  174.                     ));
  175.                     foreach ($contacts_sn as $kb => $vb) {
  176.                         $v['idcontacts'][$vb['idcontact']] = $vb['idcontact'];
  177.                     }
  178.                 }
  179.                 // rechercher les spectacles à l'affiche
  180.                 $params_spectacles_affiche = array(
  181.                     'params' => array(
  182.                         'limit' => array(020),
  183.                     ),
  184.                     'special' => array(
  185.                         'prochains' => 120,
  186.                         'random' => '',
  187.                         'idcontacts' => array('IN'$v['idcontacts']),
  188.                         'idcontact' => $v['idcontacts'],
  189.                         'publish_valid' => 1// les critiques publiées
  190.                     ),
  191.                     'dbg' => array('spectacles_' $v['idtypestructure'], 'Spectacles à l\'affiche pour les ' $v['idtypestructure'])
  192.                 );
  193.                 $params_display = array('allauthors' => true);
  194.                 $format_vignette['vignette'] = array('width' => 100'height' => 100'direction' => 'crop''valround' => 7);
  195.                 $spectacles_affiche $spectacles->getListSpectacles($params_spectacles_affiche$format_vignettefalse$params_display);
  196.                 if (! empty($spectacles_affiche)) {
  197.                     $spectacles_affiche_reduce = array();
  198.                     $i 0;
  199.                     foreach ($spectacles_affiche as $kb => $vb) {
  200.                         $vb['footer_contact'] = true;
  201.                         $spectacles_affiche_reduce[$kb] = $vb;
  202.                         $i++;
  203.                         if ($i == $nb_spectacles) {
  204.                             break;
  205.                         }
  206.                     }
  207.                     $spectacles_affiche_order[$k]['spectacles'] = $spectacles_affiche_reduce;
  208.                 } else {
  209.                     unset($spectacles_affiche_order[$k]);
  210.                 }
  211.             }
  212.             $spectacles_affiche_by_classification = [];
  213.             foreach (['TN''CDN''SN''THIN'] as $key) {
  214.                 if (! empty($spectacles_affiche_order[$key])) {
  215.                     array_push($spectacles_affiche_by_classification$spectacles_affiche_order[$key]);
  216.                 }
  217.             }
  218.             $this->context['view']->spectacles_affiche $spectacles_affiche_by_classification;
  219.             // sauver dans le cache
  220.             $item->set($this->context['view']->spectacles_affiche)
  221.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  222.             $cache->save($item);
  223.         }
  224.         //On vérifie le cache
  225.         $item $cache->getItem('spectacles_jtn_lists_home');
  226.         if ($item->isHit()) {
  227.             $this->context['view']->spectacles_soutien $item->get();
  228.         } else {
  229.             // spectacles du JTN
  230.             $params_sql_soutien = array(
  231.                 'params' => array(
  232.                     'limit' => array(04),
  233.                 ),
  234.                 'special' => array(
  235.                     'prochains' => 180,
  236.                     'random' => '',
  237.                     'aide' => [
  238.                         'idaidecontact' => 105
  239.                     ],
  240.                     'spectacle_aide' => true
  241.                 ),
  242.                 'dbg' => array('spectacle_soutien''Les spectacles avec un soutien à l\'affiche'),
  243.             );
  244.             $format_vignette['vignette'] = array('width' => 100'height' => 100'direction' => 'crop''valround' => 7);
  245.             $params_display = array('allauthors' => true);
  246.             $spectacles_soutien $spectacles->getListSpectacles($params_sql_soutien$format_vignettefalse$params_display);
  247.             if (! empty($spectacles_soutien)) {
  248.                 $i 0;
  249.                 foreach ($spectacles_soutien as $k => $v) {
  250.                     $v['footer_contact'] = true;
  251.                     $this->context['view']->spectacles_soutien[$k] = $v;
  252.                 }
  253.             }
  254.             // sauver dans le cache si les données existent
  255.             if (! empty($this->context['view']->spectacles_soutien)) {
  256.                 $item->set($this->context['view']->spectacles_soutien)
  257.                     ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  258.                 $cache->save($item);
  259.             }
  260.         }
  261.         $this->context['view']->is_new_player true;
  262.         $item $cache->getItem('video_tete_lists_home');
  263.         $exclude_videos = [];
  264.         if ($item->isHit()) {
  265.             $this->context['view']->video_tete $item->get();
  266.             $exclude_videos = array($this->context['view']->video_tete[0]['idmultimedia']);
  267.         } else {
  268.             // une vidéo d'un spectacle à l'affiche
  269.             $params_query_affiche = array(
  270.                 'idclassification' => 'class_jour_' strtolower(date('D')),
  271.                 // 'affiche' => array('today' => 180),
  272.                 // 'language' => 'fr',
  273.                 'limit' => array(01),
  274.                 'dbg' => array('tete_jour''Vidéo du jour ' strtolower(date('D'))),
  275.             );
  276.             $video_tete_result $multimedias->getListMultimedias($params_query_affiche);
  277.             // si pas de vidéo du jour, prendre la vidéo de tête
  278.             if (empty($video_tete_result)) {
  279.                 // une vidéo d'un spectacle à l'affiche
  280.                 $params_query_affiche = array(
  281.                     'affiche' => array('today' => 180),
  282.                     // 'language' => 'fr',
  283.                     'limit' => array(01),
  284.                     'where' => array(array('multimedias''video_tete'1)),
  285.                     'dbg' => array('tete''Vidéo de tête d\'un spectacle à l\'affiche'),
  286.                 );
  287.                 $video_tete_result $multimedias->getListMultimedias($params_query_affiche);
  288.             }
  289.             // si pas de vidéo de tête, prendre une vidéo à l'affiche
  290.             if (empty($video_tete_result)) {
  291.                 // une vidéo d'un spectacle à l'affiche
  292.                 $params_query_affiche = array(
  293.                     //'affiche' => array('today' => 15),
  294.                     'language' => 'fr',
  295.                     'limit' => array(01),
  296.                     'dbg' => array('tete''Vidéo de tête d\'un spectacle à l\'affiche'),
  297.                 );
  298.                 $video_tete_result $multimedias->getListMultimedias($params_query_affiche);
  299.             }
  300.             foreach ($video_tete_result as $k => $v) {
  301.                 $video_tete $v;
  302.                 $idmultimedia_affiche $v['idmultimedia'];
  303.                 break;
  304.             }
  305.             $set_format $set_format_flou = array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none''ratio' => '169');
  306.             $set_format_flou['blur'] = true;
  307.             $video_tete array_merge($video_tete, array(
  308.                 'vignette' => $multimedias->getVignetteMultimedia($video_tete['idmultimedia'], $set_format),
  309.                 'vignette_flou' => $multimedias->getVignetteMultimedia($video_tete['idmultimedia'], $set_format_flou),
  310.                 'description_courte' => $multimedias->cutSentence($video_tete['description'], 100),
  311.                 'langue' => $multimedias->getNameLanguage($video_tete['language'])
  312.             ));
  313.             // lien vers la video
  314.             foreach ($video_tete['spectacles'] as $s) {
  315.                 $video_tete['url_clean_video'] = '/spectacles/' $s['url_clean'] . '/videos/' $video_tete['url_clean'] . '?autostart';
  316.             }
  317.             $this->context['view']->video_tete = array($video_tete);
  318.             $exclude_videos = array($idmultimedia_affiche);
  319.             // sauver dans le cache
  320.             $item->set($this->context['view']->video_tete)
  321.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  322.             $cache->save($item);
  323.         }
  324.         if (isset($this->context['view']->video_tete[0])) {
  325. //            $session->setValue('currentVideo', md5($this->context['view']->video_tete[0]['idmultimedia']));
  326.         }
  327.         $item $cache->getItem('videos_affiche_lists_home');
  328.         if ($item->isHit()) {
  329.             $this->context['view']->videos_affiche $item->get();
  330.         } else {
  331.             // les vidéos de spectacles à l'affiche
  332.             $params_videos_affiche = [
  333.                 'order' => ['RAND()'],
  334.                 'where' => [
  335.                     [
  336.                         'multimedias''idmultimedia'$exclude_videos'AND''NOT IN'
  337.                     ]
  338.                 ],
  339.                 'affiche' => ['today' => 7],
  340.                 'limit' => [04],
  341.                 'dbg' => ['affiche''Vidéos de spectacles à l\'affiche'],
  342.             ];
  343.             $this->context['view']->videos_affiche $multimedias->getListMultimedias($params_videos_affiche,
  344.                 array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none''ratio' => '169'),
  345.                 array('get_schedule' => true'format_vignette' => true));
  346.             // sauver dans le cache
  347.             $item->set($this->context['view']->videos_affiche)
  348.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  349.             $cache->save($item);
  350.         }
  351.         //Les fichiers multimedias que l'on ne souhaite pas voir afficher en page d'accueil
  352.         $multimedia_exclude = array(51266056118081186311868118991189511897119012024);
  353.         try {
  354.             $plusvues $globalstats->getMostViewed(14$multimedia_exclude);
  355.         } catch (\Throwable $e) {
  356.             $plusvues false;
  357.         }
  358.         if (! empty($plusvues)) {
  359.             foreach ($plusvues as $k => $v) {
  360.                 $idmultimedia_plusvues[] = $v["idmultimedia"];
  361.             }
  362.             if (! empty($idmultimedia_plusvues)) {
  363.                 $params_query_plusvues = array(
  364.                     'limit' => array(04),
  365.                     'where' => array(array('multimedias''idmultimedia'$idmultimedia_plusvues)),
  366.                     'order' => array(array('multimedias''idmultimedia'$idmultimedia_plusvues)), // classement FIELD()
  367.                     'direction' => 'no',
  368.                     'dbg' => array('plusvues''Vidéos les plus vues'),
  369.                 );
  370.                 $this->view->plusvues_videos $multimedias->getListMultimedias($params_query_plusvues,
  371.                     array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none''ratio' => '169'),
  372.                     array('display' => array('no_footer' => true))
  373.                 );
  374.             }
  375.         }
  376.         /* -- contenus_pedagogiques_spectacles */
  377.         //Nous préparons la requête pour les spectacles de educ
  378.         // trouver les spectacles qui ont des contenus éduc => 125
  379.         $sql 'SELECT s.`idspectacle` FROM spectacles s
  380.             JOIN object_content oc  ON oc.`idobject`=s.`idspectacle`
  381.             JOIN contents c ON c.`idcontent`=oc.`idcontent`
  382.             JOIN content_classification cc ON cc.`idcontent`=c.`idcontent`
  383.         WHERE c.publish=1
  384.             AND oc.object=\'spectacles\'
  385.             AND cc.idclassification=125
  386.             AND s.`publish`=1 AND s.`valid`=1';
  387.         if ($idspectacles_from_spectacles $spectacles->queryCol($sql)) {
  388.             if (! empty($idspectacles_from_spectacles)) {
  389.                 foreach ($idspectacles_from_spectacles as $k => $v) {
  390.                     $idspectacles[$v] = $v;
  391.                 }
  392.                 $params_spectacles = array(
  393.                     'special' => array(
  394.                         'idspectacle' => $idspectacles,
  395.                         'plus_proche' => true,
  396.                         'prochains' => true
  397.                     ),
  398.                     'params' => array(
  399.                         'limit' => array(02),
  400.                     ),
  401.                     'dbg' => array('list_spectacles_educ_enscene''Liste des spectacles avec un contenu educ enscene'),
  402.                 );
  403.                 $this->view->contenus_pedagogiques_spectacles $spectacles->getListSpectacles($params_spectacles, array(), false, array('allauthors' => true));
  404.             }
  405.         }
  406.         foreach ($this->view->contenus_pedagogiques_spectacles as $k => $v) {
  407.             $this->view->contenus_pedagogiques_spectacles[$k]['footer_contact'] = true;
  408.         }
  409.         /* -- theatre-en-acte-textes */
  410. //Nous préparons la requête pour les textes de theatre-en-acte
  411.         $sql 'SELECT t.`idtext` FROM texts t
  412.             JOIN object_content oc  ON oc.`idobject`=t.`idtext`
  413.             JOIN contents c ON c.`idcontent`=oc.`idcontent`
  414.             JOIN content_classification cc ON cc.`idcontent`=c.`idcontent`
  415.         WHERE c.publish=1
  416.             AND oc.object=\'texts\'
  417.             AND cc.idclassification=207
  418.             AND t.`publish`=1 AND t.`valid`=1';
  419.         //On crée la variable pour le dataobject texts
  420.         $texts $this->em->getRepository(Texts::class);
  421.         //On execute la requête
  422.         if ($idtexts $texts->queryAll($sql)) {
  423.             //On récupère
  424.             foreach ($idtexts as $value) {
  425.                 $itexts[] = $value['idtext'];
  426.             }
  427.             $params_sql = array(
  428.                 'special' => array(
  429.                     'idtext' => $itexts,
  430.                     'prochains' => 365
  431.                 ),
  432.                 'params' => array(
  433.                     // TODO pas les adaptations =>pour avoir le MEME nombre dans les deux cas
  434.                     'where' => ' s.`title` IS NULL ',
  435. //                    'groupby' => ' s.`idtext` ',
  436.                     'limit' => array(02)
  437.                 ),
  438.                 'dbg' => array('list_spectacles_texts''Liste des textes theatre-en-acte')
  439.             );
  440.             $list_spectacles $spectacles->getListSpectacles($params_sql);
  441.             $this->view->theatre_en_acte_texts $texts->getTextsFromSpectacles($list_spectacles, array());
  442.             // $vignette_format,false,true,$params_row
  443.             $vignette_format_blur $vignette_format = array('width' => $_ENV['VIGN_TEXT_WIDTH'], 'height' => $_ENV['VIGN_TEXT_HEIGHT'], 'direction' => 'thumb');
  444.             $vignette_format_blur['blur'] = true;
  445.             if (! empty($this->view->theatre_en_acte_texts)) {
  446.                 foreach ($this->view->theatre_en_acte_texts as $key => $val) {
  447.                     $this->view->theatre_en_acte_texts[$key]['vignette'] = $this->em->getRepository(Texts::class)->getVignetteText($val['idtext'], $vignette_format);
  448.                     $this->view->theatre_en_acte_texts[$key]['vignette_flou'] = $this->em->getRepository(Texts::class)->getVignetteText($val['idtext'], $vignette_format_blur);
  449.                 }
  450.             }
  451.         }
  452.         $item $cache->getItem('derniers_texts_lists_home');
  453.         if ($item->isHit()) {
  454.             $this->context['view']->derniers_textes_publi $item->get();
  455.         } else {
  456.             // requete commune
  457.             // les derniers textes publies avec une couverture
  458.             $where_text '
  459.      AND (T1.idgenretext=1 OR T1.idgenretext IS NULL)
  460.      AND T1.idcontact_publisher!=\'\'
  461.      AND T1.publish=1
  462.      AND (T1.publication_year < YEAR(NOW()) OR (T1.publication_year=YEAR(NOW()) AND (ISNULL(T1.publication_month) OR T1.publication_month<=MONTH(NOW())))) ';
  463.             $params_sql_texts = array(
  464.                 'params' => array(
  465.                     'where' => $where_text,
  466.                     'limit' => array(020),
  467.                     'classement' => 'DESC',
  468.                     'order' => 'T1.publication_year DESC, T1.publication_month DESC ',
  469.                 ),
  470.                 'special' => array(
  471.                     'avec_couverture' => true,
  472.                 )
  473.             );
  474.             $params_list_texts = array(
  475.                 'stylemore' => array('imagep' => 'width:60px;''desctxt' => 'width:170px;'),
  476.                 'vignette_format' => array('width' => $_ENV['VIGN_TEXT_WIDTH'], 'height' => $_ENV['VIGN_TEXT_HEIGHT'], 'direction' => 'thumb'),
  477.                 'publisher_first_inverse' => true
  478.             );
  479.             $texts $this->em->getRepository(Texts::class);
  480.             // dernieres textes publies
  481.             $params_sql_texts['params']['where'] = $where_text;
  482.             //echo $texts->getSQLTexts($params_sql_texts['params'],$params_sql_texts['special']);
  483.             $derniers_textes_publi $texts->getListTexts($params_sql_texts$params_list_texts);
  484.             if (! empty($derniers_textes_publi)) {
  485.                 shuffle($derniers_textes_publi);
  486.                 $i 0;
  487.                 foreach ($derniers_textes_publi as $k => $v) {
  488.                     $v['publisher_first'] = true;
  489.                     foreach ($v['publisher'] as $publisher) {
  490.                         $v['publisher'] = $publisher;
  491.                     }
  492.                     $this->context['view']->derniers_textes_publi[$k] = $v;
  493.                     $i++;
  494.                     if ($i == 3) {
  495.                         break;
  496.                     }
  497.                 }
  498.                 $item->set($this->context['view']->derniers_textes_publi)
  499.                     ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  500.             }
  501.             // sauver dans le cache
  502.             $cache->save($item);
  503.         }
  504.         $cache_next_news $cache->getItem('next_news_lists_home');
  505.         if ($cache_next_news->isHit()) {
  506.             $this->context['view']->next_news $cache_next_news->get();
  507.         } else {
  508.             $news $this->em->getRepository(News::class);
  509.             // récupérer les prochains évènements
  510.             $news_params = array(
  511.                 'params' => array(
  512.                     'limit' => array(05),
  513.                 ),
  514.                 'special' => array(
  515.                     'prochains' => 180,
  516.                     'publish_valid' => true,
  517.                     'type_news' => 'news',
  518.                     'is_homepage' => 1,
  519.                 ),
  520.                 'dbg' => array('news''Liste des prochains évènements')
  521.             );
  522.             $this->context['view']->next_news $news->getListNews($news_params, array('display' => ['no_descrip' => true]));
  523.             // sauver dans le cache
  524.             $cache_next_news->set($this->context['view']->next_news);
  525.             $cache->save($cache_next_news);
  526.         }
  527.         // textes par l'auteur
  528.         $textesController->context['action'] = 'index';
  529.         $textesController->getTextByAuteurs(array('limit_query' => [02]));
  530.         $this->context['view']->texts $textesController->context['view']->texts;
  531.         if (! empty($this->context['view']->texts)) {
  532.             foreach ($this->context['view']->texts as $skey => $sval) {
  533.                 $sql 'SELECT p.idplaylist
  534.               FROM playlists p
  535.               LEFT JOIN playlist_classification pc ON p.idplaylist = pc.idplaylist
  536.               WHERE pc.idclassification = 144 AND p.idtext = ' $sval['idtext'] . '
  537.               GROUP BY p.idtext';
  538.                 if ($x $spectacles->queryOne($sql)) {
  539.                     $texte_par_auteurs[$skey] = $this->context['view']->texts[$skey];
  540.                     $playlists $this->em->getRepository(Playlists::class);
  541.                     $playlist $playlists->getInfosPlaylist(
  542.                         $x,
  543.                         array(
  544.                             'all' => true,
  545.                             'multimedias' => true,
  546.                             'format_vignette' => array('width' => 325'height' => 162'fleche' => 'none''ratio' => '169'//'direction'=>'crop'
  547.                         ),
  548.                         array('format_vignette' => true)
  549.                     );
  550.                     $video = (array_shift($playlist['multimedias']));
  551.                     $texte_par_auteurs[$skey]['title'] = $video['sujet_titre'];
  552.                     $texte_par_auteurs[$skey]['playlist']['vignette'] = $video['vignette'];
  553.                     $texte_par_auteurs[$skey]['playlist']['vignette_flou'] = $video['vignette_flou'];
  554.                     $texte_par_auteurs[$skey]['playlist']['thtv'] = true;
  555.                     $texte_par_auteurs[$skey]['playlist']['thtv_permalink'] = $video['permalink'];
  556.                     $texte_par_auteurs[$skey]['playlist']['url_clean_video'] = $playlist['urlClean'];
  557.                 }
  558.             }
  559.             $this->context['view']->texte_par_auteurs $texte_par_auteurs;
  560.         }
  561.         //Les spectacles à l'affiche avec podcasts audio France Culture
  562.         $params_sql = array(
  563.             'special' => array(
  564.                 'textfictif' => 0,
  565.                 'prochains' => true,
  566.                 'podcasts' => [
  567.                     'type_podcast' => 'franceculture'
  568.                 ]
  569.             ),
  570.             'params' => [
  571.                 'limit' => [04]
  572.             ],
  573.             'dbg' => array('list_textes_affiche''Liste des spectacles avec textes non fictifs qui ont un podcast'),
  574.         );
  575.         $spectacles_podcasts $spectacles->getListSpectacles($params_sqlnullfalse, array('allauthors' => true'carrer_couleurs' => true));
  576.         foreach ($spectacles_podcasts as $k => $v) {
  577.             $spectacles_podcasts[$k]['footer_contact'] = true;
  578.         }
  579.         $this->context['view']->spectacles_podcasts $spectacles_podcasts;
  580.         $franceculture_params = array(
  581.             //'direction' => 'DESC',
  582.             'limit' => array(01),
  583.             'special' => array(
  584.                 'type_podcast' => 'franceculture',
  585.             ),
  586.             'dbg' => array('derniers_franceculture''Les derniers podcasts franceculture référencés'),
  587.         );
  588.         $this->context['view']->last_podcasts $podcasts->getListPodcasts($franceculture_params);
  589.         // contacts de page d'accueil
  590.         $partenaires $contacts->getContactsByClassification('class_petit_bandeau');// idgroupclassification = 10
  591.         $classifications $this->em->getRepository(Classifications::class);
  592.         foreach ($partenaires as $k => $v) {
  593.             $v['filepath'] = $_ENV['URL_DIRECTORYUPLOAD'] . $contacts->getThumbnail($v['file'], 220'L');
  594.             // récupèrer la classification du group 10
  595.             $classifications_contact $this->em->getRepository(Classifications::class)->getObjectClassifications('contacts'$v['idcontact'], 10);
  596.             if (! empty($classifications_contact)) {
  597.                 foreach ($classifications_contact as $c) {
  598.                     $partenaires_list[$c['idclassification']]['classification'] = $this->context['tr']->trans($c['classification']);
  599.                     $partenaires_list[$c['idclassification']]['contacts'][$v['idcontact']] = $v;
  600.                 }
  601.             }
  602.         }
  603.         // classement des classifications
  604.         $partenaires_list_by_classifications = [];
  605.         $classifications_list $classifications->getClassificationsInGroup(10);// idgroupclassification = 10
  606.         foreach ($classifications_list as $k => $v) {
  607.             if (isset($partenaires_list[$v['idclassification']])) {
  608.                 $partenaires_list_by_classifications[$k] = $partenaires_list[$v['idclassification']];
  609.             }
  610.         }
  611.         $this->view->partenaires_list $partenaires_list_by_classifications;
  612.         $this->view->titre_de_la_page 'Théâtre contemporain - Auteurs de théâtre, spectacles, mise en scène et tout l\'univers du théâtre';
  613.         //Ajout d'une description pour le site
  614.         $this->view->meta_description "Theatre-contemporain.net présente la création scénique dans les pays francophones et en langue française dans le monde : textes théâtraux contemporains et classiques, danse, performances, opéra... Le site propose l’actualité en régions, des contenus pédagogiques, des vidéos, des critiques...";
  615.         // Cache des asides
  616.         $cache_next_asides $cache->getItem('asides_cache_lists_home');
  617.         if ($cache_next_asides->isHit()) {
  618.             $this->context['view']->aside $cache_next_asides->get();
  619.         } else {
  620.             $asides = new asides();
  621.             $asides->load('common_carte');
  622.             asides::setEntityManager($this->em);
  623.             asides::loadaside('Publicite')->addWithNational($asides); //$this->area
  624.             $asides->load('common_participer_contacts');
  625.             $asides->load('textes_publications_recentes');
  626.             $asides->load('common_enacte_pub');
  627.             $asides->load('common_prochain_evenement');
  628.             $asides->load('common_facebook');
  629.             $asides->load('common_partenaires');
  630.             $asides->load(['common_culturebox' => [
  631.                 'footer' => true
  632.             ]]);
  633.             $asides->load('common_twitter');
  634.             $asides->load('common_offre_annonce');
  635.             $this->context['view']->aside $asides->view();
  636.             // sauver dans le cache
  637.             $cache_next_asides->set($this->context['view']->aside);
  638.             $cache->save($cache_next_asides);
  639.         }
  640.         $item $cache->getItem('recommanded_spectacles_all_infos');
  641.         if (! $item->isHit()) {
  642.             $recommandedSpectacles $spectacles->getListSpectacles([
  643.                 "params" => [
  644.                     "limit" => [04]
  645.                 ],
  646.                 "special" => [
  647.                     "prochains" => "30",
  648.                     "recommandations" => true,
  649.                     "publish_valid" => true
  650.                 ]
  651.             ]);
  652.             $paramsVignette = [
  653.                 'vignette' => [
  654.                     'width' => 100,
  655.                     'height' => 100,
  656.                     'direction' => 'crop',
  657.                     'fleche' => 'moyen'
  658.                 ],
  659.                 'get_vignette' => true
  660.             ];
  661.             $recommandedSpectaclesAllInfos = [];
  662.             // Toutes les infos des prochains spectacles avec recommandations
  663.             foreach ($recommandedSpectacles as $spectacle) {
  664.                 $spectacle $spectacles->getInfosSpectacle($spectacle['idspectacle'], $paramsVignette);
  665.                 $spectacle['carrer'] = $spectacles->getObjectsCarrerDetails($spectacle['idspectacle']);
  666.                 if ($dates $spectacles->getProchDateLieu(array('prochains' => true), $spectacle['idspectacle'])) {
  667.                     $spectacle array_merge($spectacle$dates);
  668.                 }
  669.                 if (! isset($spectacle['affcontact'])
  670.                     && (isset($spectacle['contact']) && isset($spectacle['contact']['organisation']) && ! empty($spectacle['contact']['organisation']))
  671.                 ) {
  672.                     $spectacle['affcontact'] = true;
  673.                 }
  674.                 $spectacle['footer_critique'] = true;
  675.                 $spectacle['nombre_critique'] = $this->em->getRepository(Contents::class)->countAssociateContent('spectacles'$spectacle['idspectacle'], 'class_critique', array('publish_valid' => 1));
  676.                 $spectacle['url_clean_more'] = 'critiques/';
  677.                 $spectacle['nbRecommandations'] = $spectacles->countSpectacleRecommandations($spectacle['idspectacle']);
  678.                 $spectacle $spectacles->clearSpectaclesAddAllPersons($spectacle);
  679.                 $recommandedSpectaclesAllInfos[] = $spectacle;
  680.             }
  681.             $item->set($recommandedSpectaclesAllInfos)
  682.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  683.             $cache->save($item);
  684.         }
  685.         $this->context['view']->recommandedSpectaclesAllInfos $item->get();
  686.         $GLOBALS['rub_courante'] = 'actualites';
  687.         return $this->view('index/view.html.twig');
  688.     }
  689. }