src/Controller/SpectacleController.php line 1289

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\ClassTheatre\asides;
  4. use App\ClassTheatre\TheatreController;
  5. use App\Service\Abonnements\Abonnements;
  6. use App\Service\Ajoutaides;
  7. use App\Service\EditUtils;
  8. use App\Service\Functions;
  9. use App\Service\Opengraph\OpenGraph;
  10. use App\Service\TheatreMail\TheatreMail;
  11. use App\Service\UploadUtils;
  12. use App\Service\wiki2xhtml\wiki2xhtml;
  13. use App\Validator\CheckWebsite;
  14. use Doctrine\ORM\EntityManagerInterface;
  15. use Doctrine\ORM\Query;
  16. use Symfony\Component\Cache\Adapter\AdapterInterface;
  17. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  18. use Symfony\Component\Form\Extension\Core\Type\FormType;
  19. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  20. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  21. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  22. use Symfony\Component\Form\Extension\Core\Type\TextType;
  23. use Symfony\Component\Form\FormFactoryInterface;
  24. use Symfony\Component\HttpFoundation\RedirectResponse;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use App\Exception\RedirectException;
  27. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  28. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  29. use Symfony\Component\Routing\Annotation\Route;
  30. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  31. use Symfony\Contracts\Translation\TranslatorInterface;
  32. use Symfony\Component\Validator\Constraints\Length;
  33. use Symfony\Component\Validator\Constraints\NotBlank;
  34. use Symfony\Component\Validator\Constraints\Type;
  35. use TheatreCore\Classes\UtilsEdit;
  36. use TheatreCore\Classes\Stats\Stats as GlobalStats;
  37. use TheatreCore\Entity\Aides;
  38. use TheatreCore\Entity\BookmarkExtranetuser;
  39. use TheatreCore\Entity\Classifications;
  40. use TheatreCore\Entity\Contents;
  41. use TheatreCore\Entity\Dvds;
  42. use TheatreCore\Entity\Extranetusers;
  43. use TheatreCore\Entity\Files;
  44. use TheatreCore\Entity\Multimedias;
  45. use TheatreCore\Entity\News;
  46. use TheatreCore\Entity\Persons;
  47. use TheatreCore\Entity\Playlists;
  48. use TheatreCore\Entity\Podcasts;
  49. use TheatreCore\Entity\Schedules;
  50. use TheatreCore\Entity\SpectacleAide;
  51. use TheatreCore\Entity\Spectacles;
  52. use TheatreCore\Entity\Stats;
  53. use TheatreCore\Entity\Texts;
  54. use TheatreCore\Entity\Typesspectacles;
  55. use TheatreCore\Entity\UserAction;
  56. use TheatreCore\Repository\ContentsRepository;
  57. use TheatreCore\Repository\FilesRepository;
  58. class SpectacleController extends TheatreController
  59. {
  60.     // id du spectacle
  61.     protected $idspectacle null;
  62.     // object spectacles
  63.     protected $spectacles;
  64.     // object contents
  65.     protected $contents;
  66.     // contenu du spectacles
  67.     protected $data_spectacles = array();
  68.     // précision fil d'arianne
  69.     protected $locate null;
  70.     // titre de la page
  71.     protected $title_page null;
  72.     // nombre de com sur le spectacle
  73.     protected $nb_comments 0;
  74.     // paramètres pour les commentaires
  75.     protected $params_comments = array();
  76.     // meta keywords et meta description
  77.     protected $meta_keywords '';
  78.     protected $meta_description '';
  79.     // taille maxi des vidéos
  80.     protected $other_dimensions = array();
  81.     // infos pour mon théâtre
  82.     protected $mtinfos = array();
  83.     // pour la navigation
  84.     protected $extra_title '';
  85.     protected $extra_locate '';
  86.     // les textes
  87.     protected $ids_texts = array();
  88.     // style
  89.     protected $styles_folder = array();
  90.     // asides
  91.     protected $asides "";
  92.     // par page
  93.     protected $perPage 7;
  94.     protected $serviceAbonnements;
  95.     protected ?AdapterInterface $cache null;
  96.     // {{{ InitController()
  97.     public function InitController($slug null$action null$params = [])
  98.     {
  99.         // surbrillance du menu principal (thnet)
  100.         $GLOBALS['rub_courante'] = 'spectacles';
  101.         $this->view->action $this->context['action'] = $action;
  102.         $this->RouterOptions($slug$action$GLOBALS['rub_courante']);
  103.         $this->view->controller $GLOBALS['rub_courante'];
  104.         // charger swfobject
  105.         $this->view->jquery_flash true;
  106.         if (!empty($params['idspectacle'])) {
  107.             $this->idobject $this->id = (int)$params['idspectacle'];
  108.         } else {
  109.             $params['idspectacle'] = $this->idobject = (int)$this->id;
  110.         }
  111.         $this->context['params']['idspectacle'] = $params['idspectacle'] = $this->idspectacle $this->id;
  112.         // si id spectacle n'existe pas, on renvoi sur une page d'erreur (a faire !!!)
  113.         if (empty($params['idspectacle'])) {
  114.             throw new NotFoundHttpException();
  115.         }
  116.         // spécial lagarce
  117. //        if($this->context['module']=='lagarce') {
  118. //            $id_exclude = 3;
  119. //        } else {
  120.         $id_exclude null;
  121. //        }
  122.         // identifiant du spectacle
  123.         $this->idspectacle $params['idspectacle'];
  124.         // instancier un objet spectacles
  125.         $this->spectacles $this->em->getRepository(Spectacles::class);
  126.         $this->data_spectacles $this->spectacles->createQueryBuilder('e')
  127.             ->leftJoin('e.idtypespectacle''a')
  128.             ->leftJoin('e.idcontactCreation''cc')
  129.             ->leftJoin('e.idcontactProduction''cp')
  130.             ->leftJoin('e.idextranetuser''u')
  131.             ->andWhere('e.idspectacle = :idspectacle')
  132.             ->setParameter('idspectacle'$params['idspectacle'])
  133.             ->select('e, partial a.{idtypespectacle}, cc, cp, partial u.{idextranetuser}')
  134.             ->getQuery()
  135.             ->getSingleResult(Query::HYDRATE_ARRAY);
  136.         // si nous ne sommes pas dans l'API && vérifier que le spectacle appartient à l'utilisateur connecté ou que root est connecté
  137.         if (empty($params['api']) && $this->getUser() instanceof Extranetusers && $this->data_spectacles['idextranetuser'] == $this->getUser()->getIdExtranetuser()) {
  138.             $this->data_spectacles['my_spectacle'] = true;
  139.         }
  140.         // pour les lectures
  141.         if ($this->data_spectacles['idtypespectacle']['idtypespectacle'] == 1) {
  142.             $this->data_spectacles['is_lecture'] = true;
  143.         }
  144.         // pour les travail d'atelier
  145.         if ($this->data_spectacles['idtypespectacle']['idtypespectacle'] == 5) {
  146.             $this->data_spectacles['is_travail_atelier'] = true;
  147.         }
  148.         // si le spectacle a le statut supprimé
  149.         if ($this->data_spectacles['statut'] == 4) {
  150.             // on est root => affiché avec un message
  151.             if ($this->isGranted('ROLE_ISROOT')) {
  152.                 $this->data_spectacles['supprime'] = true;
  153.             } else {
  154.                 throw new RedirectException('/spectacles/statut/non-accessible?from=' $this->data_spectacles['urlClean']);
  155.             }
  156.         }
  157.         // si le spectacle est hors ligne
  158.         if ($this->data_spectacles['publish'] == 0) {
  159.             // on est root => affiche "ce spectacle est hors ligne"
  160.             if ($this->isGranted('ROLE_ISROOT')) {
  161.                 $this->data_spectacles['hors_ligne'] = true;
  162.                 // on est pas root mais on est l'extranetuser du spectacle => "ce spectacle est actuellement hors ligne."
  163.             } elseif (!empty($this->data_spectacles['my_spectacle'])) {
  164.                 // si le spectacle n'est pas validé (statut 1) => "votre spectacle est en cours de validation"
  165.                 // si statut supérieur à 1 et inférieur à 4 => "rien"
  166.                 if ($this->data_spectacles['statut'] == 1) {
  167.                     $this->data_spectacles['validation_encours'] = true;
  168.                 } elseif ($this->data_spectacles['statut'] == 0) {
  169.                     $this->data_spectacles['incomplet'] = true;
  170.                 } else {
  171.                     $this->data_spectacles['hors_ligne'] = true;
  172.                     // pour lien mise hors ligne
  173.                     $this->func->tokenCsrf('ajoutspectacles'$this->context);
  174.                 }
  175.             } else {
  176.                 // on est "rien" => page d'erreur
  177.                 throw new RedirectException('/spectacles/statut/non-accessible?from=' $this->data_spectacles['urlClean'] . '&publish=false');
  178.             }
  179.         }
  180.         // statut du spectacle => 1 = proposé / 2 = validé / 3 = modifié / 4 = supprimé. On affiche quand c'est un
  181.         // recuperer le titre du spectacle
  182.         $this->data_spectacles['title'] = $this->spectacles->getObjectTitle($this->idspectacle, array('idspectacle' => $this->idspectacle'title' => $this->data_spectacles['title']));
  183.         // type de spectacle (chaine traduite)
  184.         $typesspectacles $this->em->getRepository(Typesspectacles::class);
  185.         $this->data_spectacles['typespectacle'] = $typesspectacles->getTypespectacle($this->data_spectacles['idtypespectacle']['idtypespectacle'], $this->context['lng']);
  186.         // si pas de titre = collage
  187.         if ($this->data_spectacles['title'] != '') {
  188.             $this->view->data_spectacles['collage'] = true;
  189.         }
  190.         // date de creation
  191.         if (!empty($this->data_spectacles['creationDate'])) {
  192.             $this->data_spectacles['annee_creation'] = $this->spectacles->getYear($this->data_spectacles['creationDate']->format('Y'));
  193.         }
  194.         // recuperer le ou les metteurs en scene
  195.         $this->data_spectacles['alldirectors'] = $this->spectacles->noPunct($this->spectacles->getDirectors($this->idspectacle));
  196.         // metteur en scene separe par des virgules
  197.         if (!empty($this->data_spectacles['alldirectors'])) {
  198.             $this->data_spectacles['directorstring'] = $this->spectacles->getDirectorsString($this->idspectacle$this->data_spectacles['alldirectors']);
  199.         }
  200.         // recuperer la liste des textes du spectacle
  201.         $this->data_spectacles['texts'] = $this->spectacles->noPunct($this->spectacles->getSpectacleText(true$this->data_spectacles['idspectacle']));
  202.         // compter les textes
  203.         if (count($this->data_spectacles['texts']) > 1) {
  204.             $this->data_spectacles['texts_multiple'] = true;
  205.         }
  206.         if ($this->data_spectacles['textfictif'] == && count($this->data_spectacles['texts']) > 0) {
  207.             foreach ($this->data_spectacles['texts'] as $t) {
  208.                 $this->ids_texts[$t['idtext']] = $t['idtext'];
  209.             }
  210.         }
  211.         // liste des auteurs des texts qui dépendent de ce spectacle
  212.         $textauthor $this->em->getRepository(Texts::class);
  213.         $this->data_spectacles['otherauthor'] = array();
  214.         $this->data_spectacles['authorstring'] = null;
  215.         // nombre de textes
  216.         $nbtexts 0;
  217.         $month = array(
  218.             => 'Janvier',
  219.             => 'Février',
  220.             => 'Mars',
  221.             => 'Avril',
  222.             => 'Mai',
  223.             => 'Juin',
  224.             => 'Juillet',
  225.             => 'Août',
  226.             => 'Septembre',
  227.             10 => 'Octobre',
  228.             11 => 'Novembre',
  229.             12 => 'Decembre',
  230.         );
  231.         if (isset($this->data_spectacles['texts'])) {
  232.             foreach ($this->data_spectacles['texts'] as $k => $v) {
  233.                 if ($v['textfictif'] != 1) {
  234.                     $nbtexts++;
  235.                     // tous les auteurs d'un texte
  236.                     $this->data_spectacles['texts'][$k]['authors'] = $this->spectacles->noPunct($textauthor->getAuthors($v['idtext'], $v['type']));
  237.                     foreach ($this->em->getRepository(Texts::class)->getInfosText($v['idtext']) as $kdetail => $vdetail) {
  238.                         $this->data_spectacles['texts'][$k][$kdetail] = $vdetail;
  239.                         if ($kdetail == 'publication_year') {
  240.                             $this->data_spectacles['texts'][$k]['publication_year'] = $vdetail;
  241.                         }
  242.                         if ($kdetail == 'publication_month' && !empty($vdetail)) {
  243.                             if (strlen($vdetail) == 1) {
  244.                                 $this->data_spectacles['texts'][$k]['publication_month'] = '0' $vdetail;
  245.                             } else {
  246.                                 $this->data_spectacles['texts'][$k]['publication_month'] = $vdetail;
  247.                             }
  248.                             $this->data_spectacles['texts'][$k]['publication_month_caractere'] = $month[$vdetail];
  249.                         }
  250.                     }
  251.                     if (key($this->data_spectacles['texts'][$k]['authors']) != $id_exclude /* id lagarce */) {
  252.                         $this->data_spectacles['otherauthor'] = $this->spectacles->noPunct($this->data_spectacles['texts'][$k]['authors']);
  253.                     }
  254.                     // auteurs separe par des virgules
  255.                     foreach ($this->data_spectacles['texts'][$k]['authors'] as $kauthor => $vauthor) {
  256.                         $this->data_spectacles['authorstring'] .= $vauthor['firstname'] . ' ' $vauthor['lastname'];
  257.                         if (!array_key_exists('nopunct'$vauthor)) {
  258.                             $this->data_spectacles['authorstring'] .= ', ';
  259.                         }
  260.                     }
  261.                     if ($this->data_spectacles['texts'][$k]['typetxt'] == 'translate') {
  262.                         // les textes originaux
  263.                         $txtorig $this->em->getRepository(Texts::class);
  264.                         $this->data_spectacles['texts'][$k] = $txtorig->getInfosText($this->data_spectacles['texts'][$k]['idtext']);
  265.                         // pas de virgule sur le dernier translator
  266.                         if (array_key_exists('alltranslators'$this->data_spectacles['texts'][$k])) {
  267.                             $this->data_spectacles['texts'][$k]['alltranslators'] = $this->spectacles->noPunct($this->data_spectacles['texts'][$k]['alltranslators']);
  268.                         }
  269.                     }
  270.                 }
  271.             }
  272.         }
  273.         if ($nbtexts == 1) { // si un seul texte on cherche l'auteur autre que lagarce
  274.             // url
  275.             //on récupère la vignette associé au texte
  276.             $this->data_spectacles['vignette_text'] = $this->em->getRepository(Texts::class)->getVignetteText($this->data_spectacles['texts'][0]['idtext']);
  277.             $this->data_spectacles['textunique'] = true;
  278.             $this->data_spectacles['idtext'] = $this->data_spectacles['texts'][0]['idtext'];
  279.             $this->data_spectacles['url_clean_text'] = $this->data_spectacles['texts'][0]['url_clean'];
  280.             $text_publisher $this->em->getRepository(Texts::class);
  281.             $text_details $text_publisher->getInfosText($this->data_spectacles['texts'][0]['idtext']);
  282.             if (!empty($text_details['idcontact_publisher'])) {
  283. //                $pub = $text_publisher->getLink('idcontact_publisher');
  284.                 $this->data_spectacles['publisher'] = $text_details['idcontact_publisher'];
  285.                 if (!empty($pub->country)) {
  286.                     $pub_country $pub->getLink('country');
  287.                     $this->data_spectacles['publisher']['country'] = $pub_country->fr;
  288.                 } else {
  289.                     unset($this->data_spectacles['publisher']['country']);
  290.                 }
  291.             }
  292.         } else {
  293.             $this->data_spectacles['otherauthor'] = array();
  294.         }
  295.         $this->data_spectacles['texts'] = $this->spectacles->noPunct($this->data_spectacles['texts']);
  296.         // voir si le spectacle est dans educ
  297.         if ($nbtexts == && $this->isTheduc()) {
  298.             $this->data_spectacles['theduc'] = true;
  299.             $this->data_spectacles['url_clean_theduc'] = $_ENV['URL_THEDUC'] . '/pieces/' $this->data_spectacles['texts'][0]['url_clean'] . '/spectacles/' $this->data_spectacles['urlClean'] . '/';
  300.         }
  301.         // Génération de la liste des biographies (avec filtrage si auteur=metteur)
  302.         if (!empty($this->data_spectacles['otherauthor'])) {
  303.             foreach ($this->data_spectacles['otherauthor'] as $k => $v) {
  304.                 $this->data_spectacles['biographies'][$k] = $v;
  305.             }
  306.         }
  307.         if (!empty($this->data_spectacles['alldirectors'])) {
  308.             foreach ($this->data_spectacles['alldirectors'] as $k => $v) {
  309.                 if (!isset($this->data_spectacles['biographies'][$k])) {
  310.                     $this->data_spectacles['biographies'][$k] = $v;
  311.                 }
  312.             }
  313.         }
  314.         // si le texte est une adaptation a partir des textes, il faut trouver aussi les textes originaux
  315.         if ($nbtexts == && !empty($this->data_spectacles['texts'][0]['type']) && $this->data_spectacles['texts'][0]['type'] == 2) {
  316.             // retrouver les textes de l'adaptation
  317.             $texts_adaptation $this->em->getRepository(Texts::class);
  318.             $adaptations $texts_adaptation->getOriginalsTexts($this->data_spectacles['texts'][0]['idtext'], 'text_adaptation''idtextadaptation');
  319.             foreach ($adaptations as $k => $v) {
  320.                 $texts_from_adaptations $this->em->getRepository(Texts::class);
  321.                 $adaptations[$k] = $texts_from_adaptations->getInfosText($k);
  322.             }
  323.             $this->data_spectacles['texts_adaptation'] = $this->spectacles->noPunct($adaptations);
  324.             $this->data_spectacles['adaptation'] = true;
  325.         }
  326.         // recuperer l'affiche du spectacle
  327.         $this->contents $this->em->getRepository(Contents::class);
  328.         $illustrations $this->contents->getIllustrations($this->idspectacle'spectacles''class_affiche_spec');
  329.         if (!empty($illustrations)) {
  330.             // illustrations
  331.             $this->data_spectacles['illustrations'] = $illustrations['illustrations'];
  332.             $this->data_spectacles['vignette_object'] = $this->spectacles->getVignetteSpectacle($this->idspectacle, array('width' => 101'height' => 101'direction' => 'crop'));
  333.             $this->data_spectacles['vignette_object_blur'] = $this->spectacles->getVignetteSpectacle($this->idspectacle, array('width' => 102'height' => 102'direction' => 'crop''blur' => true));
  334.         }
  335.         // titre de la page (auteur + metteur + spectacle)
  336.         $this->title_page $this->data_spectacles['title']
  337.             . ' - ' $this->data_spectacles['authorstring']
  338.             . ' - ' $this->data_spectacles['idtypespectacle']['idtypespectacle'];
  339.         if (!empty($this->data_spectacles['directorstring'])) {
  340.             $this->title_page .= ' ' $this->data_spectacles['directorstring'];
  341.         }
  342.         $this->view->data_object $this->data_spectacles;
  343.         // fin infos sur le spectacle
  344.         // flux rss des commentaires du spectacle
  345.         /*$this->view->flux_rss = array(
  346.             'name' => 'Commentaires sur le spectacle '.$this->data_spectacles['title'],
  347.             'url' => $this->context['url_module'].'/spectacles/'.$this->data_spectacles['urlClean'].'/rss-commentaires/',
  348.         );*/
  349.         // style des spectacles
  350.         $this->style_more = array('dossier''spectacle',);
  351.         // fil d'arianne
  352.         $this->locate = array(
  353.             '/spectacles/' => 'Spectacles',
  354.             '/spectacles/' $this->data_spectacles['urlClean'] . '/' => $this->data_spectacles['title']
  355.         );
  356.         // pour les liens dans le template
  357.         $this->view->url_folder '/spectacles/' $this->data_spectacles['urlClean'];
  358.         $this->view->data_object['url_folder'] = '/spectacles/' $this->data_spectacles['urlClean'];
  359.     }
  360.     // {{{ __construct
  361.     public function __construct(
  362.         EntityManagerInterface $em,
  363.         TranslatorInterface $translator,
  364.         TokenStorageInterface $tokenStorage,
  365.         Functions $func,
  366.         Abonnements $abonnements,
  367.         AdapterInterface $cache
  368.     )
  369.     {
  370.         parent::__construct($translator$tokenStorage);
  371.         $this->em $em;
  372.         $this->cache $cache;
  373.         $this->func $func;
  374.         $this->serviceAbonnements $abonnements;
  375.         $this->view->include_header 'spectacles/spectacle_entete.inc.html.twig';
  376.         $this->asides = new asides();
  377.     }
  378.     // {{{ finalizeAction()
  379.     /** Code exécuté après chaque action
  380.      *
  381.      *
  382.      * @access protected
  383.      * @return void
  384.      */
  385.     protected function finalizeAction()
  386.     {
  387.         // titre de la page
  388.         if ($this->extra_title) {
  389.             $this->title_page $this->extra_title ' - ' $this->title_page;
  390.         }
  391.         // complément fil d'arianne
  392.         if ($this->extra_locate) {
  393.             $this->locate[0] = $this->extra_locate;
  394.         }
  395.         $this->view->data_spectacles $this->data_spectacles;
  396.         $this->buildMenu();
  397.         // voir si l'objet est bookmarke
  398.         $bookmark $this->em->getRepository(BookmarkExtranetuser::class);
  399.         if ($this->getUser() instanceof Extranetusers
  400.             && $bookmark->isBookmark($this->idspectacle'spectacles'$this->getUser()->getIdextranetuser())) {
  401.             $this->view->is_bookmark true;
  402.         }
  403.         // action pour add/delete bookmark
  404.         if (isset($_GET['bookmark'])) {
  405.             $this->view->bookmark true;
  406.             $do_action $_GET['do_action'];
  407.             $this->view->$do_action true;
  408.         }
  409.         // statistiques (sauf pour la page des com's) TODO url différente pour lagarce
  410.         if (empty($this->current['idcontent'])) {
  411.             $this->current['idcontent'] = null;
  412.         }
  413.         // statistiques
  414.         if (!empty($this->idspectacle) && !$this->no_stats) {
  415.             $statsinfos = array(
  416.                 'type' => 'article',
  417.                 'module' => $this->context['module'],
  418.                 'url' => $_SERVER['REQUEST_URI'],
  419.                 'idcontent' => (int)$this->current['idcontent'],
  420.                 'object' => 'spectacles',
  421.                 'idobject' => $this->idspectacle,
  422.                 'video' => (int)(!empty($this->view->detailarticle['display_media']))
  423.             );
  424.             $stats $this->em->getRepository(Stats::class);
  425.             $stats->setStats($statsinfos__FILE__ ':' __LINE__);
  426.         }
  427.         // autres infos pour montheatre
  428.         $this->mtinfos = array(
  429.             'object' => 'spectacles',
  430.             'idobject' => $this->idspectacle,
  431.             'urifrom' => $this->view->url_folder ?? $this->url_folder ?? null,
  432.             'info_rub' => 'ce spectacle',
  433.             'idcontent' => (int)$this->current['idcontent'],
  434.         );
  435.         // a la vue
  436.         $this->view->mtinfos $this->mtinfos;
  437.         // aside
  438.         $this->view->aside $this->asides->view($this->view);
  439.         // Copier/coller de l'ancien version du site en php 5.6
  440.         // ------------------------
  441.         // retour en XML ou JSON ou version mobile
  442.         if (isset($_GET['xml_version'])) {
  443.             $this->context['view']->xml_version true;
  444.             $this->view->ajaxreponse true;
  445.             header('Content-Type: application/xml');
  446.         }
  447.         if (isset($_GET['json'])) {
  448.             $this->view->ajax true;
  449.             $this->view->ajaxreponse true;
  450.             $this->context['view']->json json_encode($this->context['view']->data_spectacles);
  451.             $this->context['action'] = 'json';
  452.             header('Content-Type: application/json');
  453.         }
  454.         // fil d'arianne
  455.         $this->view->locate $this->getLocate();
  456.         // titre meta
  457.         $this->view->title_page $this->getTitlePage();
  458.         // style et js en plus
  459.         $this->view->style_more $this->getStyleMore();
  460.         $this->view->js_more $this->getJsMore();
  461.         // js en plus pour le calendrier
  462.         if (!empty($this->context['view']->schedule_detail)) {
  463.             $this->view->js_more[] = 'jquery.qtip.min.js';
  464.         }
  465.         // template de tete
  466.         $this->view->include_header 'spectacles/spectacle_entete.inc.html';
  467.         // keywords et description
  468.         $this->view->meta_keywords $this->getMetaKeywords();
  469.         $this->view->meta_description $this->getMetaDescription();
  470.         // infos monthéâtre
  471.         $this->view->mtinfos $this->getMtinfos();
  472.         if (empty($this->view->reseaux['fb']) && !isset($this->view->meta_video)) {
  473.             $social = array(
  474.                 'type' => 'website',
  475.                 'title' => $this->getTitlePage(),
  476.                 'description' => '',
  477.                 'image' => (isset($this->context['view']->profilepicture)) ? $this->context['view']->profilepicture '',
  478.                 'url' => $_ENV['URL_THNET'] . '/contacts/' $this->context['view']->data_object['urlClean'] . '/' $this->context['action']
  479.             );
  480.             $this->setSocialCustomContent($social'fb');
  481.         }
  482.         $this->addPubliciteGoogle();
  483.     }
  484.     // }}}
  485.     // {{{ buildMenu()
  486.     /** Construit le menu
  487.      *
  488.      *
  489.      * @access protected
  490.      * @return void
  491.      */
  492.     protected function buildMenu($params = [])
  493.     {
  494.         $mark_active 'on';
  495.         // le nombre de critiques
  496.         $nb_critiques $this->em->getRepository(Contents::class)->countAssociateContent('spectacles'$this->idspectacle'class_critique', array('publish_valid' => 1));
  497.         // le menu du spectacle
  498.         $menu_spectacle = array(
  499.             array('url' => '''name' => $this->context['tr']->trans('menu_accueil'), 'id' => 'home''img' => '/images/menu/icones/toolbar_home.png'),
  500.             //array('url'=>'detail-spectacle','name'=> $this->context['tr']->trans('menu_accueil'),'id'=>'home'),
  501.             array('url' => 'ensavoirplus''name' => 'En savoir +''idclassification' => '6''id' => 'splus'),
  502.             array('url' => 'biographies''name' => 'Bios''id' => 'splus'),
  503.             array('url' => 'enimages''name' => 'Photos''idclassification' => '1''id' => 'imga'),
  504.             'videos' => array('url' => 'videos''name' => 'Vidéo(s)''id' => 'ent'),
  505.             'podcasts' => array('name' => html_entity_decode('&Eacute;couter'), 'title' => 'Écouter''url' => 'podcasts'),
  506.             // array('url'=>'extraits','name'=>$this->context['tr']->trans('extraits'),'idclassification'=>'31','id'=>'ext'),
  507.             // array('url'=>'entretiens','name'=>$this->context['tr']->trans('entretiens'),'idclassification'=>'8','id'=>'ent'),
  508.             //array('url'=>'presse','name'=>$this->context['tr']->trans('dans_la_presse'),'idclassification'=>'10', 'id'=>'presse'),
  509.             array('url' => 'lesdates''name' => 'Dates''idclassification' => '0''id' => 'cal'),
  510.             array('url' => 'critiques''name' => 'Critiques (' $nb_critiques ')''idclassification' => '101''id' => 'critiques'),
  511.             'evenements' => array('url' => ''),
  512.         );
  513.         $evenements_params_commun = array(
  514.             'special' => array(
  515.                 'publish_valid' => true,
  516.                 'no_schedule_contact' => true,
  517.                 'by_object' => array('idspectacle' => $this->idspectacle),
  518.             )
  519.         );
  520.         if ($counts_events $this->em->getRepository(News::class)->countNews($evenements_params_commun)) {
  521.             $menu_spectacle['evenements'] = array('url' => 'evenements''name' => 'Evenements (' $counts_events ')');
  522.         }
  523.         // toutes les vidéos
  524.         $nb_multimedias $this->em->getRepository(Multimedias::class)->getMultimediasBy('spectacles'$this->idspectaclenull'count');
  525.         // vérifier également que pour un texte non fictif il n'y a pas un texte par l'auteur
  526.         if (!empty($this->ids_texts)) {
  527.             $nb_playlists_texts $this->em->getRepository(Playlists::class)->countPlaylists('texts'$this->ids_texts'class_texte_parauteur');
  528.             $nb_playlists_texts_traducteurs $this->em->getRepository(Playlists::class)->countPlaylists('texts'$this->ids_texts'class_texte_par_traducteur');
  529.             $nb_multimedias $nb_multimedias $nb_playlists_texts $nb_playlists_texts_traducteurs;
  530.         }
  531.         if ($nb_multimedias 0) {
  532.             $menu_spectacle['videos']['name'] = 'Vidéo(s)';
  533.         } else {
  534.             unset($menu_spectacle['videos']);
  535.         }
  536.         $countecouter $this->em->getRepository(Podcasts::class)->countPodcasts('spectacles'$this->idspectacle'franceinter');
  537.         if ($countecouter == 0) {
  538.             unset($menu_spectacle['podcasts']);
  539.         }
  540.         $menu_spectacle[] = array('url' => 'contenus-pedagogiques''name' => 'Éduc''idclassification' => '125''id' => 'educ');
  541.         $this->view->nb_files $this->countTelechargements();
  542.         if ($this->view->nb_files 0) {
  543.             $menu_spectacle[] = array('url' => 'telechargements''name' => 'Doc. numérisés''id' => 'telechargements');
  544.         }
  545.         $this->current = array();
  546.         $this->current['idcontent'] = 0;
  547.         $this->current['menu_name'] = '';
  548.         $menuitems = array();
  549.         foreach ($menu_spectacle as $key => $value) {
  550.             // notation que je ne comprends pas
  551.             $has_classification = (isset($value['idclassification']) && $value['idclassification'] != '');
  552.             //compter le nombre de contenus associes
  553.             if ($has_classification) {
  554.                 if ($value['idclassification'] == 0) {
  555.                     // y a t'il un calendrier ?
  556.                     if ($value['url'] == 'lesdates') {
  557.                         $sql 'SELECT COUNT(sc.idspectacle)
  558.                                 FROM schedules sc
  559.                                 WHERE sc.idspectacle=' $this->idspectacle;
  560.                         $menuitems[$value['idclassification']]['count'] = $this->spectacles->queryOne($sql);
  561.                     }
  562.                     if ($value['url'] == 'dvd' && ($count_dvds $this->getDvds(true)) > 0) {
  563.                         $menuitems['dvd']['count'] = $count_dvds;
  564.                     }
  565.                 } else {
  566.                     // y a t'il au moins un contenu PUBLIE ?
  567.                     $sql 'SELECT oc.idcontent
  568.                             FROM object_content oc, contents c, content_classification cc
  569.                             WHERE oc.idcontent=c.idcontent
  570.                             AND cc.idcontent=c.idcontent
  571.                             AND c.publish=1
  572.                             AND oc.object=\'spectacles\'
  573.                             AND oc.idobject=' $this->idspectacle;
  574.                     // pour les soutiens
  575.                     if ($value['idclassification'] == 11) {
  576.                         $sql .= ' AND cc.idclassification IN (11,26)';
  577.                     } else {
  578.                         $sql .= ' AND cc.idclassification=' $value['idclassification'];
  579.                     }
  580.                     $sql .= ' LIMIT 1';
  581.                     $res $this->spectacles->queryRow($sql);
  582.                     if (!empty($res)) {
  583.                         $menuitems[$value['idclassification']]['idcontent'] = $res['idcontent'];
  584.                         $menuitems[$value['idclassification']]['count'] = 1// au moins un
  585.                     }
  586.                     // pour les contenus pédagogiques, si le texte à un contenu, on affiche le menu, sinon on continue
  587.                     if ($value['idclassification'] == 125 && empty($menuitems[$value['idclassification']]) && !empty($this->data_spectacles['texts'])) {
  588.                         $nb_contenus_pedagogiques_text 0;
  589.                         foreach ($this->data_spectacles['texts'] as $t) {
  590.                             $nb_contenus_pedagogiques_text $nb_contenus_pedagogiques_text $this->contents->countAssociateContent('texts'$t['idtext'], 125, array('publish_status' => 1));
  591.                         }
  592.                         if ($nb_contenus_pedagogiques_text 0) {
  593.                             $menuitems[$value['idclassification']]['count'] = $nb_contenus_pedagogiques_text;
  594.                         }
  595.                     }
  596.                 }
  597.                 //compter
  598.                 $idcont[$value['idclassification']] = $this->spectacles->queryOne($sql);
  599.             }
  600.             //pas de contenu, enlever l'item du menu
  601.             if ($has_classification && empty($menuitems[$value['idclassification']]['count'])) {
  602.                 unset($menu_spectacle[$key]);
  603.             } elseif ((empty($value['url']) && $this->context['action'] == 'detail-spectacle') || $value['url'] == $this->context['action']) {
  604.                 // marquer la page courante
  605.                 $menu_spectacle[$key]['active'] = $mark_active;
  606.                 if (!empty($menu_spectacle[$key]['name'])) {
  607.                     $this->current['menu_name'] = $menu_spectacle[$key]['name'];
  608.                 }
  609.                 if ($has_classification && !empty($menuitems[$value['idclassification']]['idcontent'])) {
  610.                     $this->current['idcontent'] = $menuitems[$value['idclassification']]['idcontent'];
  611.                 }
  612.             }
  613.         }
  614.         if ($this->context['action'] == 'entretiens' || $this->context['action'] == 'extraits' || $this->context['action'] == 'videos' || $this->context['action'] == 'culturebox') {
  615.             $menu_spectacle['videos']['active'] = 'on';
  616.         }
  617.         if (!empty($params['remove'])) {
  618.             foreach ($params['remove'] as $value) {
  619.                 unset($menu_spectacle[$value]);
  620.             }
  621.         }
  622.         $this->view->menu_spectacle $menu_spectacle;
  623.         // id du contenu associé si demandé
  624.         if (isset($this->context['params']) && array_key_exists('idcontent'$this->context['params'])) {
  625.             $idcontent $this->context['params']['idcontent'];
  626.             $this->current['idcontent'] = $idcontent;
  627.         } else if (empty($this->current['idcontent'])) {
  628.             $this->current['idcontent'] = 0;
  629.         }
  630.     }
  631.     // }}}
  632.     // {{{ action_detail_spectacle()
  633.     /**
  634.      * @Route("/spectacles/{slug}/", name="spectacle_index")
  635.      *
  636.      * Détail du spectacle (première page)
  637.      *
  638.      */
  639.     public function action_detail_spectacle($slug null)
  640.     {
  641.         $this->InitController($slug'detail-spectacle');
  642.         // indique que l'on est sur la page d'acceuil
  643.         $this->view->is_accueil true;
  644.         // pour culturebox, masquer le spectacle lié puisqu'on y est
  645.         $this->view->hide_podcast_related true;
  646.         // fil arianne
  647.         $this->locate[0] = 'Accueil';
  648.         // est-ce un dossier converti avec spip_accueil ?
  649.         $contents $this->em->getRepository(Contents::class);
  650.         $spip_accueil $contents->getAssociateContent($this->idspectacle'spectacles''class_spip_accueil');
  651.         // autre soutien
  652.         $other_soutien $contents->getAssociateContent($this->idspectacle'spectacles''class_production');
  653.         if (!empty($other_soutien)) {
  654.             $other_soutien['text'] = $contents->wikiTransform($other_soutien['text']);
  655.             $this->data_spectacles['autre_soutien'] = $other_soutien;
  656.         }
  657.         if (!empty($spip_accueil)) {
  658.             // conversion en wiki
  659.             foreach (array('deck''text') as $v) {
  660.                 if (empty($spip_accueil[$v])) continue;
  661.                 $spip_accueil[$v] = $contents->wikiTransform($spip_accueil[$v]);
  662.             }
  663.             $this->data_spectacles['spip_accueil'] = $spip_accueil;
  664.             // mots-clés et description
  665.             $to_description = array();
  666.             foreach (array('deck''text') as $v) {
  667.                 if (empty($spip_accueil[$v])) continue;
  668.                 $to_description[] = $spip_accueil[$v];
  669.             }
  670.             $this->func->makeMetaFromHtml($to_description$this->meta_description$this->meta_keywords);
  671.         }
  672.         // recuperer la liste des comediens (idrole=5)
  673.         $this->data_spectacles['personnages'] = $this->spectacles->getPersonsByRole($this->idspectacle'actors');
  674.         $this->data_spectacles['personnages'] = $this->spectacles->noPunct($this->data_spectacles['personnages']);
  675.         // ajout des mots-clés
  676.         foreach ($this->data_spectacles['personnages'] as $v) {
  677.             $this->meta_keywords .= ' ' $v['lastname']; // nom des acteurs
  678.         }
  679.         // recuperer les prochaines dates de ce spectacle
  680.         // recuperer le tableau des dates pour les lieux à J+1 et LIMIT
  681.         $schedules $this->em->getRepository(Schedules::class);
  682.         $version 'new';
  683.         $schedule_detail $schedules->getDateLieuDemain($this->idspectacle3null$version);
  684.         if (!empty($schedule_detail)) {
  685.             $this->view->calendrier['futurs'][] = $schedule_detail;
  686.         } else {
  687.             $this->view->calendrier['anciens'][] = $x $schedules->getDateLieuCommon('old'$this->idspectacle1'DESC''old');
  688.         }
  689.         //Première date de représentation
  690.         //1 - 3 = on ne veut pas des lectures et des mises-en-espace et des travail d'atelier
  691.         if (!in_array($this->data_spectacles['idtypespectacle']['idtypespectacle'], [135])) {
  692.             $this->view->calendrier['premiere'][] = $schedules->getDateLieuCommon('tous'$this->idspectacle1null'old', ['premiere_representation' => true], $this->em);
  693.         }
  694.         // recuperer le contenu associe pour le court texte de presentation
  695.         // soit presentation courte, soit en savoir plus
  696.         // recuperer les presentations courtes
  697.         $presentations_spectacle $this->contents instanceof ContentsRepository
  698.             $this->contents->getMoreAssociateContent(
  699.                 $this->idspectacle,
  700.                 'spectacles',
  701.                 'class_presentation_spectacle'
  702.             ) : null;
  703.         // si pas de presentation courte
  704.         if (empty($presentations_spectacle)) {
  705.             /* class_article = 6 */
  706.             // si pas de presentation, recuperer le premier contenu de en savoir plus
  707.             $sql 'SELECT c.title,c.idcontent,c.language,c.deck,c.text,c.display_media, c.markdown
  708.                     FROM object_content oc, contents c, content_classification cc
  709.                        WHERE oc.idcontent=c.idcontent
  710.                        AND cc.idcontent=c.idcontent
  711.                        AND cc.idclassification=6
  712.                        AND oc.idobject=\'' $this->idspectacle '\'
  713.                        AND oc.object=\'spectacles\'
  714.                        ORDER BY c.`range`,c.dateinsert ASC LIMIT 0,1';
  715.             $presentations_spectacle $this->em->getConnection()->prepare($sql)->executeQuery()->fetchAllAssociative();
  716.             if (!empty($presentations_spectacle)) {
  717.                 $savoir_plus_present true;
  718.             }
  719.         }
  720.         // prendre soit la langue en cours, soit une autre
  721.         foreach ($presentations_spectacle as $k => $v) {
  722.             if ($v['language'] == $this->context['lng']) {
  723.                 $presentation_key $k;
  724.                 $presentation_ol false;
  725.                 $presentation_olterm false;
  726.                 break;
  727.             }
  728.             $presentation_key $k;
  729.             $presentation_ol $v['language'];
  730.             $presentation_olterm $this->spectacles->getNameLanguage($v['language']);
  731.         }
  732.         $this->data_spectacles['presentation_spectacle'] = $presentations_spectacle[$presentation_key];
  733.         $this->data_spectacles['presentation_spectacle']['ol'] = $presentation_ol;
  734.         $this->data_spectacles['presentation_spectacle']['olterm'] = $presentation_olterm;
  735.         if (isset($savoir_plus_present)) {
  736.             $this->data_spectacles['presentation_spectacle']['text'] = $this->contents->cutSentence($this->data_spectacles['presentation_spectacle']['text'], 600);
  737.             $this->data_spectacles['presentation_spectacle']['lire_suite'] = true;
  738.         }
  739.         // mise en forme des champs wiki
  740.         foreach (array('deck''text') as $v) {
  741.             if (empty($this->data_spectacles['presentation_spectacle'][$v])) continue;
  742.             $markdown $this->data_spectacles['presentation_spectacle']['markdown'];
  743.             $this->data_spectacles['presentation_spectacle'][$v] = $this->contents->wikiTransform($this->data_spectacles['presentation_spectacle'][$v], $markdown);
  744.         }
  745.         // mots-clés et description
  746.         $to_description = array();
  747.         foreach (array('deck''text') as $v) {
  748.             if (empty($this->data_spectacles['presentation_spectacle'][$v])) continue;
  749.             $to_description[] = $this->data_spectacles['presentation_spectacle'][$v];
  750.         }
  751.         $this->func->makeMetaFromHtml($to_description$this->meta_description$this->meta_keywords);
  752.         // recuperer la liste des producteurs/co-producteur/producteur delegue/diffuseurs
  753.         // (idrole=17/18/19,77, pas de type et recherche dans contacts)
  754.         $this->data_spectacles['producteurs'] = $this->spectacles->getContactsByRole($this->idspectacle17);
  755.         $this->data_spectacles['producteurs'] = $this->spectacles->noPunct($this->data_spectacles['producteurs']);
  756.         $this->data_spectacles['coproducteurs'] = $this->spectacles->getContactsByRole($this->idspectacle18);
  757.         $this->data_spectacles['coproducteurs'] = $this->spectacles->noPunct($this->data_spectacles['coproducteurs']);
  758.         $this->data_spectacles['producteurs_delegues'] = $this->spectacles->getContactsByRole($this->idspectacle19);
  759.         $this->data_spectacles['producteurs_delegues'] = $this->spectacles->noPunct($this->data_spectacles['producteurs_delegues']);
  760.         $this->data_spectacles['bureau_production'] = $this->spectacles->getContactsByRole($this->idspectacle77);
  761.         $this->data_spectacles['bureau_production'] = $this->spectacles->noPunct($this->data_spectacles['bureau_production']);
  762.         $this->data_spectacles['structure_diffusion'] = $this->spectacles->getContactsByRole($this->idspectacle77);
  763.         $this->data_spectacles['structure_diffusion'] = $this->spectacles->noPunct($this->data_spectacles['structure_diffusion']);
  764.         // récupèrer soutien JTN, ENSATT...
  765.         $this->data_spectacles['soutiens'] = $this->spectacles->getSoutiens($this->idspectacle);
  766.         // recuperer la liste des autres postes (idrole=0 et type=1)
  767.         $this->data_spectacles['others'] = $this->spectacles->getPersonsByRole($this->idspectacle'distributions');
  768.         $this->data_spectacles['others'] = $this->spectacles->noPunct($this->data_spectacles['others']);
  769.         // autres roles
  770.         $others_distrib $this->contents->getAssociateContent($this->idspectacle'spectacles''class_distribution');
  771.         if (!empty($others_distrib)) {
  772.             $others_distrib['text'] = $this->contents->wikiTransform($others_distrib['text']);
  773.             $others_distrib['text'] = preg_replace('#</?p>#i'''$others_distrib['text']);
  774.             $this->data_spectacles['others_distrib'] = $others_distrib;
  775.         }
  776.         // ajouter la virgule
  777.         if (!empty($this->data_spectacles['others_distrib']['text']) && !empty($this->data_spectacles['others'])) {
  778.             $this->data_spectacles['others_punct'] = true;
  779.         }
  780.         // si ni spip_accueil, ni presentation
  781.         if (empty($this->data_spectacles['my_spectacle']) && !$this->isGranted('ROLE_ISROOT')) { //@todo à réintégrer ici :  && !$this->context['session']->is_set('isroot')
  782.             if (empty($this->data_spectacles['presentation_spectacle']['text']) && empty($spip_accueil)) {
  783.                 $this->view->is_ancien true;
  784.                 if (!empty($this->data_spectacles['urlPage'])) {
  785.                     // mais url_page = ancien dossier en HTML
  786.                     // TODO vérifier url_page dans la BDD
  787.                     if (strpos($this->data_spectacles['urlPage'], 'dossiers_de_presse')) {
  788.                         $this->view->is_fichier true;
  789.                     } else {
  790.                         $this->view->is_old $this->data_spectacles['urlPage'];
  791.                     }
  792.                 } else {
  793.                     // si rien du tout
  794.                     $this->view->spectacle_vide true;
  795.                 }
  796.             }
  797.         }
  798.         // lien calendrier
  799.         $this->view->see_all_dates true;
  800.         //contenus vidéo sur index
  801.         $this->contenus_spectacles('class_extrait_spec''extraits');
  802.         if (isset($this->view->detailarticle)) {
  803.             $this->view->accueil_video $this->view->detailarticle;
  804.         }
  805.         //Si nous avons un extrait
  806.         if (!empty($this->view->accueil_video['media'])) {
  807.             if ($total count($this->view->accueil_video['media']) > 1) {
  808.                 $aleatoire rand(0, ($total 1));
  809.                 $videos $this->view->accueil_video['media'];
  810.                 unset($this->view->accueil_video['media']);
  811.                 $this->view->accueil_video['media'][$aleatoire] = $videos[$aleatoire];
  812.             }
  813.             foreach ($this->view->accueil_video['media'] as $key_media => $value_media) {
  814.                 if (!empty($this->view->accueil_video['media'][$key_media]['image_media'])) {
  815.                     $this->view->accueil_video['media'][$key_media]['vignette'] = $this->view->accueil_video['media'][$key_media]['image_media'];
  816.                 }
  817.             }
  818.         } //Si nous n'avons pas d'extrait, nous prenons la première vidéo qui nous vient.
  819.         else {
  820.             $multimedias $this->em->getRepository(Multimedias::class);
  821.             $params_sql = array(
  822.                 'limit' => array(01),
  823.                 'object' => array('spectacles' => $this->idspectacle),
  824.                 'novod' => true,
  825.                 'dbg' => array('videos_spectacle''Une vidéo du spectacle'),
  826.             );
  827.             $list_multimedias $multimedias->getListMultimedias(
  828.                 $params_sql,
  829.                 array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none''ratio' => '169'),
  830.                 array('format_vignette' => true)
  831.             );
  832.             $this->view->accueil_video['media'] = $list_multimedias;
  833.         }
  834.         if (empty($this->view->accueil_video['media'])) {
  835.             unset($this->view->accueil_video);
  836.         }
  837.         // contenus critiques sur index
  838.         $this->contenus_spectacles('class_critique''critiques');
  839.         $x $this->view->accueil_critiques $this->view->articles;
  840.         if (!empty($this->view->accueil_critiques['fr']['content'])) {
  841.             if (count($this->view->accueil_critiques['fr']['content']) > 2) {
  842.                 $this->view->accueil_critiques array_slice($this->view->accueil_critiques['fr']['content'], 02);
  843.             } else {
  844.                 $this->view->accueil_critiques $this->view->accueil_critiques['fr']['content'];
  845.             }
  846.         }
  847.         // des aides pour ce spectacle ?
  848.         $this->view->aides $this->spectacles->noPunct($this->em->getRepository(Aides::class)->getListAides(
  849.             array(
  850.                 'special' => array(
  851.                     'idspectacles' => $this->idspectacle,
  852.                 )
  853.             ),
  854.             null,
  855.             array(
  856.                 'groupe_by_type' => true,
  857.             )));
  858.         //Les évènements
  859.         $evenements_params = array(
  860.             'params' => array(
  861.                 'limit' => array(05)
  862.             ),
  863.             'special' => array(
  864.                 'publish_valid' => true,
  865.                 'no_schedule_contact' => true,
  866.                 'by_object' => array('idspectacle' => $this->idspectacle),
  867.                 'prochains' => true
  868.             ),
  869.         );
  870.         $nb_evenements 0;
  871.         //Les futurs évènements
  872.         $list_evenements $this->view->news_list_news['prochains'] = $this->em->getRepository(News::class)->getListNews($evenements_params);
  873.         if (!empty($list_evenements) && $nb_evenements count($list_evenements) <= 5) {
  874.             $this->view->is_news_list_news true;
  875.             foreach ($list_evenements as $k => $v) {
  876.                 $exclude_news[$k] = $v['idnew'];
  877.             }
  878.             if (!empty($exclude_news)) {
  879.                 $evenements_params['params']['where'] = ' AND T1.idnew NOT IN (' join(','$exclude_news) . ') ';
  880.             }
  881.         }
  882.         //Les anciens évènements
  883.         $evenements_params['params']['limit'] = array(0$nb_evenements);
  884.         unset($evenements_params['special']['prochains']);
  885.         $evenements_params['special']['anciens'] = true;
  886.         $this->view->news_list_news['anciens'] = $this->em->getRepository(News::class)->getListNews($evenements_params);
  887.         if (!empty($this->view->news_list_news['anciens'])) {
  888.             $this->view->is_news_list_news true;
  889.         }
  890.         //Récupérer tous les spectacles avec soutiens d'un même texte
  891.         // voir si ce spectacle à un replay culturebox
  892.         $culturebox_params = array(
  893.             'limit' => array(01),
  894.             'special' => array(
  895.                 'idspectacles' => array('idspectacle' => $this->idspectacle),
  896.                 'type_podcast' => 'culturebox',
  897.                 'current' => true
  898.             ),
  899.             'dbg' => array('derniers_culturebox''Les derniers replay culturebox référencés'),
  900.         );
  901.         $format_vignette = array('width' => 680'direction' => 'thumb');
  902.         $this->view->derniers_culturebox $this->em->getRepository(Podcasts::class)->getListPodcasts($culturebox_params$format_vignette);
  903.         // récupérer les VOD du spectacle
  904.         $culturebox_params['special']['type_diffusion'] = 1;
  905.         $culturebox_params['dbg'] = array('derniers_culturebox''Les derniers replay culturebox référencés');
  906.         $this->context['view']->dernieres_vod $this->em->getRepository(Podcasts::class)->getListPodcasts($culturebox_params$format_vignette);
  907.         //Récupérer le podcast disponible
  908.         $culturebox_params = array(
  909.             'direction' => 'DESC',
  910.             'limit' => array(01),
  911.             'special' => array(
  912.                 'idspectacles' => $this->idspectacle,
  913.                 'type_podcast' => ['franceinter''soundcloud'],
  914.                 // 'is_integrale' => true,
  915.             ),
  916.             'dbg' => array('derniers_culturebox_current''Les replay France Culture référencés'),
  917.         );
  918.         $podcasts $this->em->getRepository(Podcasts::class);
  919.         $this->view->derniers_franceculture $podcasts->getListPodcasts($culturebox_params, ['width' => 480'direction' => 'thumb']);
  920.         $this->view->nb_derniers_franceculture $podcasts->countListPodcasts($culturebox_params);
  921.         // on rajoute la fiche du dvd à la page détail pour l'affiche
  922.         $this->view->vignette_dvd $this->getDvds(false, ['limit' => array(01)]);
  923.         //Récupration des prix et distinctions
  924.         $this->view->type_aides = array(
  925.             'prix' => array(
  926.                 'type_aides' => array(23),
  927.                 'label' => 'Prix et distinctions',
  928.             ),
  929. //            'soutiens' => array(
  930. //                'type_aides' => array(1),
  931. //                'label' => 'Aide(s) et soutien(s)',
  932. //            ),
  933.             'selections' => array(
  934.                 'type_aides' => array(4),
  935.                 'label' => 'Sélection(s)',
  936.             ),
  937.         );
  938.         $spectacle_aide $this->em->getRepository(SpectacleAide::class);
  939.         foreach ($this->view->type_aides as $k => $v) {
  940.             $params_sql_aide = array(
  941.                 'where' => array(
  942.                     array('spectacle_aide''publish'1)
  943.                 ),
  944.                 'idspectacle' => $this->idspectacle,
  945.                 'special' => array(
  946.                     'aides' => array(
  947.                         'type_aides' => $v['type_aides']
  948.                     )
  949.                 ),
  950.                 'dbg' => array('spectacle_' $k$v['label']),
  951.             );
  952.             $this->view->type_aides[$k]['aides'] = $spectacle_aide->getListSpectacleAide($params_sql_aide);
  953.             if (empty($this->view->type_aides[$k]['aides'])) {
  954.                 unset($this->view->type_aides[$k]);
  955.             }
  956.         }
  957.         if (!empty($this->view->type_aides['prix'])) {
  958. //            $this->view->laureats_nominations = $this->view->type_aides['prix']['aides'];
  959. //            unset($this->view->type_aides['prix']);
  960.         }
  961.         //Spectacles devant être exclus
  962.         $idspectacles_exclude[] = $this->idspectacle;
  963.         //Si ce n'est pas un collage nous effectuons ce code là'
  964.         if (empty($this->data_spectacles['collage']) || !$this->data_spectacles['collage']) {
  965.             $idspectacles $this->GetListSpectaclesFromSpecificLanguageFromTexts(['prochains' => true'limit' => [04], 'exclude_idspectacle' => $idspectacles_exclude]);
  966.             if (!empty($idspectacles)) {
  967.                 foreach ($idspectacles as $k => $v) {
  968.                     $idspectacles[$k]['footer_contact'] = true;
  969.                     $idspectacles_exclude[] = $k;
  970.                 }
  971.                 $this->view->autresmisesenscene_prochains $idspectacles;
  972.             }
  973.             $idspectacles $this->GetListSpectaclesFromSpecificLanguageFromTexts(['limit' => [06], 'exclude_idspectacle' => $idspectacles_exclude]);
  974.             if (!empty($idspectacles)) {
  975.                 foreach ($idspectacles as $k => $v) {
  976.                     $idspectacles[$k]['display']['affiche_date_creation'] = true;
  977.                     $idspectacles[$k]['annee_creation'] = $this->spectacles->getFormeDate($idspectacles[$k]['creation_date'], '%Y'true); //%a %d/%m/%Y
  978.                 }
  979.                 $this->view->autresmisesenscene_tous $idspectacles;
  980.             }
  981.         }
  982.         //Les textes par l'auteur
  983.         $playlists $this->em->getRepository(Playlists::class);
  984.         if ($this->em->getRepository(Playlists::class)->countPlaylists('texts'$this->data_spectacles['texts'][0]['idtext'], 'class_texte_parauteur') > 0) {
  985.             $playlist $this->em->getRepository(Playlists::class)->getByClassification('texts'$this->data_spectacles['texts'][0]['idtext'], 'class_texte_parauteur');
  986.             $url_clean_playlist filter_var($playlist['urlClean'], FILTER_SANITIZE_STRING);
  987.             $idplaylist $playlists->getIdByUrl($url_clean_playlist);
  988.             $playlist $playlists->getInfosPlaylist(
  989.                 $idplaylist,
  990.                 array(
  991.                     'all' => true,
  992.                     'multimedias' => true
  993.                 )
  994.             );
  995.             foreach ($playlist['multimedias'] as $k => $v) {
  996.                 $this->view->video_par_auteur $v;
  997.                 break;
  998.             }
  999.             $this->view->video_par_auteur['url_clean_more'] = 'playlist/id/' $playlist['urlClean'];
  1000.         }
  1001.         $idspectacles = array();
  1002.         $idspectacles $this->GetListSpectaclesFromSpecificLanguageFromTexts(['limit' => [04], 'aide' => ['idcontact' => 28366], 'spectacle_aide' => true]);
  1003.         $aides $this->em->getRepository(SpectacleAide::class);
  1004.         $aides_tabeaux = array();
  1005.         if (!empty($idspectacles)) {
  1006.             foreach ($idspectacles as $k => $v) {
  1007.                 $idspectacles[$k]['display']['affiche_date_creation'] = true;
  1008.                 $idspectacles[$k]['annee_creation'] = $this->spectacles->getFormeDate($idspectacles[$k]['creation_date'], '%Y'true); //%a %d/%m/%Y
  1009.                 $aides_spectacle $aides->getListSpectacleAide(['idspectacle' => $k'special' => ['aides' => ['idcontacts' => 28366]]]);
  1010.                 unset($aides_spectacle['spectacles']);
  1011.                 $idspectacles[$k]['aide'] = reset($aides_spectacle);
  1012.             }
  1013.             $this->view->avoirsur_theatreneacte $idspectacles;
  1014.         }
  1015.         //On récupère trois contenus en savoir plus associés à ce spectacle
  1016.         $this->contenus_spectacles('class_article''ensavoirplus', [], ['limit' => 3]);
  1017.         $nb_presentation $this->contenus_spectacles('class_article''ensavoirplus', [], ['count_only' => true]);
  1018.         // style en plus pour le calendrier
  1019.         $this->style_more[] = 'calendrier_spectacle';
  1020.         $this->extra_title '';
  1021.         // aside
  1022.         $this->asides->load('spectacles_thumbnail');
  1023.         $this->asides->load('spectacles_distribution');
  1024.         // en savoir plus
  1025.         $this->asides->load(['textes_menu_educ' => array(
  1026.             'exec' => array(
  1027.                 'alone' => true,
  1028.                 'color' => 'context',
  1029.                 'border' => true
  1030.             ),
  1031.             'footer' => true,
  1032.             'nb_presentation' => $nb_presentation,
  1033.             'title' => 'en savoir plus'
  1034.         )]);
  1035.         $this->asides->load(['common_prochain_evenement' => array(
  1036.             'url_custom' => '/spectacles/' $this->data_spectacles['urlClean'] . '/evenements'
  1037.         )]);
  1038.         $this->getAsideSelections();
  1039.         $this->asides->load('common_participer_spectacles');
  1040.         if (!array_key_exists('collage'$this->data_spectacles) && array_key_exists('textunique'$this->data_spectacles)) {
  1041.             $this->asides->load('spectacles_voir_texte');
  1042.         }
  1043.         $this->asides->load('dvd_vignette');
  1044.         $this->addPubliciteGoogle();
  1045.         return $this->view('spectacles/detail-spectacle.html.twig', [
  1046.             'data_spectacles' => $this->data_spectacles
  1047.         ]);
  1048.     }
  1049.     // }}}
  1050.     // {{{ contenus()
  1051.     /** Les articles associés aux spectacles
  1052.      *
  1053.      */
  1054.     public function contenus_spectacles($type_class$type_class_view$other_dimensions = array('width' => 150'grow' => false), $params = array())
  1055.     {
  1056.         $valeur parent::contenus('spectacles'$this->idspectacle$type_class$type_class_view$other_dimensions$params);
  1057.         if (!empty($params['count_only']) || !empty($params['return_content'])) {
  1058.             return $valeur;
  1059.         }
  1060.     }
  1061.     // }}}
  1062.     /** Etape 1 sélection du type d'aide
  1063.      * @Route("/spectacles/{slug}/aides-etape", name="spectacle_aides_etape")
  1064.      */
  1065.     public function action_aides_etape(
  1066.         $slug null,
  1067.         Request $request,
  1068.         \App\Service\UtilsEdit $utilsEdit,
  1069.         FormFactoryInterface $formFactory,
  1070.         SessionInterface $session
  1071.     )
  1072.     {
  1073.         $this->InitController($slug'aides_etape');
  1074.         $text $this->getAjoutAideObject(1'aides'null$utilsEdit$formFactory$session);
  1075.         $text->getFormTypeAides($request);
  1076.         if ($text->validateAidesForm()) {
  1077.             $text->saveAides();
  1078.             return $this->redirectToRoute('spectacle_aides_etape1', ['slug' => $this->data_spectacles['urlClean']]);
  1079.         }
  1080.         $this->asides->load('ajoutaides_informations_aides_spectacles');
  1081.         $this->asides->load('common_participer_spectacles');
  1082.         return $this->view('spectacles/aides-etape.html.twig', [
  1083.             'form' => $this->context['form']->createView()
  1084.         ]);
  1085.     }
  1086.     /** Etape 1 sélection du contact
  1087.      * @Route("/spectacles/{slug}/aides-etape1/", name="spectacle_aides_etape1")
  1088.      */
  1089.     public function action_aides_etape1(
  1090.         $slug null,
  1091.         Request $request,
  1092.         \App\Service\UtilsEdit $utilsEdit,
  1093.         FormFactoryInterface $formFactory,
  1094.         SessionInterface $session
  1095.     )
  1096.     {
  1097.         $this->InitController($slug'aides_etape');
  1098.         $text $this->getAjoutAideObject(1'aides'1$utilsEdit$formFactory$session);
  1099.         $text->getSteps('test'1);
  1100.         if ($text->getFormContacts($request)) {
  1101.             if ($text->validateContactsForm()) {
  1102.                 $text->saveContacts();
  1103.                 return $this->redirectToRoute('spectacle_aides_etape2', ['slug' => $this->data_spectacles['urlClean']]);
  1104.             }
  1105.         } else {
  1106.             return $this->redirectToRoute('spectacle_aides_etape', ['slug' => $this->data_spectacles['urlClean']]);
  1107.         }
  1108.         $this->asides->load('ajoutaides_informations_aides_spectacles');
  1109.         $this->asides->load('common_participer_spectacles');
  1110.         return $this->view('spectacles/aides-etape1.html.twig', [
  1111.             'form' => $this->context['form']->createView()
  1112.         ]);
  1113.     }
  1114.     // {{{ action_aides_etape2()
  1115.     /** Etape 2 sélection de l'aide en lien avec le contact
  1116.      *
  1117.      * @Route("/spectacles/{slug}/aides-etape2/", name="spectacle_aides_etape2")
  1118.      *
  1119.      */
  1120.     public function action_aides_etape2(
  1121.         $slug null,
  1122.         Request $request,
  1123.         \App\Service\UtilsEdit $utilsEdit,
  1124.         FormFactoryInterface $formFactory,
  1125.         SessionInterface $session
  1126.     )
  1127.     {
  1128.         $this->InitController($slug'aides_etape');
  1129.         $text $this->getAjoutAideObject(1'aides'2$utilsEdit$formFactory$session);
  1130.         $text->getSteps('test'2);
  1131.         if ($text->getFormAides($request)) {
  1132.             if ($text->getValidAides()) {
  1133.                 $text->getSaveAides();
  1134.                 return $this->redirectToRoute('spectacle_aides_etape3', ['slug' => $this->data_spectacles['urlClean']]);
  1135.             }
  1136.         } else {
  1137.             return $this->redirectToRoute('spectacle_aides_etape', ['slug' => $this->data_spectacles['urlClean']]);
  1138.         }
  1139.         $this->asides->load('ajoutaides_informations_aides_spectacles');
  1140.         $this->asides->load('common_participer_spectacles');
  1141.         return $this->view('spectacles/aides-etape2.html.twig', [
  1142.             'form' => $this->context['form']->createView()
  1143.         ]);
  1144.     }
  1145.     // }}}
  1146.     /** Etape 3 message de validation
  1147.      * @Route("/spectacles/{slug}/aides-etape3", name="spectacle_aides_etape3")
  1148.      */
  1149.     public function action_aides_etape3(
  1150.         $slug null,
  1151.         \App\Service\UtilsEdit $utilsEdit,
  1152.         FormFactoryInterface $formFactory,
  1153.         SessionInterface $session
  1154.     )
  1155.     {
  1156.         $this->InitController($slug'aides_etape');
  1157.         $text $this->getAjoutAideObject(1'aides'3$utilsEdit$formFactory$session);
  1158.         $text->getSteps('test'3);
  1159.         $text->getValidation();
  1160.         $this->asides->load('ajoutaides_informations_aides_spectacles');
  1161.         $this->asides->load('common_participer_spectacles');
  1162.         return $this->view('spectacles/aides-etape3.html.twig');
  1163.     }
  1164.     /** Appel du constructeur d'aide des objets */
  1165.     public function getAjoutAideObject(
  1166.         $typeaide 1,
  1167.         $type 'aides',
  1168.         $num null,
  1169.         $utilsEdit null,
  1170.         FormFactoryInterface $formFactory,
  1171.         SessionInterface $session
  1172.     )
  1173.     {
  1174.         $params_object = array(
  1175.             'object' => [
  1176.                 'type' => 'spectacle',
  1177.                 'value' => $this->idspectacle
  1178.             ],
  1179.             'aides' => array(
  1180.                 'typeaide' => 1
  1181.             ),
  1182.             'url' => '/spectacles/' $this->view->url_clean '/' $type '-etape' $num
  1183.         );
  1184.         $this->context['formFactory'] = $formFactory->createBuilder(FormType::class, null, [
  1185.             'attr' => [
  1186.                 'id' => 'masterform'
  1187.             ]
  1188.         ]);
  1189.         return new Ajoutaides(
  1190.             $this->em,
  1191.             $utilsEdit,
  1192.             $session,
  1193.             $this->context,
  1194.             $params_object
  1195.         );
  1196.     }
  1197.     // {{{ action_evenements()
  1198.     /**
  1199.      *
  1200.      * @Route("/spectacles/{slug}/evenements", name="spectacle_evenements")
  1201.      *
  1202.      * Les évènements associés aux spectacles
  1203.      *
  1204.      */
  1205.     public function action_evenements($slug null)
  1206.     {
  1207.         $this->InitController($slug'evenements');
  1208.         $object $this->em->getRepository(News::class);
  1209.         //Pour afficher la description tiny
  1210.         $this->view->is_description true;
  1211.         //Les évènements
  1212.         $evenements_params_commun = array(
  1213.             'params' => array(
  1214.                 'limit' => array(0100)
  1215.             ),
  1216.             'special' => array(
  1217.                 'publish_valid' => true,
  1218.                 // 'no_schedule_contact' => true,
  1219.                 'by_object' => array('idspectacle' => $this->idspectacle),
  1220.             )
  1221.         );
  1222.         foreach (['prochains''anciens'] as $value) {
  1223.             $evenements_params $evenements_params_commun;
  1224.             $evenements_params['special'][$value] = true;
  1225.             if (!empty($exclude_news)) {
  1226.                 $evenements_params['params']['where'] = ' AND T1.idnew NOT IN (' join(','$exclude_news) . ') ';
  1227.             }
  1228.             $news_list[$value] = $object->getListNews($evenements_params);
  1229.             if (!empty($news_list[$value])) {
  1230.                 // liste d'exclusion => pas de en cours dans les anciens
  1231.                 foreach ($news_list[$value] as $k => $v) {
  1232.                     $exclude_news[$k] = $v['idnew'];
  1233.                 }
  1234.             }
  1235.         }
  1236.         $this->view->news_list_news $news_list;
  1237.         $this->asides->load('common_participer_spectacles');
  1238.         return $this->view('spectacles/evenements.html.twig');
  1239.     }
  1240.     // }}}
  1241.     // {{{ action_ensavoirplus()
  1242.     /**
  1243.      * @Route("/spectacles/{slug}/ensavoirplus/", name="spectacle_ensavoirplus")
  1244.      * @Route("/spectacles/{slug}/ensavoirplus/idcontent/{p_idcontent}", name="spectacle_ensavoirplus_idcontent")
  1245.      * @Route("/spectacles/{slug}/ensavoirplus/idcontent/{p_idcontent}/pdf/{p_pdf}", name="spectacle_ensavoirplus_idcontent_pdf")
  1246.      * @Route("/spectacles/{slug}/ensavoirplus/idcontent/{p_idcontent}/pdf/{p_pdf}/download/{p_download}", name="spectacle_ensavoirplus_idcontent_pdf_download")
  1247.      *
  1248.      * Les articles associés aux spectacles de type ensavoirplus
  1249.      *
  1250.      */
  1251.     public function action_ensavoirplus($slug null$p_idcontent null$p_pdf null$p_download null)
  1252.     {
  1253.         $this->InitController($slug'ensavoirplus');
  1254.         $this->setParamsPDF($p_pdf$p_download);
  1255.         $this->context['params']['idcontent'] = $p_idcontent;
  1256.         $this->context['action'] = 'ensavoirplus';
  1257.         $this->view->idcontentCurrent $p_idcontent;
  1258.         $this->contenus_spectacles('class_article''ensavoirplus');
  1259.         if ($this->getUser() instanceof Extranetusers) {
  1260.             $params_sql = [
  1261.                 'return_content' => true,
  1262.                 'specif_sql' => ' AND c.valid = 0 AND c.idextranetuser = 99'
  1263.             ];
  1264.             $this->view->mes_articles $this->contenus_spectacles('class_article''ensavoirplus', array('width' => 150'grow' => false), $params_sql);
  1265.         }
  1266.         $this->view->page_ensavoirplus true;
  1267.         //retrouver les infos sur les user
  1268.         $this->view->alone_main false;
  1269.         // aside
  1270.         // $this->asides->load('spectacles_sous_menu');
  1271.         //aside
  1272.         $this->asides->load(['textes_menu_educ' => array(
  1273.             'exec' => array(
  1274.                 'alone' => true,
  1275.                 'color' => 'context'
  1276.             ),
  1277.         )]);
  1278.         if ($this->getUser() instanceof Extranetusers) {
  1279.             $this->asides->load(['textes_menu_educ,custom_articles' => array(
  1280.                 'exec' => array(
  1281.                     'alone' => true,
  1282.                     'color' => 'context'
  1283.                 ),
  1284.                 'title' => 'Mes articles',
  1285.                 'subtitle' => 'en attente de validation',
  1286.                 'custom_articles' => $this->view->mes_articles
  1287.             )]);
  1288.         }
  1289.         asides::setEntityManager($this->em);
  1290.         asides::loadaside('Publicite')->addGoogleAsides($this->asides$this->serviceAbonnements);
  1291.         $this->asides->load('common_participer_spectacles');
  1292.         $this->checkConditionsPDF();
  1293.         return $this->view('spectacles/ensavoirplus.html.twig');
  1294.     }
  1295.     // }}}
  1296.     // {{{ action_contenus_pedagogiques()
  1297.     /**
  1298.      * @Route("/spectacles/{slug}/contenus-pedagogiques/", name="spectacle_contenus_pedagogiques")
  1299.      * @Route("/spectacles/{slug}/contenus-pedagogiques/idcontent/{p_idcontent}", name="spectacle_contenus_pedagogiques_idcontent")
  1300.      * @Route("/spectacles/{slug}/contenus-pedagogiques/idcontent/{p_idcontent}/pdf/{p_pdf}", name="spectacle_contenus_pedagogiques_idcontent_pdf")
  1301.      * @Route("/spectacles/{slug}/contenus-pedagogiques/idcontent/{p_idcontent}/pdf/{p_pdf}/download/{p_download}", name="spectacle_contenus_pedagogiques_idcontent_pdf_download")
  1302.      *
  1303.      * Les articles associés aux spectacles de type contenu education
  1304.      *
  1305.      */
  1306.     public function action_contenus_pedagogiques($slug null$p_idcontent null$p_pdf null$p_download null)
  1307.     {
  1308.         $this->InitController($slug'contenus-pedagogiques');
  1309.         $this->setParamsPDF($p_pdf$p_download);
  1310.         $this->context['params']['idcontent'] = $p_idcontent;
  1311.         $this->view->idcontentCurrent $p_idcontent;
  1312.         $this->view->is_educ true;
  1313.         $params_sql_specific = array();
  1314.         //on récupère le contenu theatre-en-acte
  1315.         $theatre_en_acte $this->contents->getAssociateContents($this->idspectacle'spectacles''class_theatre_en_acte');
  1316.         if ($theatre_en_acte) {
  1317.             $theatre_en_acte reset($theatre_en_acte);
  1318.             //On prépare les liens pour les asides
  1319.             foreach ($theatre_en_acte as $k => $v) {
  1320.                 $id_contents_exclude[] = $v['idcontent'];
  1321.                 $urls_theatrenacte[$v['idcontent']] = array(
  1322.                     'url' => '/spectacles/{v_url_clean}/contenus-pedagogiques/idcontent/key_content',
  1323.                     'name' => $v['title'],
  1324.                     'key_content' => $v['idcontent']
  1325.                 );
  1326.             }
  1327.             $urls_theatrenacte['allspectacles'] = array(
  1328.                 'url' => '/contacts/Theatre-en-Acte',
  1329.                 'name' => 'Tous les spectacles'
  1330.             );
  1331.             //on indique quel contenus ne devant pas être récupérés avec les contenus-pedagogiques
  1332.             if ($id_contents_exclude) {
  1333.                 $params_sql_specific = array(
  1334.                     'where' => ' oc.idobject=' . (int)$this->idspectacle ' AND c.idcontent NOT IN (' implode(','$id_contents_exclude) . ')'
  1335.                 );
  1336.             }
  1337.         }
  1338.         $params_sql_specific['setGroupByClassification'] = true;
  1339.         $params_sql_specific['limit'] = 'all';
  1340.         //on récupère le contenu-pedagogique en supprimant les contenus theatre-en-acte qui pourrait être récupérés
  1341.         $this->contenus_spectacles('class_contenu_educ''contenus-pedagogiques', array('width' => 150'grow' => false), $params_sql_specific);
  1342.         // trouver les autres mises en scène de ce texte qui ont des contenus educ
  1343.         if (!empty($this->ids_texts)) {
  1344.             $sql 'SELECT s.`idspectacle` FROM spectacles s
  1345.                 JOIN text_spectacle ts  ON ts.`idspectacle`=s.`idspectacle`
  1346.                 JOIN object_content oc  ON oc.`idobject`=s.`idspectacle`
  1347.                 JOIN contents c ON c.`idcontent`=oc.`idcontent`
  1348.                 JOIN content_classification cc ON cc.`idcontent`=c.`idcontent`
  1349.                 WHERE c.publish=1
  1350.                 AND oc.object=\'spectacles\'
  1351.                 AND cc.idclassification=125
  1352.                 AND ts.idtext IN (' join(','$this->ids_texts) . ')
  1353.                 AND s.idspectacle!=' $this->idspectacle '
  1354.                 AND s.`publish`=1 AND s.`valid`=1';
  1355.             $idspectacles $this->spectacles->queryCol($sql);
  1356.             if (!empty($idspectacles)) {
  1357.                 $this->view->autres_spectacles $this->spectacles->getListSpectacles(array(
  1358.                     'special' => array(
  1359.                         'idspectacle' => $idspectacles,
  1360.                     ),
  1361.                     'params' => array(
  1362.                         'limit' => array(0200)
  1363.                     ),
  1364.                     'dbg' => array('list_others_spectacles''Liste des autres mes avec un contenus éduc'),
  1365.                 ));
  1366.                 if (!empty($this->view->autres_spectacles)) {
  1367.                     foreach ($this->view->autres_spectacles as $k => $v) {
  1368.                         $this->view->autres_spectacles[$k]['url_clean_more'] = 'contenus-pedagogiques/';
  1369.                     }
  1370.                 }
  1371.             }
  1372.             // voir si le texte à un contenu pédagogique
  1373.             $this->context['view']->list_texts $this->em->getRepository(Texts::class)->getListTexts(array(
  1374.                 'special' => array(
  1375.                     'idclassification' => array(125), // classification educ
  1376.                     'idtext' => $this->ids_texts// textes de la personne
  1377.                     'join' => true// texte pas forcément publié
  1378.                 ),
  1379.                 'dbg' => array('list_texts''Liste des textes à contenus pédagogiques')
  1380.             ));
  1381.             if (!empty($this->context['view']->list_texts)) {
  1382.                 foreach ($this->context['view']->list_texts as $k => $v) {
  1383.                     $this->context['view']->list_texts[$k]['url_clean_more'] = 'contenus-pedagogiques/';
  1384.                 }
  1385.             }
  1386.         }
  1387.         //redirection si aucun article n'est chargé par défault et qu'il existe du contenu theatre-en-acte
  1388.         if (isset($this->view->detailarticle) && !$this->view->detailarticle && count(reset($theatre_en_acte)) > 0) {
  1389.             $idcontent reset($theatre_en_acte)['idcontent'];
  1390.             return $this->redirectToRoute('spectacle_contenus_pedagogiques_idcontent', ['slug' => $this->view->url_clean,  'p_idcontent' => $idcontent]);
  1391.         }
  1392.         //aside
  1393.         //on force l'affichage du menu
  1394.         $this->view->morearticle true;
  1395.         if (!empty($theatre_en_acte)) {
  1396.             $this->asides->load(['url_lists_alone' => array(
  1397.                 'exec' => array('color' => 'educ'),
  1398.                 'php' => array(
  1399.                     'method' => 'asidesUrlLists',
  1400.                     'urls' => $urls_theatrenacte,
  1401.                     'params' => array(
  1402.                         'activate' => (!empty($this->context['params']['idcontent'])) ? $this->context['params']['idcontent'] : null
  1403.                     )
  1404.                 ),
  1405.                 'title' => 'Théâtre-en-acte'
  1406.             )]);
  1407.         }
  1408.         $this->asides->load('spectacles_educ');
  1409.         $this->checkConditionsPDF();
  1410.         return $this->view('spectacles/contenus-pedagogiques.html.twig');
  1411.     }
  1412.     // }}}
  1413.     // {{{ action_extraits()
  1414.     /** Les articles associés aux spectacles de type extraits
  1415.      *
  1416.      * @Route("/spectacles/{slug}/extraits/", name="spectacle_extrait")
  1417.      *
  1418.      */
  1419.     public function action_extraits($slug null)
  1420.     {
  1421.         $this->InitController($slug'videos');
  1422.         $this->contenus_spectacles('class_extrait_spec''extraits');
  1423.         $this->view->alone_main false;
  1424.         // aside
  1425.         $this->asides->load('spectacles_sous_menu');
  1426.         return $this->view('spectacles/extraits.html.twig');
  1427.     }
  1428.     // }}}
  1429.     // {{{ action_presse()
  1430.     /** Les articles associés aux spectacles de type presse
  1431.      *
  1432.      */
  1433.     public function action_presse()
  1434.     {
  1435.         $this->contenus_spectacles('class_presse''presse');
  1436.     }
  1437.     // }}}
  1438.     // {{{ action_enimages_spectacles()
  1439.     /** Les diaporamas du spectacle
  1440.      *
  1441.      * @Route("/spectacles/{slug}/enimages/", name="spectacle_enimages")
  1442.      * @Route("/spectacles/{slug}/enimages/idcontent/{p_idcontent}", name="spectacle_enimages_idcontent")
  1443.      *
  1444.      */
  1445.     public function action_enimages_spectacles($slug null$p_idcontent null)
  1446.     {
  1447.         $this->InitController($slug'enimages');
  1448.         $this->context['params']['idcontent'] = $p_idcontent;
  1449.         parent::action_enimages($this->idspectacle'spectacles');
  1450.         return $this->view('spectacles/enimages.html.twig');
  1451.     }
  1452.     // }}}
  1453.     // {{{ action_gadget_calendrier()
  1454.     /** Gadget caelendrier
  1455.      *
  1456.      * @Route("/spectacles/{slug}/gadget-calendrier", name="spectacle_gadget_calendrier")
  1457.      *
  1458.      * @access public
  1459.      * @return void
  1460.      *
  1461.      */
  1462.     public function action_gadget_calendrier($slug nullRequest $request)
  1463.     {
  1464.         $this->InitController($slug'gadget-calendrier');
  1465.         $params = array();
  1466.         // nombre d'items maxi
  1467.         $max_nbitems 50;
  1468.         if (!empty($_POST['nbitems']) && $this->func->my_is_int($_POST['nbitems']) && $_POST['nbitems'] <= $max_nbitems) {
  1469.             $params[] = 'nbitems=' $_POST['nbitems'];
  1470.             $nbitems $_POST['nbitems'];
  1471.             if ($nbitems 5) {
  1472.                 $nbitems 5;
  1473.             }
  1474.         } else {
  1475.             $nbitems 3;
  1476.         }
  1477.         if (!empty($params) || !empty($preview)) {
  1478.             $params_string join('&'$params);
  1479.         } else {
  1480.             $params_string null;
  1481.         }
  1482.         // formulaire
  1483.         for ($i 1$i 50$i++) {
  1484.             $val[$i] = $i;
  1485.         }
  1486.         $this->context['form'] = $this->get('form.factory')->createNamedBuilder(''FormType::class, null, [
  1487.             'validation_groups' => false,
  1488.         ]);
  1489.         $this->context['form']->add('nbitems'ChoiceType::class, [
  1490.             'label' => 'Nombre à afficher',
  1491.             'choices' => $val
  1492.         ]);
  1493.         $this->context['form']->add('colsize'TextType::class, [
  1494.             'label' => 'Largeur de la colonne (en pixels)',
  1495.             'constraints' => [
  1496.                 new Type([
  1497.                     'type' => 'numeric',
  1498.                     'message' => 'La largeur doit-être un nombre'
  1499.                 ])
  1500.             ],
  1501.             'attr' => [
  1502.                 'size' => 3
  1503.             ]
  1504.         ]);
  1505.         $this->context['form']->add('heightcol'TextType::class, [
  1506.             'label' => 'Hauteur de la colonne (en pixels)',
  1507.             'constraints' => [
  1508.                 new Type([
  1509.                     'type' => 'numeric',
  1510.                     'message' => 'La hauteur doit-être un nombre'
  1511.                 ])
  1512.             ],
  1513.             'attr' => [
  1514.                 'size' => 3
  1515.             ]
  1516.         ]);
  1517.         $this->context['form'] = $this->context['form']->getForm();
  1518.         $this->context['form']->handleRequest($request);
  1519.         // largeur, nbitems et hauteur par défaut
  1520.         if (empty($_POST['colsize'])) {
  1521. //            $this->context['form']->get('colsize')->setData(s+10);
  1522.         }
  1523.         if (empty($_POST['heightcol'])) {
  1524. //            $this->context['form']->get('heightcol')->setData($hauteur_widget);
  1525.         }
  1526.         if (empty($_POST['nbitems'])) {
  1527. //            $this->context['form']->get('nbitems')->setData($nbitems);
  1528.         }
  1529.         $url_widget $_ENV['URL_THNET'] . '/spectacles/' $this->data_spectacles['urlClean'] . '/widget-calendrier/';
  1530.         $url_widget_iframe $url_widget '?' $params_string;
  1531.         $iframe_code '<iframe src="' $url_widget_iframe '" style="width:100%;border:none;" onload="this.style.height=this.contentDocument.body.scrollHeight + 30 +\'px\';"></iframe>';
  1532.         $this->view->iframe_code_html $iframe_code;
  1533.         $this->view->iframe_code htmlentities($iframe_code);
  1534.         $url_widget_ajax $url_widget '?v=ajax&' $params_string;
  1535.         $rtl "\n";
  1536.         $ajax_code '<script type="text/javascript" src="' $_ENV['URL_THNET'] . '/navigation/js/widget_thnet.js"></script>' $rtl;
  1537.         $ajax_code .= '<div class="widget_thnet_content" data-content="' $url_widget_ajax '"></div>';
  1538.         $this->view->ajax_code_html trim($ajax_code);
  1539.         $this->view->ajax_code htmlentities(trim($ajax_code));
  1540.         $this->extra_title 'Widget';
  1541.         $this->extra_locate 'Widget';
  1542.         return $this->view('spectacles/gadget-calendrier.html.twig', [
  1543.             'form' => $this->context['form']->createView()
  1544.         ]);
  1545.     }
  1546.     // }}}
  1547.     // {{{ action_lesdates()
  1548.     /**
  1549.      * @Route("/spectacles/{slug}/lesdates/", name="spectacle_lesdates")
  1550.      *
  1551.      * Page des calendrier
  1552.      *
  1553.      */
  1554.     public function action_lesdates($slug null)
  1555.     {
  1556.         $this->InitController($slug'lesdates');
  1557.         $this->context['action'] = 'lesdates';
  1558.         $version 'new';
  1559.         // affichage sour forme de liste
  1560.         if (isset($_GET['viewlist'])) {
  1561.             $this->view->viewlist true;
  1562.         }
  1563.         // on recupere le calendrier
  1564.         $schedules $this->em->getRepository(Schedules::class);
  1565.         // recuperer les dates futurs si il y en a
  1566.         $schedule_futur $schedules->getDateLieuDemain($this->idspectaclenullnull$version);
  1567.         if (!empty($schedule_futur)) {
  1568.             // date dans le futur
  1569.             $this->view->futurdate true;
  1570.             // ajout des mots clés basés sur les lieux et dates de représentation futurs
  1571.             $this->meta_keywords .= ' ' $schedules->ScheduleToKeywords($schedule_futur20);
  1572.         }
  1573.         // recuperer les dates anciennes si il y en a
  1574.         $schedule_old $schedules->getDateLieuHier($this->idspectaclenullnull$version);
  1575.         if (!empty($schedule_old)) {
  1576.             // date dans le passe
  1577.             $this->view->olddate true;
  1578.             // ajout des mots clés basés sur les lieux et dates de représentation récentes
  1579.             $this->meta_keywords .= ' ' $schedules->ScheduleToKeywords($schedule_old10);
  1580.         }
  1581.         // si date futur et ancienne
  1582.         if (isset($_GET['viewold']) || count($schedule_futur) == 0) {
  1583.             $this->view->viewold true;
  1584.             $this->view->schedule_detail $schedule_old;
  1585.             $this->view->param_date_link '&viewold';
  1586.         } else {
  1587.             $this->view->schedule_detail $schedule_futur;
  1588.             $this->view->param_date_link '&viewnow';
  1589.         }
  1590.         // Si pas de style, utiliser le style de thnet
  1591.         $this->style_more[] = 'calendrier_spectacle';
  1592.         // titre de la page et fil d'arianne
  1593.         $this->extra_locate $this->extra_title 'Les dates';
  1594.         // pas de stats
  1595.         $this->no_stats true;
  1596.         $nav_date_proch_ancien = array(
  1597.             array(
  1598.                 'name' => 'les prochaines dates',
  1599.                 'url' => '/spectacles/{v_url_clean}/lesdates/',
  1600.                 'key' => (!isset($_GET['viewold'])) ? true false,
  1601.                 'count' => count($schedule_futur)
  1602.             ),
  1603.             array(
  1604.                 'name' => 'les anciennes dates',
  1605.                 'url' => '/spectacles/{v_url_clean}/lesdates/?viewold',
  1606.                 'key' => (isset($_GET['viewold']) || (isset($this->view->viewold))) ? true false,
  1607.             ),
  1608.         );
  1609.         //asides
  1610.         $this->asides->load(['url_lists' => array(
  1611.             'exec' => array(
  1612.                 'htmlstart' => true
  1613.             ),
  1614.             'php' => array(
  1615.                 'method' => 'asidesUrlLists',
  1616.                 'urls' => $nav_date_proch_ancien,
  1617.                 'params' => array(
  1618.                     'activate' => 'key'
  1619.                 )
  1620.             ),
  1621.             'title' => 'Voir'
  1622.         )]);
  1623.         $this->asides->load(['spectacles_lesdates_nav' => array(
  1624.             'exec' => array(
  1625.                 'htmlend' => true,
  1626.             ),
  1627.             'title' => 'Affichage'
  1628.         )]);
  1629.         $this->asides->load('spectacles_gadget_calendrier');
  1630.         asides::setEntityManager($this->em);
  1631.         asides::loadaside('Publicite')->addGoogleAsides($this->asides$this->serviceAbonnements);
  1632.         $this->asides->load('common_participer_spectacles');
  1633.         return $this->view('spectacles/lesdates.html.twig');
  1634.     }
  1635.     // }}}
  1636.     // {{{ action_biographies()
  1637.     /**
  1638.      * @Route("/spectacles/{slug}/biographies/", name="spectacle_biographies")
  1639.      *
  1640.      * Page des biographies du spectacle
  1641.      *
  1642.      */
  1643.     public function action_biographies($slug null)
  1644.     {
  1645.         $this->InitController($slug'biographies');
  1646.         $this->context['action'] = 'biographies';
  1647.         $persons $this->em->getRepository(Persons::class);
  1648.         $format_photo = array('width' => $_ENV['VIGN_PERSONS_WIDTH'], 'height' => $_ENV['VIGN_PERSONS_HEIGHT'], 'direction' => 'crop');
  1649.         // Metteurs en scènes
  1650.         $alldirectors_authors $this->spectacles->getDirectors($this->idspectacle);
  1651.         foreach ($this->data_spectacles['texts'] as $text) {
  1652.             if ($text['textfictif'] != 1) {
  1653.                 $alldirectors_authors array_merge($alldirectors_authors$text['allauthors']);
  1654.                 $alldirectors_authors array_merge($alldirectors_authors$text['authors']);
  1655.             }
  1656.             if (!empty($text['alltranslators'])) {
  1657.                 $alldirectors_authors array_merge($alldirectors_authors$text['alltranslators']);
  1658.             }
  1659.         }
  1660.         if (!empty($this->data_spectacles['texts_adaptation'])) {
  1661.             foreach ($this->data_spectacles['texts_adaptation'] as $text) {
  1662.                 $alldirectors_authors array_merge($alldirectors_authors$text['allauthors']);
  1663.                 $alldirectors_authors array_merge($alldirectors_authors$text['authors']);
  1664.             }
  1665.         }
  1666.         $auteurs_liste = [];
  1667.         foreach ($alldirectors_authors as $key => $value) {
  1668.             if (empty($auteurs_liste[$value['idperson']])) {
  1669.                 $auteurs_liste[$value['idperson']] = $value;
  1670.                 $auteurs_liste[$value['idperson']]['photo'] = $persons->getVignettePerson($value['idperson'], $format_photo);
  1671.                 $auteurs_liste[$value['idperson']]['carrer'] = $persons->getObjectsCarrerDetails($value['idperson'], 'persons'$this->cache);
  1672.             }
  1673.         }
  1674.         $this->view->alldirectors_authors $auteurs_liste;
  1675.         //Les acteurs
  1676.         $acteurs $this->spectacles->getPersonsByRole($this->idspectacle'actors');
  1677.         foreach ($acteurs as $key => $value) {
  1678.             $acteurs[$key]['photo'] = $persons->getVignettePerson($value['idperson'], $format_photo);
  1679.             $acteurs[$value['idperson']]['carrer'] = $persons->getObjectsCarrerDetails($value['idperson'], 'persons'$this->cache);
  1680.         }
  1681.         $this->view->acteurs $acteurs;
  1682.         //La distribution suite
  1683.         $distribution_suite $this->spectacles->getPersonsByRole($this->idspectacle'distributions');
  1684.         foreach ($distribution_suite as $key => $value) {
  1685.             $distribution_suite[$key]['photo'] = $persons->getVignettePerson($value['idperson'], $format_photo);
  1686.             $distribution_suite[$value['idperson']]['carrer'] = $persons->getObjectsCarrerDetails($value['idperson'], 'persons');
  1687.             $distribution_suite[$key]['label_role'] = true;
  1688.         }
  1689.         $this->view->distribution_suite $distribution_suite;
  1690.         $this->asides->load(['biographies_carrer_informations' => [
  1691.             'exec' => [
  1692.                 'color' => 'biographies'
  1693.             ]
  1694.         ]]);
  1695.         $this->asides->load('bio_maj_v2');
  1696.         asides::setEntityManager($this->em);
  1697.         asides::loadaside('Publicite')->addGoogleAsides($this->asides$this->serviceAbonnements);
  1698.         $this->extra_locate $this->extra_title 'Les biographies';
  1699.         return $this->view('spectacles/biographies.html.twig');
  1700.     }
  1701.     // }}}
  1702.     // {{{ action_videos()
  1703.     /**
  1704.      * Page des videos du spectacle
  1705.      *
  1706.      * @Route("/spectacles/{slug}/videos/", name="spectacle_videos")
  1707.      * @Route("/spectacles/{slug}/videos/{p_inutile}", name="spectacle_videos_p_inutile")
  1708.      * @Route("/spectacles/{slug}/videos/media/{params_media}", name="spectacle_videos_media")
  1709.      */
  1710.     public function action_videos(Request $request$slug null$params_media nullGlobalStats $globalstats$p_inutile null)
  1711.     {
  1712.         $this->context['params']['media'] = $params_media;
  1713.         $this->InitController($slug'videos');
  1714.         $multimedias $this->em->getRepository(Multimedias::class);
  1715.         // Vidéos associées au spectacle directement
  1716.         $params_sql = array(
  1717.             'limit' => array(01000),
  1718.             'object' => array('spectacles' => $this->idspectacle),
  1719.             'dbg' => array('videos_spectacle''Les vidéos du spectacle'),
  1720.         );
  1721.         $vignette_size = array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none''ratio' => '169');
  1722.         $vignette = array('format_vignette' => true);
  1723.         $list_multimedias $multimedias->getListMultimedias(
  1724.             $params_sql,
  1725.             $vignette_size,
  1726.             $vignette
  1727.         );
  1728.         // nombre
  1729.         $this->view->nb_multimedias count($list_multimedias);
  1730.         foreach ($list_multimedias as $k => $v) {
  1731.             // si une vidéo est demandée
  1732.             if (!empty($this->context['params']['media']) && $v['url_clean'] == $this->context['params']['media']) {
  1733.                 $idmultimedia $v['idmultimedia'];
  1734.             }
  1735.         }
  1736.         // choisir une vidéo au hasard
  1737.         if (empty($idmultimedia) && !empty($list_multimedias)) {
  1738.             $idmultimedia array_rand($list_multimedias);
  1739.         }
  1740.         // vidéo de tête
  1741.         if (!empty($idmultimedia)) {
  1742.             $video $this->em->getRepository(Multimedias::class)->getInfosMultimedia($idmultimediafalsetrue, array('tableau' => true));
  1743.             if (!empty($video)) {
  1744.                 $width_video 560;
  1745.                 $height_video round(($width_video $video['flv_height']) / $video['flv_width']);
  1746.                 $multimedias->setDimensions(array('width' => $width_video'height' => $height_video));
  1747.                 $video['player'] = $multimedias->getPlayer($video);
  1748.                 $video['partenaires'] = $list_multimedias[$idmultimedia]['partenaires'];
  1749.                 // couper la description
  1750.                 $taille_description 350;
  1751.                 $video['description'] = $this->contents->wikiTransform($video['description_wiki'], $video['markdown']);
  1752.                 if (mb_strlen($video['description'], 'utf8') > $taille_description) {
  1753.                     $video['description_courte'] = $multimedias->cutSentence(html_entity_decode($video['description']), $taille_descriptiontrue);
  1754.                     $video['cut_description'] = true;
  1755.                 }
  1756.                 $video['share'] = true;
  1757.                 $this->view->video $video;
  1758.             }
  1759.             if (isset($this->view->video)) {
  1760.                 $request->getSession()->set('currentVideo'md5($this->view->video['idmultimedia']));
  1761.             }
  1762.             unset($list_multimedias[$idmultimedia]);
  1763.         }
  1764.         $this->view->list_multimedias $list_multimedias;
  1765.         $this->view->first_spectacles true;
  1766.         // vérifier également que pour un texte non fictif il n'y a pas un texte par l'auteur
  1767.         if (!empty($this->ids_texts)) {
  1768.             $nb_playlists_texts $this->em->getRepository(Playlists::class)->countPlaylists('texts'$this->ids_texts'class_texte_parauteur');
  1769.             // voir s'il y a des textes par l'auteur
  1770.             $this->view->list_playlists $this->em->getRepository(Playlists::class)->getListPlaylists(
  1771.                 array(
  1772.                     'special' => array(
  1773.                         'idclassifications' => 144// class_texte_parauteur //
  1774.                         'idtext' => $this->ids_texts// les texts du spectacle
  1775.                     ),
  1776.                     'dbg' => array('list_playlists''Playlist texte par l\'auteur'),
  1777.                 ),
  1778.                 array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none''ratio' => '169'),
  1779.                 array('other_url_clean' => true'format_vignette' => true)
  1780.             );
  1781.             $nb_playlists_texts_traducteurs $this->em->getRepository(Playlists::class)->countPlaylists('texts'$this->ids_texts'class_texte_par_traducteur');
  1782.             // voir s'il y a des textes par leurs traducteurs
  1783.             $this->view->list_playlists_traducteurs $this->em->getRepository(Playlists::class)->getListPlaylists(
  1784.                 array(
  1785.                     'special' => array(
  1786.                         'idclassifications' => 178// class_texte_par_traducteur //
  1787.                         'idtext' => $this->ids_texts// les texts du spectacle
  1788.                     ),
  1789.                     'dbg' => array('list_playlists''Playlist texte par traducteur'),
  1790.                 ),
  1791.                 array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none''ratio' => '169'),
  1792.                 array('other_url_clean' => true'format_vignette' => true)
  1793.             );
  1794.             $this->view->nb_multimedias $this->view->nb_multimedias $nb_playlists_texts $nb_playlists_texts_traducteurs;
  1795.         }
  1796.         $this->context['view']->plusvues_videos $this->video_populaire($globalstats);
  1797.         //Liste des vidéos en suggestions
  1798.         if (isset($this->context['view']->video)) {
  1799.             $liste_related_videos $multimedias->getAssociateMultimedias($this->context['view']->video['idmultimedia'], 6'AND m.mp3=0');
  1800.             if (!empty($liste_related_videos)) {
  1801.                 // trouver les videos en fonction du type
  1802.                 $sql 'SELECT * FROM ' $multimedias->__table '
  1803.                     WHERE idmultimedia IN (' implode(','$liste_related_videos) . ')';
  1804.                 //echo $sql;
  1805.                 $multimedias->query($sql);
  1806.                 $set_format = (array('width' => 130'height' => 110'direction' => 'crop''fleche' => 'moyen'));
  1807.                 while ($data $multimedias->fetch()) {
  1808.                     $multimedias->loadResult($data);
  1809.                     $idm $multimedias->idmultimedia;
  1810.                     $videos[$idm] = $multimedias->getInfosMultimedia($idmfalsefalse, array('vignette' => $set_format'tableau' => true));
  1811.                     $videos[$idm]['description_courte'] = $multimedias->cutSentence($videos[$idm]['description'], 100);
  1812.                 }
  1813.                 $this->context['view']->videos $videos;
  1814.                 $this->context['view']->first_spectacles true;
  1815.                 if (!empty($json)) {
  1816.                     $video['related'] = $videos;
  1817.                 }
  1818.             }
  1819.         }
  1820.         // titre de la page et fil d'arianne
  1821.         $this->extra_locate $this->extra_title 'Les vidéos';
  1822.         // pas de stats
  1823.         $this->no_stats true;
  1824.         //Opengraph pour les vidéos
  1825.         $this->view->meta_video true;
  1826.         $this->setAsideDVDVOD('videos');
  1827.         $this->asides->load(['common_participer_spectacles' => array(
  1828.             'exec' => array(
  1829.                 'color' => 'videos'
  1830.             )
  1831.         )]);
  1832.         $this->asides->load('videos_suggestions');
  1833.         $asides_publicite = new asides();
  1834.         asides::setEntityManager($this->em);
  1835.         asides::loadaside('Publicite')->addGoogleCorrespondantImageVideo($asides_publicite$this->serviceAbonnements);
  1836.         $this->context['view']->asides_publicite_footer $asides_publicite->view($this->context['view']);
  1837.         return $this->view('spectacles/videos.html.twig');
  1838.     }
  1839.     // }}}
  1840.     // {{{ action_podcasts()
  1841.     /**
  1842.      *
  1843.      * @Route("/spectacles/{slug}/podcasts", name="spectacle_podcasts")
  1844.      * @Route("/spectacles/{slug}/podcasts/emission/{pemission}", name="spectacle_podcasts_p_emission")
  1845.      * @Route("/spectacles/{slug}/podcasts/type/{ptype}", name="spectacle_podcasts_p_type")
  1846.      * @Route("/spectacles/{slug}/podcasts/podcast/{ppodcast}", name="spectacle_podcasts_p_podcast")
  1847.      *
  1848.      * Détail du spectacle (première page)
  1849.      *
  1850.      */
  1851.     public function action_podcasts($slug null$pemission null$ptype null$ppodcast null)
  1852.     {
  1853.         $this->context['params']['emission'] = $pemission;
  1854.         $this->context['params']['type'] = $ptype;
  1855.         $this->context['params']['podcast'] = $ppodcast;
  1856.         $this->InitController($slug'podcasts');
  1857.         $podcasts $this->em->getRepository(Podcasts::class);
  1858.         $format_vignette = array('width' => 480'direction' => 'thumb');
  1859.         // Culturebox => les derniers référencés
  1860.         $culturebox_params = array(
  1861.             'direction' => 'DESC',
  1862.             'limit' => array(0200),
  1863.             'special' => array(
  1864.                 'idspectacles' => $this->idspectacle,
  1865.                 'type_podcast' => ['franceinter'],
  1866.             ),
  1867.             'dbg' => array('derniers_culturebox_current''Les replay France Culture référencés'),
  1868.         );
  1869.         $culturebox_params['special']['type_franceinter'] = null//Pour France Culture
  1870.         $countFranceCulture $podcasts->countListPodcasts($culturebox_params);
  1871.         $culturebox_params['special']['type_franceinter'] = 1;
  1872.         $countFranceInter $podcasts->countListPodcasts($culturebox_params);
  1873.         $culturebox_params['special']['type_podcast'] = 'soundcloud';
  1874.         unset($culturebox_params['special']['type_franceinter']);
  1875.         $countSoundcloud $podcasts->countListPodcasts($culturebox_params);
  1876.         $filtres_emissions = [
  1877.             'franceculture' => [
  1878.                 'name' => 'France Culture',
  1879.                 'count' => $countFranceCulture,
  1880.                 'params' => null,
  1881.                 'type' => 'franceculture'
  1882.             ],
  1883.             'franceinter' => [
  1884.                 'name' => 'France Inter',
  1885.                 'count' => $countFranceInter,
  1886.                 'params' => 1,
  1887.                 'type' => 'franceinter'
  1888.             ],
  1889.             'soundcloud' => [
  1890.                 'name' => 'Soundcloud',
  1891.                 'count' => $countSoundcloud,
  1892.                 'url' => '/spectacles/{v_url_clean}/podcasts/podcast/key_type',
  1893.                 'type' => 'soundcloud'
  1894.             ]
  1895.         ];
  1896.         $curseur null;
  1897.         if (!empty($this->context['params']['emission']) && array_key_exists($this->context['params']['emission'], $filtres_emissions)) {
  1898.             $curseur $this->context['params']['emission'];
  1899.             $culturebox_params['special']['type_franceinter'] = $filtres_emissions[$curseur]['params'];
  1900.             $culturebox_params['special']['type_podcast'] = $filtres_emissions[$curseur]['type'];
  1901.         } else if (!empty($this->context['params']['podcast']) && array_key_exists($this->context['params']['podcast'], $filtres_emissions)) {
  1902.             $curseur $this->context['params']['podcast'];
  1903.             $culturebox_params['special']['type_podcast'] = $filtres_emissions[$curseur]['type'];
  1904.         } else {
  1905.             $culturebox_params['special']['type_podcast'] = ['franceinter''soundcloud'];
  1906.             unset($culturebox_params['special']['type_franceinter']);
  1907.         }
  1908.         $this->view->list_captations $podcasts->getListPodcasts($culturebox_params$format_vignette);
  1909.         $this->asides->load(['url_lists' => array(
  1910.             'exec' => [
  1911.                 'htmlstart' => true,
  1912.                 'alone' => false
  1913.             ],
  1914.             'php' => array(
  1915.                 'method' => 'asidesUrlLists',
  1916.                 'urls' => [
  1917.                     [
  1918.                         'name' => 'Toutes les émissions'
  1919.                     ]
  1920.                 ],
  1921.                 'url' => '/spectacles/{v_url_clean}/podcasts/',
  1922.                 'params' => array(
  1923.                     'activate' => (is_null($curseur)) ? true false
  1924.                 )
  1925.             ),
  1926.             'title' => 'écouter'
  1927.         )]);
  1928.         $this->asides->load(['url_lists,tst' => array(
  1929.             'exec' => [
  1930.                 'htmlend' => true,
  1931.                 'alone' => false
  1932.             ],
  1933.             'php' => array(
  1934.                 'method' => 'asidesUrlLists',
  1935.                 'urls' => $filtres_emissions,
  1936.                 'url' => '/spectacles/{v_url_clean}/podcasts/emission/key_type',
  1937.                 'params' => array(
  1938.                     'key_type' => 'auto_key',
  1939.                     'activate' => $curseur
  1940.                 )
  1941.             ),
  1942.             'title' => 'Trier'
  1943.         )]);
  1944.         if ($countFranceCulture) {
  1945.             $this->asides->load(['bio_franceculture' => ['noactive' => true]]);
  1946.         }
  1947.         //Pour France Inter
  1948.         if ($countFranceInter) {
  1949.             $this->asides->load([
  1950.                 'contact_franceculture_menu,franceinter' => [
  1951.                     'custom_url_clean' => 'France-Inter',
  1952.                     'title_custom' => 'France Inter',
  1953.                     'logo_custom' => 'france-inter'
  1954.                 ]
  1955.             ]);
  1956.         }
  1957.         asides::setEntityManager($this->em);
  1958.         asides::loadaside('Publicite')->addGoogleAsides($this->asides$this->serviceAbonnements);
  1959.         $this->asides->load('common_participer_spectacles');
  1960.         return $this->view('spectacles/podcasts.html.twig');
  1961.     }
  1962.     // }}}
  1963.     // {{{ action_article_edit()
  1964.     /** Modifier un article
  1965.      *
  1966.      * @Route("/spectacles/{slug}/edit-article", name="spectacle_edit_article")
  1967.      *
  1968.      * @access public
  1969.      * @return void
  1970.      */
  1971.     public function action_edit_article($slug nullRequest $requestTheatreMail $TheatreMailEditUtils $editUtils)
  1972.     {
  1973.         $this->InitController($slug'edit_article');
  1974.         $idspectacle $this->idspectacle;
  1975.         $abs_directory $_ENV['PATH_DIRECTORYUPLOAD'] . 'preview/';
  1976.         // si connecté, instancier la classe utilitaires d'édition
  1977.         if ($this->context['session'] instanceof Extranetusers) {
  1978.             // déclare les variables
  1979.             $edit false;
  1980.             $idcontent null;
  1981.             $idfile null;
  1982.             // jquery
  1983.             $this->context['view']->jquery_cal 'datepicker';
  1984.             $contents $this->em->getRepository(Contents::class);
  1985.             $data_content null;
  1986.             // mode édition ?
  1987.             if (isset($_GET['edit']) && $contents->my_is_int($_GET['idcontent'])) {
  1988.                 $edit true;
  1989.                 $idcontent = (int)$_GET['idcontent'];
  1990.                 // vérifier si l'idcontent est valable sans tenir compte du status
  1991.                 $data_content $contents->getInfosContent($idcontent, array('get_files' => true));
  1992.                 // ce contenu n'est pas disponible => erreur 404
  1993.                 /*if(empty($data_content) || $data_content['idextranetuser']!=$session->getValue('idextranetuser')) { }*/
  1994.                 // récupèrer le contenu
  1995.                 $this->view->data_content $data_content;
  1996.                 // vérifier s'il y a un fichier/idfile
  1997.                 if (!empty($data_content['files'][0])) {
  1998.                     $idfile $data_content['files'][0]['idfile'];
  1999.                 }
  2000.             }
  2001.             // on cherche un lien
  2002.             if (!empty($request->request->get('link_article')) && preg_match('|^http(s)?://|ui'$request->request->get('link_article'))) {
  2003.                 $type_article 'link';
  2004.                 // on cherche avec opengraph si besoin
  2005.                 if (empty($request->request->get('link'))) {
  2006.                     $graph OpenGraph::fetch(strip_tags($request->request->get('link_article')));
  2007.                 }
  2008.                 $this->context['view']->link_article strip_tags($_POST['link_article']);
  2009.             } elseif (!empty($_GET['is_article'])) {
  2010.                 $type_article 'article';
  2011.             } else {
  2012.                 $type_article null;
  2013.                 $this->context['view']->choice_type_article true;
  2014.             }
  2015.             // paramètre d'instanciation
  2016.             $params_edit = array(
  2017.                 'idobject' => $this->idspectacle,
  2018.                 'object' => 'spectacles',
  2019.             );
  2020.             $url_redirect '/spectacles/' $this->context['view']->url_clean '/';
  2021.             // controlleur pour l'edition
  2022.             $edit_utils = new UtilsEdit($this->context$params_edit);
  2023.             $wiki = new wiki2xhtml();
  2024.             // afficher aide wiki
  2025.             $this->view->aide_wiki utf8_encode($wiki->help());
  2026.             $this->context['formFactory'] = $this->get('form.factory')->createBuilder(FormType::class, $data_content, [
  2027.                 'attr' => [
  2028.                     'id' => 'masterform',
  2029.                     'novalidate' => true
  2030.                 ]
  2031.             ]);
  2032.             // formulaire simple
  2033.             $this->context['formFactory']->add('title'TextType::class, [
  2034.                 'label' => 'Titre',
  2035.                 'required' => true,
  2036.                 'constraints' => [
  2037.                     new NotBlank([
  2038.                         'message' => 'Titre : veuillez préciser le titre de votre article'
  2039.                     ])
  2040.                 ],
  2041.                 'attr' => [
  2042.                     'id' => 'title',
  2043.                     'size' => '45'
  2044.                 ]
  2045.             ]);
  2046.             $this->context['formFactory']->add('preview'SubmitType::class, [
  2047.                 'label' => 'Prévisualiser les informations avant d\'enregistrer',
  2048.                 'attr' => [
  2049.                     'class' => 'tc-btn-classic boutform boutbig',
  2050.                     'id' => 'preview'
  2051.                 ]
  2052.             ]);
  2053.             if ($request->query->get('preview')) {
  2054.                 $label_validation 'Prévisualiser';
  2055.                 $this->context['formFactory']->add('validation'SubmitType::class, [
  2056.                     'label' => $label_validation,
  2057.                     'attr' => [
  2058.                         'class' => 'boutform boutbig'
  2059.                     ]
  2060.                 ]); // validation
  2061.             }
  2062.             // c'est un lien
  2063.             if ($type_article == 'link') {
  2064.                 $fields = array('title''deck''link''writer_group''writer_group_url''writer''date_article');
  2065.                 $this->context['formFactory']->add('deck'TextareaType::class, [
  2066.                     'label' => 'Description, introduction',
  2067.                     'required' => true,
  2068.                     'constraints' => [
  2069.                         new NotBlank([
  2070.                             'message' => 'Description, introduction : veuillez préciser une introduction ou une description de l\'article'
  2071.                         ]),
  2072.                         new Length([
  2073.                             'max' => 450,
  2074.                             'maxMessage' => 'La description ne doit pas faire plus de 450 caractères'
  2075.                         ])
  2076.                     ],
  2077.                     'attr' => [
  2078.                         'id' => 'deck',
  2079.                         'cols' => '90',
  2080.                         'rows' => '5'
  2081.                     ],
  2082.                 ]);
  2083.                 $this->context['formFactory']->add('link'TextType::class, [
  2084.                     'label' => 'Lien vers l\'article',
  2085.                     'required' => true,
  2086.                     'constraints' => [
  2087.                         new NotBlank([
  2088.                             'message' => 'Lien vers l\article : le lien est obligatoire'
  2089.                         ])
  2090.                     ],
  2091.                     'attr' => [
  2092.                         'id' => 'link',
  2093.                         'size' => '60'
  2094.                     ]
  2095.                 ]);
  2096.                 // le site et son lien
  2097.                 $this->context['formFactory']->add('writer_group'TextType::class, [
  2098.                     'label' => 'Nom du site',
  2099.                     'required' => true,
  2100.                     'constraints' => [
  2101.                         new NotBlank([
  2102.                             'message' => 'Veuillez préciser le média ou le site source'
  2103.                         ])
  2104.                     ],
  2105.                     'attr' => [
  2106.                         'id' => 'writer_group',
  2107.                         'size' => '45'
  2108.                     ]
  2109.                 ]);
  2110.                 // le journaliste
  2111.                 $this->context['formFactory']->add('writer'TextType::class, [
  2112.                     'label' => 'Journaliste ou rédacteur',
  2113.                     'required' => true,
  2114.                     'constraints' => [
  2115.                         new NotBlank([
  2116.                             'message' => 'Veuillez préciser le journaliste'
  2117.                         ])
  2118.                     ],
  2119.                     'attr' => [
  2120.                         'id' => 'writer',
  2121.                         'size' => '45'
  2122.                     ]
  2123.                 ]);
  2124.                 // la date de parution
  2125.                 $this->context['formFactory']->add('date_article'TextType::class, [
  2126.                     'label' => 'Date de parution',
  2127.                     'required' => true,
  2128.                     'constraints' => [
  2129.                         new NotBlank([
  2130.                             'message' => 'Veuillez préciser la date de parution de l\'article'
  2131.                         ])
  2132.                     ],
  2133.                     'attr' => [
  2134.                         'size' => '10',
  2135.                         'maxlength' => '10',
  2136.                         'id' => 'date_article'
  2137.                     ]
  2138.                 ]);
  2139.                 $this->context['formFactory']->add('date_article_us'HiddenType::class, [
  2140.                     'attr' => [
  2141.                         'id' => 'date_article_us'
  2142.                     ]
  2143.                 ]); // date de création US
  2144.                 // remplir le form si besoin
  2145.                 if (!empty($graph)) {
  2146.                     $fields_og = array(
  2147.                         'deck' => 'description',
  2148.                         'title' => 'title',
  2149.                         'link' => 'url',
  2150.                         'writer_group' => 'site_name',
  2151.                     );
  2152.                     foreach ($fields_og as $k => $v) {
  2153.                         if (!empty($graph->$v)) {
  2154.                             $this->context['formFactory']->get($k)->setData($graph->$v);
  2155.                         }
  2156.                     }
  2157.                     // on récupère  le site si on a le site_name et l'url
  2158.                     if (!empty($graph->site_name) && !empty($graph->url)) {
  2159.                         $url_scheme parse_url($graph->url);
  2160.                         // $this->context['formFactory']->setData(array('writer_group_url' => $url_scheme['scheme'] . '://' . $url_scheme['host']));
  2161.                     }
  2162.                     // il y a une image
  2163.                     if (!empty($graph->image)) {
  2164.                         $this->context['view']->proposed_thumbnail['vignette'] = $graph->image;
  2165.                     }
  2166.                 }
  2167.                 $this->context['view']->is_link true;
  2168.                 // c'est un article
  2169.             } else {
  2170.                 $fields = array('title''subtitle''deck''text''writer''writer_group''writer_group_url');
  2171.                 $this->context['formFactory']->add('subtitle'TextType::class, [
  2172.                     'label' => 'Sous-titre',
  2173.                     'attr' => [
  2174.                         'id' => 'title',
  2175.                         'size' => '45'
  2176.                     ]
  2177.                 ]);
  2178.                 $this->context['formFactory']->add('deck'TextareaType::class, [
  2179.                     'label' => 'Chapeau',
  2180.                     'attr' => [
  2181.                         'id' => 'deck',
  2182.                         'cols' => '80',
  2183.                         'rows' => '5',
  2184.                         'class' => 'markitup'
  2185.                     ]
  2186.                 ]);
  2187.                 $this->context['formFactory']->add('text'TextareaType::class, [
  2188.                     'label' => 'Texte',
  2189.                     'constraints' => [
  2190.                         new NotBlank([
  2191.                             'message' => 'Texte : veuillez préciser le texte de votre article'
  2192.                         ])
  2193.                     ],
  2194.                     'attr' => [
  2195.                         'id' => 'text',
  2196.                         'cols' => '130',
  2197.                         'rows' => '20',
  2198.                         'class' => 'markitup'
  2199.                     ]
  2200.                 ]);
  2201.                 $this->context['formFactory']->add('writer'TextType::class, [
  2202.                     'label' => 'Signature de l\'article',
  2203.                     'attr' => [
  2204.                         'id' => 'writer',
  2205.                         'size' => '45'
  2206.                     ]
  2207.                 ]);
  2208.                 $this->context['formFactory']->add('writer_group'TextType::class, [
  2209.                     'label' => 'Nom du groupe',
  2210.                     'attr' => [
  2211.                         'id' => 'writer_group',
  2212.                         'size' => '45'
  2213.                     ]
  2214.                 ]);
  2215.                 $this->context['formFactory']->add('writer_group_url'TextType::class, [
  2216.                     'label' => 'Site du groupe',
  2217.                     'constraints' => [
  2218.                         new CheckWebsite([
  2219.                             'message' => 'Site du groupe : le site Internet que vous avez précisé ne semble pas disponible ! Vérifiez qu\'il s\'agit bien de la bonne adresse qui commence par http://\''
  2220.                         ])
  2221.                     ],
  2222.                     'attr' => [
  2223.                         'id' => 'writer_group_url',
  2224.                         'size' => '45'
  2225.                     ]
  2226.                 ]);
  2227.                 // copyright et titre du fichier
  2228.                 $this->context['formFactory']->add('legend'TextType::class, [
  2229.                     'label' => 'Légende',
  2230.                     'attr' => [
  2231.                         'size' => '45',
  2232.                         'id' => 'legend'
  2233.                     ]
  2234.                 ]);
  2235.                 $this->context['formFactory']->add('copyright'TextType::class, [
  2236.                     'label' => 'Copyright',
  2237.                     'attr' => [
  2238.                         'size' => '45',
  2239.                         'id' => 'copyright'
  2240.                     ]
  2241.                 ]);
  2242.                 $this->context['view']->is_article true;
  2243.             }
  2244.             $this->context['form'] = $this->context['formFactory']->getForm();
  2245.             $this->context['form']->handleRequest($request);
  2246.             if (!empty($this->context['form']->get('preview')) and $this->context['form']->get('preview')->isClicked()) {
  2247.                 $preview true;
  2248.             } else {
  2249.                 $preview false;
  2250.             }
  2251.             // on valide uniquement si on sait déjà le type d'article posté
  2252.             if (!empty($type_article) && $this->context['form']->isSubmitted() && $this->context['form']->isValid()) {
  2253.                 // on regarde s'il y a une image en préview
  2254.                 if (!empty($_POST['photo_preview'])
  2255.                     && preg_match('/^[0-9,a-z,A-Z,\-]+\.jpg$/'$_POST['photo_preview'])
  2256.                     && file_exists($abs_directory $_POST['photo_preview'])) {
  2257.                     // récupère => sera ecrasé si nouvel upload
  2258.                     $photo_preview $_POST['photo_preview'];
  2259.                     $photo_normal_preview str_replace('thumb-'''$photo_preview);
  2260.                     $this->view->photo_preview $photo_preview;
  2261.                 }
  2262.                 // infos statiques
  2263.                 $values = array(
  2264.                     'idspectacle' => $this->idspectacle,
  2265.                     'idextranetuser' => $this->getUser()->getIdextranetuser(),
  2266.                     'language' => 'fr',
  2267.                 );
  2268.                 // si c'est une édition, on laisse le contenu en ligne => modération à postériori
  2269.                 if (empty($edit)) {
  2270.                     $values['publish'] = 0;
  2271.                 }
  2272.                 // les champs classiques
  2273.                 foreach ($fields as $f) {
  2274.                     if ($this->context['form']->has($f)) {
  2275.                         $values[$f] = $this->context['form']->get($f)->getData();
  2276.                     }
  2277.                 }
  2278.                 // un lien ?
  2279.                 if ($type_article == 'link') {
  2280.                     $values['is_link'] = 1;
  2281.                     $values['text'] = 'Lien vers un article';
  2282.                     $values['deck'] = $values['deck'] . '...';
  2283.                 }
  2284.                 // date de parution
  2285.                 $date_article_us $this->context['form']->get('date_article_us')->getData();
  2286.                 if (!empty($date_article_us)) {
  2287.                     $values['date_article'] = $date_article_us;
  2288.                 }
  2289.                 // un copyright pour l'image ?
  2290.                 $copyright null;
  2291.                 $legend null;
  2292.                 if ($this->context['form']->has('copyright')) {
  2293.                     $copyright $this->context['form']->get('copyright')->getData();
  2294.                     $legend $this->context['form']->get('legend')->getData();
  2295.                 }
  2296.                 // date d'insertion si nouveau
  2297.                 if (empty($idcontent)) {
  2298.                     $values['dateinsert'] = $this->func->now();
  2299.                     // si pas de date de parution, date de parution = date d'insertion
  2300.                     if (empty($values['date_article'])) {
  2301.                         $values['date_article'] = $values['dateinsert'];
  2302.                     }
  2303.                 }
  2304.                 // on insère le draft
  2305.                 if (!$preview) {
  2306.                     $contents $this->em->getRepository(Contents::class);
  2307.                     $contents->setUpdateFields($values);
  2308.                     if ($res $contents->addContent('spectacles'$idspectacle$idcontent0, array('101' => '101'))) {
  2309.                         // idcontent
  2310.                         if (empty($idcontent)) {
  2311.                             $idcontent $idcontent_new $res;
  2312.                         } else {
  2313.                             $this->view->edit true;
  2314.                         }
  2315.                         // on confirme
  2316.                         $this->view->enregistrement true;
  2317.                         // logguer l'action
  2318.                         $log $this->em->getRepository(UserAction::class);
  2319.                         // l'identifiant de la nouvelle fiche (mode creation)
  2320.                         // envoyer un mail à l'admin
  2321.                         $editUtils->setParams($this->context, [
  2322.                             'idobject' => $idcontent,
  2323.                             'object' => 'contents',
  2324.                             'em' => $this->em
  2325.                         ]);
  2326.                         if (!empty($idcontent_new)) {
  2327.                             $log->setAction('contents'$idcontent_new'create'$this->getUser()->getIdextranetuser());
  2328.                             $editUtils->sendAlerte($idspectacle'update''Ajout d\'une critique [contents][' $idcontent_new ']'$TheatreMail);
  2329.                         } else {
  2330.                             $log->setAction('contents'$idcontent'update'$this->getUser()->getIdextranetuser());
  2331.                             $editUtils->sendAlerte($idspectacle'update''Modification d\'une critique [contents][' $idcontent ']'$TheatreMail);
  2332.                         }
  2333.                         $this->view->extranetuser_email $this->getUser()->getEmail();
  2334.                     }
  2335.                     // on copie l'image qui est en preview dans son répertoire final et on l'associe à la fiche  du spectacle
  2336.                     if (!empty($photo_normal_preview)) {
  2337.                         $files $this->em->getRepository(FilesRepository::class);
  2338.                         // data pour le fichier
  2339.                         $filedata = array(
  2340.                             'range' => 'NULL',
  2341.                             'title' => $legend,
  2342.                             'description' => '',
  2343.                             'language' => 'fr',
  2344.                             'idextranetuser' => $this->getUser()->getIdExtranetuser(),
  2345.                             'idcontent' => $idcontent// retourne l'idcontent
  2346.                             'copyright' => $copyright,
  2347.                             'publish' => 1,
  2348.                             'valid' => 1
  2349.                         );
  2350.                         // si c'est une édition, on laisse le contenu en ligne => modération à postériori
  2351.                         if (empty($edit)) {
  2352.                             $filedata['publish'] = 0;
  2353.                         } else {
  2354.                             if (!empty($data_content['publish'])) {
  2355.                                 $filedata['publish'] = $data_content['publish'];
  2356.                             }
  2357.                         }
  2358.                         // associée en temps que photos associées
  2359.                         $files->uploadObjectFile(array('file' => $abs_directory $photo_normal_preview), 22'contents'$idcontent$filedata$idfile);
  2360.                         // supprimer le fichier de preview et la vignette
  2361.                         @unlink($abs_directory $photo_normal_preview);
  2362.                         @unlink($abs_directory $photo_preview);
  2363.                     } else {
  2364.                         // voir s'il faut mettre à jour uniquement le copyright ou la légende
  2365.                         if (!empty($idfile)) {
  2366.                             if ((!empty($copyright) && $copyright != $data_content['files'][0]['copyright'])
  2367.                                 || (!empty($legend) && $legend != $data_content['files'][0]['title'])) {
  2368.                                 $files $this->em->getRepository(Files::class);
  2369.                                 $files->setUpdateFields(array('copyright' => $copyright'title' => $legend));
  2370.                                 $files->setData($idfile);
  2371.                             }
  2372.                         }
  2373.                     }
  2374.                     // on prévisualise
  2375.                 } else {
  2376.                     // conversion en wiki du chapeau et du texte
  2377.                     if (!empty($values['text'])) {
  2378.                         $values['text'] = $wiki->transform($values['text']);
  2379.                     }
  2380.                     // pas de texte en prévisu de lien
  2381.                     if (!empty($values['is_link'])) {
  2382.                         $values['text'] = null;
  2383.                     }
  2384.                     $values['deck'] = $wiki->transform($values['deck']);
  2385.                 }
  2386.                 // upload d'un fichier
  2387. //                if($objfile->isUploadedFile()) {
  2388. //                    // check la validité
  2389. //                    if($extension = $edit_utils->checkFile($objfile)) {
  2390. //
  2391. //                        // nom du fichier = url_clean coupé + identifiant
  2392. //                        $nomfichier = $edit_utils->getFileName($this->context['view']->data_spectacles['urlClean'],$extension);
  2393. //
  2394. //                        // nom de la vignette
  2395. //                        $nomvignette = 'thumb-'.$nomfichier;
  2396. //
  2397. //                        // upload en mode preview dans le dossier preview
  2398. //                        if($preview) {
  2399. //
  2400. //                            // si deja un fichier preview pour ce contenu, on le supprime
  2401. //                            if(!empty($photo_preview)) {
  2402. //                                @unlink($abs_directory.$photo_preview);
  2403. //                                @unlink($abs_directory.str_replace('thumb-','', $photo_preview));
  2404. //                            }
  2405. //
  2406. //                            if(!$objfile->moveUploadedFile($abs_directory,$nomfichier)) {
  2407. //                                $error['dl'] = 'Il y a eu un problème pendant le téléchargement de votre fichier.
  2408. //                                            Merci de réessayer ou de contacter l\'assistance technique.';
  2409. //                            } else {
  2410. //
  2411. //                                // réduire la preview
  2412. //                                require_once PATH_LIBS.'Images/Images.php';
  2413. //                                $images = new Images();
  2414. //                                $images->setVignetteFormat(array('width'=>220,'height'=>'180','direction'=>'L'));
  2415. //                                $images->setThumbnail($abs_directory.$nomfichier,$abs_directory.$nomvignette,220);
  2416. //
  2417. //                                // URL du fichier pour la vue
  2418. //                                $this->view->photo_preview = $nomvignette;
  2419. //
  2420. //                            }
  2421. //                        }
  2422. //
  2423. //                    } else {
  2424. //                        $preview = false;
  2425. //                    }
  2426. //
  2427. //                    // on a une vignette a récupèrer
  2428. //                }
  2429.                 if (!empty($_POST['vignette_url'])) {
  2430.                     $extension 'jpg';
  2431.                     // nom du fichier = url_clean coupé + identifiant
  2432.                     $nomfichier $edit_utils->getFileName($this->context['view']->data_spectacles['urlClean'], $extension);
  2433.                     // nom de la vignette
  2434.                     $nomvignette 'thumb-' $nomfichier;
  2435.                     // upload en mode preview dans le dossier preview
  2436.                     if ($preview) {
  2437.                         // si deja un fichier preview pour ce contenu, on le supprime
  2438.                         if (!empty($photo_preview)) {
  2439.                             @unlink($abs_directory $photo_preview);
  2440.                             @unlink($abs_directory str_replace('thumb-'''$photo_preview));
  2441.                         }
  2442.                         // récupèrer le fichier
  2443.                         $url $_POST['vignette_url'];
  2444.                         $path $abs_directory $nomfichier;
  2445.                         $ch curl_init($url);
  2446.                         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  2447.                         $data curl_exec($ch);
  2448.                         curl_close($ch);
  2449.                         if (!file_put_contents($path$data)) {
  2450.                             $error['dl'] = 'Il y a eu un problème pendant le téléchargement de votre fichier. 
  2451.                                         Merci de réessayer ou de contacter l\'assistance technique.';
  2452.                         } else {
  2453.                             // réduire la preview
  2454.                             require_once PATH_LIBS 'Images/Images.php';
  2455.                             $images = new Images();
  2456.                             $images->setVignetteFormat(array('width' => 220'height' => '180''direction' => 'L'));
  2457.                             $images->setThumbnail($abs_directory $nomfichier$abs_directory $nomvignette220);
  2458.                             // URL du fichier pour la vue
  2459.                             $this->view->photo_preview $nomvignette;
  2460.                         }
  2461.                     }
  2462.                 }
  2463.                 // ajouter le copyright pour le renvoyer à la vue
  2464. //                $values['copyright'] = $copyright;
  2465. //                $values['legend'] = $legend;
  2466.                 // la date de p FR pour la vue
  2467.                 if (!empty($_REQUEST['date_article'])) {
  2468.                     $values['date_article'] = filter_var($_REQUEST['date_article'], FILTER_SANITIZE_URL);
  2469.                 }
  2470.                 // envoyer les infos au template
  2471.                 $this->view->detailarticle $values;
  2472.                 // réduire la taille du lien
  2473.                 $this->view->detailarticle['link_cut'] = substr($values['link'], 060) . '...';
  2474.                 // précier le mode (preview ou pas)
  2475.                 $this->view->preview $preview;
  2476.             }
  2477.             // récupérer les infos
  2478.             if (empty($idcontent_new) && !empty($data_content)) {
  2479.                 $this->context['formFactory']->add('idcontent'HiddenType::class); // $idcontent
  2480.                 $this->context['formFactory']->setData($data_content);
  2481.                 //setDebug($data_content);
  2482.                 // voir s'il y a aussi une image proposée ?
  2483.                 if (empty($this->view->photo_preview) && !empty($data_content['files'][0])) {
  2484.                     if (!empty($data_content['files'][0]['copyright'])) {
  2485.                         $this->context['formFactory']->setData(array('copyright' => $data_content['files'][0]['copyright']));
  2486.                     }
  2487.                     if (!empty($data_content['files'][0]['title'])) {
  2488.                         $this->context['formFactory']->setData(array('legend' => $data_content['files'][0]['title']));
  2489.                     }
  2490.                     // réduire la preview
  2491.                     require_once PATH_LIBS 'Images/Images.php';
  2492.                     $images = new Images();
  2493.                     $images->setVignetteFormat(array('width' => 220'height' => '180''direction' => 'L'));
  2494.                     $data_content['files'][0]['vignette_moy'] = $contents->getThumbnail($data_content['files'][0]['file'], 270'thumb');
  2495.                     $data_content['files'][0]['vignette'] = $contents->getThumbnail($data_content['files'][0]['file'], 100'thumb');
  2496.                     $this->view->proposed_file $data_content['files'][0];
  2497.                     $this->view->remplace_file true;
  2498.                 }
  2499.             }
  2500.             // compter les caractères (450 max)
  2501.             $this->context['view']->js_more_final[] = '/navigation/js/textcounter/textcounter.min.js';
  2502.         } else { // l'internaute n'est pas logué
  2503.             return $this->redirectToRoute('app_login', ['urifrom' => '/spectacles/' $this->data_spectacles['urlClean'] . '/edit-article/''entete_connexion' => 'spectacles']);
  2504.         }
  2505.         $this->extra_locate $this->extra_title 'Proposer un ajout/une modification';
  2506.         $this->style_more[] = array(
  2507.             '/navigation/css/style_montheatre.css',
  2508.             '/navigation/js/markitup/skins/markitup/style.css',
  2509.             '/navigation/js/markitup/sets/dotclear/style.css'
  2510.         );
  2511.         $this->js_more[] = 'markitup/jquery.markitup.js';
  2512.         $this->js_more[] = 'markitup/sets/dotclear/set.js';
  2513.         //aside
  2514.         $this->asides->load('common_participer_spectacles');
  2515.         return $this->view('spectacles/edit-article.html.twig', [
  2516.             'form' => $this->context['form']->createView()
  2517.         ]);
  2518.     }
  2519.     // }}}
  2520.     // {{{ action_article()
  2521.     /** Présentation
  2522.      *
  2523.      *
  2524.      * @access public
  2525.      * @return void
  2526.      */
  2527.     public function action_article()
  2528.     {
  2529.         // presentation "bio_txt"
  2530.         $biotxt $this->contents->getAssociateContent($this->idperson'persons''class_biotxt', array('wiki_convert' => true));
  2531.         if (!empty($biotxt['text'])) {
  2532.             $this->view->biotxt $biotxt;
  2533.             // mots-clés et description
  2534.             $this->func->makeMetaFromHtml($biotxt['text'], $this->meta_description$this->meta_keywords);
  2535.         }
  2536.         // il faut également la photo associé et le site web
  2537.         $files $this->em->getRepository(Files::class);
  2538.         $files->setPublishStatus($this->publish_status);
  2539.         $photos_person $files->getObjectFiles($this->idperson'persons''class_photo_person');
  2540.         $format_vignette_person = array('width' => 220'height' => '180''direction' => 'L');
  2541.         if (!empty($photos_person)) {
  2542.             // creation d'une vignette
  2543.             foreach ($photos_person as $k => $v) {
  2544.                 $photos_person[$k]['vignette'] = $this->persons->getVignettePerson($this->idperson$format_vignette_person);
  2545.             }
  2546.             $this->view->photos $photos_person;
  2547.         }
  2548.         // si il manque quelques choses, on le précise
  2549.         //$fields = array('text','link','facebook','twitter');
  2550.         // javascript prettyphoto
  2551.         $this->style_more[] = 'prettyphoto';
  2552.         $this->js_more[] = 'jquery.prettyPhoto.js';
  2553.     }
  2554.     // }}}
  2555.     // {{{ action_critiques()
  2556.     /**
  2557.      *
  2558.      * @Route("/spectacles/{slug}/critiques", name="spectacle_critiques")
  2559.      *
  2560.      * Les articles associés aux spectacles de type critique
  2561.      *
  2562.      */
  2563.     public function action_critiques($slugAdapterInterface $cache)
  2564.     {
  2565.         $this->InitController($slug'critiques');
  2566.         //afficher les infos sur l'utilisateur qui a ajouté l'article
  2567.         $this->view->display_extranetuser true;
  2568.         $this->view->top_menu_articles true;
  2569.         //on compte le nombre de critiques
  2570.         $nombre_critiques $this->contenus_spectacles('class_critique''critiques', array(), ['count_only' => true]);
  2571.         //on limite le nombre de critiques à 10 par pages
  2572.         $this->perPage 10;
  2573.         //on récupère les critiques
  2574.         $this->contenus_spectacles('class_critique''critiques', array('width' => 500), ['limit' => array($this->getLimitStart(), $this->perPage)]);
  2575.         $this->view->pagination $this->getPagination($nombre_critiques10);
  2576.         $this->view->pagination['totalItems'] = $nombre_critiques;
  2577.         $this->view->pagination['custom'] = true;
  2578.         $this->view->pagination['custom_name'] = 'critiques';
  2579.         if (!empty($this->view->articles['fr']['content'])) {
  2580.             $this->view->nb_articles $nombre_critiques;
  2581.         }
  2582.         // ne pas afficher l'article s'il n'y a pas d'ID content dans l'URL
  2583.         if (!empty($this->context['params']['idcontent'])) {
  2584.             if (!empty($this->view->articles['fr']['content'])) {
  2585.                 foreach ($this->view->articles['fr']['content'] as $k => $v) {
  2586.                     if ($v['idcontent'] == $this->context['params']['idcontent']) {
  2587.                         unset($this->view->articles['fr']['content'][$k]);
  2588.                     }
  2589.                 }
  2590.                 $this->view->nb_articles count($this->view->articles['fr']['content']);
  2591.             }
  2592.             $this->view->is_article true;
  2593.         } else {
  2594.             // titre de la page et fil d'arianne
  2595.             $this->extra_locate $this->extra_title 'Espace critiques';
  2596.             // description
  2597.             $this->meta_description 'Toutes les références vers les pages critiques de
  2598.             ' $this->data_spectacles['title'] . ', les articles de presse, les blogs...
  2599.             Et vous pouvez aussi ajouter vos propres critiques ou référencer les articles de vos blogs';
  2600.         }
  2601.         $this->getAsideSelections();
  2602.         //aside
  2603.         $this->asides->load(['common_participer_spectacles' => array(
  2604.             'exec' => ['color' => 'critiques']
  2605.         )]);
  2606.         asides::setEntityManager($this->em);
  2607.         asides::loadaside('Publicite')->addGoogleCritiques($this->asides$this->serviceAbonnements);
  2608.         $this->asides->load(['spectacles_gadget_calendrier' => array(
  2609.             'exec' => ['color' => 'critiques']
  2610.         )]);
  2611.         $this->asides->load('spectacles_proposez_critiques');
  2612.         //On affiche la publicité google
  2613.         $asides_publicite = new asides();
  2614.         asides::setEntityManager($this->em);
  2615.         asides::loadaside('Publicite')->addGoogleCorrespondant($asides_publicite$this->serviceAbonnements);
  2616.         $this->context['view']->asides_publicite_footer $asides_publicite->view($this->context['view']);
  2617.         $item $cache->getItem('recommanded_spectacles_all_infos');
  2618.         if (! $item->isHit()) {
  2619.             $spectacles $this->em->getRepository(Spectacles::class);
  2620.             $recommandedSpectacles $spectacles->getListSpectacles([
  2621.                 "params" => [
  2622.                     "limit" => [04]
  2623.                 ],
  2624.                 "special" => [
  2625.                     "prochains" => "30",
  2626.                     "recommandations" => true,
  2627.                     "publish_valid" => true
  2628.                 ]
  2629.             ]);
  2630.             $paramsVignette = [
  2631.                 'vignette' => [
  2632.                     'width' => 100,
  2633.                     'height' => 100,
  2634.                     'direction' => 'crop',
  2635.                     'fleche' => 'moyen'
  2636.                 ],
  2637.                 'get_vignette' => true
  2638.             ];
  2639.             $recommandedSpectaclesAllInfos = [];
  2640.             // Toutes les infos des prochains spectacles avec recommandations
  2641.             foreach ($recommandedSpectacles as $spectacle) {
  2642.                 $spectacle $spectacles->getInfosSpectacle($spectacle['idspectacle'], $paramsVignette);
  2643.                 $spectacle['carrer'] = $spectacles->getObjectsCarrerDetails($spectacle['idspectacle']);
  2644.                 if ($dates $spectacles->getProchDateLieu(array('prochains' => true), $spectacle['idspectacle'])) {
  2645.                     $spectacle array_merge($spectacle$dates);
  2646.                 }
  2647.                 if (! isset($spectacle['affcontact'])
  2648.                     && (isset($spectacle['contact']) && isset($spectacle['contact']['organisation']) && ! empty($spectacle['contact']['organisation']))
  2649.                 ) {
  2650.                     $spectacle['affcontact'] = true;
  2651.                 }
  2652.                 $spectacle['footer_critique'] = true;
  2653.                 $spectacle['nombre_critique'] = $this->em->getRepository(Contents::class)->countAssociateContent('spectacles'$spectacle['idspectacle'], 'class_critique', array('publish_valid' => 1));
  2654.                 $spectacle['url_clean_more'] = 'critiques/';
  2655.                 $spectacle['nbRecommandations'] = $spectacles->countSpectacleRecommandations($spectacle['idspectacle']);
  2656.                 $spectacle $spectacles->clearSpectaclesAddAllPersons($spectacle);
  2657.                 $recommandedSpectaclesAllInfos[] = $spectacle;
  2658.             }
  2659.             $item->set($recommandedSpectaclesAllInfos)
  2660.                 ->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
  2661.             $cache->save($item);
  2662.         }
  2663.         $this->context['view']->recommandedSpectaclesAllInfos $item->get();
  2664.         return $this->view('spectacles/critiques.html.twig');
  2665.     }
  2666.     // }}}
  2667.     // {{{ action_dvd()
  2668.     /** Les dvds associées à ce spectacle
  2669.      *
  2670.      * @route("/spectacles/{slug}/dvd", name="spectacle_dvd")
  2671.      *
  2672.      */
  2673.     public function action_dvd($slug null)
  2674.     {
  2675.         $this->InitController($slug'videos');
  2676.         $this->view->list_dvds $this->getDvds();
  2677.         $this->setAsideDVDVOD('dvd''videos');
  2678.         return $this->view('spectacles/dvd.html.twig');
  2679.     }
  2680.     // }}}
  2681.     // {{{ action_qrcode()
  2682.     /** retourner l'url du qrcode du spectacle
  2683.      *
  2684.      *
  2685.      * @route("/spectacles/{slug}/qrcode", name="spectacle_qrcode")
  2686.      *
  2687.      */
  2688.     public function action_qrcode($slug null)
  2689.     {
  2690.         $this->InitController($slug'qurcode');
  2691.         $this->view->qrcode_url $this->func->generateQRcode($GLOBALS['url_module'] . '/spectacles/' $this->data_spectacles['urlClean'] . '/'400);
  2692.         $this->asides->load('qrcode');
  2693.         return $this->view('spectacles/qrcode.html.twig');
  2694.     }
  2695.     // }}}
  2696.     // {{{ action_widget()
  2697.     /** widget du spectacle
  2698.      *
  2699.      * @Route("/spectacles/{slug}/widget", name="spectacle_widget")
  2700.      *
  2701.      * @access public
  2702.      * @return void
  2703.      */
  2704.     public function action_widget($slug null)
  2705.     {
  2706.         $this->InitController($slug'widget');
  2707.         $this->style_more[] = 'widget_thnet';
  2708.         // renvoyer en json ou en html ?
  2709.         if (!empty($_GET['v']) && $_GET['v'] == 'ajax') {
  2710.             $this->context['json_response'] = true;
  2711.         } else {
  2712.             $this->view->iframe_style true;
  2713.         }
  2714.         // avec ou sans image (null,small,medium)
  2715.         $preview_sizes = array(
  2716.             'none' => 0,
  2717.             'small' => 55,
  2718.             'bigsmall' => 80,
  2719.             'large' => 100,
  2720.         );
  2721.         if (!empty($_GET['preview']) && array_key_exists($_GET['preview'], $preview_sizes)) {
  2722.             $vignette_size $preview_sizes[$_GET['preview']];
  2723.         } else {
  2724.             $vignette_size 100;
  2725.         }
  2726.         // largeur de la colonne du texte
  2727.         $max_colsize 10000;
  2728.         if (!empty($_GET['colsize']) && $this->func->my_is_int($_GET['colsize']) && $_GET['colsize'] <= $max_colsize) {
  2729.             $colsize $_GET['colsize'];
  2730.         } else {
  2731.             $colsize 200 $vignette_size;
  2732.         }
  2733.         $colsize $colsize $vignette_size;
  2734.         // nombre d'items maxi
  2735.         $max_nbitems 50;
  2736.         if (!empty($_GET['nbitems']) && $this->func->my_is_int($_GET['nbitems']) && $_GET['nbitems'] <= $max_nbitems) {
  2737.             $nbitems $_GET['nbitems'];
  2738.         } else {
  2739.             $nbitems 2;
  2740.         }
  2741.         // format vignette
  2742.         if (!empty($vignette_size)) {
  2743.             $format = array('width' => $vignette_size'height' => $vignette_size'forme' => 'round''direction' => 'crop''valround' => 7);
  2744.         } else {
  2745.             $format false;
  2746.             $vignette_size 0;
  2747.         }
  2748.         // selection des spectacles aujourd'hui et demain
  2749.         $params_sql_spectacle = array(
  2750.             'params' => array(
  2751.                 'where' => ' AND s.idspectacle=' $this->idspectacle,
  2752.             ),
  2753.             'special' => array(
  2754.                 'plus_proche' => true
  2755.             ),
  2756.             'dbg' => array('widget''Le spectacle')
  2757.         );
  2758.         $params_display = array(
  2759.             'stylemore' => array('imagep' => 'width:' $vignette_size 'px''descsp' => 'width:' $colsize 'px'),
  2760.             'vignette' => $format,
  2761.         );
  2762.         $list_spectacle $this->spectacles->getListSpectacles($params_sql_spectacle$params_display);
  2763.         // largeur de la colonne = vignette_size + colsize + les marges
  2764.         $this->view->widget_width $vignette_size $colsize 10;
  2765.         $this->view->li_fleche_width $vignette_size $colsize 5;
  2766.         $this->view->spec $list_spectacle;
  2767.         return $this->view('spectacles/widget.html.twig');
  2768.     }
  2769.     // }}}
  2770.     // {{{ action_widget_calendrier()
  2771.     /** widget calendrier du spectacle
  2772.      *
  2773.      * @Route("/spectacles/{slug}/widget-calendrier", name="spectacle_widget_calendrier")
  2774.      *
  2775.      * @access public
  2776.      * @return void
  2777.      */
  2778.     public function action_widget_calendrier($slug null)
  2779.     {
  2780.         $this->InitController($slug'widget-calendrier');
  2781.         $this->view->page_nobody true;
  2782.         $version 'new';
  2783.         // renvoyer en json ou en html ?
  2784.         if (!empty($_GET['v']) && $_GET['v'] == 'ajax') {
  2785.             $this->context['json_response'] = true;
  2786.         } else {
  2787.             $this->view->iframe_style true;
  2788.         }
  2789.         // nombre d'items maxi
  2790.         $max_nbitems 50;
  2791.         if (!empty($_GET['nbitems']) && $this->func->my_is_int($_GET['nbitems']) && $_GET['nbitems'] <= $max_nbitems) {
  2792.             $nbitems $_GET['nbitems'];
  2793.         } else {
  2794.             $nbitems 3;
  2795.         }
  2796.         // on recupere le calendrier
  2797.         $schedules $this->em->getRepository(Schedules::class);
  2798.         //Si aucune date n'existe on affiche un mesage d'erreur
  2799.         $this->view->date_exists true;
  2800.         // recuperer les dates futurs si il y en a
  2801.         $schedule_futur $schedules->getDateLieuDemain($this->idspectacle$nbitemsnull$version);
  2802.         if (!empty($schedule_futur)) {
  2803.             $this->view->schedule_detail_futur $schedule_futur;
  2804.             //Si une date existe on l'affiche
  2805.             $this->view->date_exists true;
  2806.             // date dans le futur
  2807.             $this->view->futurdate true;
  2808.             // ajout des mots clés basés sur les lieux et dates de représentation futurs
  2809.             $this->meta_keywords .= ' ' $schedules->ScheduleToKeywords($schedule_futur20);
  2810.         }
  2811.         // recuperer les dates anciennes si il y en a
  2812.         $schedule_old $schedules->getDateLieuHier($this->idspectacle$nbitemsnull$version);
  2813.         if (!empty($schedule_old)) {
  2814.             $this->view->schedule_detail_old $schedule_old;
  2815.             //Si une date existe on l'affiche
  2816.             $this->view->date_exists true;
  2817.             // date dans le passe
  2818.             $this->view->olddate true;
  2819.             // ajout des mots clés basés sur les lieux et dates de représentation récentes
  2820.             $this->meta_keywords .= ' ' $schedules->ScheduleToKeywords($schedule_old10);
  2821.         }
  2822.         return $this->view('spectacles/widget-calendrier.html.twig');
  2823.     }
  2824.     // }}}
  2825.     // {{{ action_api()
  2826.     /** Informations sur le spectacle
  2827.      *
  2828.      *
  2829.      * @access public
  2830.      * @return void
  2831.      */
  2832.     public function action_api($api_data true)
  2833.     {
  2834.         // calendrier du spectacle
  2835.         if (array_key_exists('schedules'$this->context['params'])) {
  2836.             $datas = array(
  2837.                 array(
  2838.                     'title' => $this->data_spectacles['title'],
  2839.                     'permanent_url' => $_ENV['URL_THNET'] . '/spectacles/' $this->data_spectacles['urlClean'] . '/',
  2840.                     'dates' => $this->em->getRepository(Schedules::class)->getSchedule($this->idspectacletrue),
  2841.                 )
  2842.             );
  2843.         } else {
  2844.             $datas = array(
  2845.                 array(
  2846.                     'title' => $this->data_spectacles['title'],
  2847.                     'permanent_url' => $_ENV['URL_THNET'] . '/spectacles/' $this->data_spectacles['urlClean'] . '/',
  2848.                 )
  2849.             );
  2850.             $infos $this->spectacles->getListSpectacles(array(
  2851.                 'special' => array(
  2852.                     'idspectacle' => $this->idspectacle,
  2853.                 ),
  2854.                 'dbg' => array('infos''infos sur le spectacle'),
  2855.             ), nullfalse, array('api' => true));
  2856.             foreach ($infos as $k => $v) {
  2857.                 $datas = array($v);
  2858.                 break;
  2859.             }
  2860.             // ajouter les infos complémentaires
  2861.             if (!empty($GLOBALS['api']['data']) && $GLOBALS['api']['data'] == 'extended') {
  2862.                 /*
  2863.                 A ajouter
  2864.                 Extrait video
  2865.                 Images*/
  2866.                 $datas[0]['creation_date'] = $this->data_spectacles['creation_date']; // date de création
  2867.                 $datas[0]['poster_big']['file'] = $this->data_spectacles['illustrations'][0]['url_file_path']; // affiche
  2868.                 $datas[0]['poster_big']['copyright'] = $this->data_spectacles['illustrations'][0]['copyright']; // copyright
  2869.                 $datas[0]['duration'] = $this->data_spectacles['duration']; // durée
  2870.                 $datas[0]['abstract'] = $this->getAbstract(); // résumé
  2871.                 $datas[0]['contents'] = $this->contents->getAssociateContents($this->idspectacle'spectacles''class_article', array('get_texts' => true'api' => true));
  2872.             }
  2873.         }
  2874.         return $datas;
  2875.     }
  2876.     // }}}
  2877.     // {{{ action_documents_edit()
  2878.     /** Ajouter des documents à la structure
  2879.      *
  2880.      * @Route("/spectacles/{slug}/documents-edit", name="spectacle_documents_edit")
  2881.      * @Route("/spectacles/{slug}/documents-edit/idfile/{p_idfile}", name="spectacle_documents_edit_idfile")
  2882.      *
  2883.      * @access public
  2884.      * @return void
  2885.      */
  2886.     public function action_documents_edit($slug null$p_idfile nullFilesController $files_utilsRequest $requestEditUtils $editUtils)
  2887.     {
  2888.         $this->InitController($slug'documents-edit');
  2889.         $this->context['params']['idfile'] = $p_idfile;
  2890.         /* géré par Files_edit */
  2891.         $this->extra_locate $this->extra_title 'Ajouter/modifier un document';
  2892.         $this->context['view']->object_rights['update'] = true;
  2893.         // paramètre d'instanciation
  2894.         $params_edit = array(
  2895.             'idobject' => $this->idspectacle,
  2896.             'object' => 'spectacles',
  2897.         );
  2898.         if (!$this->getUser() instanceof Extranetusers) {
  2899.             return $this->redirectToRoute('app_login', ['urifrom' => $this->context['view']->data_object['url_folder'] . '/documents''entete_connexion' => $params_edit['object']]);
  2900.         }
  2901.         // pour la gestion des fichiers
  2902.         $files_utils->InitFilesController($this->context$params_edit);
  2903.         $response $files_utils->documents_edit($request$editUtils);
  2904.         if ($response instanceof RedirectResponse) {
  2905.             return $response;
  2906.         }
  2907.         $this->js_more[] = 'upload/jquery.fineuploader-3.0.min.js';
  2908.         $this->js_more[] = 'ajax.relation.js';
  2909.         $this->getAsidesDocuments();
  2910.         return $this->view('spectacles/documents-edit.html.twig', [
  2911.             'form' => $files_utils->context['form']->createView()
  2912.         ]);
  2913.     }
  2914.     // }}}
  2915.     // {{{ action_documents_delete()
  2916.     /** Supprimer un document associé au spectacle
  2917.      *
  2918.      * @Route("/spectacles/{slug}/documents-delete/idfile/{idfile}", name="spectacle_documents_delete_idfile")
  2919.      *
  2920.      * @access public
  2921.      * @return void
  2922.      */
  2923.     public function action_documents_delete($idfile null$slug nullUploadUtils $edit_utilsFilesController $files_utilsRequest $request)
  2924.     {
  2925.         $this->InitController($slug'documents');
  2926.         $this->context['params']['idfile'] = $idfile;
  2927.         $this->extra_locate $this->extra_title 'Supprimer un document';
  2928.         // paramètre d'instanciation
  2929.         $params_edit = array(
  2930.             'idobject' => $this->idspectacle,
  2931.             'object' => 'spectacles',
  2932.         );
  2933.         // si connecté, instancier la classe utilitaires d'édition
  2934.         if ($this->getUser() instanceof Extranetusers) {
  2935.             // controlleur pour l'edition
  2936.             $edit_utils->load($this->context$params_edit);
  2937.             // les droits
  2938.             // $object_rights = $edit_utils->checkObjectRights();
  2939.             // @TODO besoin de créer un nouvelle table pour les droits?
  2940.             $this->context['view']->object_rights = [
  2941.                 "delete" => true,
  2942.                 "update" => true,
  2943.                 "insert" => true,
  2944.                 "select" => true,
  2945.                 "isroot" => false,
  2946.                 "isadmin" => true,
  2947.                 "rights" => "15"
  2948.             ];
  2949.             // pour la gestion des fichiers
  2950.             $files_utils->InitFilesController($this->context$params_edit);
  2951.             $this->context['view']->data_object $this->data_spectacles;
  2952.             $this->context['view']->data_object['url_folder'] = '/spectacles/' $this->data_spectacles['urlClean'];
  2953.             $response $files_utils->documents_delete($request);
  2954.             if ($response instanceof RedirectResponse) {
  2955.                 return $response;
  2956.             }
  2957.             //    } else { // la personne n'a pas les droits => renvoi sur le formulaire de demande
  2958.             //        actionRedirect($context['view']->data_object['url_folder'].'/autorisation/');
  2959.             //    }
  2960.         } else { // personne non loguée
  2961.             // rediriger vers montheatre/connexion
  2962.             return $this->redirectToRoute('app_login', ['urifrom' => $this->context['view']->data_object['url_folder'] . '/documents-edit''entete_connexion' => $params_edit['object']]);
  2963.         }
  2964.         $this->extra_locate $this->extra_title 'Ajouter/modifier un document';
  2965.         return $this->view('spectacles/documents-delete.html.twig', [
  2966.         ]);
  2967.     }
  2968.     // }}}
  2969.     // {{{ action_documents()
  2970.     /** Les documents lié à la structure
  2971.      *
  2972.      * @Route("/spectacles/{slug}/documents", name="spectacle_documents")
  2973.      *
  2974.      * @access public
  2975.      * @return void
  2976.      */
  2977.     public function action_documents($slug nullFilesController $files_utilsRequest $request)
  2978.     {
  2979.         $this->InitController($slug'documents');
  2980.         // paramètre d'instanciation
  2981.         $params_edit = array(
  2982.             'idobject' => $this->idspectacle,
  2983.             'object' => 'spectacles',
  2984.         );
  2985.         // si connecté, instancier la classe utilitaires d'édition
  2986.         if ($this->getUser() instanceof Extranetusers) {
  2987.             $this->context['formFactory'] = $this->get('form.factory')->createBuilder(FormType::class, null, [
  2988.                 'attr' => [
  2989.                     'id' => 'masterform'
  2990.                 ]
  2991.             ]);
  2992.             // pour la gestion des fichiers
  2993.             $files_utils->InitFilesController($this->context$params_edit);
  2994.             $files_utils->documents($request);
  2995. //            $this->view = (object) array_merge((array) $this->view, (array) $ecoles_folder->view);
  2996.             $this->context['view'] = (object)array_merge((array)$this->context['view'], (array)$files_utils->context['view']);
  2997.         } else { // personne non loguée
  2998.             // rediriger vers montheatre/connexion
  2999.             return $this->redirectToRoute('app_login', ['urifrom' => $this->context['view']->data_object['url_folder'] . '/documents''entete_connexion' => $params_edit['object']]);
  3000.         }
  3001.         /* géré par Files_edit */
  3002.         $this->extra_locate $this->extra_title 'Documents associés';
  3003.         foreach (array('rubrique''dossier''auteur''pageregion''montheatre') as $s) {
  3004.             $this->view->style_more[] = $s;
  3005.         }
  3006.         $this->getAsidesDocuments();
  3007.         return $this->view('spectacles/documents.html.twig');
  3008.     }
  3009.     // }}}
  3010.     // {{{ action_telechargements()
  3011.     /** Les documents lié au spectacle
  3012.      *
  3013.      *
  3014.      * @Route("/spectacles/{slug}/telechargements", name="spectacle_telechargements")
  3015.      *
  3016.      * @access public
  3017.      * @return void
  3018.      */
  3019.     public function action_telechargements($slug null)
  3020.     {
  3021.         $this->InitController($slug'telechargements');
  3022.         $files $this->em->getRepository(Files::class);
  3023.         $classifications $this->em->getRepository(Classifications::class);
  3024.         // classifications des spectacles
  3025.         $classifications_list $classifications->getClassificationList('files''spectacles'null, array(1), 'get_value');
  3026.         // liste des fichiers
  3027.         $params_object_files = array(
  3028.             'valid' => 1,
  3029.             'publish' => 1,
  3030.             'force_mode' => 'file',
  3031.             'vignette_width' => 250,
  3032.             'debug_sql_associate' => false
  3033.         );
  3034.         $object_files $files->getObjectFiles($this->idspectacle'spectacles'$classifications_list$params_object_files);
  3035.         if (!empty($object_files)) {
  3036.             foreach ($object_files as $k => $v) {
  3037.                 if (!empty($v['saison'])) {
  3038.                     $saisons[$v['saison']] = $v['saison'];
  3039.                     // trouver kles autres associations
  3040.                     $v['objects'] = $files->getObjects($v['idfile'], array('object' => 'spectacles''idobject' => $this->idspectacle));
  3041.                     if (!empty($v['objects'])) {
  3042.                         foreach ($v['objects'] as $kb => $vb) {
  3043.                             $v['objects'][$vb['object']][$vb['idobject']] = $vb;
  3044.                         }
  3045.                     }
  3046.                     $this->context['view']->files['general'][$k] = $v;
  3047.                 }
  3048.             }
  3049.             $this->context['view']->is_file true;
  3050.             if (!empty($saisons)) {
  3051.                 //setDebug($saisons);
  3052.             }
  3053.         }
  3054.         /* géré par Files_edit */
  3055.         $this->extra_locate $this->extra_title 'Documents associés';
  3056.         foreach (array('rubrique''dossier''auteur''pageregion''montheatre') as $s) {
  3057.             $this->style_more[] = $s;
  3058.         }
  3059.         $this->js_more[] = 'jquery.matchHeight-min.js';
  3060.         //aside
  3061.         $this->asides->load('spectacles_telecharge_doc');
  3062.         return $this->view('spectacles/telechargements.html.twig');
  3063.     }
  3064.     // }}}
  3065.     // {{{ action_modifier_dates()
  3066.     /** L'interface de modification des dates associés aux spectacles
  3067.      *
  3068.      * @Route("/spectacles/{slug}/modifier-dates", name="spectacle_modifier_dates")
  3069.      * @Route("/spectacles/{slug}/modifier-dates/idspectacle/{idspectacle}/idcontact/{idcontact}", name="spectacle_modifier_dates_idspectacle")
  3070.      *
  3071.      */
  3072.     public function action_modifier_dates($slug$idspectacle null$idcontact nullAjoutSpectacleController $ajoutspectacleRequest $request)
  3073.     {
  3074.         $this->InitController($slug'presentation');
  3075.         $this->context['params']['idspectacle'] = $idspectacle;
  3076.         $this->context['params']['idcontact'] = $idcontact;
  3077.         // rediriger vers montheatre/connexion
  3078.         if (!$this->getUser() instanceof Extranetusers) {
  3079.             return $this->redirectToRoute('app_login', ['urifrom' => '/spectacles/' $this->data_spectacles['urlClean'] . '/ajoutdates/''entete_connexion' => 'spectacles''special' => 'dates']);
  3080.         }
  3081.         // envoi idspectacle à la vue
  3082.         $this->view->idspectacle $this->idspectacle;
  3083.         // idcontact => mode édition
  3084.         if (!empty($this->context['params']['idcontact']) && $this->func->my_is_int($this->context['params']['idcontact'])) {
  3085.             $idcontact $this->context['params']['idcontact'];
  3086.         } else {
  3087.             $idcontact null;
  3088.         }
  3089.         $ajoutspectacle_params = array(
  3090.             'idspectacle' => $this->idspectacle,
  3091.             'path' => 'spectacles/' $this->data_spectacles['urlClean'],
  3092.             'idcontact' => $idcontact,
  3093.             'no_check_extranetuser' => true// n'importe quel utilisateur peut ajouter des dates
  3094.             'send_to_owner' => true// prévenir l'utilisateur que quelqu'un a modifié son spectacle
  3095.             'possible_do' => array('edit_schedule''delete_schedule''active_representation''disable_representation')
  3096.         );
  3097.         $ajoutspectacle->InitAjoutSpectacle($ajoutspectacle_params);
  3098.         $ajoutspectacle->context['formFactory'] = $this->get('form.factory')->createBuilder(FormType::class, null, [
  3099.             'attr' => [
  3100.                 'id' => 'masterform'
  3101.             ]
  3102.         ]);
  3103.         $ajoutspectacle->getScheduleForm($this->idspectacle$idcontact);
  3104.         $ajoutspectacle->context['form'] = $ajoutspectacle->context['formFactory']->getForm();
  3105.         $ajoutspectacle->context['form']->handleRequest($request);
  3106.         if ($ajoutspectacle->validateScheduleForm() || !empty($_POST['dates'])) {
  3107.             if (empty($_POST['dates'])) {
  3108.                 $this->context['error']['precise_date'] = 'Vous devez préciser au moins une date de représentation';
  3109.             } elseif (empty($ajoutspectacle->context['form']->get('idcontact'))) {
  3110.                 //$this->context['error']['precise_contact'] = 'Vous devez choisir un lieu de représentation';
  3111.             } else {
  3112.                 return $ajoutspectacle->saveSchedule($this->idspectacle$idcontact);
  3113.             }
  3114.         }
  3115.         $ajoutspectacle->getAjoutspectacleCommon();
  3116.         foreach ($ajoutspectacle->view as $key => $value) {
  3117.             $this->view->$key $value;
  3118.         }
  3119.         $this->view->style_more[] = array(
  3120.             '/navigation/js/multidate/multidatepicker.css',
  3121.         );
  3122.         // js en plus
  3123.         // style css
  3124.         $jqueryui_theme 'themes_2018';
  3125.         $jqueryui_version '1.12-1';
  3126.         $this->js_more[] = 'ajax.relation.js';
  3127.         $this->js_more[] = 'jquery-ui/jquery-ui-' $jqueryui_version '.min.js';
  3128.         $this->js_more[] = 'multidate/jquery-ui.multidatespicker.js';
  3129.         $this->js_more[] = 'jquery-ui/jquery.ui.datepicker-fr.js';
  3130.         return $this->view('spectacles/modifier-dates.html.twig', [
  3131.             'form' => $ajoutspectacle->context['form']->createView()
  3132.         ]);
  3133.     }
  3134.     // }}}
  3135.     // {{{ action_dates()
  3136.     /** Les dates associés aux spectacles
  3137.      *
  3138.      * @Route("/spectacles/{slug}/dates", name="spectacle_dates")
  3139.      * @Route("/spectacles/{slug}/dates/idspectacle/{p_idspectacle}", name="spectacle_dates_idspectacle")
  3140.      * @Route("/spectacles/{slug}/ajoutdates", name="spectacle_ajout_dates")
  3141.      *
  3142.      */
  3143.     public function action_dates($slug null$p_idspectacle nullAjoutSpectacleController $ajoutspectacle)
  3144.     {
  3145.         $this->InitController($slug'dates');
  3146.         $this->context['params']['idspectacle'] = $p_idspectacle;
  3147.         // rediriger vers montheatre/connexion
  3148.         if (!$this->getUser() instanceof Extranetusers) {
  3149.             return $this->redirectToRoute('app_login', ['urifrom' => '/spectacles/' $this->data_spectacles['urlClean'] . '/ajoutdates/''entete_connexion' => 'spectacles''special' => 'dates']);
  3150.         }
  3151.         // créer un token pour anti-csrf
  3152.         $this->func->tokenCsrf('ajoutdate'$this->context);
  3153.         // instancie
  3154.         $ajoutspectacle_params = array(
  3155.             'idspectacle' => $this->idspectacle,
  3156.             'no_check_extranetuser' => true// n'importe quel utilisateur peut ajouter des dates
  3157.             'path' => 'spectacles/' $this->data_spectacles['urlClean'],
  3158.             'send_to_owner' => true// prévenir l'utilisateur que quelqu'un a modifié son spectacle
  3159.             'do' => array('edit''delete')
  3160.         );
  3161.         $ajoutspectacle->InitAjoutSpectacle($ajoutspectacle_params);
  3162.         foreach (['active_representation''disable_representation'] as $value) {
  3163.             if (!empty($_GET[$value])) {
  3164.                 $this->context['view']->returnDo true;
  3165.                 $this->context['view']->$value true;
  3166.             }
  3167.         }
  3168.         // formulaire
  3169.         $ajoutspectacle->getSchedule($this->idspectacle);
  3170.         // élèments commun (css, js, barre d'outils)
  3171.         $ajoutspectacle->getAjoutspectacleCommon();
  3172.         // les horaires
  3173.         $this->js_more[] = 'jquery.qtip.min.js';
  3174.         $this->view->schedule_detail $ajoutspectacle->view->schedule_detail;
  3175.         $this->view->page_courante 'spectacles/' $this->data_spectacles['urlClean'];
  3176.         $this->view->idspectacle $this->id;
  3177.         return $this->view('spectacles/dates.html.twig');
  3178.     }
  3179.     // }}}
  3180.     // {{{ action_validation()
  3181.     /** La page de validation des spectacles (lesdates; ajout de contenu etc.)
  3182.      *
  3183.      * @Route("/spectacles/{slug}/validation/idspectacle/{p_idspectacle}", name="spectacle_validation_idspectacle")
  3184.      * @Route("/spectacles/{slug}/validation/", name="spectacle_validation")
  3185.      *
  3186.      */
  3187.     public function action_validation($slug null)
  3188.     {
  3189.         $this->InitController($slug'validation');
  3190.         return $this->redirectToRoute('spectacle_lesdates', ['slug' => $this->data_spectacles['urlClean']]);
  3191.     }
  3192.     // }}}
  3193.     /**
  3194.      *
  3195.      * @Route("/spectacles/{slug}/article/signer/idcontent/{idcontent}", name="spectacle_article_signer")
  3196.      *
  3197.      **/
  3198.     public function action_articles_signer($slug$idcontent nullAjoutArticleController $ajoutArticleRequest $request)
  3199.     {
  3200.         $this->context['params']['idcontent'] = $idcontent;
  3201.         $this->InitController($slug'article');
  3202.         if (!$this->getUser() instanceof Extranetusers) {
  3203.             return $this->redirectToRoute('app_login', ['urifrom' => '/spectacles/' $this->data_spectacles['urlClean'] . '/ajoutdates/''entete_connexion' => 'spectacles']);
  3204.         }
  3205.         $url_path 'spectacles';
  3206.         $ajoutArticle->InitAjoutArticle($this->context, ['path' => $url_path]);
  3207.         $ajoutArticle->setObject($this->data_spectacles);
  3208.         // print_r($this->spectacles);
  3209.         $ajoutArticle->action_signer($request);
  3210.         $this->context['view']->formulaire_css true;
  3211.         $this->contenus_spectacles('class_article''ensavoirplus');
  3212.         $this->asides->load(['textes_menu_educ_edit' => array(
  3213.             'exec' => array(
  3214.                 'alone' => true,
  3215.                 'color' => 'context'
  3216.             ),
  3217.         )]);
  3218.         $this->asides->load('textes_menu_educ_edit_current');
  3219.         return $this->view('spectacles/article-signer.html.twig', [
  3220.             'form' => $this->context['form']->createView()
  3221.         ]);
  3222.     }
  3223.     /**
  3224.      *
  3225.      * @Route("/spectacles/{slug}/article/ecritures", name="spectacle_article_ecritures")
  3226.      * @Route("/spectacles/{slug}/article/ecritures/idcontent/{idcontent}", name="spectacle_article_ecritures_idcontent")
  3227.      *
  3228.      **/
  3229.     public function action_articles_ecritures($slug$idcontent nullAjoutArticleController $ajoutArticleRequest $request)
  3230.     {
  3231.         $this->InitController($slug'article');
  3232.         $this->context['params']['idcontent'] = $idcontent;
  3233.         if (!$this->getUser() instanceof Extranetusers) {
  3234.             return $this->redirectToRoute('app_login', ['urifrom' => '/spectacles/' $this->data_spectacles['urlClean'], 'entete_connexion' => 'spectacles']);
  3235.         }
  3236.         $url_path 'spectacles';
  3237.         $ajoutArticle->InitAjoutArticle($this->context, ['path' => $url_path]);
  3238.         $ajoutArticle->setObject($this->data_spectacles);
  3239.         // print_r($this->spectacles);
  3240.         $ajoutArticle->action_ecriture($request);
  3241.         $this->context['view']->formulaire_css true;
  3242.         $this->contenus_spectacles('class_article''ensavoirplus');
  3243.         $this->asides->load(['textes_menu_educ_edit' => array(
  3244.             'exec' => array(
  3245.                 'alone' => true,
  3246.                 'color' => 'context'
  3247.             ),
  3248.         )]);
  3249.         $this->asides->load('textes_menu_educ_edit_current');
  3250.         return $this->view('spectacles/article-ecritures.html.twig', [
  3251.             'form' => $this->context['form']->createView()
  3252.         ]);
  3253.     }
  3254.     /**
  3255.      *
  3256.      * @Route("/spectacles/{slug}/article/licence", name="spectacle_article_licence")
  3257.      *
  3258.      **/
  3259.     public function action_articles_licence($slugAjoutArticleController $ajoutArticleRequest $request)
  3260.     {
  3261.         return $this->redirect('/');
  3262.         $this->InitController($slug'article');
  3263.         if (!$this->getUser() instanceof Extranetusers) {
  3264.             return $this->redirectToRoute('app_login', ['urifrom' => '/spectacles/' $this->data_spectacles['urlClean'], 'entete_connexion' => 'spectacles']);
  3265.         }
  3266.         $url_path 'spectacles';
  3267.         $ajoutArticle->InitAjoutArticle($this->context, ['path' => $url_path]);
  3268.         $ajoutArticle->setObject($this->data_spectacles);
  3269.         // print_r($this->spectacles);
  3270.         $ajoutArticle->action_licence($request);
  3271.         return $this->view('spectacles/article-licence.html.twig', [
  3272.             'form' => $this->context['form']->createView()
  3273.         ]);
  3274.     }
  3275.     /**
  3276.      *
  3277.      * @Route("/spectacles/{slug}/article/previsualisation/idcontent/{idcontent}", name="spectacle_article_previsualisation")
  3278.      *
  3279.      **/
  3280.     public function action_article_previsualisation($slug$idcontent nullAjoutArticleController $ajoutArticleRequest $request)
  3281.     {
  3282.         $this->context['params']['idcontent'] = $idcontent;
  3283.         $this->InitController($slug'article');
  3284.         if (!$this->getUser() instanceof Extranetusers) {
  3285.             return $this->redirectToRoute('app_login', ['urifrom' => '/spectacles/' $this->data_spectacles['urlClean'], 'entete_connexion' => 'spectacles']);
  3286.         }
  3287.         $url_path 'spectacles';
  3288.         $ajoutArticle->InitAjoutArticle($this->context, ['path' => $url_path]);
  3289.         $ajoutArticle->setObject($this->data_spectacles);
  3290.         // print_r($this->spectacles);
  3291.         $ajoutArticle->action_previsualisation($request);
  3292.         $this->contenus_spectacles('class_article''ensavoirplus');
  3293.         $this->asides->load(['textes_menu_educ_edit' => array(
  3294.             'exec' => array(
  3295.                 'alone' => true,
  3296.                 'color' => 'context'
  3297.             ),
  3298.         )]);
  3299.         $this->asides->load('textes_menu_educ_edit_current');
  3300.         return $this->view('spectacles/article-previsualisation.html.twig');
  3301.     }
  3302.     // }}}
  3303.     // {{{ GetListSpectaclesFromSpecificLanguageFromTexts()
  3304.     /**
  3305.      * Récupération des textes en scènes dans la langue original ou dans les langues de traductions
  3306.      *
  3307.      */
  3308.     public function GetListSpectaclesFromSpecificLanguageFromTexts($params = array(), $params_display = ['allauthors' => true'carrer_couleurs' => true])
  3309.     {
  3310.         $spectacle $this->em->getRepository(Spectacles::class);
  3311.         $person $this->em->getRepository(Persons::class);
  3312.         if (empty($this->data_spectacles['texts'][0])) {
  3313.             return null;
  3314.         }
  3315.         $this->view->data_text $this->data_spectacles['texts'][0];
  3316.         //si nous sommes sur un texte traduit basé sur un texte original
  3317.         $original true;
  3318.         if (isset($this->view->data_text['typetxt'])) {
  3319.             if ($this->view->data_text['typetxt'] == 'translate') {
  3320.                 $original false;
  3321.             }
  3322.         }
  3323.         //language_egal
  3324.         //language_different
  3325.         if (!empty($this->view->data_text['idtext'])) {
  3326.             // translation
  3327.             // adaptation_by_language_spectacle
  3328.             //si c'est un texte oiginal nous voulons les textes traduits
  3329.             if ($original) {
  3330.                 if (isset ($this->view->data_text['language_src'])) {
  3331.                     $language_original $this->view->data_text['language_src'];
  3332.                 }
  3333.                 $this->view->traduc $person->getTextsPerson($this->idspectacle'translation''publish'null$this->view->data_text['idtext']);
  3334.                 foreach ($this->view->traduc as $t) {
  3335.                     $idtexts[] = $t['idtext'];
  3336.                 }
  3337.                 $idtexts_original = array($this->view->data_text['idtext']);
  3338.             } else {
  3339. //                $language_original = $this->view->data_text['originaltext']['language_src'];
  3340.                 $language_original 'fr';
  3341.                 $langue_traduction $this->view->data_text['language_src'];
  3342.                 $this->view->traduc = array($this->view->data_text['idtext'] => $this->view->data_text);
  3343.                 $idtexts = array($this->view->data_text['idtext']);
  3344.                 $idtexts_original = array($this->view->data_text['idtextoriginal']);
  3345.             }
  3346.         }
  3347.         // parcourir les traductions et trouver les mises en scènes
  3348.         $params_request = array(
  3349.             'params' => array(
  3350.                 'order' => ['creation_date''DESC'],
  3351.                 'limit' => array(0500),
  3352.             ),
  3353.             'dbg' => array('list_traductions_mise_en_scene''Liste des mises en scène à partir des traductions'),
  3354.         );
  3355.         if (!empty($params['prochains'])) {
  3356.             unset($params_request['params']['order']);
  3357.             $params_request['special']['prochains'] = true;
  3358.         }
  3359.         if (!empty($params['limit'])) {
  3360.             $params_request['params']['limit'] = $params['limit'];
  3361.         }
  3362.         if (!empty($params['exclude_idspectacle'])) {
  3363.             $params_request['special']['exclude_idspectacle'] = $params['exclude_idspectacle'];
  3364.         }
  3365.         //Si nous sélections un type de spectacle spécifique
  3366.         if (!empty($params['idtypespectacle'])) {
  3367.             $params_request['params']['where'] = 'AND s.idtypespectacle = 4 ';
  3368.         }
  3369.         //Si nous sélections un type d'aide
  3370.         if (!empty($params['aide'])) {
  3371.             $params_request['special']['aide'] = $params['aide'];
  3372.         }
  3373.         if (!empty($params['spectacle_aide'])) {
  3374.             $params_request['special']['spectacle_aide'] = true;
  3375.         }
  3376.         //Si nous voulons une limite aux spectacles
  3377.         if (!empty($params['limit'])) {
  3378.             if (!is_array($params['limit'])) {
  3379.                 $params['limit'] = explode(','$params['limit']);
  3380.                 if (count($params['limit']) == 1) {
  3381.                     array_unshift($params['limit'], 0);
  3382.                 }
  3383.             }
  3384.             $params_request['params']['limit'] = $params['limit'];
  3385.         }
  3386.         if (!empty($params['traduction'])) {
  3387.             if (isset($idtexts)) {
  3388.                 $params_request['special']['idtext'] = $idtexts;
  3389.             } else {
  3390.                 $params_request['special']['idtext'] = $idtexts_original;
  3391.             }
  3392.             if ($original) {
  3393.                 $params_request['special']['spectacle']['language_different'] = $language_original;
  3394.             } else {
  3395.                 $params_request['special']['spectacle']['language_egal'] = $langue_traduction;
  3396.             }
  3397.             // print_r($params_request);
  3398.             // 'language_different' => $language_original
  3399.         } else {
  3400.             $params_request['special']['join'] = true;
  3401.             $params_request['special']['select_by_text_or_adaptation'] = $this->view->data_text['idtext'];
  3402.             if (isset($language_original)) {
  3403.                 $params_request['special']['spectacle'] = array(
  3404.                     'language_egal' => $language_original
  3405.                 );
  3406.             }
  3407.         }
  3408.         if (!empty($params['count'])) {
  3409.             $params_request['params']['cout_only'] = true;
  3410.             return count($spectacle->getListSpectacles($params_request));
  3411.         } else {
  3412.             return $spectacle->getListSpectacles($params_requestnullfalse$params_display);
  3413.         }
  3414.     }
  3415.     // }}}
  3416.     // {{{ getDataSpectacles()
  3417.     /** Les infos sur spectacle
  3418.      *
  3419.      */
  3420.     public function getDataSpectacles()
  3421.     {
  3422.         return $this->data_spectacles;
  3423.     }
  3424.     // }}}
  3425.     // {{{ getLocate()
  3426.     /** Ou se trouve t'on (getter)
  3427.      *
  3428.      */
  3429.     public function getLocate()
  3430.     {
  3431.         return $this->locate;
  3432.     }
  3433.     // }}}
  3434.     // {{{ getAsidesDocuments()
  3435.     /** Ou se trouve t'on (getter)
  3436.      *
  3437.      */
  3438.     public function getAsidesDocuments()
  3439.     {
  3440.         $menu_admin = array(
  3441.             'documents' => array(
  3442.                 'name' => 'Liste de mes documents',
  3443.                 'key' => 'documents'
  3444.             ),
  3445.             'documents-edit' => array(
  3446.                 'name' => 'Ajouter un document',
  3447.                 'key' => 'documents-edit'
  3448.             )
  3449.         );
  3450.         $this->asides->load(['url_lists_alone' => array(
  3451.             'php' => array(
  3452.                 'method' => 'asidesUrlLists',
  3453.                 'urls' => $menu_admin,
  3454.                 'url' => '/spectacles/{v_url_clean}/key',
  3455.                 'params' => array(
  3456.                     'activate' => $this->context['action']
  3457.                 )
  3458.             ),
  3459.             'title' => 'Modifier'
  3460.         )
  3461.         ]);
  3462.     }
  3463.     // }}}
  3464.     // {{{ getAsideSelections()
  3465.     public function getAsideSelections()
  3466.     {
  3467.         $this->view->type_aides = array(
  3468.             'prix' => array(
  3469.                 'type_aides' => array(23),
  3470.                 'label' => 'Prix et distinctions',
  3471.             ),
  3472. //            'soutiens' => array(
  3473. //                'type_aides' => array(1),
  3474. //                'label' => 'Aide(s) et soutien(s)',
  3475. //            ),
  3476.             'selections' => array(
  3477.                 'type_aides' => array(4),
  3478.                 'label' => 'Sélection(s)',
  3479.             ),
  3480.         );
  3481.         $spectacle_aide $this->em->getRepository(SpectacleAide::class);
  3482.         foreach ($this->view->type_aides as $k => $v) {
  3483.             $params_sql_aide = array(
  3484.                 'where' => array(
  3485.                     array('spectacle_aide''publish'1)
  3486.                 ),
  3487.                 'idspectacle' => $this->idspectacle,
  3488.                 'special' => array(
  3489.                     'aides' => array(
  3490.                         'type_aides' => $v['type_aides']
  3491.                     )
  3492.                 ),
  3493.                 'dbg' => array('spectacle_' $k$v['label']),
  3494.             );
  3495.             $this->view->type_aides[$k]['aides'] = $spectacle_aide->getListSpectacleAide($params_sql_aide);
  3496.             if (empty($this->view->type_aides[$k]['aides'])) {
  3497.                 unset($this->view->type_aides[$k]);
  3498.             }
  3499.         }
  3500.         $this->asides->load('common_aside_selections');
  3501.     }
  3502.     // }}}
  3503.     // {{{ getTitlePage()
  3504.     /** Titre de la page (getter)
  3505.      *
  3506.      */
  3507.     public function getTitlePage()
  3508.     {
  3509.         return $this->title_page;
  3510.     }
  3511.     // }}}
  3512.     // {{{ getStyleMore()
  3513.     /** Style en plus (getter)
  3514.      *
  3515.      */
  3516.     public function getStyleMore()
  3517.     {
  3518.         return $this->style_more;
  3519.     }
  3520.     // }}}
  3521.     // {{{ getMetaKeywords()
  3522.     /** Keywords (getter)
  3523.      *
  3524.      */
  3525.     public function getMetaKeywords()
  3526.     {
  3527.         return $this->meta_keywords;
  3528.     }
  3529.     // }}}
  3530.     // {{{ getMetaDescription()
  3531.     /** Description (getter)
  3532.      *
  3533.      */
  3534.     public function getMetaDescription()
  3535.     {
  3536.         return $this->meta_description;
  3537.     }
  3538.     // }}}
  3539.     // {{{ getMtinfos()
  3540.     /** Infos mon théâtre
  3541.      *
  3542.      */
  3543.     public function getMtinfos()
  3544.     {
  3545.         return $this->mtinfos;
  3546.     }
  3547.     // }}}
  3548.     // {{{ setOtherDimensions()
  3549.     /** Taille maxi des vidéos
  3550.      *
  3551.      */
  3552.     public function setOtherDimensions($other_dimensions)
  3553.     {
  3554.         $this->other_dimensions $other_dimensions;
  3555.     }
  3556.     // }}}
  3557.     // {{{ setParamsComments()
  3558.     /** Paramètre des commentaires
  3559.      *
  3560.      */
  3561.     public function setParamsComments($params_comments)
  3562.     {
  3563.         $this->params_comments $params_comments;
  3564.     }
  3565.     // }}}
  3566.     // {{{ isTheduc()
  3567.     /** texter si le spectacle est de theduc
  3568.      *
  3569.      */
  3570.     public function isTheduc($idspectacle null)
  3571.     {
  3572.         $sql 'SELECT COUNT(idspectacle)
  3573.                 FROM spectacle_classification
  3574.                 WHERE idspectacle=' $this->idspectacle '
  3575.                 AND idclassification=60';
  3576.         return $this->spectacles->queryOne($sql);
  3577.     }
  3578.     // }}}
  3579.     // {{{ getDvds()
  3580.     /** Les dvds et la VOD associées à ce spectacle
  3581.      *
  3582.      * @param bool $count_only Compter seulement
  3583.      * @return array|int
  3584.      *
  3585.      */
  3586.     public function getDvds($count_only false$params = array())
  3587.     {
  3588.         $params_sql = array(
  3589.             'dbg' => array('dvds_spectacle''Les dvds associés au spectacle'),
  3590.             'special' => array(
  3591.                 'dvd' => true,
  3592.                 'idspectacles' => array($this->data_spectacles['idspectacle'])
  3593.             )
  3594.         );
  3595.         if ($count_only) {
  3596.             $params_sql['count_only'] = true;
  3597.             $params_sql['limit'] = array('all');
  3598.         } else {
  3599.             if (!empty($params['limit'])) {
  3600.                 $params_sql['limit'] = $params['limit'];
  3601.             } else {
  3602.                 $params_sql['limit'] = array(0100);
  3603.             }
  3604.         }
  3605.         $format_vignette = array('vignette_format' => array('width' => 300'height' => 300'direction' => 'thumb')); // taille de la vignette
  3606.         return $this->em->getRepository(Dvds::class)->getListDvds($params_sql$format_vignette);
  3607.     }
  3608.     // {{{ getVods()
  3609.     /** Les VOD associées à ce spectacle
  3610.      *
  3611.      * @param bool $count_only Compter seulement
  3612.      * @return array|int
  3613.      *
  3614.      */
  3615.     public function getVods()
  3616.     {
  3617.         $params_sql = array(
  3618.             'dbg' => array('dvds_spectacle''Les dvds associés au spectacle'),
  3619.             'special' => array(
  3620.                 'vods' => true,
  3621.                 'idspectacles' => array($this->data_spectacles['idspectacle']),
  3622.             )
  3623.         );
  3624.         $params_sql['limit'] = array(0100);
  3625.         return $this->em->getRepository(Dvds::class)->getListDvds($params_sql);
  3626.     }
  3627.     // }}}
  3628.     // {{{ getAbstract()
  3629.     /** récupèrer la présentation du spectacle
  3630.      *
  3631.      * @return array|int
  3632.      *
  3633.      */
  3634.     public function getAbstract()
  3635.     {
  3636.         // si pas de presentation, recuperer le premier contenu de en savoir plus
  3637.         $sql 'SELECT c.title,c.idcontent,c.language,c.deck,c.text,c.display_media
  3638.                 FROM object_content oc, contents c, content_classification cc
  3639.                    WHERE oc.idcontent=c.idcontent
  3640.                    AND cc.idcontent=c.idcontent
  3641.                    AND cc.idclassification=6
  3642.                    AND oc.idobject=\'' $this->idspectacle '\'
  3643.                    AND oc.object=\'spectacles\'
  3644.                    ORDER BY c.`range`,c.dateinsert ASC LIMIT 0,1';
  3645.         $presentations_spectacle $this->contents->queryAll($sql);
  3646.         if (!empty($presentations_spectacle)) {
  3647.             foreach ($presentations_spectacle as $k => $v) {
  3648.                 return array(
  3649.                     'text' => $this->contents->wikiTransform($v['text']),
  3650.                     'title' => $v['title'],
  3651.                 );
  3652.             }
  3653.         } else {
  3654.             return null;
  3655.         }
  3656.     }
  3657.     // }}}
  3658.     // {{{ countTelechargements()
  3659.     /** compter les fichiers
  3660.      *
  3661.      * @return int
  3662.      *
  3663.      */
  3664.     public function countTelechargements()
  3665.     {
  3666.         return $this->em->getRepository(Files::class)->countObjectFiles(
  3667.             $this->idspectacle'spectacles',
  3668.             $this->em->getRepository(Classifications::class)->getClassificationList('files''spectacles'null, array(1), 'get_value'),
  3669.             array(
  3670.                 'valid' => 1,
  3671.                 'publish' => 1,
  3672.                 'force_mode' => 'file',
  3673.             )
  3674.         );
  3675.     }
  3676.     // }}}
  3677.     public function setAsideDVDVOD($activate 'videos'$bg_color "videos")
  3678.     {
  3679.         $menu_video_dvd = array();
  3680.         $menu_video_dvd[] = array(
  3681.             'name' => 'Vidéos',
  3682.             'key_type' => 'videos'
  3683.         );
  3684.         if ($x $this->getDvds(true) > 0) {
  3685.             $menu_video_dvd[] = array(
  3686.                 'name' => 'DVD',
  3687.                 'key_type' => 'dvd'
  3688.             );
  3689.         }
  3690.         //aside
  3691.         $this->asides->load(['url_lists_alone' => array(
  3692.             'exec' => array(
  3693.                 'color' => $bg_color,
  3694.             ),
  3695.             'php' => array(
  3696.                 'method' => 'asidesUrlLists',
  3697.                 'urls' => $menu_video_dvd,
  3698.                 'url' => '/spectacles/{v_url_clean}/key_type',
  3699.                 'params' => array(
  3700.                     'activate' => $activate
  3701.                 )
  3702.             ),
  3703.             'title' => 'Voir'
  3704.         )]);
  3705.         $this->asides->load(['common_participer_spectacles' => array(
  3706.             'exec' => ['color' => $bg_color]
  3707.         )]);
  3708.     }
  3709.     // {{{ getBuildMenu()
  3710.     public function getBuildMenu($params = [])
  3711.     {
  3712.         $this->buildMenu($params);
  3713.     }
  3714.     // }}}
  3715. }