src/Controller/DvdController.php line 62

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\ClassTheatre\asides;
  4. use App\ClassTheatre\TheatreController;
  5. use App\Exception\RedirectException;
  6. use App\Service\Functions;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  10. use Symfony\Contracts\Translation\TranslatorInterface;
  11. use TheatreCore\Entity\BookmarkExtranetuser;
  12. use TheatreCore\Entity\Contents;
  13. use TheatreCore\Entity\Dvds;
  14. use TheatreCore\Entity\Extranetusers;
  15. use TheatreCore\Entity\Spectacles;
  16. class DvdController extends TheatreController
  17. {
  18.     // asides
  19.     protected $asides "";
  20.     public function __construct(EntityManagerInterface $emTranslatorInterface $translatorTokenStorageInterface $tokenStorageFunctions $func)
  21.     {
  22.         // surbrillance du menu principal (thnet)
  23.         $GLOBALS['rub_courante'] = 'dvd';
  24.         parent::__construct($translator$tokenStorage);
  25.         $this->em $em;
  26.         $this->func $func;
  27.         $this->view->include_header 'spectacles/spectacle_entete.inc.html.twig';
  28.         $this->asides = new asides();
  29.     }
  30.     public function InitController($slug null$action null)
  31.     {
  32.         $this->context['action'] = $action;
  33.         $this->RouterOptions($slug$action$GLOBALS['rub_courante']);
  34.         $this->view->controller $GLOBALS['rub_courante'];
  35.         // charger swfobject
  36.         $this->view->jquery_flash true;
  37.         $params['iddvd'] = $this->iddvd $this->id;
  38.         // si id spectacle n'existe pas, on renvoi sur une page d'erreur (a faire !!!)
  39.         if (empty($params['iddvd'])) {
  40.             throw new RedirectException($this->generateUrl('erreur'));
  41.         }
  42.     }
  43.     /**
  44.      * @Route("/dvd/{slug}", name="dvd_slug")
  45.      */
  46.     public function action_view($slug null)
  47.     {
  48.         $this->InitController($slug'view');
  49.         $dvds $this->em->getRepository(Dvds::class);
  50.         $iddvd $this->iddvd;
  51.         // video
  52.         $dvd $dvds->getInfosDvd(
  53.             $iddvd,
  54.             array('all' => true'multimedias' => true), // ttes les données et les vidéos associées
  55.             array('vignette_format' => array('width'=>300,'height'=>300,'direction'=>'thumb')) // taille de la vignette
  56.         );
  57.         if (!empty($dvd['multimedias'])) {
  58.             // voir si il y a de la VOD dans le tas
  59.             foreach($dvd['multimedias'] as $k=>$v) {
  60.                 if ($v['status']==5) {
  61.                     $this->view->vod $v;
  62.                 }
  63.             }
  64.         }
  65.         // récupèrer les infos sur le spectacle
  66.         if (!empty($dvd['dvd_spectacle'])) {
  67.             $spectacles $this->em->getRepository(Spectacles::class);
  68.             foreach($dvd['dvd_spectacle'] as $s) {
  69.                 // infos sur le spectacle
  70.                 $dvd['spectacles'][$s['idspectacle']] = $spectacles->getInfosSpectacle($s['idspectacle']);
  71.                 // recuperer la liste des comediens (idrole=5)
  72.                 $dvd['spectacles'][$s['idspectacle']]['personnages'] = $this->func->noPunct($spectacles->getPersonsByRole($s['idspectacle'],'actors'));
  73.                 // recuperer la liste des producteurs/co-producteur/producteur delegue
  74.                 // (idrole=17/18/19, pas de type et recherche dans contacts)
  75.                 $dvd['spectacles'][$s['idspectacle']]['producteurs'] = $this->func->noPunct($spectacles->getContactsByRole($s['idspectacle'],17));
  76.                 $dvd['spectacles'][$s['idspectacle']]['coproducteurs'] = $this->func->noPunct($spectacles->getContactsByRole($s['idspectacle'],18));
  77.                 $dvd['spectacles'][$s['idspectacle']]['producteurs_delegues'] = $this->func->noPunct($spectacles->getContactsByRole($s['idspectacle'],19));
  78.                 // recuperer la liste des autres postes (idrole=0 et type=1)
  79.                 $dvd['spectacles'][$s['idspectacle']]['others'] = $this->func->noPunct($spectacles->getPersonsByRole($s['idspectacle'],'distributions'));
  80.                 // autres roles
  81.                 $contents $this->em->getRepository(Contents::class);
  82.                 $others_distrib $contents->getAssociateContent($s['idspectacle'],'spectacles','class_distribution');
  83.                 if (!empty($others_distrib)) {
  84.                     $others_distrib['text'] = $contents->wikiTransform($others_distrib['text']);
  85.                     $others_distrib['text'] = preg_replace('#</?p>#i','',$others_distrib['text']);
  86.                     $dvd['spectacles'][$s['idspectacle']]['others_distrib'] = $others_distrib;
  87.                 }
  88.             }
  89.         }
  90.         // si URL de vente = copat
  91.         if (!empty($dvd['urlVente']) && strpos($dvd['urlVente'],'copat')!==false) {
  92.             $dvd['url_vente_copat'] = $dvd['urlVente'];
  93.             $dvd['url_vente_bis_copat'] = str_replace('copat.fr/''copat.fr/enseignement/'$dvd['urlVente']);
  94.         }
  95.         if (!empty($dvd['url_vente_bis']) && strpos($dvd['url_vente_bis'],'copat')!==false) {
  96.             $dvd['url_vente_bis_copat'] = $dvd['url_vente_bis'];
  97.         }
  98.         //setDebug($dvd);
  99.         // spectacle en premier dans les blocs
  100.         $this->view->first_spectacles true;
  101.         // meta keywords et comments
  102.         if (empty($meta_keywords)) $meta_keywords '';
  103.         // ajout des noms des auteurs et metteurs en scène aux keywords
  104.         foreach(array('authors''directors') as $field) {
  105.             if (!empty($dvd[$field])) {
  106.                 // ajout des auteurs aux keywords
  107.                 foreach($dvd[$field] as $k => $v) {
  108.                     $meta_keywords .= ' '.$v['lastname'];
  109.                 }
  110.             }
  111.         }
  112.         // ajout du lieu aux keywords
  113.         if (!empty($dvd['lieu_shooting'])) $meta_keywords .= ' '.$dvd['lieu_shooting'];
  114.         // ajout des titres de spectacles aux keywords
  115.         if (!empty($dvd['spectacles'])) {
  116.             foreach($dvd['spectacles'] as $k => $v) {
  117.                 $meta_keywords .= ' '.$v['title'];
  118.             }
  119.         }
  120.         // afficher les titres
  121.         $this->view->only_title true;
  122.         $this->view->dvd $dvd;
  123.         $title_page $dvd['title'];
  124.         // autres infos
  125.         $this->view->mtinfos = array('object' => 'dvds''idobject' => $iddvd'urifrom' => '/dvd/'.$dvd['urlClean'], 'info_rub' => 'ce DVD''special_pattern' => 'admin_barre');
  126.         // voir si l'objet est bookmarke
  127.         if ($this->context['session'] instanceof  Extranetusers){
  128.             $bookmark $this->em->getRepository(BookmarkExtranetuser::class);
  129.             if ($bookmark->isBookmark($iddvd,'dvds',$this->getUser()->getIdextranetuser())) {
  130.                 $this->view->is_bookmark true;
  131.             }
  132.         }
  133.         // action pour add/delete bookmark
  134.         if (isset($_GET['bookmark'])) {
  135.             $this->view->bookmark true;
  136.             $do_action $_GET['do_action'];
  137.             $this->view->$do_action true;
  138.             $this->view->fem='e';
  139.         }
  140.         //setDebug($this->view->dvd);
  141.         $this->asides->load('ajoutez_MT.inc');
  142.         $this->asides->load('dvd_thumbnail');
  143.         $this->context['view']->aside $this->asides->view();
  144.         // bouton de partage
  145.         $this->view->use_addthis true;
  146.         return $this->view('dvd/view.html.twig', [
  147.         ]);
  148.     }
  149. }