src/Controller/StructuresController.php line 121

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\ClassTheatre\asides;
  4. use App\ClassTheatre\TheatreController;
  5. use App\Exception\RedirectException;
  6. use App\Service\Functions;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  10. use Symfony\Contracts\Translation\TranslatorInterface;
  11. use TheatreCore\Entity\Contacts;
  12. use TheatreCore\Entity\Contents;
  13. use TheatreCore\Entity\Files;
  14. use TheatreCore\Entity\Multimedias;
  15. use TheatreCore\Entity\News;
  16. use TheatreCore\Entity\Persons;
  17. use TheatreCore\Entity\Playlists;
  18. use TheatreCore\Entity\Spectacles;
  19. use TheatreCore\Entity\Texts;
  20. use TheatreCore\Entity\Typesstructures;
  21. class StructuresController extends TheatreController
  22. {
  23.     // objet newsletters
  24.     public $newsletters null;
  25.     // objet abonnés / subscribers
  26.     public $subscribers null;
  27.     // raccourci view
  28.     public $view null;
  29.     // raccourci form
  30.     public $form null;
  31.     //les aides
  32.     private $asides null;
  33.     private $menu_content null;
  34.     private $area null;
  35.     private $structures_listes null;
  36.     private $structure null;
  37.     private $spectacles null;
  38.     private $function;
  39.     // {{{ _construct()
  40.     public function __construct(EntityManagerInterface $emTranslatorInterface $translatorTokenStorageInterface $tokenStorageFunctions $function)
  41.     {
  42.         parent::__construct($translator$tokenStorage);
  43.         $this->context['controller'] = $this->view->controller 'structures';
  44.         $this->view->area '';
  45.         $this->em $em;
  46.         $this->function $function;
  47.         $this->spectacles $em->getRepository(Spectacles::class);
  48.         $this->asides = new asides();
  49.     }
  50.     private function InitController($structure null$action null)
  51.     {
  52.         $this->view->action $this->context['action'] = $action;
  53.         $choix_structures = array(
  54.             'SN',
  55.             'TN',
  56.             'CDN',
  57.             'SC'
  58.         );
  59.         // les types de structure
  60.         $this->structures_listes $this->em->getRepository(Typesstructures::class)->getTypeStructureList(true,true,$choix_structures);
  61.         $this->context['view']->idstructure $this->structure $structure;
  62.         if(array_key_exists($this->structure$this->structures_listes)){
  63.             $this->context['view']->structure_name $this->structures_listes[$this->structure];
  64.             $this->context['view']->idtypestructure $this->structure;
  65.         }
  66.         else{
  67.             throw new RedirectException($this->generateUrl('index'));
  68.         }
  69.     }
  70.     public function finalizeAction()
  71.     {
  72.         $this->getAsides();
  73.         $this->context['view']->aside $this->asides->view($this->context['view']);
  74.         $asides_top = new asides();
  75.         $asides_top->load(['aside_top' => array(
  76.             'php' => array(
  77.                 'method' => 'asidesUrlListsMenuCDN',
  78.             )
  79.         )
  80.         ]);
  81.         $this->context['view']->aside_top $asides_top->view($this->context['view']);
  82.     }
  83.     // {{{ action_actualites()
  84.     /** page d'accueil de la région
  85.      *
  86.      * @Route("/structures/actualites/{structure}", name="structures_actualites")
  87.      *
  88.      * @access public
  89.      * @return void
  90.      */
  91.     public function action_actualites($structure null)
  92.     {
  93.         $this->InitController($structure'actualites');
  94.         $route $this->getSpectaclesAffiches(); //les spectacles à l'affiche
  95.         if ($route != null) {
  96.             return $route;
  97.         }
  98.         $this->getSpectaclesAffichesVideos(); //les spectacles à l'affiche en vidéo
  99.         $this->getEvenements(); //les évènements
  100.         $this->getDirecteursAffiches(); //textes par l'auteur
  101.         // $this->getSpectaclesJTN();
  102.         // $this->getContamporainAffiche(); //les auteurs contemporainrs à l'affiche
  103.         // $this->getCritiques(); //les critiques
  104.         // $this->getTextesByAuteurs(); //textes par l'auteur
  105.         $this->context['view']->is_actu true;
  106.         $this->view->locate = array(
  107.             => 'Actualités'
  108.         );
  109.         return $this->view('structures/actualites.html.twig');
  110.     }
  111.     // }}}
  112.     // {{{ getEvenements()
  113.     public function getDirecteursAffiches(){
  114.         $params_sql = array(
  115.             'params' => array(
  116.                 'limit' => array(0,4)
  117.             ),
  118.             'special' => array(
  119.                 'contact_person' => array(
  120.                     'idoffice' => 'directeur'// Direction
  121.                     'idtypestructure' => $this->structure,
  122.                     'actual' => true
  123.                 ),
  124.                 'spectacle' => array(
  125.                     'type' => 'director',
  126.                     'prochains' => '360D'
  127.                 ),
  128.                 'random' => '',
  129.             ),
  130.             'dbg' => array('directeur','Les directeurs de '.$this->structure)
  131.         );
  132.         // echo  $this->em->getRepository(Persons::class)->countListPersons($params_sql);
  133.         $params_display['vignette_format'] = array('width'=>$_ENV['VIGN_PERSONS_WIDTH'],'height'=>$_ENV['VIGN_PERSONS_HEIGHT'],'direction'=>'crop');
  134.         $this->context['view']->directeurs_affiches $this->em->getRepository(Persons::class)->getListPersons($params_sql,$params_display);
  135.     }
  136.     // }}}
  137.     // {{{ getEvenements()
  138.     /** Nous récupérons les informrations des évènéments
  139.      *
  140.      *
  141.      * @access public
  142.      * @return void
  143.      */
  144.     public function getEvenements(){
  145.         $news $this->em->getRepository(News::class);
  146.         // récupérer les prochains évènements
  147.         $news_params = array(
  148.             'params' => array(
  149.                 'limit' => array(0,5),
  150.             ),
  151.             'special' => array(
  152.                 'prochains' => 180,
  153.                 'publish_valid' => true,
  154.                 'type_news' => 'news',
  155.                 'is_homepage' => 1,
  156.                 'idtypestructure' => $this->structure
  157.             ),
  158.             'dbg' => array('news','Liste des prochains évènements')
  159.         );
  160.         $this->context['view']->next_news $news->getListNews($news_params);
  161.     }
  162.     // }}}
  163.     // {{{ getContamporainAffiche()
  164.     /** Nous récupérons les informrations des auteurs contemporains à l'affiche
  165.      *
  166.      *
  167.      * @access public
  168.      * @return void
  169.      */
  170.     private function getContamporainAffiche(){
  171.         $person $this->em->getRepository(Persons::class);
  172.         $sql_area $this->regions->getZipCode($this->area);
  173.         $params_sql = array(
  174.             'special' => array(
  175.                 'with_photo' => true,
  176.                 'spectacle' => array(
  177.                     'type' => 'author',
  178.                     'prochains' => '100D',
  179.                     'person_periode' => 'contemporain',
  180.                     'text_edite' => true,
  181.                     'country' => 'FR'
  182.                 ),
  183.                 'random' => '',
  184.             ),
  185.             'params' => array(
  186.                 'limit' => array(0,4),
  187.                 'where' => $sql_area
  188.             ),
  189.             'dbg' => array('affiche_persons','Les auteurs à l\'affiche')
  190.         );
  191.         $params_display['vignette_format'] = array('width'=>$_ENV['VIGN_PERSONS_WIDTH'],'height'=>$_ENV['VIGN_PERSONS_HEIGHT'],'direction'=>'crop');
  192.         $this->context['view']->persons $person->getListPersons($params_sql,$params_display);
  193.     }
  194.     // }}}
  195.     public function getSpectaclesAffichesVideos(){
  196.         $multimedias $this->em->getRepository(Multimedias::class);
  197.         $contacts $this->getContactsByType($this->structure);
  198.         $where_idcontact ' AND contacts.idcontact IN ('.join(','$contacts['ids']).') ';
  199.         $params_videos_affiche = array(
  200.             'where' => array(
  201.                 // $where_idcontact
  202.                 array('spectacles','idspectaclegenre',1), // uniquement les spectacles
  203.                 array('schedules','idcontact',$contacts['ids']), // uniquement dans ces structures
  204.             ),
  205.             'affiche' => array('today' => 120),
  206.             'limit' => array(0,4),
  207.             'dbg' => array('affiche','Vidéos de spectacles à l\'affiche'),
  208.         );
  209.         $this->context['view']->videos_affiche $multimedias->getListMultimedias($params_videos_affiche,
  210.             array('width'=>$_ENV['VIGN_VIDEO_WIDTH'],'height'=>$_ENV['VIGN_VIDEO_HEIGHT'],'fleche'=>'none','ratio' => '169'),
  211.             array('get_schedule' => $contacts['ids'], 'format_vignette' => true)
  212.         );
  213.     }
  214.     //on récupère les textes par l'auteurs auteurs
  215.     public function getTextesByAuteurs(){
  216.         $spectacles $this->em->getRepository(Multimedias::class);
  217.         $textes $this->em->getRepository(Texts::class);
  218.         $params_sql_spectacles = array(
  219.             'params' => array(
  220.                 'limit' => array(0,2),
  221.             ),
  222.             'special' => array(
  223.                 'playlists' => array(
  224.                     'text' => true,
  225.                     'idclassifications' => array(144), // par l'auteur
  226.                 ),
  227.                 'textfictif' => 0,
  228.                 'prochains' => '150D',
  229.                 'area' => $this->area,
  230.                 'plus_proche' => true,
  231.             ),
  232.             'dbg' => array('spectacles_auteurs_affiche','Texte par l\'auteur à l\'affiche'),
  233.         );
  234.         $list_spectacles $this->spectacles->getListSpectacles($params_sql_spectacles);
  235.         $this->context['view']->textes_par_auteurs $textes->getTextsFromSpectacles($list_spectacles);
  236.         if(isset($this->context['view']->textes_par_auteurs)) {
  237.             foreach ($this->context['view']->textes_par_auteurs as $k => $v) {
  238.                 // voir s'il y a des contenus le texte par l'auteur
  239.                 if ($this->em->getRepository(Playlists::class)->countPlaylists('texts'$v['idtext'], 'class_texte_parauteur') > 0) {
  240.                     $playlist $this->em->getRepository(Playlists::class)->getByClassification('texts'$v['idtext'], 'class_texte_parauteur');
  241.                     $this->context['view']->textes_par_auteurs[$k]['url_clean_more'] = 'playlist/id/' $playlist['url_clean'];
  242.                     $playlists $this->em->getRepository(Playlists::class);
  243.                     $sql 'SELECT p.idplaylist
  244.                           FROM playlists p
  245.                           LEFT JOIN playlist_classification pc ON p.idplaylist = pc.idplaylist
  246.                           WHERE pc.idclassification = 144 AND p.idtext = '.$v['idtext'].'
  247.                           GROUP BY p.idtext';
  248.                     $x $playlists->db->queryOne($sql);
  249.                     $pl $playlists->getInfosPlaylist(
  250.                         $x,
  251.                         array(
  252.                             'all' => true,
  253.                             'multimedias' => true,
  254.                             'format_vignette' => array('width'=>325,'height'=>162,'fleche'=>'none'//'direction'=>'crop'
  255.                         ),
  256.                         array('format_vignette' => true)
  257.                     );
  258.                     $video = (array_shift($pl['multimedias']));
  259.                     $this->context['view']->textes_par_auteurs[$k]['playlist']['vignette'] = $video['vignette'];
  260.                     $this->context['view']->textes_par_auteurs[$k]['playlist']['vignette_flou'] = $video['vignette_flou'];
  261.                     $this->context['view']->textes_par_auteurs[$k]['playlist']['thtv'] = true;
  262.                     $this->context['view']->textes_par_auteurs[$k]['playlist']['thtv_permalink'] = $video['permalink'];
  263.                     $this->context['view']->textes_par_auteurs[$k]['playlist']['url_clean_video'] = $playlist['url_clean'];
  264.                 }
  265.             }
  266.         }
  267.     }
  268.     public function getCritiques(){
  269.         $spectacles $this->em->getRepository(Multimedias::class);
  270.         $where_genre ' ';
  271.         $where_zone $sql_area $this->regions->getZipCode($this->area);
  272.         /* -- les dernières critiques -- */
  273.         $params_sql_regions = array(
  274.             'params' => array(
  275.                 'where' => $where_genre.$where_zone,
  276.                 'limit' => array(04),
  277.             ),
  278.             'special' => array(
  279.                 'prochains' => true,
  280.                 'publish_valid' => 1,
  281.                 'random' => '',
  282.                 'idclassification' => 101,
  283.                 'get_schedule_ville' => $this->area
  284.             ),
  285.             'dbg' => array('affiche_region','A l\'affiche en région')
  286.         );
  287.         $this->context['view']->critiques_spectacles $this->spectacles->getListSpectacles($params_sql_regions,array(),false,['allauthors' => true]);
  288.         $nb_total_critiques 0;
  289.         foreach($this->context['view']->critiques_spectacles AS $k => $v){
  290.             $this->context['view']->critiques_spectacles[$k]['footer_critique'] = true;
  291.             $nb_total_critiques += $this->context['view']->critiques_spectacles[$k]['nombre_critique'] = $this->em->getRepository(Contents::class)->countAssociateContent('spectacles',$v['idspectacle'],'class_critique',array('publish_valid' => 1));
  292.         }
  293.     }
  294.     public function getSpectaclesAffiches(){
  295.         $contacts $this->em->getRepository(Contacts::class);
  296.         // trouver les contacts correspondants TN/CDN/Autres théare
  297.         $nb_spectacles 2;
  298.         $groupe_contacts = array(128,129,130,131);
  299.         $partenaires $contacts->getContactsByClassification($groupe_contacts);// idgroupclassification = 10
  300.         // grouper par type de partenaires
  301.         foreach($partenaires as $k=>$v) {
  302.             $spectacles_affiche_order[$v['idtypestructure']]['contacts'][$v['idcontact']] = $v;
  303.             $spectacles_affiche_order[$v['idtypestructure']]['idcontacts'][$v['idcontact']] = $v['idcontact'];
  304.             if($v['idtypestructure']=='THIN') {
  305.                 $spectacles_affiche_order[$v['idtypestructure']]['classification'] = 'Autres théâtres partenaires';
  306.                 $spectacles_affiche_order[$v['idtypestructure']]['no_link'] = true;
  307.                 $spectacles_affiche_order[$v['idtypestructure']]['classification_nomaj'] = strtolower($spectacles_affiche_order[$v['idtypestructure']]['classification']);
  308.             } elseif($v['idtypestructure']=='CDN') {
  309.                 $spectacles_affiche_order[$v['idtypestructure']]['classification'] = 'Centres dramatiques';
  310.                 $spectacles_affiche_order[$v['idtypestructure']]['classification_nomaj'] = 'centres dramatiques';
  311.             } else {
  312.                 $spectacles_affiche_order[$v['idtypestructure']]['classification_nomaj'] = strtolower($this->context['tr']->trans($v['classification']));
  313.                 $spectacles_affiche_order[$v['idtypestructure']]['classification'] = $this->context['tr']->trans($v['classification']);
  314.             }
  315.             $spectacles_affiche_order[$v['idtypestructure']]['idclassification'] = $v['idclassification'];
  316.             $spectacles_affiche_order[$v['idtypestructure']]['idtypestructure'] = $v['idtypestructure'];
  317.         }
  318.         if (!isset($spectacles_affiche_order[$this->structure])) {
  319.             return $this->redirectToRoute('erreur_type', ['type' => 'introuvable']);
  320.         }
  321.         $structure_selected[$this->structure] = $spectacles_affiche_order[$this->structure];
  322.         unset($spectacles_affiche_order);
  323.         foreach($structure_selected as $k=>$v) {
  324.             // pour les scènes nationales, rechercher dans toutes les scènes
  325.             if($v['idclassification']==130) {
  326.                 $v['idcontacts'] = array();
  327.                 $contacts_sn $this->em->getRepository(Contacts::class)->getListContacts(array(
  328.                     'idtypestructure' => 'SN',
  329.                     'limit' => array(0,100),
  330.                     'dbg' => array('liste_sn''liste des scènes nationales'),
  331.                 ));
  332.                 foreach($contacts_sn as $kb=>$vb) {
  333.                     $v['idcontacts'][$vb['idcontact']] = $vb['idcontact'];
  334.                 }
  335.             }
  336.             $where_idcontact ' AND contacts.idcontact IN ('.join(','$v['idcontacts']).') ';
  337.             // rechercher les spectacles à l'affiche
  338.             $params_spectacles_affiche = array(
  339.                 'params' => array(
  340.                     'where' => $where_idcontact.' AND s.publish=1 ',
  341.                     'limit' => array(0,6),
  342.                 ),
  343.                 'special' => array(
  344.                     'prochains' => 150,
  345.                     'random' => '',
  346.                     'publish_valid' => 1// les critiques publiées
  347.                     // 'get_schedule_ville' => $this->area
  348.                     'structures_specifiques' => $this->structure
  349.                 ),
  350.                 'dbg' => array('spectacles_'.$v['idtypestructure'], 'Spectacles à l\'affiche pour les '.$v['idtypestructure'])
  351.             );
  352.             if(!in_array($this->area, ['CH','BE','LU'])){
  353.                 $params_spectacles_affiche['idcontacts'] = array('IN'$v['idcontacts']);
  354.                 $params_spectacles_affiche['idcontact'] = $v['idcontacts'];
  355.             }
  356.             $params_display = array('allauthors' => true);
  357.             $format_vignette['vignette'] = array('width'=>$_ENV['VIGN_SPECTACLE_HEIGHT'],'height'=>$_ENV['VIGN_SPECTACLE_HEIGHT'],'direction'=>'crop');
  358.             $spectacles_affiche $this->spectacles->getListSpectacles($params_spectacles_affiche,$format_vignette,false,$params_display);
  359.             if(!empty($spectacles_affiche)) {
  360.                 $spectacles_affiche_reduce = array();
  361.                 foreach($spectacles_affiche as $kb=>$vb) {
  362.                     $vb['footer_contact'] = true;
  363.                     $spectacles_affiche_reduce[$kb] = $vb;
  364.                 }
  365.                 $structure_selected[$k]['spectacles'] = $spectacles_affiche_reduce;
  366.             } else {
  367.                 unset($structure_selected[$k]);
  368.             }
  369.         }
  370.         $filtre_cdn = ['TN','CDN','SN','THIN'];
  371.         foreach($filtre_cdn as $vc){
  372.             if(!empty($structure_selected[$vc])){
  373.                 if($structure_selected[$vc]){
  374.                     $spectacles_affiche_by_classification[$vc] = $structure_selected[$vc];
  375.                 }
  376.             }
  377.         }
  378.         if(isset($spectacles_affiche_by_classification)){
  379.             $this->context['view']->spectacles_affiche_dans true;
  380.             $this->context['view']->spectacles_affiche $spectacles_affiche_by_classification;
  381.         }
  382.     }
  383.     private function getSpectaclesJTN(){
  384.         $spectacles $this->em->getRepository(Multimedias::class);
  385.         $where_genre ' ';
  386.         $where_zone $this->regions->getZipCode($this->area);
  387.         $params_sql_soutien = array(
  388.             'params' => array(
  389.                 'limit' => array(0,20),
  390.                 'where' => $where_genre.$where_zone
  391.             ),
  392.             'special' => array(
  393.                 'prochains' => 180,
  394.                 'random' => '',
  395.                 'by_classification' => 103,
  396.                 'get_schedule_ville' => $this->area
  397.             ),
  398.             'dbg' => array('spectacle_soutien','Les spectacles avec un soutien à l\'affiche'),
  399.         );
  400.         $format_vignette['vignette'] = array('width'=>$_ENV['VIGN_SPECTACLE_WIDTH'],'height'=>$_ENV['VIGN_SPECTACLE_HEIGHT']);
  401.         $params_display = array('allauthors' => true);
  402.         $spectacles_soutien $this->spectacles->getListSpectacles($params_sql_soutien$format_vignettefalse$params_display);
  403.         $nb_spectacles 2;
  404.         if(!empty($spectacles_soutien)) {
  405.             $i 0;
  406.             foreach($spectacles_soutien as $k=>$v) {
  407.                 $v['footer_contact'] = true;
  408.                 $this->context['view']->spectacles_affiche_dans true;
  409.                 $this->context['view']->spectacles_soutien[$k] = $v;
  410.                 $i++;
  411.                 if($i==$nb_spectacles) {
  412.                     break;
  413.                 }
  414.             }
  415.         }
  416.     }
  417.     private function getAsides(){
  418.         $this->asides->load(['url_lists_alone,tn_cdn_sn' => array(
  419.             'exec' => ['color' => true,'color' => 'contacts'],
  420.             'rmv' => 'ALL',
  421.             'php' => [
  422.                 'method' => 'tn_cdn_sn',
  423.                 'url' => '/structures/actualites/key_structure',
  424.                 'params' => array(
  425.                     'activate' => $this->structure
  426.                     //     'activate' => (!is_null($this->context['idtypestructure'])) ? $this->context['idtypestructure'] : 'ALL',
  427.                     //     'key_action' => $this->context['view']->context['action'],
  428.                     //     'key_area' => $this->context['view']->area
  429.                 ),
  430.                 // 'structure' => array(
  431.                 //     'theatre' => 'key_action',
  432.                 //     'area' => 'key_area',
  433.                 //     'structure_classic' => array(
  434.                 //         'idtypestructure' => 'key_structure',
  435.                 //         'd' => $this->context['view']->days
  436.                 //     )
  437.                 // )
  438.             ],
  439.             'title' => 'Rechercher par label'
  440.         )]);
  441.         if (isset($this->context['view']->idtypestructure)) {
  442.             if ($this->context['view']->idtypestructure == 'CDN') {
  443.                 $this->asides->load('contact_acdn');
  444.             }
  445.         }
  446.         $this->asides->load(['common_carte' => array(
  447.             'url' => '/regions/actualites/area/get_id'
  448.         )]);
  449.         $this->asides->load('common_prochain_evenement');
  450.         $this->asides->load('common_facebook');
  451.         $this->asides->load('common_twitter');
  452.         // $this->asides->load('common_offre_annonce');
  453.     }
  454.     // {{{ getContactsByType()
  455.     /** Les contacts par type de structure avec bandeau
  456.      *
  457.      */
  458.     public function getContactsByType($idtypestructure) {
  459.         // rechercher les scènes conventionnées
  460.         $params_sql_typestructure = array(
  461.             'where' => array(
  462.                 array('contacts''idtypestructure'$idtypestructure),
  463.                 array('contacts''country''FR'),
  464.                 ' AND contacts.idcontact NOT IN (SELECT idcontact FROM contact_classification WHERE idclassification=99) ',
  465.             ),
  466.             'order' => array('contacts' => 'organisation'),
  467.             'direction' => 'ASC',
  468.             'idclassification' => array('NOT' => array(99)),
  469.             'limit' => array(0,500),
  470.             'dbg' => array('structures','Contacts avec un type précis'),
  471.         );
  472.         $structures $this->em->getRepository(Contacts::class)->getListContacts($params_sql_typestructure);
  473.         // classe fichiers
  474.         $files $this->em->getRepository(Files::class);
  475.         foreach($structures as $k=>$s) {
  476.             $ids_contact[] = $s['idcontact'];
  477.             // voir si la structure à une petite bannière
  478.             $structures[$k]['petit_bandeau'] = $files->getObjectFiles($s['idcontact'],'contacts',114);
  479.         }
  480.         return array(
  481.             'contacts' => $structures,
  482.             'nb_contacts' => count($structures),
  483.             'ids' => $ids_contact,
  484.         );
  485.     }
  486.     // }}}
  487. }