<?php
namespace App\Controller;
use App\ClassTheatre\asides;
use App\ClassTheatre\TheatreController;
use App\ClassTheatre\UtilsContacts;
use App\Exception\RedirectException;
use App\Service\Abonnements\Abonnements;
use App\Service\Date_time;
use App\Service\EditUtils;
use App\Service\Functions;
use App\Service\TheatreMail\TheatreMail;
use App\Service\UploadUtils;
use App\Service\UtilsEdit;
use App\Validator\CheckWebsite;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Url;
use TheatreCore\Classes\Constants\Constants;
use TheatreCore\Classes\Ecoles;
use TheatreCore\Classes\Images\Images;
use TheatreCore\Entity\Aidecontacts;
use TheatreCore\Entity\Aides;
use TheatreCore\Entity\BookmarkExtranetuser;
use TheatreCore\Entity\Classifications;
use TheatreCore\Entity\Contacts;
use TheatreCore\Entity\Contents;
use TheatreCore\Entity\Dvds;
use TheatreCore\Entity\Extranetusers;
use TheatreCore\Entity\Files;
use TheatreCore\Entity\Multimedias;
use TheatreCore\Entity\News;
use TheatreCore\Entity\ObjectMultimedia;
use TheatreCore\Entity\PersonEcole;
use TheatreCore\Entity\Persons;
use TheatreCore\Entity\Playlists;
use TheatreCore\Entity\Podcasts;
use TheatreCore\Entity\Regions;
use TheatreCore\Entity\Schedules;
use TheatreCore\Entity\Spectacles;
use TheatreCore\Entity\Stats;
use TheatreCore\Entity\Texts;
use TheatreCore\Entity\Typesstructures;
use TheatreCore\Form\Type\RelationsType;
class ContactController extends TheatreController
{
// id de l'objet
protected $idobject = null;
// objet
protected $obj = null;
// type d'objet
protected $type_object = 'contacts';
// object contents
protected $contents;
// object multimedias
protected $multimedias;
// infos sur l'objet
protected $infosobject = array();
// précision fil d'arianne
protected $locate = null;
// titre de la page
protected $title_page = null;
// meta keywords et meta description
protected $meta_keywords = '';
protected $meta_description = '';
// taille maxi des vidéos
protected $other_dimensions = array();
// infos pour mon théâtre
protected $mtinfos = array();
// pour le menu principal
protected $rub_courante = null;
// titre et localisation en plus
protected $extra_title = '';
protected $extra_locate = '';
// est-ce qu'on est sur la home ?
protected $is_accueil = false;
// les styles standard des blocs text et spectacle
protected $stylemore_spectacle = array('imagep' => 'width:80px;', 'descsp' => 'width:300px;');
protected $stylemore_text = array('imagep' => 'width:60px;', 'desctxt' => 'width:295px;');
// soutien JTN
protected $idclassification_soutien;
protected $ids_spectacle_in;
protected $ids_spectacle_prod;
protected $ids_spectacle_structures_diffusions;
protected $ids_spectacle_all;
protected $ids_spectacle_anciens;
protected $ids_spectacle_soutien;
protected $ids_spectacle_aide;
protected $ids_spectacle_laureats_nominations;
protected $ids_spectacle_soutiens;
protected $ids_spectacle_selections;
protected $ids_spectacle_publisher;
protected $ids_multimedia_in;
protected $ids_multimedia_prod;
protected $ids_multimedia_contact;
protected $ids_multimedia_all;
protected $nb_contact_recherche = 5;
public $format_vignette = array(
'stylemore' => array('imagep' => 'width:65px;', 'descsp' => 'width:330px;'),
'vignette' => array('width' => 65, 'height' => 65, 'direction' => 'crop')
);
protected $asides = "";
protected $serviceAbonnements;
private ?LoggerInterface $logger = null;
private $redirectedFrom = null;
private ?AdapterInterface $cache = null;
// {{{ _construct()
/** constructeur hérité
*
*/
public function __construct(
EntityManagerInterface $em,
TranslatorInterface $translator,
TokenStorageInterface $tokenStorage,
Functions $func,
Abonnements $abonnements,
LoggerInterface $logger,
AdapterInterface $cache
)
{
// load new aside
$this->asides = new asides();
$this->func = $func;
$this->serviceAbonnements = $abonnements;
$GLOBALS['rub_courante'] = 'contacts';
$GLOBALS['publish'] = 1;
$this->em = $em;
$this->logger = $logger;
$this->cache = $cache;
// hérite du constructeur parent
parent::__construct($translator, $tokenStorage);
}
public function InitController($slug = null, $action = null, $params_init = [])
{
$this->slug = $slug;
$this->view->action = $this->context['action'] = $action;
$this->RouterOptions($slug, $action, $GLOBALS['rub_courante']);
$this->view->controller = $GLOBALS['rub_courante'];
// charger swfobject
$this->context['view']->jquery_flash = true;
if (!empty($params_init['idcontact'])) {
$this->idobject = $this->id = (int)$params_init['idcontact'];
} else {
$this->context['params']['idcontact'] = $this->idobject = (int)$this->id;
}
// si idcontact n'existe pas, on renvoi sur une page d'erreur TODO
if (empty($this->id)) {
throw new RedirectException($this->context['url_module'] . '/erreur/');
}
// Classe principale (ici contact)
$this->obj = $this->em->getRepository('TheatreCore\\Entity\\' . ucfirst($this->type_object));
// Classe Contents
$this->contents = $this->em->getRepository(Contents::class);
// Classe Multimedias
$this->multimedias = $this->em->getRepository(Multimedias::class);
// status des contenus => publié
$this->contents->setPublishStatus($this->publish_status);
// on recupere l'enregistrement
$this->infosobject = $this->obj->getInfosContact($this->idobject, array('get_idtypestructure' => true));
if (($this->infosobject['idtypestructure'] == 'ED' || $this->infosobject['idtypestructure'] == 'RV') && empty($params_init)) {
throw new RedirectException('/editions/' . $this->infosobject['url_clean']);
}
// voir si c'est une école de théâtre
$ecoles_type = array('EC', 'LE', 'JT');
if (in_array($this->infosobject['idtypestructure'], $ecoles_type)) {
$this->context['view']->is_ecole = true;
}
// si JTN => class_spectacle_jtn => 103
if ($this->idobject == 3914) {
$this->context['view']->is_jtn = true;
$this->idclassification_soutien = 103;
}
// trouver le directeur actuel de la structure
$boss = $this->obj->getAssociatePersons($this->idobject, 1, false);
foreach ($boss as $k => $v) {
$date_current = new \Datetime(date('Y-m-d H:i:s'));
$date_current = $date_current->format('Y-m-d');
if ($v['date_start'] != '0000-00-00 00:00:00') {
$date_start = new \Datetime($v['date_start']);
$date_start = $date_start->format('Y-m-d');
if ($date_start > $date_current) {
unset($boss[$k]);
}
}
if ($v['date_end'] != '0000-00-00 00:00:00') {
$date_end = new \Datetime($v['date_end']);
$date_end = $date_end->format('Y-m-d');
if ($date_end < $date_current) {
unset($boss[$k]);
}
}
}
$this->infosobject['boss'] = $boss;
// tester si il y a un bandeau custom
$files = $this->em->getRepository(Files::class);
$files->setPublishStatus(1);
$this->context['view']->bandeau = $files->getObjectFiles($this->idobject, 'contacts', 100);
// tester si il y a une image de profile
$profilepicture = $this->obj->getVignetteContact($this->idobject, array('width' => 90, 'height' => 90), 'class_pp');
if (strpos($profilepicture, 'normal-def') === false) {
$this->context['view']->profilepicture = $profilepicture;
}
// si france
if ($this->infosobject['country'] != 'France') {
$this->infosobject['country_view'] = true;
}
// le nombre de spectacles
$this->infosobject['nb_spectacles'] = $this->countAllSpectacles();
// le nombre de vidéos
$this->infosobject['nb_multimedias'] = $this->countAllMultimedias();
// les critiques
$this->infosobject['nb_critiques'] = $this->countAllCritiques();
// url_folder
$this->infosobject['url_folder'] = '/' . $this->type_object . '/' . $this->infosobject['url_clean'];
// url du dossier
$this->url_folder = $this->infosobject['url_folder'];
// style
$this->style_more = array('rubrique', 'dossier', 'auteur', 'pageregion');
// seulement les données publiées
$GLOBALS['publish'] = 1;
/*
format orrect à remettre lors de la mis-en-production
public $format_vignette = array(
'stylemore' => array('imagep' => 'width:65px;', 'descsp' => 'width:330px;'),
'vignette' => array('width'=>100,'height'=>100,'direction'=>'crop')
);
*/
$this->format_vignette = array(
'vignette' => array('width' => 100, 'height' => 100, 'direction' => 'crop')
);
}
// }}}
// {{{ contenus()
/** Les articles associés aux object
*
*/
public function contenus_contact($type_class, $type_class_view, $other_dimensions = array('width' => 500, 'grow' => false))
{
parent::contenus($this->type_object, $this->idobject, $type_class, $type_class_view, $other_dimensions);
}
// }}}
// {{{ buildMenuAdmin()
/** Construit le menu admin
*
*
* @access protected
* @return void
*/
protected function buildMenuAdmin()
{
$menu_object['presentation-edit'] = array('nom' => 'Présentation', 'title' => 'Présentation de ' . $this->infosobject['fullname']);
$menu_object['infos-generales'] = array('nom' => 'Infos générales', 'title' => 'Infos générales de ' . $this->infosobject['fullname']);
// if(!empty($this->infosobject['is_partenaire'])) {
$menu_object['bandeau'] = array('nom' => 'Bandeau', 'title' => 'Bandeau de ' . $this->infosobject['fullname']);
// }
// TODO: a remettre pour la V3
// if(!empty($this->infosobject['stats_access'])) {
// $menu_object['stats'] = array('nom' => 'Stats spectacles', 'title' => 'Stats de '.$this->infosobject['fullname']);
// $menu_object['stats-videos'] = array('nom' => 'Stats vidéos', 'title' => 'Stats vidéos de '.$this->infosobject['fullname']);
// }
$menu_object['documents'] = array('nom' => 'Documents (PDF)', 'title' => 'Documents numérisés de ' . $this->infosobject['fullname']);
// si c'est une ecole => menu ecole JTN uniquement pour l'instant
if ($this->em->getRepository(PersonEcole::class)->countEleves($this->infosobject['idcontact']) > 0 && $this->infosobject['idcontact'] == 3914) {
$menu_object['eleves'] = array('nom' => 'Élèves', 'title' => 'Élèves de ' . $this->infosobject['fullname']);
}
// menu courant actif
$menu_object[$this->context['action']]['active'] = 'on';
if ($this->context['action'] == 'documents-edit' || $this->context['action'] == 'documents-delete') {
$menu_object['documents']['active'] = 'on';
}
$keys_menu_object = array_keys($menu_object);
$first = reset($keys_menu_object);
$menu_object[$first]['first'] = true;
// envoyer le menu
$this->view->menu_admin = $menu_object;
}
// }}}
// {{{ buildMenu()
/** Construit le menu et l'envoie à la vue
*
*
* @access protected
* @return void
*/
protected function buildMenu()
{
// le nombre de spectacles (ajoute spectacle à venir dans aside "voir")
// $this->infosobject['nb_spectacles'] = $this->countAllSpectacles();
// le nombre de vidéos
$this->infosobject['nb_multimedias'] = $this->countAllMultimedias();
// les critiques
$this->infosobject['nb_critiques'] = $this->countAllCritiques();
// url_folder
$this->infosobject['url_folder'] = '/' . $this->type_object . '/' . $this->infosobject['url_clean'];
// url du dossier
$this->url_folder = $this->infosobject['url_folder'];
// style
$this->style_more = array('rubrique', 'dossier', 'auteur', 'pageregion');
// seulement les données publiées
$GLOBALS['publish'] = 1;
$menu_object = array();
// accueil avec l'actualite
$menu_object['detail-contact'] = array('nom' => 'Actualité', 'title' => 'Actualités de ' . $this->infosobject['fullname']);
if ($this->contents->getAssociateContent($this->idobject, $this->type_object, 'class_presentation_structure')) {
$menu_object['presentation'] = array('nom' => 'En savoir +', 'title' => 'Présentation de ' . $this->infosobject['fullname']);
}
$res_class_articles = $this->contents->getAssociateContent($this->idobject, $this->type_object, 'class_article');
if (!is_null($res_class_articles) && count($res_class_articles) > 0) {
$menu_person['presentation'] = array('nom' => 'En savoir +', 'title' => 'Présentation de ' . $this->infosobject['fullname'], 'icone' => '111-user.png');
}
// presentation du contact
// voir si le contact est associé à un prix
$aides = $this->em->getRepository(Aides::class);
$params_sql_aides = array(
'special' => array(
'aides' => array(
'idcontacts' => $this->infosobject['idcontact'],
),
'type_aide' => 2, // Prix et distinctions
),
'dbg' => array('nombre_prix', 'Nombre de prix'),
);
$nb_laureats = $aides->countAides($params_sql_aides);
if ($nb_laureats > 0) {
$menu_object['laureats'] = array('nom' => 'Lauréats', 'title' => 'Lauréats de ' . $this->infosobject['fullname']);
}
$params_sql_aides['special']['type_aide'] = 3; // nominations
$params_sql_aides['dbg'] = array('nombre_nominations', 'Nombre de nominations');
$nb_nomination = $aides->countAides($params_sql_aides);
if ($nb_nomination > 0) {
$menu_object['nominations'] = array('nom' => 'Nominations', 'title' => 'Nominations de ' . $this->infosobject['fullname']);
}
//Si nous sommes sur France Culture
// || $this->context['view']->nb_spectacles_in_audio > 0 || $this->context['view']->nb_spectacles_anciens_audio > 0 || $this->context['view']->nb_spectacles_prod_audio > 0 || $this->context['view']->nb_spectacles_coprod_audio > 0
if ($this->idobject == 595 || $this->idobject == 5222) {
$menu_object['podcasts'] = array('nom' => html_entity_decode('Écouter'), 'title' => html_entity_decode('Écouter') . ' France Culture ' . $this->infosobject['fullname']);
}
$sql = 'SELECT COUNT(p.idplaylist)
FROM playlists p
LEFT JOIN playlist_classification pc ON p.idplaylist = pc.idplaylist
LEFT JOIN aides a ON a.idcontact=' . $this->infosobject['idcontact'] . '
LEFT JOIN text_aide ta ON a.`idaide`=ta.`idaide`
WHERE 1 AND a.`publish`=1 AND a.`type_aide` IN (2,3) AND pc.idclassification = 144 AND p.idtext = ta.idtext
GROUP BY p.idtext';
$nb_textes_auteurs = $this->obj->queryOne($sql);
if ($nb_textes_auteurs > 0) {
$menu_object['auteurs'] = array('nom' => 'Le texte par l\'auteur', 'title' => 'Le texte par leurs auteurs');
}
$params_sql_aides['special']['type_aide'] = 1; // soutiens
$params_sql_aides['dbg'] = array('nombre_soutiens', 'Nombre de soutiens');
$nb_soutien = $aides->countAides($params_sql_aides);
if ($nb_soutien > 0) {
$menu_object['soutiens'] = array('nom' => 'Soutiens', 'title' => 'Soutenus par ' . $this->infosobject['fullname']);
}
$params_sql_aides['special']['type_aide'] = 4; // sélection
$params_sql_aides['dbg'] = array('nombre_selections', 'Nombre de sélections');
$nb_selection = $aides->countAides($params_sql_aides);
if ($nb_selection > 0) {
$menu_object['selections'] = array('nom' => 'Sélections', 'title' => 'Sélectionnés par ' . $this->infosobject['fullname']);
}
// // ancien élèves si école
$ecoles_type = array('EC', 'LE', 'JT');
//
if (in_array($this->infosobject['idtypestructure'], $ecoles_type)) {
$person_ecole = $this->em->getRepository(PersonEcole::class);
$nb_eleves = $person_ecole->countEleves($this->infosobject['idcontact']);
if ($this->idobject == 3914) {
$label_etudiants = 'Artistes';
$label_anciens = 'Anciens artistes';
} else {
$label_etudiants = 'Étudiants';
$label_anciens = 'Anciens étudiants';
}
// trouver les étudiants en cours d'étude = étudiant sans date de fin ou date de fin > à la date du jour
if ($nb_eleves > 0) {
$menu_object['etudiants'] = array('nom' => $label_etudiants, 'title' => $label_etudiants . ' de ' . $this->infosobject['fullname']);
}
}
//Les prochains spectacles avec émissions associés
$totalProchainsSpectaclesPodcasts = 0;
if (in_array($this->idobject, [595, 5222])) {
$params_sql = array(
'special' => array(
'textfictif' => 0,
'plus_proche' => true,
'podcasts' => [
'type_podcast' => 'franceculture'
]
),
'dbg' => array('total_spectacles_emissions_associces', 'Total des spectacles avec textes non fictifs qui ont un podcast'),
);
$params_sql['special']['type_franceinter'] = null;
if ($this->idobject == 5222) {
$params_sql['special']['type_franceinter'] = 1;
}
$totalProchainsSpectaclesPodcasts = $this->em->getRepository(Spectacles::class)->countListSpectacles($params_sql);
}
// archives des spectacles
$nb_anciens = $nb_affiche = 0;
if ($this->infosobject['nb_spectacles'] > 0) {
if (empty($this->context['view']->nb_total_spectacle)) {
$this->action_spectacles(null, false);
}
$menu_object['spectacles'] = array(
'nom' => 'En scènes (' . $this->context['view']->nb_total_spectacle . ')',
'title' => 'Tous les spectacles de ' . $this->infosobject['fullname'],
'subaction' => array(
'en-scene' => 'soutiens en scène'
)
);
} else if ($nb_soutien > 0 || $nb_laureats > 0 || $nb_nomination > 0 || ($nb_affiche = $this->countEnScene(['affiche' => true])) || ($nb_anciens = $this->countEnScene(['anciens' => true])) || $totalProchainsSpectaclesPodcasts > 0) {
$menu_object['en-scene'] = array('nom' => 'En scène', 'title' => 'Les mises en scène autour de ' . $this->infosobject['fullname']);
}
// les spectacles à l'affiche avec des textes nonfictif
$this->context['view']->nb_en_scene = $this->em->getRepository(Spectacles::class)->countListSpectacles(array(
'special' => array(
'textfictif' => 0,
'aide' => array(
'idcontact' => $this->idobject,
),
'text_aide' => true,
),
'dbg' => array('menu_list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont reçu une aide'),
));
//$nb_selection == 0 &&
// if($nb_soutien==0 && $nb_laureats==0 && $nb_nomination==0 && $this->context['view']->nb_en_scene>0) {
// $menu_object['en-scene'] = array('nom' => 'En scène', 'title' => 'Tous les textes soutenus à l\'affiche de '.$this->infosobject['fullname']);
// }
// else {
// // pour en scène
// if($this->context['action']=='en-scene') {
// if(!empty($_SESSION['from_page_aide']) && !empty($menu_object[$_SESSION['from_page_aide']])) {
// $this->current = $menu_object[$_SESSION['from_page_aide']];
// $menu_object[$_SESSION['from_page_aide']]['active'] = 'on';
// }
// }
// // pour les auteurs
// else if($this->context['action']=='auteurs') {
// if(!empty($_SESSION['from_page_aide'])) {
// $this->current = $menu_object[$_SESSION['from_page_aide']];
// $menu_object[$_SESSION['from_page_aide']]['active'] = 'on';
// }
// }
// }
// TODO: Enlever à la release
// if(in_array($this->infosobject['idtypestructure'],$ecoles_type)) {
//
// if($nb_eleves_old>0) {
// $menu_object['anciens-etudiants'] = array('nom' => $label_anciens.' ('.$nb_eleves_old.')', 'title' => $label_anciens.' de '.$this->infosobject['fullname']);
// } else {
// $menu_object['anciens-etudiants'] = array('nom' => $label_anciens, 'title' => $label_anciens.' de '.$this->infosobject['fullname']);
// $this->context['view']->no_eleve = true;
// }
//
// // spectacles des élèves
// if($nb_eleves>0) {
// $menu_object['etudiants-spectacles'] = array('nom' => 'Anciens à l\'affiche', 'title' => $label_anciens.' de '.$this->infosobject['fullname']);
// }
// }
// 15621 = ministere de l'education
if (!empty($this->idobject) && $this->idobject == 15621) {
$menu_object['en-scene'] = array('nom' => 'en scène', 'title' => 'Tous les textes en scène de ' . $this->infosobject['fullname']);
unset($menu_object['spectacles']);
}
// évènements
$news = $this->em->getRepository(News::class);
$news_params = array(
'special' => array(
'by_object' => array('idcontact' => $this->idobject),
),
);
$countnews = $news->countNews($news_params);
// les critiques
if ($this->infosobject['nb_critiques'] > 0) {
$menu_object['critiques'] = array('nom' => 'Critiques (' . $this->infosobject['nb_critiques'] . ')', 'title' => 'Toutes les critiques des spectacles de ' . $this->infosobject['fullname']);
}
// 15621 = ministere de l'education
// if(!empty($this->idobject) && $this->idobject != 15621){
if ($countnews > 0) {
$menu_object['evenements'] = array('nom' => 'Évènements', 'title' => 'Évènements autour de ' . $this->infosobject['fullname'] . ' proposés par les internautes');
}
// }
// Y a t"il des vidéos
if ($this->infosobject['nb_multimedias'] > 0) {
$menu_object['videos'] = array('nom' => 'Vidéos (' . $this->infosobject['nb_multimedias'] . ')', 'title' => 'Vidéos de ' . $this->infosobject['fullname']);
} else {
$culturebox_params = array(
'special' => array(
'type_podcast' => 'culturebox', //commun
'is_integrale' => true, //commun
'idcontacts' => $this->idobject
),
'dbg' => array('culturebox_data', 'Les replay culturebox'),
);
$derniers_culturebox = $this->em->getRepository(Podcasts::class)->countListPodcasts($culturebox_params);
if ($derniers_culturebox) {
$menu_object['captations'] = array('nom' => 'Vidéos', 'title' => 'Vidéos de ' . $this->infosobject['fullname']);
}
}
// emmision ou podcast
$countecouter = $this->em->getRepository(Podcasts::class)->countPodcasts('spectacles', $this->ids_spectacle_all, 'franceinter', true);
$countPodcast = (int)$this->em->getRepository(Podcasts::class)->countPodcastsForContact($this->idobject);
if ($countecouter > 0) {
$menu_object['emissions'] = array('nom' => 'Audio', 'title' => 'Audio de ' . $this->infosobject['fullname']);
} else if ($countPodcast > 0) {
$menu_object['podcasts'] = array('nom' => 'Audio', 'title' => 'Audio de ' . $this->infosobject['fullname']);
}
// Y a t"il des contenus éduc
$nb_educ = $this->countAllEduc();
if ($nb_educ > 0) {
$menu_object['contenu-pedagogique'] = array('nom' => 'Éduc (' . $nb_educ . ')', 'title' => 'Contenus pédagogiques de ' . $this->infosobject['fullname']);
}
$this->context['view']->nb_files = $this->countTelechargements();
if ($this->context['view']->nb_files > 0) {
$menu_object['telechargements'] = array('nom' => html_entity_decode('<span class="tc-icon-download-outline"></span>'), 'oldnom' => 'DOC. NUMÉRISÉS', 'title' => 'Documents numérisés de ' . $this->infosobject['fullname']);
}
// menu courant actif
foreach ($menu_object as $kmenu => $vmenu) {
if ($kmenu == $this->context['action'] || !empty($vmenu['subaction'][$this->context['action']])) {
$menu_object[$kmenu]['active'] = 'on';
$this->current = $menu_object[$kmenu];
}
}
//Si nous sommes dans des captations
if ($this->context['action'] == 'captations' || $this->context['action'] == 'dvd') {
$menu_object['videos']['active'] = 'on';
$this->current = $menu_object['videos'];
}
// Audios actifs
if ($this->context['action'] == 'podcasts') {
$menu_object['emissions']['active'] = 'on';
$this->current = $menu_object['emissions'];
}
// anciens à l'affiche
if (in_array($this->context['action'], ['anciens-etudiants'])) {
$menu_object['etudiants']['active'] = 'on';
$this->current = $menu_object['etudiants'];
} else if (in_array($this->context['action'], ['etudiants-spectacles-tous', 'etudiants-spectacles', 'calendrier'])) {
$menu_object['spectacles']['active'] = 'on';
$this->current = $menu_object['spectacles'];
}
if ($this->context['action'] == 'telechargements') {
$menu_object['telechargements']['nom'] = html_entity_decode('<span class="tc-icon-download"></span>');
}
// ajoute la class
foreach ($menu_object as $k => $v) {
$menu_object[$k]['classcolor'] = ' menu_' . $k;
}
$key_menu_object = array_keys($menu_object);
$first = reset($key_menu_object);
$menu_object[$first]['first'] = true;
// envoyer le menu
$this->view->menu_object = $menu_object;
// retraiter le menu pour créer un sous menu étudiant
// if(!empty($menu_object['etudiants']) || !empty($menu_object['anciens-etudiants'])) {
// foreach($menu_object as $k=>$v) {
// $new_menu_object[$k] = $v;
// }
//
// if($this->context['action']=='etudiants-spectacles' || $this->context['action']=='etudiants' || $this->context['action']=='anciens-etudiants' || $this->context['action']=='etudiants-spectacles-tous') {
// $new_menu_object['ecoles']['active'] = 'on';
// $this->current = $new_menu_object['ecoles'];
// }
//
// $this->view->menu_object = $new_menu_object;
//
// }
}
// }}}
// {{{ finalizeAction()
/** Après l'action, construit le titre de page et le fil d'arianne
*
*
* @access protected
* @return void
*/
protected function finalizeAction()
{
$this->context['controller'] = 'contacts';
// construction du menu
$this->buildMenu();
// menu admin
$this->buildMenuAdmin();
if (!empty($this->extra_title)) {
$this->title_page .= $this->extra_title . ' - ' . $this->infosobject['fullname'];
} else if (!empty($this->current['title'])) {
$this->title_page .= $this->current['title'];
} else {
$this->title_page .= $this->infosobject['fullname'];
}
// titre de la page
$this->title_page .= ' - tous ses textes, mises en scène, activités';
// situation
$this->view->locate = array('/contacts/' => 'Contacts');
// rubrique (pour le menu principal)
$this->rub_courante = 'contacts';
// complément du fil d'arianne
if (empty($this->is_accueil)) {
if (empty($this->extra_locate) && !empty($this->current['nom'])) {
$this->extra_locate = $this->current['nom'];
}
// on ajoute la sous-rubrique actuelle
$this->view->locate[$this->infosobject['url_folder'] . '/'] = $this->infosobject['fullname'];
$this->view->locate[0] = $this->extra_locate;
} else {
// à l'accueil, on ne précise pas la sous-rubrique
$this->view->locate[0] = $this->infosobject['fullname'];
$this->view->is_accueil = true;
}
// envoi au template
$this->view->data_object = $this->infosobject;
// autres infos pour mon theatre
$mtinfos = array(
'object' => $this->type_object,
'idobject' => $this->idobject,
'urifrom' => '/' . $this->type_object . '/' . $this->infosobject['url_clean'] . '/',
'info_rub' => 'ce contact'
);
$this->view->mtinfos = $mtinfos;
// barre de modification
$this->view->barre_infos[] = array(
'url' => '/contacts/' . $this->infosobject['url_clean'] . '/infos-generales',
'title' => 'modifier ce contact',
'icone' => 'edit_icon',
);
$this->view->barre_infos[] = array(
'url' => '/contacts/' . $this->infosobject['url_clean'] . '/documents-edit',
'title' => 'ajouter un document PDF',
'icone' => 'addpdf_icon',
);
// voir si l'objet est bookmarke
$bookmark = $this->em->getRepository(BookmarkExtranetuser::class);
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')
&& $bookmark->isBookmark($this->idobject, 'contacts', $this->context['session']->getIdextranetuser())) {
$this->view->is_bookmark = true;
}
// action add/delete bookmark
if (isset($_GET['bookmark'])) {
$this->view->bookmark = true;
$do_action = $_GET['do_action'];
$this->view->$do_action = true;
}
if (empty($this->current['idcontent'])) {
$this->current['idcontent'] = null;
}
// statistique de visite
if (!empty($this->idobject) && !$this->no_stats) {
$statsinfos = array(
'type' => 'article',
'module' => $this->context['module'],
'url' => $_SERVER['REQUEST_URI'],
'idcontent' => (int)$this->current['idcontent'],
'object' => 'contacts',
'idobject' => $this->idobject,
'video' => (int)(!empty($this->view->detailarticle['display_media']))
);
$stats = $this->em->getRepository(Stats::class);
$stats->setStats($statsinfos, __FILE__ . ':' . __LINE__);
}
// pour les liens dans le template
$this->view->url_folder = $this->url_folder;
$this->context['view']->info_theatre = true;
// charge l'aside à la vue,
$this->view->aside = $this->asides->view($this->view);
$this->exports();
}
// }}}
// {{{ action_detail_contact()
/** Accueil de la page contact
*
* @Route("/contacts/{slug}/", name="contact_view")
* @Route("/contacts/{slug}/detail-contact/", name="contact_detail_contact")
*
**/
public function action_detail_contact(Request $request, $slug)
{
$this->InitController($slug, 'detail-contact');
$this->action_actualites($request);
// presentation "bio_txt"
$biotxt = $this->contents->getAssociateContent($this->idobject, $this->type_object, 'class_presentation_structure', array('wiki_convert' => true));
if (!empty($biotxt['text'])) {
if (strlen($biotxt['text']) > 351) {
$biotxt['text'] = substr($biotxt['text'], 0, 351);
$biotxt['text'] = strip_tags($biotxt['text'], '<a>');
$biotxt['text_strlen'] = true;
}
$this->view->biotxt = $biotxt;
// mots-clés et description
$this->func->makeMetaFromHtml($biotxt['text'], $this->meta_description, $this->meta_keywords);
}
foreach ($this->context['view']->spectacles_affiche as $k => $v) {
$this->context['view']->spectacles_affiche[$k]['footer_date'] = true;
}
foreach ($this->context['view']->spectacles_derniers as $k => $v) {
$this->context['view']->spectacles_derniers[$k]['no_date'] = true;
$this->context['view']->spectacles_derniers[$k]['footer_date'] = true;
}
foreach ($this->context['view']->spectacles_prod as $k => $v) {
$this->context['view']->spectacles_prod[$k]['footer_contact'] = true;
}
foreach ($this->context['view']->spectacles_prod_derniers as $k => $v) {
$this->context['view']->spectacles_prod_derniers[$k]['footer_contact'] = true;
}
$schedules = $this->em->getRepository(Schedules::class);
$ids_spectacle_in = $this->obj->getSpectaclesIn($this->idobject);
$ids_spectacle_structures_diffusions = $this->obj->getSpectaclesProd($this->idobject, false, null, 77);
$ids_spectacles = array_merge($ids_spectacle_in, $ids_spectacle_structures_diffusions);
if (!empty($ids_spectacles)) {
$biographies_dates_demains = $schedules->getDateBySpectaclesDemain($ids_spectacles, 3, null, 'old', ['idcontact' => $this->idobject]);
$biographies_dates_demains_reconstruction = array();
foreach ($biographies_dates_demains as $k => $v) {
$date_month = $schedules->getFormeDate($k, "%B %Y", true);
$date_month_hastag = $schedules->getFormeDate($k, "%B_%Y", true);
$biographies_dates_demains_reconstruction[$date_month_hastag]['datas'][$k] = $v;
foreach ($biographies_dates_demains_reconstruction[$date_month_hastag]['datas'][$k]['datas'] as $idata => $data) {
$biographies_dates_demains_reconstruction[$date_month_hastag]['datas'][$k]['datas'][$idata]['spectacle'] = $this->em->getRepository(Spectacles::class)->getInfosSpectacle($data['idspectacle'], ['get_vignette' => true]);
}
}
$this->context['view']->asides_prochaines_representations = $biographies_dates_demains_reconstruction;
}
// $t = "text";
// $params_sql_aidecontact = array(
// 'special' => array(
// 'object' => $t,
// 'aides' => array(
// //'idcontacts' => $this->idobject,
// 'no_empty' => true,
// 'type_aides' => array(3),
// ),
// ),
// 'limit' => array(0,100),
// 'dbg' => array('list_aidecontacts_'.$t,'Liste des catégories d\'aide pour '.$t),
// );
// $aidecontacts = Theatre::factory('aidecontacts');
// $this->context['view']->list_aidecontacts = $aidecontacts->getListAidecontacts($params_sql_aidecontact);
// print_r($this->context['view']->list_aidecontacts);
//derniers lauréats
$this->getContactAides(array(2), array('vignette_video' => false, 'limit' => array(0, 2), 'no_year_array' => true));
if (!empty($this->view->list_aides_text)) {
$this->view->list_derniers_laureats = $this->view->list_aides_text;
// unset($this->view->list_aides_text);
//
// foreach($list_aides_text AS $idcontent => $value){
// $this->context['view']->list_aides_text[$idcontent] = $value;
// }
}
//Spectacles soutenus par "nom de l'école" à l'affiche
$params_sql = array(
'params' => array(
'where' => ' s.publish=1 ',
'limit' => array(0, 4),
'order' => ['sad.dateStart', 'DESC']
),
'special' => array(
// 'plus_proche' => true,
// avec une aides
'spectacle_aide' => true,
'aide' => array(
'idcontact' => $this->idobject,
'type_aide' => [1] //Les spectacles sélectionnés
)
),
'dbg' => array('aide', 'Les spectacles avec une aide du contact'),
);
unset($params_sql['special']['prochains']);
unset($params_sql['special']['plus_proche']);
$spectacles_soutenus_ecoles = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, ['display' => ['affiche_date_creation' => true]], false, ['allauthors' => true]);
foreach ($spectacles_soutenus_ecoles as $ks => $value_spectacle) {
$spectacles_soutenus_ecoles[$ks]['annee_creation'] = $this->em->getRepository(Spectacles::class)->getFormeDate($spectacles_soutenus_ecoles[$ks]['creation_date'], '%Y', true); //%a %d/%m/%Y;
unset($spectacles_soutenus_ecoles[$ks]['contact_creation']);
}
$this->view->list_spectacles_sountenu_par_ecole = $spectacles_soutenus_ecoles;
unset($params_sql['params']['order']);
$params_sql['special']['plus_proche'] = true;
$params_sql['special']['prochains'] = true;
$this->view->list_spectacles_sountenu_prochains = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, null, false, ['allauthors' => true, 'carrer_couleurs' => true]);
foreach ($this->view->list_spectacles_sountenu_prochains as $ks => $v) {
$this->view->list_spectacles_sountenu_prochains[$ks]['footer_contact'] = true;
}
//Les spectacles soutenus
$params_sql['params']['order'] = ['sad.dateStart', 'DESC'];
unset($params_sql['special']['prochains']);
unset($params_sql['special']['plus_proche']);
$params_sql['special']['aide']['type_aide'] = [4];
$spectacles_selectionnes_ecoles = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, ['display' => ['affiche_date_creation' => true]], false, ['allauthors' => true, 'carrer_couleurs' => true]);
foreach ($spectacles_selectionnes_ecoles as $ks => $value_spectacle) {
$spectacles_selectionnes_ecoles[$ks]['annee_creation'] = $this->em->getRepository(Spectacles::class)->getFormeDate($spectacles_selectionnes_ecoles[$ks]['creation_date'], '%Y', true); //%a %d/%m/%Y;
unset($spectacles_selectionnes_ecoles[$ks]['contact_creation']);
}
$this->view->list_spectacles_selectionnes_par_ecole = $spectacles_selectionnes_ecoles;
unset($params_sql['params']['order']);
$params_sql['special']['plus_proche'] = true;
$params_sql['special']['prochains'] = true;
$this->view->list_spectacles_selectionne_prochains = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, null, false, ['allauthors' => true, 'carrer_couleurs' => true]);
foreach ($this->view->list_spectacles_selectionne_prochains as $ks => $v) {
$this->view->list_spectacles_selectionne_prochains[$ks]['footer_contact'] = true;
}
$this->getContactAides(array(2, 3), ['limit' => [0, 2], 'no_year_array' => true]);
if (!empty($this->context['view']->list_aides_text)) {
$this->context['view']->textes_nommes = $this->context['view']->list_aides_text;
$this->context['view']->list_aides_text = null;
}
// if(!$this->context['view']->is_prix){
$this->getContactAides(array(4), ['limit' => [0, 2], 'no_year_array' => true]);
if (!empty($this->context['view']->list_aides_text)) {
$this->context['view']->textes_selectionnes = $this->context['view']->list_aides_text;
$this->context['view']->list_aides_text = null;
}
$this->getContactAides(array(1), ['limit' => [0, 2], 'no_year_array' => true]);
if (!empty($this->context['view']->list_aides_text)) {
$this->context['view']->textes_soutenus = $this->context['view']->list_aides_text;
$this->context['view']->list_aides_text = null;
}
$spectacles = $this->em->getRepository(Spectacles::class);
if (in_array($this->idobject, [595, 5222])) {
//Les spectacles à l'affiche avec podcasts audio France Culture
$params_sql = array(
'special' => array(
'textfictif' => 0,
'prochains' => true,
'podcasts' => [
'type_podcast' => 'franceculture'
]
),
'params' => [
'limit' => [0, 4]
],
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont un podcast'),
);
$params_sql['special']['type_franceinter'] = null;
if ($this->idobject == 5222) {
$params_sql['special']['type_franceinter'] = 1;
}
//Les derniers spectacles en lien avec France Radio
$this->context['view']->spectacles_podcasts = $spectacles->getListSpectacles($params_sql, null, false, ['carrer_couleurs' => true]);
} else {
//Les spectacles à l'affiche avec podcasts audio France Culture
$params_sql = array(
'special' => array(
'textfictif' => 0,
'prochains' => true,
'podcasts' => [
'type_podcast' => 'franceculture',
],
'idcontact' => $this->idobject,
),
'params' => [
'where' => ' AND s.publish=1 AND ' . $this->getWhereIdcontact(),
'limit' => [0, 2]
],
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont un podcast'),
);
//Les derniers spectacles en lien avec France Radio
$this->context['view']->spectacles_emission = $spectacles->getListSpectacles($params_sql, null, false, ['carrer_couleurs' => true]);
}
//Les anciens étudiants à l'affiche
$list_idpersons = $this->em->getRepository(PersonEcole::class)->getPersons($this->idobject, array('get_ids' => true));
if (!empty($list_idpersons)) {
$where_idperson = 'sp.`idperson` IN (' . join(',', $list_idpersons) . ') ';
$params_sql = array(
'params' => array(
'where' => ' AND (' . $where_idperson . ') ',
'limit' => array(0, 4),
),
'special' => array(
'prochains' => true,
// les élèves du contact
'get_eleves' => array(
'idcontact' => $this->idobject,
),
),
'dbg' => array('scenes', 'Les spectacles à l\'affiche'),
);
//On récupère la listes
$this->context['view']->spectacles_anciens_etudiants_affiches = $spectacles->getListSpectacles($params_sql, null, false, ['allauthors' => true]);
}
$this->context['view']->show_prix = false;
//Aside spécifique à théâtre en acte
if ($this->infosobject['idcontact'] == 28366) {
$this->asides->load('educ_canope_enacte');
$this->asides->load('educ_lettre_info');
}
$this->asides->load('contact_adresse');
$this->asides->load('contact_calendrier');
$this->asides->load('contact_telecharge_pdf');
//Uniquement pour les contacts écoles
if ($this->infosobject['idtypestructure'] == 'EC') {
$this->asides->load('ecoles_generic');
}
$this->asides->load('common_prochain_evenement');
$this->asides->load(['common_culturebox' => [
'footer_custom' => true
]]);
// $this->asides->load('contact_franceculture');
// $this->asides->load('contact_maj');
$this->asides->load('common_carrer_informations');
$this->asides->load('common_participer_contacts');
if (!empty($this->infosobject['facebook'])) {
$this->asides->load(['common_facebook' => array(
'url_custom' => $this->infosobject['facebook']
)]);
}
if (!empty($this->infosobject['twitter'])) {
$this->asides->load(['common_twitter' => array(
'url_custom' => $this->infosobject['twitter']
)]);
}
return $this->view('contacts/detail-contact.html.twig');
}
// }}}
// {{{ action_actualites()
/** Actualites du contact (première page)
*
*/
public function action_actualites(Request $request)
{
// indique que l'on est sur la page d'acceuil
$this->view->is_accueil = true;
$aides = $this->em->getRepository(Aides::class);
$multimedias = $this->em->getRepository(Multimedias::class);
$spectacles = $this->em->getRepository(Spectacles::class);
$params_display_text = array(
'vignette_format' => array('width' => $_ENV['VIGN_TEXT_WIDTH'], 'height' => $_ENV['VIGN_TEXT_HEIGHT'], 'direction' => 'thumb'),
'hide_publishing_date' => true,
);
$limit_spectacle_a_laffiche = 6;
$limit_critiques_accueil = 4;
$limit_en_tournee_spectacles = 4;
$limit_derniers_programmes = 4;
$this->context['view']->is_aides = true;
// les textes lauréats et nominés à l'affiche
$params_sql_spectacle_text_aide = array(
'special' => array(
'prochains' => 180,
'aide' => array(
'idcontact' => $this->idobject,
'type_aide' => array(2, 3), // lauréats et nominés
),
'text_aide' => true,
),
'params' => array(
'limit' => array(0, 5),
),
'dbg' => array('text_aide_spectacle_laureats_nominations', 'Les textes lauréats ou nominés'),
);
// quand on demande le texte, demander également l'aide pour le contact
$params_sql_text_aides = array(
'get_aides' => array(
'special' => array(
'aides' => array(
'idcontacts' => array($this->idobject),
)
),
)
);
/*
* Textes
* LAURÉATS OU NOMINÉS À L'AFFICHE
*
*/
$params_sql_spectacle_text_aide['spectacle']['aide']['type_aide'] = array(2);
$params_sql_spectacle_text_aide['params']['limit'] = array(0, 2);
$this->context['view']->aides_texts_laureats_alone_affiche = $this->em->getRepository(Texts::class)->getTextsFromSpectacles(
$this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql_spectacle_text_aide, array(), false, array('allauthors' => true, 'carrer_couleurs' => true)), // texts à l'affiche avec une aide de ce contact
$params_sql_text_aides, // quelles aides ?
$params_display_text // affichage texte
);
/*
* Textes
* soutenus à l'affiche
*
*/
unset($params_sql_spectacle_text_aide['spectacle']);
$params_sql_spectacle_text_aide['special']['aide']['type_aide'] = array(1); //soutenu
$params_sql_spectacle_text_aide['special']['aide']['dbg'] = array('text_aide_spectacle_soutiens', 'Les textes avec un soutien/aide');
$params_sql_spectacle_text_aide['params']['limit'] = array(0, 4);
$this->context['view']->aides_texts_soutiens_affiche = $this->em->getRepository(Texts::class)->getTextsFromSpectacles(
$this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql_spectacle_text_aide, array(), false, ['carrer_couleurs' => true]), // texts à l'affiche avec une aide de ce contact
$params_sql_text_aides, // quelles aides ?
$params_display_text // affichage texte
);
/*
* Textes
* sélectionnés à l'affiche
*/
$params_sql_spectacle_text_aide['special']['aide']['type_aide'] = array(4); //sélectionné
$params_sql_spectacle_text_aide['special']['aide']['dbg'] = array('text_aide_spectacle_selections', 'Les textes avec un selections/aide');
$params_sql_spectacle_text_aide['params']['limit'] = array(0, 4);
$this->context['view']->textes_selections_affiches = $this->em->getRepository(Texts::class)->getTextsFromSpectacles(
$this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql_spectacle_text_aide, array(), false, ['carrer_couleurs' => true]), // texts à l'affiche avec une aide de ce contact
$params_sql_text_aides, // quelles aides ?
$params_display_text // affichage texte
);
/*
* @spectacles
* lauréats ou nominés à l'affiche
*/
$params_sql_spectacle_aide = array(
'special' => array(
'prochains' => 180,
'aide' => array(
'idcontact' => $this->idobject,
'type_aide' => array(2, 3), // lauréats ou nominés
),
'spectacle_aide' => true,
),
'dbg' => array('aides_spectacles_laureats_affiche', 'Les spectacles avec laureats à l\'affiche'),
);
$this->context['view']->aides_spectacles_laureats_affiche = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql_spectacle_aide, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
// les spectacles lauréats ou nominés à l'affiche
// $this->getContactAides(2, ['limit' => [0, 2]]);
/*
* Programme de saison
*/
$this->context['view']->booklets = $this->em->getRepository(Files::class)->getBookletsCurrent($this->idobject, true);
/*
* Les évènements
*/
$news = $this->em->getRepository(News::class);
$news_params = array(
'params' => array(
'limit' => array(0, 5),
),
'special' => array(
'publish_valid' => true,
'no_schedule_contact' => true,
'by_object' => array('idcontact' => $this->idobject),
),
);
// trouver 7 prochains évènements
// si pas de 7 prochains, trouver 7 anciens
foreach (array('news') as $t) {
$news_list = array();
$count_total = 0;
$news_params['special']['type_news'] = $t;
foreach (array('prochains', 'anciens') as $d) {
$news_params['dbg'] = array('news_' . $d, 'Liste des news ' . $d);
$news_params['special'][$d] = true;
if (!empty($exclude_news)) {
$news_params['params']['where'] = ' AND T1.idnew NOT IN (' . join(',', $exclude_news) . ') ';
}
$news_params['params']['limit'] = array(0, 5 - $count_total);
$news_list[$d] = $news->getListNews($news_params);
if (!empty($news_list[$d])) {
$count_total = $total_prochains_evements = count($news_list[$d]);;
// liste d'exclusion => pas de en cours dans les anciens
foreach ($news_list[$d] as $k => $v) {
$exclude_news[$k] = $v['idnew'];
}
$this->view->{'is_news_list_' . $t} = true;
}
unset($news_params['special'][$d]);
}
$this->view->{'news_list_' . $t} = $news_list;
}
$exclude = null;
$exclude_tab = array();
/*
* Les critiques
*/
// trouver les contenus associés 101 et les classer par date
$params_sql = array(
'special' => array(
'get_critiques_idcontact' => $this->idobject,
'get_extranetuser' => true, // on veut l'utilisateur
'publish' => 1, // les critiques publiées
),
'sql' => array(
'limit' => array(0, $limit_critiques_accueil),
'order' => ' ct.`date_article` DESC', // classement
),
'dbg' => array('critiques', 'Liste des critiques'),
);
$cacheItem = $this->cache->getItem("contact_actualites_get_critiques_{$this->idobject}");
if (! $cacheItem->isHit()) {
$result = $this->em->getRepository(Contents::class)->getListContents($params_sql, array('get_critiques' => true));
$cacheItem->set($result)
->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
$this->cache->save($cacheItem);
}
$this->context['view']->dernieres_critiques = $cacheItem->get();
// un objet spectacles
$spectacles = $this->em->getRepository(Spectacles::class);
// recherche sur le contact
$where_idcontact = ' AND ' . $this->getWhereIdcontact();
/*
* Spectacles
* Prochains spectacles
* réalisés avec le soutien de contact
*
*/
$params_sql_affiche = array(
'params' => array(
'where' => $where_idcontact . ' AND s.publish=1 ',
'limit' => array(0, $limit_spectacle_a_laffiche),
),
'special' => array(
'prochains' => 500,
'idcontact' => $this->idobject,
),
'dbg' => array('spectacles_affiche', 'Les prochains spectacles à l\'affiche'),
);
// cas festival
if (!empty($this->infosobject['is_festival'])) {
$params_sql_affiche['special']['type_contact'] = 'idcontactFestival';
}
// spectacles de ce contact à l'affiche en ce moment (180 jours) => recherche sur le calendrier
$spectacles_affiche = $spectacles->getListSpectacles($params_sql_affiche, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
foreach ($spectacles_affiche as $k => $v) {
$spectacles_affiche[$k]['no_date'] = true;
if (!empty($v['city'])) {
unset($spectacles_affiche[$k]['city']);
}
if (!empty($v['periode']['city'])) {
unset($spectacles_affiche[$k]['periode']['city']);
}
}
//$spectacles->getSQLSpectacles($params_sql_affiche['params'],$params_sql_affiche['special'],false);
$this->view->spectacles_affiche = $spectacles_affiche;
// a exclure à la fin
if (!empty($spectacles_affiche)) {
$exclude_tab = $this->func->getExclude($spectacles_affiche);
}
if (!empty($exclude_tab)) {
$exclude = ' NOT IN (' . implode(',', $exclude_tab) . ')';
} else {
$exclude = null;
}
/*
* #Productteur (17), coprod (18), prod délégué (19). Recherche sur spectacle_contact+idrole
* En scène
* Prochains spectacles
* réalisés avec le soutien de contact
*
* prochains spectacles coproduit PAR ce lieu mais pas dans ce lieu puisque en tournée
*
*/
// TODO à réintégrer pour la release
$params_sql_and_exclude = '';
if (!is_null($exclude)) {
$params_sql_and_exclude .= ' AND s.idspectacle ' . $exclude;
}
$params_sql_prod = array(
'params' => array(
'from' => ['SpectacleContact sc_relation' => 'sc_relation.idspectacle=s.idspectacle'],
'where' => ' AND s.publish=1 AND sc_relation.idrole IN (17,18,19) AND sc_relation.idcontact=' . $this->idobject . $params_sql_and_exclude,
'groupby' => 's.idspectacle',
'select' => 'contacts.idcontact as datecontact',
'limit' => array(0, $limit_en_tournee_spectacles),
),
'special' => array(
'prochains' => 500,
// exclure les spectacles qui sont dans le lieu
'from_schedules' => 'SELECT idcontact,idspectacle,date FROM schedules WHERE idcontact!=' . $this->idobject . ' AND date>=\'' . date('Y-m-d') . '\' ',
),
'dbg' => array('spectacles_prod', 'Les spectacles coproduits')
);
$spectacles_prod = $this->view->spectacles_prod = $spectacles->getListSpectacles($params_sql_prod, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
$exclude_prod_tab = $this->func->getExclude($spectacles_prod);
// TODO FIN DU --
// liste d'exclusion
if (!empty($exclude_prod_tab)) {
$exclude_prod = ' NOT IN (' . implode(',', $exclude_prod_tab) . ')';
} else {
$exclude_prod = null;
}
// suite exclusion
if (!empty($spectacles_prod)) {
$exclude_tab = array_merge($exclude_prod_tab, $exclude_tab);
}
if (!empty($exclude_tab)) {
$exclude = ' NOT IN (' . implode(',', $exclude_tab) . ')';
} else {
$exclude = null;
}
/*
* #derniers spectacles (exclusion de à l'affiche) => recherche sur le calendrier
* Spectacles
* Derniers spectacles programmés
*
*/
$params_sql_derniers = array(
'params' => array(
'limit' => array(0, $limit_derniers_programmes),
'where' => $where_idcontact . ' AND s.publish=1 ', //AND s.idspectacle '.$exclude,
'select' => 'contacts.idcontact as datecontact',
),
'special' => array(
'anciens_stricts' => true,
'count_in_spectacle_anciens' => true,
// 'idcontact' => $this->idobject,
)
);
$spectacles_derniers = $spectacles->getListSpectacles($params_sql_derniers, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
$this->view->spectacles_derniers = $spectacles_derniers;
// suite exclusion
if (!empty($spectacles_derniers)) {
$exclude_tab = array_merge($this->func->getExclude($this->view->spectacles_derniers), $exclude_tab);
}
// nb de spectacle
$nb_spectacles = count($spectacles_derniers) + count($spectacles_affiche);
$this->view->nb_spectacles = $nb_spectacles;
// derniers spectacles coproduits
$where_sql_prod_derniers = ' AND s.publish=1
AND (sc_relation.idrole IN (17,18,19) AND sc_relation.idcontact=' . $this->idobject . ')';
if (!is_null($exclude_prod)) {
$where_sql_prod_derniers .= ' AND s.idspectacle ' . $exclude_prod;
}
$params_sql_prod_derniers = array(
'params' => array(
'from' => ['SpectacleContact sc_relation' => 'sc_relation.idspectacle=s.idspectacle'],
'where' => $where_sql_prod_derniers,
'limit' => array(0, $limit_en_tournee_spectacles),
'select' => 'contacts.idcontact as datecontact',
),
'special' => array(
'anciens' => 'all',
),
'dbg' => array('spectacles_prod_derniers', 'Les derniers spectacles coproduits')
);
$spectacles_prod_derniers = $spectacles->getListSpectacles($params_sql_prod_derniers, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
$this->view->spectacles_prod_derniers = $spectacles_prod_derniers;
$nb_spectacles_prod = count($spectacles_prod);
$this->view->nb_spectacles_prod = $nb_spectacles_prod;
// derniers spectacles coproduits
$where_sql_par_role_diffuseurs = ' AND s.publish=1 AND (sc_relation.idrole IN (77) AND sc_relation.idcontact=' . $this->idobject . ')';
$params_sql_par_role_diffuseurs = array(
'params' => array(
'from' => ['SpectacleContact sc_relation' => 'sc_relation.idspectacle=s.idspectacle'],
'where' => $where_sql_par_role_diffuseurs,
'limit' => array(0, $limit_en_tournee_spectacles),
'select' => 'contacts.idcontact as datecontact',
),
'special' => array(
'anciens' => 'all',
),
'dbg' => array('spectacles_par_role_diffuseurs', 'Les derniers spectacles coproduits')
);
$spectacles_par_role_diffuseurs = $spectacles->getListSpectacles($params_sql_par_role_diffuseurs, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
$this->view->spectacles_par_role_diffuseurs = $spectacles_par_role_diffuseurs;
// nombre total de spectacles/videos/coprod
$nb_total = $nb_spectacles + $nb_spectacles_prod;
$this->view->nb_total = $nb_total;
// suite exclusion
if (!empty($spectacles_prod_derniers)) {
$exclude_tab = array_merge($this->func->getExclude($spectacles_prod_derniers), $exclude_tab);
}
//$this->view->debug_view = $spectacles->getDebugView(true);
// liste d'exclusion
$excluded = '';
if (!empty($exclude_tab)) {
$exclude_final = ' AND s.idspectacle NOT IN (' . implode(',', $exclude_tab) . ')';
$excluded = 'excluded_' . implode('-', $exclude_tab);
} else {
$exclude_final = null;
}
$cacheItem = $this->cache->getItem("contact_actualites_count_nb_autres_{$this->idobject}_$excluded");
if (! $cacheItem->isHit()) {
$sql_count_autres = 'SELECT COUNT(DISTINCT(sct.idspectacle))
FROM spectacles s
INNER JOIN spectacle_contact sct ON sct.idspectacle = s.idspectacle
INNER JOIN schedules sc ON sc.idspectacle = s.idspectacle
WHERE (
(sct.idrole IN (17,18,19) AND sct.idcontact=' . $this->idobject . ')
OR (sc.idcontact=' . $this->idobject . ')
) ' . $exclude_final;
// nb
$nb_autres = $spectacles->queryOne($sql_count_autres);
$cacheItem->set($nb_autres)
->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
$this->cache->save($cacheItem);
}
$this->view->nb_autres = $cacheItem->get();
// voir si il y a d'autres spectacles
if (!empty($this->infosobject['idmultimedia'])) {
$params = array(
'idmultimedia' => $this->infosobject['idmultimedia']
);
$this->view->video_tete = $multimedias->getInfosVideoTete($params, false, array('width' => '415', 'height' => '345'));
}
if (!empty($this->view->video_tete)) {
// voir s'il y a une vidéo à l'affiche, sinon, dernière vidéo à l'affiche
$params_sql_videos = array(
'params' => array(
'limit' => array(0, 1),
'where' => $where_idcontact . ' AND s.publish=1 ',
'select' => 'contacts.idcontact as datecontact',
'groupby' => ' om.idmultimedia ',
),
'special' => array(
'multimedias_videos_associes' => 'all', //multimedias_videos_associes
'prochains' => true,
//'tri_plus_proches' => true, // NE FONCTIONNE PAS
),
'dbg' => array('videos_recentes', 'Lesvidéos récentes')
);
$videos_contact = $spectacles->getListSpectacles($params_sql_videos, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
// voir s'il y a une vidéo à l'affiche, sinon, dernière vidéo à l'affiche
if (empty($videos_contact)) {
unset($params_sql_videos['special']['prochains']);
$params_sql_videos['special']['anciens'] = true;
$videos_contact = $spectacles->getListSpectacles($params_sql_videos, $this->format_vignette, false, array('allauthors' => true, 'carrer_couleurs' => true));
}
foreach ($videos_contact as $v) {
$this->view->video_tete = $multimedias->getInfosVideoTete($v, false, array('width' => '415', 'height' => '345'));
break;
}
if (isset($this->view->video_tete['media'][0])) {
$request->getSession()->set('currentVideo', md5($this->view->video_tete['media'][0]['idmultimedia']));
}
}
// TODO FIN DU --
//Les vidéos en partenartiat
$params_query_commun = array(
'object' => array($this->idobject => ['contacts']),
'where' => array(array('multimedias', 'audio_video', 2)),
'order' => array('multimedias.date'),
'limit' => array(0, 4),
'dbg' => array('last_listes', 'Vidéo en partenariat du contact - liste des multimedias'),
);
$params_videos = array(
'alldata' => true,
'display' => array(
'no_footer' => true,
'videos_169_format' => true
)
);
$this->view->videos_last_publish = $this->em->getRepository(Multimedias::class)->getListMultimedias($params_query_commun, array(), $params_videos);
// Podcast franceculture culturebox => les derniers référencés
$podcasts = $this->em->getRepository(Podcasts::class);
if (in_array($this->idobject, [595, 5222])) {
$franceculture_params = array(
'limit' => array(0, 3),
'special' => array(
'type_podcast' => 'franceculture',
'type_franceinter' => null
),
'dbg' => array('derniers_franceculture', 'Les trois derniers podcasts france radio référencés'),
);
if ($this->idobject == 5222) {
$franceculture_params['special']['type_franceinter'] = 1;
}
$api_derniers_franceculture = $podcasts->getListPodcasts($franceculture_params);
foreach ($api_derniers_franceculture as $k => $v) {
$currentDate = $v['datePodcast']->format('Y-m-d h:i');
if (empty($derniers_franceculture[$currentDate])) {
$derniers_franceculture[$currentDate]['date'] = $podcasts->getFormeDate($currentDate, '%a %d %B %Y', true); //%a %d/%m/%Y
}
$derniers_franceculture[$currentDate]['datas'][] = $v;
}
$this->context['view']->podcasts_par_date = $derniers_franceculture;
} else {
// franceculture
$franceculture_params = array(
'limit' => array(0, 7),
'special' => array(
'idcontacts' => array('idcontact' => $this->idobject),
'type_podcast' => 'franceculture',
),
'dbg' => array('derniers_franceculture', 'Les derniers podcasts franceculture référencés pour le contact'),
);
$this->context['view']->derniers_franceculture = $podcasts->getListPodcasts($franceculture_params);
}
// Culturebox => les derniers référencés
$culturebox_params = array(
'limit' => array(0, 1),
'special' => array(
'idcontacts' => array('idcontact' => $this->idobject),
'type_podcast' => 'culturebox',
),
'dbg' => array('derniers_culturebox', 'Les derniers replay culturebox référencés'),
);
$format_vignette = array('width' => 480, 'direction' => 'thumb');
$this->context['view']->derniers_culturebox = $podcasts->getListPodcasts($culturebox_params, $format_vignette);
//Prochains spectacles avec vidéos à l'affiche
$params_sql = array(
'special' => array(
// 'plus_proche' => true,
'prochains' => true, //prochains
'multimedias_videos_associes' => true //Avec vidéos
),
'params' => array(
'limit' => array(0, 20),
'where' => ' AND s.publish=1 AND ' . $this->getWhereIdcontact()
),
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont reçu une aide'),
);
$list_spectacles_videos = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql);
$this->view->spectacles_nocity = true;
$this->view->contactsvideos = true;
$format_vignette = array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none', 'ratio' => '169');
foreach ($list_spectacles_videos as $idspectacle => $spectacle) {
// not working because of doctrine join table with no condition (object = spectacle)
// $idmultimedia = $spectacle['idmultimedia'];
$sql = "SELECT DISTINCT om.idmultimedia
FROM object_multimedia om
WHERE om.idobject = $idspectacle AND object like 'spectacles'
LIMIT 1";
$spectacle['idmultimedia'] = $idmultimedia = $this->em->getRepository(Multimedias::class)->queryOne($sql, array(), null, true);
$nb_multimedias = $multimedias->getMultimediasBy('spectacles', $spectacle['idspectacle'], null, 'count');
if ($nb_multimedias > 0) {
$multimedia_listes[$idmultimedia] = $this->em->getRepository(Multimedias::class)->getInfosMultimedia($idmultimedia, true, false, array('vignette' => $format_vignette));
$multimedia_listes[$idmultimedia]['spectacle'] = $spectacle;
$multimedia_listes[$idmultimedia]['spectacle']['schedule'] = $this->em->getRepository(Spectacles::class)->getProchDateLieu(
array('prochains' => true),
$spectacle['idspectacle'],
$this->idobject
);
if (count($multimedia_listes) == 5) {
break;
}
}
}
if (isset($multimedia_listes)) {
if (empty($this->view->video_tete)) {
$multimedia_listes_array_values = array_values($multimedia_listes);
$video_tete = array_shift($multimedia_listes_array_values);
$this->view->video_tete = $multimedias->getInfosVideoTete($video_tete, false, array('width' => '415', 'height' => '345'));
unset($multimedia_listes[$video_tete['idmultimedia']]);
}
$this->view->multimedia_affiches = $multimedia_listes;
}
//Les prochaines dates
$schedules = $this->em->getRepository(Schedules::class);
$ids_spectacle_prod = $this->obj->getSpectaclesProd($this->idobject);
$ids_spectacle_structures_diffusions = $this->obj->getSpectaclesProd($this->idobject, false, null, 77);
$ids_spectacles = array_merge($ids_spectacle_prod, $ids_spectacle_structures_diffusions);
if (!empty($ids_spectacles)) {
$biographies_dates_demains = $schedules->getDateBySpectaclesDemain($ids_spectacles, 3);
foreach ($biographies_dates_demains as $k => $v) {
foreach ($biographies_dates_demains[$k]['datas'] as $idata => $data) {
$biographies_dates_demains[$k]['datas'][$idata]['spectacle'] = $this->em->getRepository(Spectacles::class)->getInfosSpectacle($data['idspectacle'], ['get_vignette' => true]);
}
}
$this->context['view']->schedules_dates_demains = $biographies_dates_demains;
}
}
// }}}
// {{{ action_emissions()
/** Podcasts de la page contact
*
* @Route("/contacts/{slug}/emissions", name="contact_emissions")
* @Route("/contacts/{slug}/emissions/cat/{params_cat}", name="contact_emissions_cat")
* @Route("/contacts/{slug}/emissions/cat/{params_cat}/type/{type}", name="contact_emissions_cat_type")
*
* @access public
* @return void
*/
public function action_emissions($slug = null, $params_cat = 'podcasts-spectacles', $type = 'in')
{
$this->InitController($slug, 'emissions');
$this->context['params']['type'] = $type;
$this->context['params']['cat'] = $params_cat;
$this->action_spectacles($slug, false, ['filtre_type' => 'audio', 'get_spectacles_with_audios' => true]);
$arrays_type_podcasts = [
'podcasts-spectacles' => 'spectacles',
'podcasts-spectacles-tous' => 'spectacles',
'podcasts-spectacles-anciens' => 'spectacles',
'podcasts-spectacles-coprod' => 'spectacles',
'podcasts-spectacles-selections' => 'spectacles',
'podcasts-textes' => 'textes'
];
$arrays_order_redirect = [
'in' => 'podcasts-spectacles',
// '' => 'podcasts-spectacles-tous',
'anciens' => 'podcasts-spectacles-anciens',
'coprod' => 'podcasts-spectacles-coprod',
'selections' => 'podcasts-spectacles-selections',
];
$cat = 'podcasts-spectacles';
if (isset($params_cat) && array_key_exists($params_cat, $arrays_type_podcasts)) {
$cat = $params_cat;
}
$this->view->cat = $cat;
if ($this->context['view']->{'nb_spectacles_' . $type . '_audio'} == 0) {
foreach ($arrays_order_redirect as $key => $value) {
if (isset($this->context['view']->{'nb_spectacles_' . $key . '_audio'}) && $this->context['view']->{'nb_spectacles_' . $key . '_audio'} > 0) {
return $this->redirectToRoute('contact_emissions_cat_type', ['slug' => $this->context['view']->url_clean, 'params_cat' => $value, 'type' => $key]);
}
}
}
$this->context['view']->podcasts_content = true;
$this->context['view']->type_content = $type_content = $arrays_type_podcasts[$cat];
$params_sql = $this->setCommonSearchSpectacles(array(
'special' => array(
'textfictif' => 0,
'prochains' => true
),
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont un podcast'),
));
if (!empty($this->context['params']['type']) && $this->context['params']['type'] == 'prod' && in_array($this->idobject, [595, 5222])) {
unset($params_sql['special']['prochains']);
}
$spectacles = $this->em->getRepository(Spectacles::class);
$textes = $this->em->getRepository(Texts::class);
$display_spectacle = [];
$format_vignette = [];
//Spectacles
if ($type_content == 'spectacles') {
//Si c'est France Culture
if (in_array($this->idobject, [595, 5222])) {
$params_sql['special']['podcasts'] = [
'type_podcast' => 'franceculture',
'publish' => 1
];
$params_sql['special']['type_franceinter'] = null;
if ($this->idobject == 5222) {
$params_sql['special']['type_franceinter'] = 1;
}
$display_spectacle = ['carrer_couleurs' => true, 'allauthors' => true];
if ($type == 'podcasts-spectacles-tous') {
$format_vignette['display'] = ['affiche_date_creation' => true];
$params_sql['params']['order'] = 'creation_date DESC';
}
} else {
$this->redirectedFrom = 'emissions';
$this->action_spectacles($slug, true, ['filtre_type' => 'audio', 'get_spectacles_with_audios' => true]);
}
} //Textes
else {
$params_sql['count_only_distinct'] = 't.`idtext`';
}
$this->context['view']->nb_spectacles_total = $spectacles->countListSpectacles($params_sql);
$params_sql['params']['limit'] = array($this->getLimitStart(), $this->perPage);
$list_spectacles = $spectacles->getListSpectacles($params_sql, $format_vignette, false, $display_spectacle);
//Les spectacles et si c'est france culture
if ($type_content == 'spectacles' && in_array($this->idobject, [595, 5222])) {
$this->context['view']->spectacles = $list_spectacles;
$this->context['view']->pagination = $this->getPagination($this->context['view']->nb_spectacles_total, 10);
$this->context['view']->pagination['spectacle'] = true;
if ($type == 'podcasts-spectacles-tous' || $type == 'podcasts-spectacles') {
foreach ($this->context['view']->spectacles as $idspectacle => $spectacle) {
if (!empty($spectacle['creation_date']) && $type == 'podcasts-spectacles-tous') {
$this->context['view']->spectacles[$idspectacle]['annee_creation'] = $spectacles->getFormeDate($spectacle['creation_date'], '%Y', true);
unset($this->context['view']->spectacles[$idspectacle]['contact_creation']);
}
if ($type == 'podcasts-spectacles') {
$this->context['view']->spectacles[$idspectacle]['footer_contact'] = true;
// unset($this->context['view']->spectacles[$idspectacle]['contact_creation']);
}
}
}
} //Les textes
else if ($type_content == 'textes') {
foreach ($list_spectacles as $k => $v) {
if (!empty($v['idtext'])) {
$idtexts[$v['idtext']] = $v['idtext'];
}
}
$params_sql_texts['special'] = array(
'idtext' => array('IN', $idtexts),
'join' => true,
);
$params_sql_texts['special']['podcasts'] = [
'type_podcast' => 'franceculture'
];
$vignette = array(
'vignette_format' =>
array(
'height' => $_ENV['VIGN_TEXT_HEIGHT'],
'width' => $_ENV['VIGN_TEXT_WIDTH'],
'direction' => 'thumb'
)
);
$this->context['view']->texts = $textes->getTextsFromSpectacles($list_spectacles, $params_sql_texts, $vignette);
}
if (!empty($this->context['view']->texts) || !empty($this->context['view']->spectacles)) {
$this->context['view']->contents = true;
}
$this->getAsidesAudios();
return $this->view('contacts/emissions.html.twig');
}
// }}}
// {{{ action_captations()
/** Captations de la page contact
*
* @Route("/contacts/{slug}/captations", name="contact_captations")
* @Route("/contacts/{slug}/captations/filtre/{p_filtre}", name="contact_captations_p_filtre")
* @Route("/contacts/{slug}/captations/type/{p_type}", name="contact_captations_p_type")
*
* @access public
* @return void
*/
public function action_captations($slug = null, $execute_corps = true, $p_filtre = null, $p_type = null)
{
$this->context['params']['filtre'] = $p_filtre;
$this->context['params']['type'] = $p_type;
if (!is_null($slug) && $execute_corps) {
$this->InitController($slug, 'captations');
}
$podcasts = $this->em->getRepository(Podcasts::class);
$format_vignette = array('width' => 480, 'direction' => 'thumb');
$filtre_vod = array(
'vod' => array(
'type' => 1
),
'svod' => array(
'type' => 2
)
);
$filtre_culturebox = array(
'all' => array(
'name' => 'Toutes les captations en ligne',
'key_type' => 'all'
),
'derniere-chance' => array(
'name' => 'Dernière chance',
'key_type' => 'derniere-chance'
),
'captations-a-venir' => array(
'name' => 'Captations à venir',
'key_type' => 'captations-a-venir'
)
);
$filtre = (!empty($this->context['params']['filtre']) && array_key_exists($this->context['params']['filtre'], $filtre_culturebox)) ? $this->context['params']['filtre'] : 'all';
$type = (!empty($this->context['params']['type']) && array_key_exists($this->context['params']['type'], $filtre_vod)) ? $this->context['params']['type'] : null;
$culturebox_params = array(
'limit' => ($filtre == 'derniere-chance') ? array(0, 4) : array(0, 200),
'special' => array(
'type_podcast' => 'culturebox', //commun
'is_integrale' => true, //commun
'idcontacts' => $this->idobject
),
'dbg' => array('culturebox_data', 'Les replay culturebox'),
);
if (!is_null($type)) {
$culturebox_params['special']['type_diffusion'] = $filtre_vod[$type]['type'];
$this->view->subaside_action = $type;
$this->view->subaside_action_view = 'type/' . $type;
}
$culturebox_params_opts['all']['special']['current'] = true;
//dernières en ligne
//$culturebox_params_opts['last']['special']['current'] = true;
//$culturebox_params_opts['last']['special']['order'] = array('podcasts' => 'debut_visionnage_ft'); //dernières
//prochains
$culturebox_params_opts['captations-a-venir']['special']['next'] = true;
//last chance
$culturebox_params_opts['derniere-chance']['special']['lastchance'] = true;
$culturebox_params_opts['derniere-chance']['special']['current'] = true;
foreach ($filtre_culturebox as $k => $v) {
if (isset($culturebox_params_opts[$k])) {
$culturebox_params_counts = array_merge_recursive($culturebox_params, $culturebox_params_opts[$k]);
$filtre_culturebox[$k]['count'] = $podcasts->countListPodcasts($culturebox_params_counts);
}
}
$this->context['view']->filtre_culturebox = $filtre_culturebox;
if (!$execute_corps) {
return true;
}
if (isset($culturebox_params_opts[$filtre])) {
if ($filtre_culturebox[$filtre]['count'] > 0) {
$culturebox_params = array_merge_recursive($culturebox_params, $culturebox_params_opts[$filtre]);
} else /*if ($filtre !== 'all')*/ {
// return $this->redirectToRoute('contact_captations_p_filtre', ['slug' => $this->context['view']->url_clean, 'filtre' => 'all']);
}
}
$this->context['view']->list_captations = $podcasts->getListPodcasts($culturebox_params, $format_vignette);
$arrays_contacts = [];
foreach ($this->context['view']->list_captations as $value) {
if (!empty($value['podcast_contact'])) {
foreach ($value['podcast_contact'] as $key => $contact) {
$arrays_contacts[$key] = $contact;
}
}
}
usort($arrays_contacts, function ($a, $b) {
return strcmp($a['organisation'], $b['organisation']);
});
$this->view->contacts_partenaires = $arrays_contacts;
// compter le nombre totale de captations intégrales
$this->context['view']->nb_podcasts = $podcasts->countPodcasts();
if ($filtre == 'all') {
$this->context['view']->is_all_captation = true;
}
if ($filtre == 'derniere-chance') {
$this->context['view']->is_last_chance = true;
}
if ($filtre == 'captations-a-venir') {
$this->context['view']->is_future_captation = true;
}
$this->getAsidesVideos(null, $filtre);
// titre de la page
$this->view->title_page = 'Captation culturebox';
$this->rub_courante = 'culturebox';
$this->view->locate = array(
0 => $this->view->title_page
);
//On affiche la publicité google
$asides_publicite = new asides();
asides::setEntityManager($this->em);
asides::loadaside('Publicite')->addGoogle($asides_publicite, $this->serviceAbonnements);
$this->context['view']->asides_publicite = $asides_publicite->view($this->context['view']);
return $this->view('contacts/captations.html.twig');
}
// {{{ action_podcasts()
/** Podcasts de la page contact
*
* @Route("/contacts/{slug}/podcasts", name="contact_podcasts")
* @Route("/contacts/{slug}/podcasts/emission/{emission}", name="contact_podcasts_par_emission")
* @Route("/contacts/{slug}/podcasts/podcast/{podcast}", name="contact_podcasts_par_podcast")
*
* @access public
* @return void
*/
public function action_podcasts($slug = null, $emission = null, $podcast = null)
{
$this->context['params']['emission'] = $emission;
$this->context['params']['podcast'] = $podcast;
$this->InitController($slug, 'podcasts');
$podcasts = $this->em->getRepository(Podcasts::class);
$culturebox_params = array(
'direction' => 'DESC',
'special' => array(
'type_podcast' => ['soundcloud', 'franceinter']
),
'dbg' => array('derniers_culturebox_current', 'Les replay France Culture référencés'),
);
$choices = [
'franceculture' => 0,
'franceinter' => 1
];
if (!in_array($this->idobject, [595, 5222])) {
$aside_spectacle_audios = true; //Pour le chargement des asides en dessous
$culturebox_params['special']['idcontacts'] = $this->idobject;
} else {
$aside_spectacle_audios = false; //Pour le chargement des asides en dessous
$culturebox_params['special']['type_podcast'] = 'franceculture';
$culturebox_params['special']['type_franceinter'] = 0;
if ($this->idobject == 5222) {
$culturebox_params['special']['type_franceinter'] = 1;
}
}
if (!empty($this->context['params']['emission'])) {
$culturebox_params['special']['type_podcast'] = 'franceinter';
$culturebox_params['special']['emission'] = $this->context['params']['emission'];
} else if (!empty($this->context['params']['podcast'])) {
$culturebox_params['special']['type_podcast'] = $this->context['params']['podcast'];
if ($this->context['params']['podcast'] === 'franceinter') {
$culturebox_params['special']['type_franceinter'] = $choices['franceinter'];
} else if ($this->context['params']['podcast'] === 'franceculture') {
$culturebox_params['special']['type_franceinter'] = $choices['franceculture'];
}
}
$this->perPage = 10;
//Nombre total de podcasts
$total_podcasts = $podcasts->countListPodcasts($culturebox_params);
$this->context['view']->pagination = $this->getPagination($total_podcasts);
$this->context['view']->pagination['totalItems'] = $total_podcasts;
$this->context['view']->pagination['custom'] = true;
$this->context['view']->pagination['custom_name'] = "podcasts";
$culturebox_params['limit'] = array($this->getLimitStart(), $this->perPage);
//données renvoyées à la vue
$this->context['view']->list_captations = $podcasts->getListPodcasts($culturebox_params);
$this->getAsidesAudios(true, $aside_spectacle_audios);
return $this->view('contacts/podcasts.html.twig');
}
// }}}
// {{{ action_presentation()
/** Présentation générale
*
* @Route("/contacts/{slug}/presentation", name="contact_presentation")
* @Route("/contacts/{slug}/presentation/idcontent/{p_idcontent}/pdf/{p_pdf}", name="contact_presentation_pdf")
* @Route("/contacts/{slug}/presentation/idcontent/{p_idcontent}/pdf/{p_pdf}/download/{p_download}", name="contact_presentation_pdf_download")
*
* @access public
* @return void
*/
public function action_presentation($slug = null, $execute = true, $p_idcontent = null, $p_pdf = null, $p_download = null)
{
if ($execute) {
$this->InitController($slug, 'presentation');
}
$this->context['params']['idcontent'] = $p_idcontent;
$this->setParamsPDF($p_pdf, $p_download);
$show_default_ensavoirplus = true;
// presentation "bio_txt"
$biotxt = $this->contents->getAssociateContent($this->idobject, $this->type_object, 'class_presentation_structure', array('wiki_convert' => true));
if (!empty($biotxt['text'])) {
$this->view->biotxt = $biotxt;
// mots-clés et description
$this->func->makeMetaFromHtml($biotxt['text'], $this->meta_description, $this->meta_keywords);
$show_default_ensavoirplus = false;
}
$this->action_ensavoirplus($slug, false, $show_default_ensavoirplus);
// il faut également la photo associé et le site web
$files = $this->em->getRepository(Files::class);
$files->setPublishStatus($this->publish_status);
$photos = $files->getObjectFiles($this->idobject, $this->type_object, 'class_photo_person');
$format_vignette = $format_vignette = array('width' => 220, 'height' => '180', 'direction' => 'L');
$format_vignette_fou['blur'] = true;
if (!empty($photos)) {
// creation d'une vignette
foreach ($photos as $k => $v) {
$photos[$k]['vignette'] = $this->obj->getVignetteContact($this->idobject, $format_vignette);
$photos[$k]['vignette_flou'] = $this->obj->getVignetteContact($this->idobject, $format_vignette_fou);
}
$this->view->photos = $photos;
}
// carte google ?
if (isset($this->infosobject['geocodable']) && $this->infosobject['geocodable'] == 1) {
$this->view->google_maps_key = Constants::Get('google_maps_key', 0);
$this->view->cartox = $this->infosobject['x'];
$this->view->cartoy = $this->infosobject['y'];
$this->view->cartoc = 11;
// dimension de la carte
$this->view->cartow = 360;
$this->view->cartoh = 240;
$this->view->geocodable = true;
}
$this->setAsidesCommunEnSavoirPlus();
if ($execute) {
$this->checkConditionsPDF();
return $this->view('contacts/presentation.html.twig');
}
}
// }}}
// {{{ action_ensavoirplus()
/** ensavoirplus
*
* @Route("/contacts/{slug}/ensavoirplus", name="contact_ensavoirplus")
* @Route("/contacts/{slug}/ensavoirplus/idcontent/{p_idcontent}", name="contact_ensavoirplus_idcontent")
* @Route("/contacts/{slug}/ensavoirplus/idcontent/{p_idcontent}/pdf/{p_pdf}", name="contact_ensavoirplus_idcontent_pdf")
* @Route("/contacts/{slug}/ensavoirplus/idcontent/{p_idcontent}/pdf/{p_pdf}/download/{p_download}", name="contact_ensavoirplus_idcontent_pdf_download")
*
* @access public
* @return void
*/
public function action_ensavoirplus($slug = null, $aside = true, $default_content = false, $p_idcontent = null, $p_pdf = null, $p_download = null)
{
if ($aside) {
$this->InitController($slug, 'ensavoirplus');
}
$this->context['params']['idcontent'] = $p_idcontent;
$this->setParamsPDF($p_pdf, $p_download);
$this->extra_locate = $this->extra_title = 'En savoir +';
$bioarticles = $this->contents->getAssociateContent($this->idobject, 'contacts', 'class_article');
if (!empty($bioarticles['text'])) {
$this->view->bioarticles = $bioarticles;
if ($default_content) {
return $this->redirectToRoute('contact_ensavoirplus_idcontent', ['slug' => $this->context['view']->url_clean, 'p_idcontent' => $bioarticles['idcontent']]);
}
}
$this->contenus('class_article', 'ensavoirplus', array(), array('limit' => 'all'));
if ($aside) {
if (!empty($this->context['params'])) {
$params = $this->context['params'];
}
if (isset($params) && (!empty($params['idcontent']) || $this->func->my_is_int($params['idcontent']))) {
$this->context['view']->bioarticles = $this->em->getRepository(Contents::class)->getInfosContent($params['idcontent'], ['wiki_convert' => true, 'get_files' => true]);
} else if (!empty($this->context['view']->list_captations)) {
} else {
return $this->redirect('/biographies/' . $this->context['view']->url_clean . '/presentation/');
}
//Gestion du réseau social custom
if (!empty($this->view->detailarticle['deck'])) {
$description_html = $this->view->detailarticle['deck'];
} else {
$description_html = $this->view->detailarticle['text'];
}
// $url = URL_THNET.'/biographies/'.$this->infosperson['url_clean'].'/'.$this->context['action'].'/idcontent/'.$this->view->detailarticle['idcontent'];
// $title = $this->view->detailarticle['title'].' - '.$this->infosperson['fullname'];
// $this->setReseauSocial($title, $description_html, $url);
$this->setAsidesCommunEnSavoirPlus();
}
if ($aside) {
$this->checkConditionsPDF();
return $this->view('contacts/ensavoirplus.html.twig');
}
}
// }}}
// {{{ action_videos()
/** Vidéos associés à cette personne
*
* @Route("/contacts/{slug}/videos", name="contact_videos")
* @Route("/contacts/{slug}/videos/type/{params_type}", name="contact_videos_type")
*
* @access public
* @return void
*/
public function action_videos($slug = null, $params_type = null)
{
$this->context['params']['type'] = $params_type;
$this->InitController($slug, 'videos');
$object_multimedia = $this->em->getRepository(ObjectMultimedia::class);
$multimedias = $this->em->getRepository(Multimedias::class);
$format_vignette = array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none', 'ratio' => '169');
/*
Trouver les vidéos directement associées au contact ET aux spectacles dont le contact a pu être
- producteur / coprod / prod delegue
- compagnie / lieu de création
- lieu de représentation
*/
//20 résultats par page
$this->perPage = 20;
//On indique que l'on souhaite faire afficher les vidéos en lien avec des spectacles
$this->context['view']->videos_blocks = true;
$this->context['view']->spectacles_videos = true;
//On récupères les spectacles - à venir - anciens - produit - coproduit
$this->action_spectacles($slug, true, [
'get_spectacles_with_multimedias' => true
]);
//Nombres total de vidéos en partenariat
$nb_videos_partenariats = $this->multimedias->getMultimediasBy('contacts', $this->idobject, ' AND m.audio_video=2', 'count');
//LE tableau renvoyé vers la vue.
$multimedia = [];
// On récupère les vidéos en partenariat spécifique à l'action des vidéos
if (isset($this->context['params']['type']) && in_array($this->context['params']['type'], ['partenariat'])) {
$this->context['view']->type_spectacle = 'partenariat';
//paramètre commun utile à plusieurs requêtes
$params_query_commun = array(
'object' => array($this->idobject => ['contacts']),
'where' => array(array('multimedias', 'audio_video', 2)),
'order' => array('multimedias.date'),
'limit' => array('all'),
'dbg' => array('last_commun', 'Vidéos en partenariat du contact'),
);
// On récupère la liste des dates pour les saisons et les années
$params_query_get_dates = array_merge($params_query_commun, array(
'select' => array('multimedias.`date`', 'YEAR(multimedias.`date`) as annee'),
'count_only_spectacles' => true,
'dbg' => array('last_dates', 'Vidéo en partenariat du contact - liste des dates'),
));
$sql_dates_multimedias = $this->em->getRepository(Multimedias::class)->getSQLMultimedias($params_query_get_dates, false);
$listdates = $multimedias->queryAll($sql_dates_multimedias);
if (!empty($listdates)) {
foreach ($listdates as $a) {
if ($a['date'] > date('Y-m-d', mktime(0, 0, 0, 8, 31, $a['annee']))) {
$s = $a['annee'] . '-' . ($a['annee'] + 1);
} else {
$s = ($a['annee'] - 1) . '-' . $a['annee'];
}
$saisons[$s] = $s;
$saisons_key[] = $s;
$annees[$a['annee']] = $a['annee'];
}
if (!empty($saisons)) {
// liste des saisons des spectacles
$this->view->saisons = $saisons;
if (!empty($saisons)) {
$this->getCommonSearch(array(
'saisons_annees' => [
'saisons' => $saisons
]
)
);
$this->getCommonSearchView();
}
// dernière saison
foreach ($saisons as $s) {
$this->view->current_saison = $s;
break;
}
}
}
// recherche par saison
if (!empty($_REQUEST['s'])) {
$saison = filter_var($_REQUEST['s'], FILTER_SANITIZE_URL);
} else {
$saison = null;
}
$annees_saison = explode('-', $saison);
if (count($annees_saison) == 2) {
$datestart = Date_time::getSaisonDatestart((int)$annees_saison[0]);
$dateend = Date_time::getSaisonDateend((int)$annees_saison[1]);
}
// On ajout le paramètre des dates à la requête commune
if (!empty($datestart) && !empty($dateend)) {
$params_query_commun['where_date_multimedias'] = array(
'datestart' => $datestart,
'dateend' => $dateend
);
}
//On récupère le nombre total de multimédias
$params_query_total = array_merge($params_query_commun, array(
'select' => array(),
'dbg' => array('last_total', 'Vidéo en partenariat du contact - liste totales des vidéos'),
));
$sql_dates_multimedias = $this->em->getRepository(Multimedias::class)->getSQLMultimedias($params_query_total, false);
$total = $this->em->getRepository(Multimedias::class)->queryAll($sql_dates_multimedias);
$nb_videos_partenariats = count($total);
//On s'ocucpe de la pagination
$this->context['view']->pagination = $this->getPagination($nb_videos_partenariats);
$this->context['view']->pagination['totalItems'] = $nb_videos_partenariats;
$this->context['view']->pagination['custom'] = true;
$this->context['view']->pagination['custom_name'] = "vidéos";
// Récupération de la liste des dernières videos du contact
$params_query_last = array_merge($params_query_commun, array(
'limit' => array($this->getLimitStart(), $this->perPage),
'dbg' => array('last_listes', 'Vidéo en partenariat du contact - liste des multimedias'),
));
$videos_listes_partenariats = $this->em->getRepository(Multimedias::class)->getListMultimedias($params_query_last, array(), ['alldata' => true]);
}
//Si nous récupérons des vidéos en provenance en partenariat
if (!empty($videos_listes_partenariats)) {
$this->context['view']->videos_classic = true;
// $multimedia ;
foreach ($videos_listes_partenariats as $idmultimedia => $v) {
$multimedia[$idmultimedia] = $this->em->getRepository(Multimedias::class)->getInfosMultimedia($idmultimedia, true, false, array('vignette' => $format_vignette));
if ($idspectacle = key($v['spectacles'])) {
$multimedia[$idmultimedia]['spectacle'] = $this->em->getRepository(Spectacles::class)->getInfosSpectacle($idspectacle);
}
}
} ///Sinon nous affichons les vidéos en lien avec les spectacles de l'action_spectacles
else if (!empty($this->context['view']->spectacles)) {
//Nous affichons des données différent en fonction des filtres de l'utilisateur
//Par dérfault les prochains spectacles
$params_schedule = array('prochains' => true);
if (in_array($this->context['view']->type_spectacle, ['anciens'])) {
//Les anciens spectacles
$params_schedule = array('anciens' => true);
}
$idobject = $this->idobject;
if (in_array($this->context['view']->type_spectacle, ['coprod'])) {
$idobject = null;
}
//on traite les données pour pouvoir les afficher comme convenus
foreach ($this->context['view']->spectacles as $idspectacle => $spectacle) {
$idmultimedia = $spectacle['idmultimedia'];
$multimedia[$idmultimedia] = $this->em->getRepository(Multimedias::class)->getInfosMultimedia($idmultimedia, true, false, array('vignette' => $format_vignette));
$multimedia[$idmultimedia]['spectacle'] = $spectacle;
if (in_array($this->context['view']->type_spectacle, ['prod'])) {
$multimedia[$idmultimedia]['spectacle']['footer_creation_date'] = true;
} else {
$multimedia[$idmultimedia]['spectacle']['schedule'] = $this->em->getRepository(Spectacles::class)->getProchDateLieu(
$params_schedule,
$spectacle['idspectacle'],
$idobject
);
}
}
} else {
if ($nb_videos_partenariats > 0) {
return $this->redirectToRoute('contact_videos_type', ['slug' => $this->context['view']->url_clean, 'params_type' => 'partenariat']);
}
}
$this->context['view']->spectacles = $multimedia;
$this->context['view']->contactsvideos = true;
$this->getAsidesVideos();
return $this->view('contacts/videos.html.twig');
}
// }}}
// {{{ action_videos_v1() à réactiver en temps voulu par françois
/** Vidéos associés à cette personne
*
*
* @access public
* @return void
*/
public function action_videos_v1() //ancienne version de la page vidéo
{
/*
Trouver les vidéos associées directement au contact ET aux spectacles dont le contact à pu être
- producteur / coprod / prod delegue
- compagnie / lieu de création
- lieu de représentation
*/
// les vidéos de spectacles joués dans ce lieu
$ids_multimedia_in = $this->getMultimediasIn($this->ids_spectacle_in);
// les vidéos de spectacle coproduit par ce contact
$ids_multimedia_prod = $this->getMultimediasProd($this->ids_spectacle_prod);
// commence le tableau de tout
$ids_multimedia_all = array_unique(array_merge($ids_multimedia_in, $ids_multimedia_prod));
$ids_multimedia_all_doublons = array_merge($ids_multimedia_in, $ids_multimedia_prod);
// les vidéos de spectacle associées (en partenariat) à ce contact
$ids_multimedia_contact = $this->getMultimediasContact(false, $ids_multimedia_all_doublons);
// les vidéos associées aux contact => soit parceque c'est un lieu de représentation, soit parceque c'est une coprod/partenariat
if (!empty($ids_multimedia_contact)) {
$ids_multimedia_all = array_unique(array_merge($ids_multimedia_all, $ids_multimedia_contact));
}
// toutes les valeurs
$valeurs = array(
'multimedias' => array(
'in' => array('nb' => count($ids_multimedia_in)),
'prod' => array('nb' => count($ids_multimedia_prod)),
'contact' => array('nb' => count($ids_multimedia_contact)),
'all' => array('nb' => count($ids_multimedia_all)),
),
'spectacles' => array(
'in' => array('nb' => count($this->ids_spectacle_in)),
'prod' => array('nb' => count($this->ids_spectacle_prod)),
'all' => array('nb' => count($this->ids_spectacle_all)),
),
);
$this->view->nb = $valeurs;
if ($valeurs['multimedias']['all']['nb'] > $this->nb_contact_recherche) {
// trouver les auteurs qui sont liés directement au contact ou à ses spectacles
$sql_authors = 'SELECT DISTINCT(persons.idperson), persons.firstname, persons.lastname, persons.url_clean
FROM persons, object_multimedia
WHERE object_multimedia.object=\'persons\'
AND object_multimedia.idobject=persons.idperson
AND object_multimedia.idrole IN (1,21)
AND object_multimedia.idmultimedia IN (' . join(',', $ids_multimedia_all) . ') ORDER BY persons.lastname';
$authors = $this->obj->queryAll($sql_authors);
if (!empty($authors)) {
// liste des auteurs
$authors_tab[0] = 'Choisissez un auteur/metteur en scène...';
foreach ($authors as $k => $v) {
$authors_tab[$v['idperson']] = mb_strtoupper($v['lastname'], CHARSET) . ' ' . $v['firstname'];
if (!empty($_REQUEST['idperson']) && $v['idperson'] == $_REQUEST['idperson']) {
$this->view->search_person = $v;
}
}
$this->context['form']->addElement('select', 'idperson', 'Auteurs', $authors_tab, array('id' => 'idperson_author'));
// on recherche les vidéos du contact associées à une personne
if (!empty($_REQUEST['idperson']) && $this->func->my_is_int($_REQUEST['idperson'])
&& !empty($authors_tab[$_REQUEST['idperson']])) {
$idperson = (int)$_REQUEST['idperson'];
// les vidéos associées à cette personne
$params_query_person = array(
'where' => array(
array('multimedias', 'idmultimedia', $ids_multimedia_all),
),
'object' => array('persons' => $idperson),
'language' => 'fr',
'limit' => array(0, 15),
'dbg' => array('person', 'Vidéos associé au contact et à une personne'),
);
$videos_person = $this->multimedias->getListMultimedias($params_query_person);
$this->view->videos_person = $videos_person;
// la personne
}
}
// trouver les années des vidéos (vidéos publiées en)
// trouver les années et saison des spectacles
$current_year = $this->getYear();
// recherche une saison ?
$saison = $this->getSaison();
// grouper les dates par saisons
$sql_annees = 'SELECT schedules.date, YEAR(schedules.date) as annee
FROM schedules, spectacles, object_multimedia, multimedias
WHERE schedules.idspectacle=spectacles.idspectacle
AND object_multimedia.idobject=spectacles.idspectacle AND object_multimedia.object=\'spectacles\'
AND multimedias.idmultimedia=object_multimedia.idmultimedia
AND multimedias.publish=1
AND spectacles.publish=1
AND object_multimedia.idmultimedia IN (' . join(',', $ids_multimedia_all) . ') ORDER BY schedules.date';
// autres propositions
//AND schedules.idspectacle IN ('.join(',', $ids_spectacle_all).') ORDER BY schedules.date';
//AND object_multimedia.idmultimedia IN ('.join(',', $ids_multimedia_all).') ORDER BY schedules.date';
//AND schedules.idspectacle IN ('.join(',', $ids_spectacle_all).') ORDER BY schedules.date';
//AND schedules.idspectacle IN ('.join(',', $ids_spectacle_in).') ORDER BY schedules.date';
//AND schedules.idcontact='.$this->idobject.' ORDER BY schedules.date';
$listdates = $this->obj->queryAll($sql_annees);
// liste des saisons et des années
if (PEAR::isError($listdates)) {
echo $listdates->getDebugInfos();
} elseif (!empty($listdates)) {
foreach ($listdates as $a) {
if ($a['date'] > date('Y-m-d', mktime(0, 0, 0, 8, 31, $a['annee']))) {
$s = $a['annee'] . '-' . ($a['annee'] + 1);
} else {
$s = ($a['annee'] - 1) . '-' . $a['annee'];
}
$saisons[$s] = $s;
$saisons_key[] = $s;
$annees[$a['annee']] = $a['annee'];
}
// liste des saisons des spectacles
$this->view->saisons = $saisons;
if (!empty($saisons)) {
$this->context['form']->addElement('select', 's', 'Saisons', array_merge(array('' => 'Choisissez une saison...'), $saisons), array('id' => 'saisons'));
}
// liste des annees des spectacles
$this->view->annees = $annees;
if (!empty($annees)) {
$this->context['form']->addElement('select', 'y', 'Années', array_merge(array('' => 'Choisissez une année...'), $annees), array('id' => 'annees'));
}
}
// si aucune recherche par person, par année ou par saison => recherche par saison
if (empty($current_year) && empty($saison) && empty($idperson)) {
if (!empty($saisons)) {
$saison = Date_time::getLastSaison($saisons);
}
}
// recherche par saison
if (!empty($saison)) {
$annees_saison = explode('-', $saison);
if (count($annees_saison) == 2) {
$datestart = date('Y-m-d', mktime(0, 0, 0, 9, 1, (int)$annees_saison[0]));
$dateend = date('Y-m-d', mktime(0, 0, 0, 8, 31, (int)$annees_saison[1]));
}
// saison de recherche
$this->view->saison = $saison;
// saison précédente / suivante
if (!empty($saisons)) {
foreach ($saisons as $s) {
if (isset($prev)) {
$saisons_nav['next'] = $s;
break;
}
if ($s == $saison && !isset($saisons_nav['prev'])) {
if (isset($current_s)) {
$saisons_nav['prev'] = $current_s;
}
$prev = true;
}
$current_s = $s;
}
if (!empty($saisons_nav)) {
$this->view->saisons_nav = $saisons_nav;
}
}
}
// annee
if (!empty($current_year)) { // recherche par année
$datestart = date('Y-m-d', mktime(0, 0, 0, 1, 1, $current_year));
$dateend = date('Y-m-d', mktime(0, 0, 0, 12, 31, $current_year));
// annee de recherche
$this->view->current_year = $current_year;
}
// recherche période
if (!empty($datestart) && !empty($dateend)) {
//$where_idcontact .= ' AND sc.date BETWEEN \''.$datestart.'\' AND \''.$dateend.'\' ';
}
if (empty($datestart) && empty($dateend)) {
// un objet spectacle
$spectacles = $this->em->getRepository(Spectacles::class);
// trouver le spectacle avec vidéo avec la date la plus proche
$sql = 'SELECT MAX(schedules.date) as lastdate, MAX(YEAR(schedules.date)) as annee
FROM schedules, object_multimedia
WHERE schedules.idspectacle=object_multimedia.idobject
AND object_multimedia.object=\'spectacles\'
AND schedules.idcontact=' . $this->idobject . '
AND object_multimedia.idmultimedia IN (' . join(',', $ids_multimedia_all) . ')';
$last_spectacle_video = $this->obj->queryRow($sql);
// si la date est avant le 7 juillet, alors saison = annee / annee-1
if ($last_spectacle_video['lastdate'] < date('Y-m-d', mktime(0, 0, 0, 7, 1, $last_spectacle_video['annee']))) {
$datestart = date('Y-m-d', mktime(0, 0, 0, 9, 1, $last_spectacle_video['annee'] - 1));
$dateend = date('Y-m-d', mktime(0, 0, 0, 8, 31, $last_spectacle_video['annee']));
} else {
$datestart = date('Y-m-d', mktime(0, 0, 0, 9, 1, $last_spectacle_video['annee']));
$dateend = date('Y-m-d', mktime(0, 0, 0, 8, 31, $last_spectacle_video['annee'] + 1));
$this->view->current_saison = true;
}
}
$this->view->datestart = $datestart;
$this->view->dateend = $dateend;
}
// les vidéos de spectacles à l'affiche dans le lieu
if ($valeurs['multimedias']['in']['nb'] > 0) {
$params_query_in = array(
'affiche' => true,
'where' => array(
//array('schedules','idcontact',$this->idobject),
array('schedules', 'idspectacle', $this->ids_spectacle_in),
),
'group' => array('multimedias' => 'idmultimedia'),
'direction' => 'DESC',
'limit' => array(0, 40),
'dbg' => array('affiche', 'Vidéos de spectacles à l\'affiche dans ce lieu'),
);
// si datestart et dateend
if (!empty($datestart) && !empty($dateend)) {
$params_query_in['affiche'] = array('saison' => array($datestart, $dateend));
}
$spectacles_in = $this->multimedias->getListMultimedias($params_query_in);
$this->view->spectacles_in = $spectacles_in;
$nb_spectacles_in = count($spectacles_in);
$this->view->nb_spectacles_in_saison = $nb_spectacles_in;
}
// les vidéos de spectacles coproduits par ce contact
if ($valeurs['multimedias']['prod']['nb'] > 0) {
$params_query_prod = array(
'affiche' => true,
'where' => array(
array('schedules', 'idspectacle', $this->ids_spectacle_prod),
),
'group' => array('multimedias' => 'idmultimedia'),
'direction' => 'DESC',
'limit' => array(0, 100),
'dbg' => array('coprod', 'Vidéos de spectacles à l\'affiche coproduit par ce contact'),
);
// si datestart et dateend
if (!empty($datestart) && !empty($dateend)) {
$params_query_prod['affiche'] = array('saison' => array($datestart, $dateend));
}
$spectacles_prod = $this->multimedias->getListMultimedias($params_query_prod);
$nb_spectacles_prod = count($spectacles_prod);
$this->view->nb_spectacles_prod_saison = $nb_spectacles_prod;
$this->view->spectacles_prod = $spectacles_prod;
}
// les vidéos en partenariat avec le contact
if ($valeurs['multimedias']['contact']['nb'] > 0) {
$params_query_contact = array(
//'affiche' => true,
'where' => array(
array('multimedias', 'idmultimedia', $ids_multimedia_contact),
),
'limit' => array(0, 100),
'direction' => 'DESC',
'group' => array('multimedias' => 'idmultimedia'),
'dbg' => array('contact', 'Vidéos en partenariat avec ce contact'),
);
// si datestart et dateend
if (!empty($datestart) && !empty($dateend)) {
$params_query_contact['affiche'] = array('saison' => array($datestart, $dateend));
}
$videos_contact = $this->multimedias->getListMultimedias($params_query_contact);
$nb_videos_contact = count($videos_contact);
$this->view->nb_videos_contact_saison = $nb_videos_contact;
$this->view->videos_contact = $videos_contact;
}
// colonne un si il y a des spectacles
if ($valeurs['multimedias']['in']['nb'] > 0) {
$this->view->colonne_unb = true;
}
// contact important
if ($valeurs['multimedias']['all']['nb'] > $this->nb_contact_recherche) {
$this->view->big_contact = true;
}
$sql = 'SELECT DISTINCT(idmultimedia) FROM object_multimedia WHERE object=\'contact\' AND idobject=' . $this->idobject;
$idmultimedias_object = $this->obj->queryCol($sql);
// trouver les videos de l'espace vidéo
$this->context['view']->nb_multimedias = $this->multimedias->getMultimediasBy('contacts', $this->idobject, ' AND m.audio_video=2', 'count');
// pas de commentaire et de vote
$this->view->no_comment = true;
$this->view->no_vote = true;
// le spectacle en premier
$this->view->first_spectacles = true;
$this->style_more[] = 'videos';
$this->extra_locate = 'Vidéos';
$this->extra_title = $this->extra_locate;
//aside
$this->asides->load('contact_saison_auteurs');
$this->asides->load('common_participer_contacts');
}
// }}}
// {{{ action_spectacles()
/** Spectacles de la structure
*
* @Route("/contacts/{slug}/spectacles", name="contact_spectacles")
* @Route("/contacts/{slug}/spectacles/type/{p_type}", name="contact_spectacles_type")
*
* @access public
* @return void
*/
public function action_spectacles($slug = null, $execute_corps_page = true, $params = array(), $p_type = null)
{
if (empty($this->context['params']['type'])) {
$this->context['params']['type'] = $p_type;
}
if ($execute_corps_page && empty($params)) {
$this->InitController($slug, 'spectacles');
}
//menu en scène
if (empty($this->context['view']->all_en_scene)) {
$this->context['view']->all_en_scene = $this->countEnScene(['affiche' => true]);
}
if (empty($this->context['view']->anciens_en_scene)) {
$this->context['view']->anciens_en_scene = $this->countEnScene(['anciens' => true]);
}
$whereIdContact = '';
if (in_array($this->idobject, [595, 5222]) && $this->context['action'] == 'emissions') {
$whereIdContact = '';
} else {
$whereIdContact = ' AND ' . $this->getWhereIdcontact();
}
$this->perPage = 20;
$filtres = array(
//les spectacles produits dans le contact (in)
'in' => array(
// 'idcontact' => $this->idobject,
'params_sql' => array(
'params' => array(
'where' => ' AND s.publish=1 ' . $whereIdContact,
'classement' => 'ASC', //$this->getOrder()
'groupby' => 's.idspectacle',
),
'special' => array(
'idcontact' => $this->idobject,
'prochains' => true,
'order' => true
),
'dbg' => array('spectacles_in_list', 'Les spectacles à l\'affiche dans ce lieu')
),
'view' => array(
'special' => array(
'footer_date' => true,
'no_date' => true
),
'spectacles_nocity' => true //spécifique à la page vidéo
)
),
//les anciens spectacles
'anciens' => array(
'params_sql' => array(
'params' => array(
'where' => ' AND s.publish=1 ' . $whereIdContact,
'select' => 'contacts.idcontact as datecontact',
'groupby' => 's.idspectacle',
),
'special' => array(
'anciens_stricts' => true,
'count_in_spectacle_anciens' => true,
'idcontact' => $this->idobject,
),
'dbg' => array('spectacles_anciens_list', 'Spectacles anciens par ce contact')
),
'view' => array(
'noshow' => true,
'special' => array(
'footer_date' => true,
),
'spectacles_nocity' => true //spécifique à la page vidéo
),
'unset' => array(
'special,prochains' => true,
'special,count_in_spectacle_anciens' => true
)
),
//les productions -anciennes
// 'prod-anciens' => array(
// 'params_sql' => array(
// 'params' => array(
// 'from' => 'spectacle_contact sct',
// 'where' => 'AND s.publish=1
// AND sct.idspectacle=s.idspectacle
// AND sct.idrole IN ('.implode(',', array(17,18,19)).')
// AND (sct.idcontact='.$this->idobject.' OR s.idcontact_production='.$this->idobject.') ',
// 'groupby' => 's.idspectacle',
// 'order' => 's.creation_date DESC'
// ),
// 'special' => array(
// 'anciens_stricts' => true,
// 'count_in_spectacle_anciens' => true
// ),
// 'dbg' => array('spectacles_prod_list','Spectacles prod/coprod/prod deleg de ce contact')
// ),
// 'unset' => array(
// 'special,prochains' => true,
// 'special,count_in_spectacle_anciens' => true
// ),
// 'view' => array(
// 'special' => array(
// 'display' => array('affiche_date_creation' => true),
// 'annee_creation' => true
// )
// )
// ),
//les prod
'diffusions' => array(
'params_sql' => array(
'params' => array(
'from' => 'TheatreCore\Entity\SpectacleContact sct',
'where' => ' AND s.publish=1 AND sct.idspectacle=s.idspectacle
AND (sct.idrole IN (77) AND sct.idcontact=' . $this->idobject . ')',
'groupby' => 's.idspectacle',
'order' => ['creation_date', 'DESC']
),
'dbg' => array('spectacles_prod_list', 'Spectacles prod/coprod/prod deleg de ce contact')
),
'unset' => array(
'special,prochains' => true,
// 'special,count_in_spectacle_anciens' => true
),
'view' => array(
'special' => array(
'display' => array('affiche_date_creation' => true),
'annee_creation' => true
)
)
),
'prod' => array(
'params_sql' => array(
'params' => array(
'from' => 'TheatreCore\Entity\SpectacleContact sct',
'where' => 'AND s.publish=1
AND sct.idspectacle=s.idspectacle
AND sct.idrole IN (' . implode(',', array(17, 18, 19)) . ')
AND (sct.idcontact=' . $this->idobject . ' OR s.idcontactProduction=' . $this->idobject . ') ',
'groupby' => 's.idspectacle',
'order' => ['creation_date', 'DESC']
),
'dbg' => array('spectacles_prod_list', 'Spectacles prod/coprod/prod deleg de ce contact')
),
'unset' => array(
'special,prochains' => true,
// 'special,count_in_spectacle_anciens' => true
),
'view' => array(
'special' => array(
'display' => array('affiche_date_creation' => true),
'annee_creation' => true
)
)
),
//les coproductions
'coprod' => array(
'params_sql' => array(
'params' => array(
'from' => 'TheatreCore\Entity\SpectacleContact sct',
'where' => 'AND s.publish=1
AND sct.idspectacle=s.idspectacle
AND sct.idrole IN (' . implode(',', array(17, 18, 19)) . ')
AND (sct.idcontact=' . $this->idobject . ' OR s.idcontactProduction=' . $this->idobject . ') ',
'groupby' => 's.idspectacle',
),
'special' => array(
'prochains' => true,
'plus_proche' => true
),
'dbg' => array('spectacles_prod_list', 'Spectacles prod/coprod/prod deleg de ce contact')
),
'view' => array(
'special' => array(
'footer_contact' => true,
)
),
'unset' => array(
'params,order' => true
)
),
'soutiens,selections,laureats_nominations,aide' => array(
'params_sql' => array(
'params' => array(
'groupby' => 's.idspectacle',
),
'special' => array(
'prochains' => true,
// TODO: chercher une solution pour ça
// 'idspectacle' => $this->ids_spectacle_soutiens,
'idspectacle' => 'checks_exists',
// 'idcontact' => $this->idobject,
),
'dbg' => array('spectacles_multiples_list', 'Spectacles multiples par ce contact')
),
'view' => array(
'special' => array(
'footer_contact' => true,
)
)
)
);
$this->format_vignette = array(
'stylemore' => array('imagep' => 'width:75px;', 'descsp' => 'width:100%;'),
'vignette' => array('width' => $_ENV['VIGN_SPECTACLE_WIDTH'], 'height' => $_ENV['VIGN_SPECTACLE_HEIGHT'], 'direction' => 'crop')
);
//Tous les filtres par défaults (spectacles simples, ou spectacles avec podcasts France Culture);
$filtre_type = ['spectacles', 'audio'];
//Si on doit executer le corps de page
if ($execute_corps_page) {
$filtre_type = ['spectacles'];
}
//Si on demande un filtre spécifique
if (!empty($params['filtre_type'])) {
if (!is_array($params['filtre_type'])) {
$params['filtre_type'] = [$params['filtre_type']];
}
$filtre_type = $params['filtre_type'];
}
if (!isset($this->context['view']->nb_total_spectacle)) {
$this->context['view']->nb_total_spectacle = 0;
}
$selected = $this->context['view']->type_spectacle = 'in';
$total_spectacle = $total_spectacle_plus = 0;
foreach ($filtre_type as $k_filtre_type => $v_filtre_type) {
foreach ($filtres as $kfiltres => $vfiltres) {
$filtres_plus = explode(',', $kfiltres);
//on clean le nom du filtre
$var_filtres = preg_replace('/-/', '_', $kfiltres);
// cas festival
if (!empty($this->infosobject['is_festival'])) {
$filtres[$kfiltres]['params_sql']['special']['type_contact'] =
$vfiltres['params_sql']['special']['type_contact'] = 'idcontactFestival';
}
if (!empty($params['get_spectacles_with_multimedias'])) {
$filtres[$kfiltres]['params_sql']['special']['multimedias_videos_associes'] =
$vfiltres['params_sql']['special']['multimedias_videos_associes'] = true;
// if (!empty($this->infosobject['is_festival'])) {
// $filtres[$kfiltres]['params_sql']['special']['multimedias_videos_associes_contact_festival'] =
// $vfiltres['params_sql']['special']['multimedias_videos_associes_contact_festival'] = $this->idobject;
// }
if ($var_filtres != 'coprod') {
$filtres[$kfiltres]['params_sql']['special']['multimedias_videos_associes_contact'] =
$vfiltres['params_sql']['special']['multimedias_videos_associes_contact'] = $this->idobject;
}
}
if (!empty($params['get_spectacles_with_critiques'])) {
$filtres[$kfiltres]['params_sql']['special']['contenus_associes_critiques'] =
$vfiltres['params_sql']['special']['contenus_associes_critiques'] = true;
// if($var_filtres != 'coprod'){
// $filtres[$kfiltres]['params_sql']['special']['multimedias_videos_associes_contact'] =
// $vfiltres['params_sql']['special']['multimedias_videos_associes_contact'] = $this->idobject;
// }
}
if (!empty($params['get_spectacles_coprod'])) {
$vfiltres['params_sql']['special']['coprod'] = $params['get_spectacles_coprod'];
$filtres[$kfiltres]['params_sql']['special']['coprod'] = $params['get_spectacles_coprod'];
}
if (!empty($filtres[$kfiltres]['unset'])) {
foreach ($filtres[$kfiltres]['unset'] as $ku => $vu) {
$ku = explode(',', $ku);
unset($filtres[$kfiltres]['params_sql'][$ku[0]][$ku[1]]);
unset($vfiltres['params_sql'][$ku[0]][$ku[1]]);
}
}
$filtre_sup = '';
if ($v_filtre_type == 'audio') {
$vfiltres['params_sql']['special']['podcasts'] = [
'type_podcast' => 'franceculture',
'publish' => 1
];
$filtre_sup = '_audio';
}
//si c'est un choix multiples comme par exemple : aide,soutiens,selections,laureats_nominations
if (count($filtres_plus) > 1) {
foreach ($filtres_plus as $kk => $vv) {
$filtres_cp = $filtres[$kfiltres];
if ($vv == "soutiens") {
// $filtres_cp['params_sql']['special']['by_classification'] = 103;
$filtres_cp['params_sql']['special']['spectacle_aide']['end'] = date('Y-m-d');
}
if (!empty($filtres_cp['params_sql']['special']['idspectacle'])) {
$filtres_cp['params_sql']['special']['idspectacle'] = $this->{'ids_spectacle_' . $vv};
}
if (!empty($this->{'ids_spectacle_' . $vv})) {
$total_spectacle_plus += $this->context['view']->{'nb_spectacles_' . $vv . $filtre_sup} = $this->em->getRepository(Spectacles::class)->countListSpectacles($filtres_cp['params_sql']);
//On applique le filtre des années/saisons/jours après avoir compter le nombre total de spectacle dans la « catégorie »
if ($this->context['params']['type'] == $vv && !empty($filtres_cp[$vv]['params_sql'])) {
$vfiltres['params_sql'] = $this->setCommonSearchSpectacles($filtres_cp[$vv]['params_sql']);
}
//Pour la pagination
$this->context['view']->{'nb_spectacles_filtre_' . $vv . $filtre_sup} = $this->em->getRepository(Spectacles::class)->countListSpectacles($filtres_cp['params_sql']);
if (!empty($this->context['params']['type']) && $this->context['params']['type'] == $vv && $this->context['view']->{'nb_spectacles_' . $vv} > 0) {
$this->context['view']->type_spectacle = $vv;
$selected = $vv;
}
$filtres[$vv] = $filtres_cp;
}
}
} else {
if (!empty($filtres[$kfiltres]['params_sql']['special']['idspectacle'])) {
if (!empty($this->{'ids_spectacle_' . $var_filtres})) {
$vfiltres['params_sql']['special']['idspectacle'] = $this->{'ids_spectacle_' . $var_filtres};
$filtres[$kfiltres]['params_sql']['special']['idspectacle'] = $this->{'ids_spectacle_' . $var_filtres};
}
}
$this->context['view']->{'nb_spectacles_' . $var_filtres . $filtre_sup} = $this->em->getRepository(Spectacles::class)->countListSpectacles($vfiltres['params_sql']);
//On applique le filtre des années/saisons/jours après avoir compter le nombre total de spectacle dans la « catégorie »
if ($this->context['params']['type'] == $var_filtres && !empty($filtres[$var_filtres]['params_sql'])) {
$vfiltres['params_sql'] = $filtres[$var_filtres]['params_sql'] = $this->setCommonSearchSpectacles($filtres[$var_filtres]['params_sql'], true);
}
//Pour la pagination
$this->context['view']->{'nb_spectacles_filtre_' . $var_filtres . $filtre_sup} = $this->em->getRepository(Spectacles::class)->countListSpectacles($vfiltres['params_sql']);
if (!empty($this->context['view']->{'nb_spectacles_' . $var_filtres . $filtre_sup})) {
$total_spectacle += ((int)$this->context['view']->{'nb_spectacles_' . $var_filtres . $filtre_sup});
if (!empty($this->context['params']['type']) && in_array($this->context['params']['type'], explode(',', $kfiltres)) && $this->context['view']->{'nb_spectacles_' . $var_filtres . $filtre_sup} > 0) {
$this->context['view']->type_spectacle = $kfiltres;
$selected = $kfiltres;
}
}
}
}
}
$this->context['view']->nb_total_spectacle = $total_spectacle + $total_spectacle_plus;
if (empty($this->context['view']->{'nb_spectacles_' . $selected . $filtre_sup}) && $this->context['view']->{'nb_spectacles_' . $selected . $filtre_sup} == 0) {
foreach ($filtres as $kfiltres => $vfiltres) {
$filtres_plus = explode(',', $kfiltres);
if (count($filtres_plus) > 1) {
foreach ($filtres_plus as $kk => $vv) {
if ($this->context['view']->{'nb_spectacles_' . $vv} > 0) {
$this->context['view']->type_spectacle = $vv;
$selected = $vv;
break 1;
}
}
} else {
$test = preg_replace('/-/', '_', $kfiltres);
if (!empty($this->context['view']->{'nb_spectacles_' . $test}) && $this->context['view']->{'nb_spectacles_' . $test} > 0) {
$this->context['view']->type_spectacle = $kfiltres;
$selected = $kfiltres;
break 1;
}
}
}
}
$this->context['view']->total_spectacle = $total_spectacle;
// print_r($this->context['view']);
if (($total_spectacle > 0 || $total_spectacle_plus > 0) && $execute_corps_page) {
$this->context['view']->current_page = 'spectacles';
$this->context['view']->{'spectacles_' . $selected} = true;
$params_sql = $filtres[$selected]['params_sql'];
$params_sql['params']['limit'] = array($this->getLimitStart(), $this->perPage);
$filtre_sup = '';
if (in_array('audio', $filtre_type)) {
$params_sql['special']['podcasts'] = [
'type_podcast' => 'franceculture',
'publish' => 1
];
$filtre_sup = '_audio';
}
$options_spectacles = [
'allauthors' => true,
'carrer_couleurs' => true
];
//Suppression des carrer pour les appels ajax de la page
if (!empty($_GET['v'])) {
unset($options_spectacles['carrer_couleurs']);
}
$spectacles = $this->em->getRepository(Spectacles::class);
$this->context['view']->spectacles = $spectacles->getListSpectacles($params_sql, $this->format_vignette, false, $options_spectacles);
$this->context['view']->pagination = $this->getPagination(
$this->context['view']->{'nb_spectacles_filtre_' . $selected . $filtre_sup},
$this->perPage,
[
//Nombre total des représentations pour cette liste de spectacles
'total_dates' => $spectacles->countListSchedules($params_sql),
]
);
if (isset($this->redirectedFrom) && $this->redirectedFrom === 'emissions'){
$paramsSqlNoPerPage = $params_sql;
unset($paramsSqlNoPerPage['params']['limit']);
$nbSpectacles = $spectacles->countListSpectacles($paramsSqlNoPerPage, false);
$this->context['view']->pagination = $this->getPagination(
$nbSpectacles,
$this->perPage,
[
//Nombre total des représentations pour cette liste de spectacles
'total_dates' => $spectacles->countListSchedules($params_sql),
]
);
$this->context['view']->pagination['totalItems'] = $nbSpectacles;
} else {
$this->context['view']->pagination['totalItems'] = $this->context['view']->{'nb_spectacles_filtre_' . $selected . $filtre_sup};
}
$this->context['view']->pagination['spectacle'] = true;
$this->context['view']->pagination['representation_spectacle'] = true;
//on initialise tout ce qui est nécessaire à la vue
if (!empty($filtres[$selected]['view'])) {
$params_view = $filtres[$selected]['view'];
unset($params_view['special']);
if (!empty($params_view) && is_array($params_view)) {
foreach ($params_view as $k => $v) {
$this->context['view']->$k = $v;
}
}
if (!empty($filtres[$selected]['view']['special'])) {
foreach ($this->context['view']->spectacles as $ks => $vs) {
foreach ($filtres[$selected]['view']['special'] as $kv => $vv) {
if ($kv == 'annee_creation') {
if (!empty($this->context['view']->spectacles[$ks]['spectacle'])) {
$this->context['view']->spectacles[$ks]['spectacle']['annee_creation'] = $this->em->getRepository(Spectacles::class)->getFormeDate($this->context['view']->spectacles[$ks]['spectacle']['creation_date'], '%Y', true); //%a %d/%m/%Y;
} else {
$this->context['view']->spectacles[$ks]['annee_creation'] = $this->em->getRepository(Spectacles::class)->getFormeDate($this->context['view']->spectacles[$ks]['creation_date'], '%Y', true); //%a %d/%m/%Y;
}
} else {
$this->context['view']->spectacles[$ks][$kv] = $vv;
}
}
}
}
}
$ListSeasonsYears = null;
$search_ids_spectacles = [];
if (!empty($this->{'ids_spectacle_' . $selected})) {
$search_ids_spectacles = $this->{'ids_spectacle_' . $selected};
}
if (!empty($params["get_spectacles_with_critiques"])) {
$critiqueParam = true;
} else {
$critiqueParam = false;
}
if ($SpectaclesDates = $this->getSpectaclesDates($critiqueParam, $search_ids_spectacles)) {
$ListSeasonsYears = $this->getListSeasonsYears($SpectaclesDates);
}
$this->getCommonSearch(array(
'inverse_periode' => true,
'saisons_annees' => $ListSeasonsYears,
'nb_days' => 1200,
)
);
$this->getCommonSearchView();
if ((empty($params['get_spectacles_with_multimedias']) && empty($params['get_spectacles_with_critiques'])) && empty($params['get_spectacles_with_audios'])) {
// github issue #465 : retirer la recherche par période (ajout utilisation d'un booléen)
$this->getAsidesSpectacles(true);
}
return $this->view('contacts/spectacles.html.twig');
}
else {
return $this->redirectToRoute("contact_view", [
"slug" => $this->slug
]);
}
}
// }}}
// {{{ action_contenu_pedagogique()
/** Spectacles avec contenu pédagogiques
*
* @Route("/contacts/{slug}/contenu-pedagogique", name="contenu_pedagogique")
*
* @access public
* @return void
*/
public function action_contenu_pedagogique($slug = null)
{
$this->InitController($slug, 'contenu-pedagogique');
// contenus éduc
$idclassification = 125;
// contrainte de recherche sur le contact
$where_idcontact = null;
// auteur
$idperson_author = null;
$ids_spectacle_in = $this->obj->getSpectaclesIn($this->idobject, false, $idclassification);
$ids_spectacle_prod = $this->obj->getSpectaclesProd($this->idobject, false, $idclassification);
// les spectacles DANS ce lieu
$nb_spectacles_in = count($ids_spectacle_in);
$this->view->nb_spectacles_in = $nb_spectacles_in;
// pour afficher la colonne spectacle_in_or_jtn
if (!empty($nb_spectacles_in)) {
$this->view->spectacles_in_or_soutien = true;
}
// les spectacles coproduits ou lieu de cré ou compagnie
$nb_spectacles_prod = count($ids_spectacle_prod);
$this->view->nb_spectacles_prod = $nb_spectacles_prod;
$ids_spectacle_all = array_unique(array_merge($ids_spectacle_prod, $ids_spectacle_in));
// si c'est le JTN (idcontact = 3914), trouver les spectacles avec cette classification
// classification JTN => 103 => class_spectacle_jtn
if (!empty($this->idclassification_soutien)) {
$ids_spectacle_soutien = $this->obj->getSpectaclesSoutien($this->idobject, false, $idclassification);
$nb_spectacles_soutien = count($ids_spectacle_soutien);
$this->view->nb_spectacles_soutien = $nb_spectacles_soutien;
// pour afficher la colonne spectacle_in_or_soutien
if (empty($nb_spectacles_in)) {
$this->view->spectacles_in_or_soutien = true;
}
$ids_spectacle_all = array_unique(array_merge($ids_spectacle_all, $ids_spectacle_soutien));
}
// si un des 2 nbs est sup à 30
if ($nb_spectacles_in > $this->nb_contact_recherche || $nb_spectacles_prod > $this->nb_contact_recherche ||
(!empty($nb_spectacles_soutien) && $nb_spectacles_soutien > $this->nb_contact_recherche)) {
$sql_from = null;
// trouver tous les metteurs en scènes associés aux spectacles de ce contact
$directors = $this->getSpectaclesDirectors($ids_spectacle_all);
// liste des metteurs en scène
if (!empty($directors)) {
foreach ($directors as $k => $v) {
$directors_tab[$v['idperson']] = mb_strtoupper($v['lastname'], 'utf8') . ' ' . $v['firstname'];
if (!empty($_REQUEST['idperson_director']) && $v['idperson'] == $_REQUEST['idperson_director']) {
$this->view->search_director = $v;
}
}
natsort($directors_tab);
$directors_tab[0] = 'Choisissez un metteur en scène...';
// $this->context['form']->addElement('select', 'idperson_director', 'Metteurs en scène', $directors_tab, array('id' => 'idperson_director'));
// si on cherche un metteur en scène
if (!empty($_REQUEST['idperson_director']) && $this->func->my_is_int($_REQUEST['idperson_director'])
&& !empty($directors_tab[$_REQUEST['idperson_director']])) {
$idperson_director = (int)$_REQUEST['idperson_director'];
$where_idcontact .= ' AND sp.idperson=' . $idperson_director . ' AND sp.idrole=1 ';
} else {
// $this->context['form']->setDefaults(array('idperson_director' => 0));
}
}
// trouver tous les auteurs associés aux spectacles de ce contact
$authors = $this->getSpectaclesAuthors($ids_spectacle_all);
// liste des auteurs
if (!empty($authors)) {
foreach ($authors as $k => $v) {
$authors_tab[$v['idperson']] = mb_strtoupper($v['lastname'], 'utf8') . ' ' . $v['firstname'];
if (!empty($_REQUEST['idperson_author']) && $v['idperson'] == $_REQUEST['idperson_author']) {
$this->view->search_author = $v;
}
}
natsort($authors_tab);
$authors_tab[0] = 'Choisissez un auteur...';
// $this->context['form']->addElement('select', 'idperson_author', 'Auteurs', $authors_tab, array('id' => 'idperson_author'));
// si on cherche un auteur
if (!empty($_REQUEST['idperson_author']) && $this->func->my_is_int($_REQUEST['idperson_author'])
&& !empty($authors_tab[$_REQUEST['idperson_author']])) {
$idperson_author = (int)$_REQUEST['idperson_author'];
} else {
// $this->context['form']->setDefaults(array('idperson_author' => 0));
}
}
// recherche une année ?
$current_year = $this->getYear();
// une saison ?
$saison = $this->getSaison();
// les dates des spectacles de tous les spectacles associés à ce contact
$listdates = $this->getSpectaclesDates(false, $ids_spectacle_all);
// récupérer la liste des années et des saisons et générer les listes déroulantes
if (!empty($listdates)) {
$annees_saisons = $this->getListSeasonsYears($listdates);
// liste des saisons
$this->view->saisons = $annees_saisons['saisons'];
// liste des annees
$this->view->annees = $annees_saisons['annees'];
$this->getCommonSearch([
'saisons_annees' => [
'saisons' => $annees_saisons['saisons'],
'annees' => $annees_saisons['annees'] + $annees_saisons['annees']
]
]);
$this->getCommonSearchView();
}
// si aucune recherche par person, par année ou par saison => recherche par saison
// if(empty($current_year) && empty($saison) && empty($idperson_director) && empty($idperson_author)) {
// // prendre la dernière saison
// $saison = Date_time::getLastSaison($annees_saisons['saisons']);
// }
// recherche par saison
if (!empty($saison)) {
$annees_saison = explode('-', $saison);
if (count($annees_saison) == 2) {
$datestart = Date_time::getSaisonDatestart((int)$annees_saison[0]);
$dateend = Date_time::getSaisonDateend((int)$annees_saison[1]);
}
// saison de recherche
$this->view->saison = $saison;
// saison précédente / suivante
$this->view->saisons_nav = $this->getSaisonsNav($annees_saisons['saisons'], $saison);
$this->context['view']->booklets = $this->em->getRepository(Files::class)->getBookletsBySaison($saison, $this->idobject);
}
// annee
if (!empty($current_year)) { // recherche par année
$datestart = date('Y-m-d', mktime(0, 0, 0, 1, 1, $current_year));
$dateend = date('Y-m-d', mktime(0, 0, 0, 12, 31, $current_year));
// annee de recherche
$this->view->current_year = $current_year;
}
// recherche période
if (!empty($datestart) && !empty($dateend)) {
$where_idcontact .= ' AND sc.date BETWEEN \'' . $datestart . '\' AND \'' . $dateend . '\' ';
}
}
// spectacles de ce contact à l'affiche en ce moment (s jours) => recherche sur le calendrier
$spectacles_in = $this->getListSpectaclesIn($where_idcontact, $idperson_author, array('allauthors' => true), array(), $idclassification);
if (!empty($spectacles_in)) {
foreach ($spectacles_in as $k => $v) {
$idspectacles_in[$v['idspectacle']] = $v['idspectacle'];
$spectacles_in[$k]['url_clean_more'] = 'contenus-pedagogiques/';
}
}
$this->view->nb_spectacles_in_saison = count($spectacles_in);// nombre affiché
// github issue #462 : afficher par ordre antéchronologique
// $this->view->spectacles_in = $spectacles_in;
$this->view->spectacles_in= $this->sortSpectaclesByEndDate($spectacles_in);
$sqlSchedules = 'SELECT idcontact FROM schedules WHERE idcontact=' . $this->idobject . ' ' . str_replace('sc.', '', $where_idcontact);
$subQuery = $this->em->getConnection()->executeQuery($sqlSchedules);
$resSubQuery = $subQuery->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_ASSOC);
$where_idcontact_tournee = $where_idcontact . '
AND sc.idcontact NOT IN (' . implode(',', $resSubQuery) . ') ';
$spectacles_prod = $this->getListSpectaclesProd($where_idcontact_tournee, $idperson_author, array('allauthors' => true), array(), $idclassification);
// ajouter le lien
if (!empty($spectacles_prod)) {
foreach ($spectacles_prod as $k => $v) {
$spectacles_prod[$k]['url_clean_more'] = 'contenus-pedagogiques/';
}
}
$this->view->spectacles_prod = $spectacles_prod;
$this->view->nb_spectacles_prod_saison = count($spectacles_prod); // nombre affiché
// les soutiens JTN
if (!empty($nb_spectacles_soutien)) {
$spectacles_soutien = $this->getListSpectaclesSoutien($where_idcontact, $idperson_author, array('allauthors' => true), array(), $idclassification);
// ajouter le lien
if (!empty($spectacles_soutien)) {
foreach ($spectacles_soutien as $k => $v) {
$spectacles_soutien[$k]['url_clean_more'] = 'contenus-pedagogiques/';
}
}
$this->view->spectacles_soutien = $spectacles_soutien;
$this->view->nb_spectacles_soutien_saison = count($spectacles_soutien);
}
// contact avec bcp de bordel => affichage avec moteur de recherche
if ($nb_spectacles_in > $this->nb_contact_recherche
|| $nb_spectacles_prod > $this->nb_contact_recherche
|| (!empty($nb_spectacles_soutien) && $nb_spectacles_soutien > $this->nb_contact_recherche)) {
$this->view->big_contact = true;
}
//$this->style_more[] = 'pageregion';
// $menu_object['spectacles_in'] = array('nom' => 'Dans ce lieu ('.$this->view->nb_spectacles_in_saison.')');
// $menu_object['spectacles_prod'] = array('nom' => 'Coproduction en tournée ('.$this->view->nb_spectacles_prod_saison.')');
//
// // menu courant actif
// $menu_object[$this->context['action']]['active'] = 'on';
// $first = reset(array_keys($menu_object));
// $menu_object[$first]['first'] = true;
//
// $this->context['view']->menu_spectacles = $menu_object;
// On supprime les mentions mise en scene, les dates et ville
foreach ($this->context['view']->spectacles_in as $k => $v) {
$this->context['view']->spectacles_in[$k]['no_date'] = true;
$this->context['view']->spectacles_in[$k]['footer_date'] = true;
}
// github issue #462 : ne pas afficher la recherche par période
$this->context['view']->noPeriodSearch = true;
$menu_urls = array(
'contenu-pedagogique' => array(
'name' => 'Tous les spectacles',
'key_page' => 'contenu-pedagogique'
)
);
//aside
$this->asides->load(['contact_contenu_educ' => array(
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $menu_urls,
'url' => '/contacts/key_url_clean/key_page',
'params' => array(
'key_url_clean' => $this->context['view']->url_clean,
'key_page' => 'auto_key',
'activate' => (empty($saison)) ? $this->context['action'] : false
)
)
)]);
$this->asides->load(['common_participer_contacts' => array(
'exec' => array(
'color' => 'educ'
)
)]);
return $this->view('contacts/contenu-pedagogique.html.twig');
}
// }}}
// {{{ action_critiques()
/** Critiques des spectacles dans le lieu
*
* @Route("/contacts/{slug}/critiques", name="contact_critiques")
* @Route("/contacts/{slug}/critiques/type/{p_type}", name="contact_critiques_type")
*
* @access public
* @return void
*/
public function action_critiques($slug = null, $p_type = null)
{
$this->context['params']['type'] = $p_type;
$this->InitController($slug, 'critiques');
$this->action_spectacles($slug, true, [
'get_spectacles_with_critiques' => true
]);
$critiques_spectacles = array(
'in' => array(
'name' => 'Spectacles à venir',
'key' => 'in',
'count' => $this->context['view']->nb_spectacles_in
),
'anciens' => array(
'name' => 'Spectacles passés',
'key' => 'anciens',
'count' => $this->context['view']->nb_spectacles_anciens
),
'coprod' => array(
'name' => 'Production en scène',
'key' => 'coprod',
'count' => $this->context['view']->nb_spectacles_coprod
),
'prod' => array(
'name' => 'Toutes les produtions',
'key' => 'prod',
'count' => $this->context['view']->nb_spectacles_prod
),
'diffusions' => array(
'name' => 'Diffusés',
'key_type' => 'diffusions',
'count' => $this->context['view']->nb_spectacles_diffusions
)
);
$idobject = $this->idobject;
if (in_array($this->context['view']->type_spectacle, ['coprod'])) {
$idobject = null;
}
if (!empty($this->context['view']->spectacles)) {
foreach ($this->context['view']->spectacles as $k => $s) {
$this->context['view']->spectacles[$k]['critiques'] = $this->em->getRepository(Contents::class)->countAssociateContent('spectacles', $s['idspectacle'], 'class_critique', array('publish_valid' => 1));
if (!in_array($this->context['view']->type_spectacle, ['coprod'])) {
unset($this->context['view']->spectacles[$k]['city']);
}
if (!empty($annees_saisons)) {
$this->context['view']->spectacles[$k]['no_date'] = true;
}
}
}
// asides
$this->asides->load(['url_lists,filtre_critiques' => array(
'exec' => array(
'color' => 'critiques',
'htmlstart' => true,
'htmlend' => ($this->context['view']->type_spectacle == 'anciens') ? false : true
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $critiques_spectacles,
'url' => '/contacts/key_url_clean/critiques/type/key_url',
'params' => array(
'key_url_clean' => $this->context['view']->url_clean,
'key_url' => 'auto_key',
'activate' => $this->context['view']->type_spectacle
)
),
'title' => html_entity_decode('À l\'affiche'),
)]);
if ($this->context['view']->type_spectacle == 'anciens') {
$this->asides->load(['par_saison' => array(
'exec' => array(
'htmlend' => true,
'color' => 'critiques'
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/critiques/type/anciens',
),
'title' => 'Recherche par saison'
)]);
}
$this->asides->load(['common_participer_contacts' => array(
'exec' => ['color' => 'critiques']
)]);
return $this->view('contacts/critiques.html.twig');
}
// }}}
// {{{ action_api()
/** Spectacles de la structure
*
*
* @access public
* @return void
*/
public function action_api($api_data = true)
{
$datas = null;
$where_idcontact = null;
// recherche de spectacles
if (!empty($this->context['params']['spectacles']) || array_key_exists('authors', $this->context['params'])) {
// inactif pour le moment
$idperson_author = null;
// par défaut, recherche sur la saison si aucune demande
if (!$this->isSearchPeriod() && !$this->isSearchSeason()) {
// les dates des spectacles de tous les spectacles associés à ce contact
$listdates = $this->getSpectaclesDates();
// récupérer la dernière saison
if (!empty($listdates)) {
$saison = Date_time::getLastSaison($this->getListSeasonsYears($listdates, 'saisons'));
// récupèrer le début et la fin de cette saison
$annees_saison = explode('-', $saison);
// remplier search_period
if (count($annees_saison) == 2) {
$this->setSearchPeriod(Date_time::getSaisonDatestart((int)$annees_saison[0]), Date_time::getSaisonDateend((int)$annees_saison[1]));
}
}
}
// une saison ?
if ($this->isSearchSeason()) {
// récupèrer le début et la fin de cette saison
$annees_saison = explode('-', $this->getSeason());
// remplier search_period
if (count($annees_saison) == 2) {
$this->setSearchPeriod(Date_time::getSaisonDatestart((int)$annees_saison[0]), Date_time::getSaisonDateend((int)$annees_saison[1]));
}
}
// les saisons avec des spectacles
if (isset($_REQUEST['get_seasons']) && count($this->ids_spectacle_all) > 0) {
if (!empty($listdates)) {
$saisons_annees = $this->getListSeasonsYears($listdates);
} else {
$saisons_annees = $this->getListSeasonsYears($this->getSpectaclesDates());
}
return $saisons_annees;
}
// maintenant c'est OK
if ($this->isSearchPeriod()) {
$where_idcontact = ' AND sc.date BETWEEN \'' . $this->getFromPeriod() . '\' AND \'' . $this->getToPeriod() . '\' ';
}
}
if (!empty($this->context['params']['spectacles'])) {
// spectacles soutenus par une aide de la structure
if ($this->context['params']['spectacles'] == 'aide' && count($this->ids_spectacle_aide) > 0) {
// uniquement les saisons qui présentent des aides
if (isset($_REQUEST['get_seasons'])) {
return $this->getListSeasonsYears($this->getSpectaclesDates(false, $this->ids_spectacle_aide));
}
$datas = $this->getListSpectaclesAide($where_idcontact, $idperson_author, array('api' => $api_data));
}
// spectacles joués dans ce lieu (défaut = saison courante)
if ($this->context['params']['spectacles'] == 'in' || $this->context['params']['spectacles'] == 'publisher') {
$this->setOrder("ASC");
if (!empty($_REQUEST['order'])) {
$this->setOrder($_REQUEST['order']);
}
// uniquement les saisons qui présentent des spectacles joués dans le lieu
if (isset($_REQUEST['get_seasons']) && count($this->ids_spectacle_in) > 0) {
return $this->getListSeasonsYears($this->getSpectaclesDates(false, $this->ids_spectacle_in));
}
$datas = $this->getListSpectaclesIn($where_idcontact, $idperson_author, array('api' => $api_data));
}
// Productteur (17), coprod (18), prod délégué (19). Recherche sur spectacle_contact+idrole
// spectacles coproduits par ce lieu (défaut = saison courante)
if ($this->context['params']['spectacles'] == 'prod' && count($this->ids_spectacle_prod) > 0) {
// uniquement les saisons qui présentent des spectacles prod/coprod
if (isset($_REQUEST['get_seasons'])) {
return $this->getListSeasonsYears($this->getSpectaclesDates(false, $this->ids_spectacle_prod));
}
$datas = $this->getListSpectaclesProd($where_idcontact, $idperson_author, array('api' => $api_data));
}
// anciens élèves
if ($this->context['params']['spectacles'] == 'eleve') {
$datas = $this->getListSpectaclesEleve($where_idcontact, $idperson_author, array('api' => $api_data));
}
// les soutiens JTN (défaut : saison courante)
if (!empty($this->idclassification_soutien)) {
if ($this->context['params']['spectacles'] == 'soutien' && count($this->ids_spectacle_soutien) > 0) {
// uniquement les saisons qui présentent des spectacles soutenus
if (isset($_REQUEST['get_seasons'])) {
return $this->getListSeasonsYears($this->getSpectaclesDates(false, $this->ids_spectacle_soutien));
}
$datas = $this->getListSpectaclesSoutien($where_idcontact, $idperson_author, array('api' => $api_data));
}
}
// spectacles avec l'aide d'une structure en particulier sur les textes
if ($this->context['params']['spectacles'] == 'partners') {
$datas = $this->getListSpectaclesTextAideContact($where_idcontact, $idperson_author, array('api' => $api_data));
}
// infos de base
} else {
$datas = array(
array(
'name' => $this->infosobject['organisation'],
'permanent_url' => $_ENV['URL_THNET'] . '/contacts/' . $this->infosobject['url_clean'] . '/',
'country' => $this->infosobject['country']
)
);
// ajouter les infos complémentaires
if (!empty($GLOBALS['api']['data']) && $GLOBALS['api']['data'] == 'extended') {
$field_more = array(
'id' => 'idcontact',
'subtitle' => 'nom_suite',
'address' => 'address1',
'address_more' => 'address2',
'zip' => 'zip',
'city' => 'city',
'country' => 'country',
'phone' => array(
'general' => 'phone1',
'booking' => 'phone2',
),
'website' => 'url',
'geo' => array(
'x' => 'x',
'y' => 'y',
),
);
// parcourir
foreach ($field_more as $k => $v) {
if (is_array($v)) {
foreach ($v as $kb => $vb) {
$datas[0][$k][$kb] = $this->infosobject[$vb];
}
} else {
$datas[0][$k] = $this->infosobject[$v];
}
}
}
}
// recherche de personnes
if (array_key_exists('authors', $this->context['params'])) {
// les auteurs de la maison d'édition
$persons = $this->em->getRepository(Persons::class);
$param_sql_persons = array(
'special' => array(
'contacts' => array(
'publishers' => array($this->idobject)
)
),
'params' => array(
'limit' => array(0, 1000)
),
'dbg' => array('api_contacts_authors', 'Liste des auteurs associes a l\'editeur')
);
$datas = $persons->getListPersons($param_sql_persons);
if (!empty($datas)) {
foreach ($datas as $k => $v) {
$idpersons[$v['idperson']] = $v['idperson'];
}
}
// spectacles associés à ces personnes
if ($this->context['params']['authors'] == 'spectacles' && !empty($idpersons)) {
$spectacles = $this->em->getRepository(Spectacles::class);
$params_sql = array(
'special' => array(
'join_person' => array(
'idperson_authors_roles' => $idpersons
)
),
'params' => array(
'where' => $where_idcontact . ' AND s.`publish`=1 ',
'limit' => $this->getLimit(null, true),
),
'dbg' => array('api_contacts_authors_spectacles', 'Spectacles avec ces personnes comme auteur/metteur ou autre')
);
if ($this->isSearchArea()) {
$spectacles->setZoneRecherche($this->em->getRepository(Regions::class)->getZipCode($this->getArea())); // définir la zone de recherche
$params_sql['special']['carte_version'] = 'bigregions';
$params_sql['special']['area'] = $this->getArea();
}
$datas = $spectacles->getListSpectacles($params_sql, $this->format_vignette, false, array('api' => $api_data));
// noter les auteurs de l'éditeur
foreach ($datas as $k => $v) {
if (!empty($v['authors'])) {
foreach ($v['authors'] as $kb => $vb) {
if (isset($_REQUEST['get_person_illustration'])) {
$datas[$k]['authors'][$kb]['poster'] = $persons->getVignettePerson($kb, array('width' => 800, 'height' => 800, 'direction' => 'thumb'), true);
}
if (array_key_exists($kb, $idpersons)) {
$datas[$k]['authors'][$kb]['is_publisher_author'] = true;
}
}
}
if (!empty($v['directors'])) {
foreach ($v['directors'] as $kb => $vb) {
if (isset($_REQUEST['get_person_illustration'])) {
$datas[$k]['directors'][$kb]['poster'] = $persons->getVignettePerson($kb, array('width' => 800, 'height' => 800, 'direction' => 'thumb'), true);
}
if (array_key_exists($kb, $idpersons)) {
$datas[$k]['directors'][$kb]['is_publisher_author'] = true;
}
}
}
}
}
}
return $datas;
}
// }}}
// {{{ action_evenements()
/** Evenements et spectacles proposé par les internautes
*
* @Route("/contacts/{slug}/evenements", name="contact_evenements")
*
* @access public
* @return void
*/
public function action_evenements($slug = null)
{
$this->InitController($slug, 'evenements');
$this->context['view']->is_description = true;
// les évènements
$news = $this->em->getRepository(News::class);
$news_params = array(
'params' => array(
'limit' => array(0, 200),
),
'special' => array(
'publish_valid' => true,
'by_object' => array('idcontact' => $this->idobject),
),
);
// trouver 7 prochains évènements
// si pas de 7 prochains, trouver 7 anciens
foreach (array('news', 'spectacles') as $t) {
$news_list = array();
$news_params['special']['type_news'] = $t;
foreach (array('prochains', 'anciens') as $d) {
if ($d == 'anciens' && !empty($_GET['v']) && $_GET['v'] == 'ajax') {
$news_params['params']['limit'] = array(0, 3);
} else {
$news_params['params']['limit'] = array(0, 200);
}
$news_params['dbg'] = array('news_' . $d, 'Liste des news ' . $d);
$news_params['special'][$d] = true;
if (!empty($exclude_news)) {
$news_params['params']['where'] = ' AND T1.idnew NOT IN (' . join(',', $exclude_news) . ') ';
}
$news_list[$d] = $news->getListNews($news_params);
if (!empty($news_list[$d])) {
// liste d'exclusion => pas de en cours dans les anciens
foreach ($news_list[$d] as $k => $v) {
$exclude_news[$k] = $v['idnew'];
}
$this->view->{'is_news_list_' . $t} = true;
}
unset($news_params['special'][$d]);
}
$this->view->{'news_list_' . $t} = $news_list;
}
// page en cours
$this->view->from_page = $this->url_folder . '/evenements/';
//asides
$this->asides->load(['common_participer_contacts' => array(
'exec' => ['color' => 'evenements']
)]);
return $this->view('contacts/evenements.html.twig');
}
// }}}
// {{{ action_dvd()
/** Liste des DVDs VOD associés à des spectacles coproduits par le contact TODO
*
* @Route("/contacts/{slug}/dvd", name="contact_dvd")
*
* @access public
* @return void
*/
public function action_dvd($slug = null, Images $images)
{
$this->InitController($slug, 'dvd');
//On récupères le total des spectacles avec vidéos
$this->action_spectacles($slug, true, [
'get_spectacles_with_multimedias' => true
]);
//On récupère la liste des DVDS
$this->view->list_dvds = $this->getDvds();
$this->getAsidesVideos(null);
return $this->view('contacts/dvd.html.twig');
}
// }}}
// {{{ action_autorisation()
/** Demander à l'utilisateur s'il possède l'autorisation de modifier la page contact
*
* @Route("/contacts/{slug}/autorisation", name="contact_autorisation")
*
*/
public function action_autorisation($slug = null, UploadUtils $edit_utils, FilesController $files_utils, Request $request)
{
$GLOBALS['rub_courante'] = 'contacts';
$this->InitController($slug, 'detail-contact');
if ($this->getUser() instanceof Extranetusers) {
// paramètre d'instanciation
$params_edit = array(
'idobject' => $this->idobject,
'object' => 'contacts',
'page' => 'contacts',
);
$url_redirect = '/' . $params_edit['page'] . '/' . $this->infosobject['urlClean'] . '/';
// controlleur pour l'edition
$edit_utils->load($this->context, $params_edit);
// les droits
$object_rights = $edit_utils->checkObjectRights();
$this->view->object_rights = $object_rights;
// checker si la personne connectée à les droits sur cette fiche
if (!empty($object_rights['update'])) {
return $this->redirect($url_redirect . 'presentation-edit/'); // rediriger sur la page d'édition
} elseif (!empty($object_rights['wait'])) {
// si success, afficher le message d'attente
if (isset($_GET['success'])) {
$this->view->success = true;
$this->view->extranetuser_email = $this->getUser()->getEmail();
} else {
return $this->redirect($url_redirect . 'presentation/'); // rediriger sur la page de présentatio où il y a le message wait
}
} else { // sinon, form de demande de droits
$this->context['formFactory'] = $this->get('form.factory')->createBuilder(FormType::class, null, [
'attr' => [
'id' => 'masterform',
'novalidate' => true
]
]);
// formulaire
$this->context['formFactory']->add('himself', CheckboxType::class, [
'label' => '« Je représente ' . $this->infosobject['organisation'] . ' »',
'required' => false,
]);
$this->view->is_contact = true;
$constraints = [];
if (empty($_POST['form']['himself'])) {
$constraints = [
new NotBlank([
'message' => 'Justification : vous devez justifier votre demande'
])
];
}
$this->context['formFactory']->add('justification', TextareaType::class, [
'label' => 'Justification',
'required' => false,
'constraints' => $constraints,
'attr' => [
'rows' => 5,
'cols' => 100
]
]);
$this->context['formFactory']->add('validation', SubmitType::class, [
'label' => 'Envoyer la demande',
'attr' => [
'class' => 'boutform'
]
]); // validation
$this->context['form'] = $this->context['formFactory']->getForm();
$this->context['form']->handleRequest($request);
// le nom et l'url pour le template autorisation
$this->view->fullname = $this->infosobject['fullname'];
// url_folder
$this->infosobject['url_folder'] = '/' . $this->type_object . '/' . $this->infosobject['url_clean'];
// url du dossier
$this->url_folder = $this->infosobject['url_folder'];
$this->view->url_folder = $this->infosobject['url_folder'];
if ($this->context['form']->isSubmitted() && $this->context['form']->isValid()) {
//=> enregistrer dans person_extranetuser
$himself = $this->context['form']->get('himself')->getData();
// droits à 15 ==> autoriser directement / 8 ==> attente
$type_right = 15;
if (!empty($himself)) {
$motif = 'Je représente ' . $this->view->fullname;
} else {
$motif = $this->context['form']->get('justification')->getData();
}
$edit_utils->setRights($type_right, array('justification' => $motif, 'status' => 1));
// envoyer le mail à l'admin
if ($type_right == 8) {
$edit_utils->sendAlerte($this->context['view']->data_object['idcontact'], 'access', $this->context['form']->exportValue('justification'));
}
// rediriger sur cette page avec le message d'attente
return $this->redirect($url_redirect . 'autorisation/?success');
}
}
} else { // personne non loguée
// rediriger vers montheatre/connexion
return $this->redirectToRoute('app_login', ['urifrom' => '/contacts/' . $this->context['view']->url_clean . '/presentation-edit/', 'entete_connexion' => 'contacts']);
}
$this->extra_locate = $this->extra_title = 'Autorisation de modification';
return $this->view('contacts/autorisation.html.twig', [
'form' => $this->context['form']->createView()
]);
}
// }}}
// {{{ action_etudiants()
/** Les étudiants
*
* @Route("/contacts/{slug}/etudiants", name="contact_etudiants")
*
*/
public function action_etudiants($slug = null, Ecoles $ecoles, EcolesController $ecoles_folder)
{
$this->InitController($slug, 'laureats');
if ($this->em->getRepository(PersonEcole::class)->countEleves($this->infosobject['idcontact'], ['current' => true]) == 0) {
return $this->redirectToRoute('contact_anciens_etudiants', ['slug' => $this->context['view']->url_clean]);
}
$ecoles_folder->action_etudiants($ecoles, [
'idcontact' => $this->idobject,
'stop_execute' => true
]);
$this->view = (object)array_merge((array)$this->view, (array)$ecoles_folder->view);
$this->context = array_merge($this->context, $ecoles_folder->context);
$this->context['view']->page = $this->url_folder . '/etudiants';
$this->context['view']->affiche_ecole = false;
$this->extra_locate = $this->extra_title = 'Étudiants actuellement inscrits';
$this->context['view']->voir_tous_etudiants = true;
//aside
$this->getAsidesEtudiants('etudiants');
$this->asides->load(['ecoles_with_photos' => array(
'exec' => array(
'htmlstart' => true,
),
'title_sub' => (isset($this->view->is_jtn) && $this->view->is_jtn) ? 'Artistes' : 'Type d\'affichage',
)]);
$this->asides->load(['ecoles_promotions_encours' => array(
'exec' => array(
'alone' => false
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->annees,
'url' => 'key_page/y/key_year/photo/key_photos',
'params' => array(
'annee' => 'auto_key',
'key_page' => $this->context['view']->page,
'key_photo' => $this->context['view']->photos,
)
),
'title' => (isset($this->view->is_jtn) && $this->view->is_jtn) ? 'Promotions' : 'Promotions en cours d\'étude',
)]);
$titre_ecole_roles = 'Tri par section';
$titre_ecole_roles .= (!empty($this->context['view']->annee_promo)) ? 'pour la promo ' . $this->context['view']->annee_promo : '';
$this->asides->load(['ecoles_roles' => array(
'exec' => array(
'htmlend' => true
),
'title' => $titre_ecole_roles,
)]);
$this->asides->load('ecoles_modifier');
return $this->view('contacts/etudiants.html.twig');
}
// }}}
/** Les anciens étudiants
*
* @Route("/contacts/{slug}/anciens-etudiants", name="contact_anciens_etudiants")
*/
public function action_anciens_etudiants(
$slug = null,
Ecoles $ecoles,
EcolesController $ecoles_folder,
FormFactoryInterface $formFactory
)
{
$this->InitController($slug, 'etudiants');
$ecoles_folder->action_anciens(
$ecoles,
[
'idcontact' => $this->idobject,
'stop_execute' => true
],
null, null, null,
$formFactory
);
$this->view = (object)array_merge((array)$this->view, (array)$ecoles_folder->view);
$this->context = array_merge($this->context, $ecoles_folder->context);
$this->context['view']->page = $this->url_folder . '/anciens-etudiants';
$this->context['view']->affiche_ecole = false;
if (isset($this->view->is_jtn) && $this->view->is_jtn) {
$this->extra_locate = $this->extra_title = 'Anciens artistes JTN';
} else {
$this->extra_locate = $this->extra_title = 'Anciens étudiants';
}
//asides
$this->getAsidesEtudiants('anciens-etudiants');
$this->asides->load(['ecoles_with_photos' => [
'exec' => [
'htmlstart' => true
],
'title_sub' => html_entity_decode('Type d\'affichage'),
]]);
$this->asides->load(['recherche_promotion' => [
'exec' => [
'htmlstart' => true,
'htmlend' => true
],
'action' => '/contacts/' . $this->view->url_clean . '/anciens-etudiants',
'title_sub' => 'choisir une promotion'
]]);
$this->asides->load(['ecoles_roles' => [
'exec' => [
'htmlend' => true
],
'title' => 'Tri par section pour la promo',
]]);
$this->asides->load('ecoles_modifier');
return $this->view('contacts/anciens-etudiants.html.twig');
}
// {{{ action_etudiants_spectacles()
/** Les anciens étudiants
*
* @Route("/contacts/{slug}/etudiants-spectacles/", name="contact_etudiants_spectacles")
*
*/
public function action_etudiants_spectacles($slug = null, Ecoles $ecoles, EcolesController $ecoles_folder)
{
$this->InitController($slug, 'etudiants-spectacles');
$ecoles_folder->action_anciens_affiche($ecoles, [
'idcontact' => $this->idobject,
'stop_execute' => true
]);
$this->view = (object)array_merge((array)$this->view, (array)$ecoles_folder->view);
$this->context = array_merge($this->context, $ecoles_folder->context);
$this->context['view']->page = $this->url_folder . '/etudiants-spectacles';
$this->context['view']->affiche_ecole = false;
if (isset($this->view->is_jtn) && $this->view->is_jtn) {
$this->extra_locate = $this->extra_title = 'Anciens artistes à l\'affiche';
} else {
$this->extra_locate = $this->extra_title = 'Anciens étudiants à l\'affiche';
}
$this->action_spectacles($slug, false);
//asides
$this->getAsidesSpectacles('etudiants-spectacles');
$this->asides->load(['ecoles_with_photos' => array(
'title' => html_entity_decode('Filtres'),
)]);
$this->asides->load(['ecoles_roles' => array(
'exec' => array(
'htmlend' => true
),
'title' => 'Tri par section pour la promo ' . $this->__getView('annee_promo'),
)]);
$this->asides->load('ecoles_modifier');
return $this->View('contacts/etudiants-spectacles.html.twig');
}
// }}}
/** Trie le tableau entrant par ordre inverse des dates de fin de spectacles
*
* @param array $array
* @return array
*/
private function sortSpectaclesByEndDate(array $array): array
{
$sortedArray = [];
$intermediateArray = [];
foreach ($array as $key => $value) {
if (isset($value['periode']['dateend_std'])) {
$intermediateArray[$key] = $value['periode']['dateend_std'];
} else {
$intermediateArray[$key] = $value['prochdate_std'];
}
}
arsort($intermediateArray);
foreach ($intermediateArray as $key => $value) {
$sortedArray[$key] = $array[$key];
}
return $sortedArray;
}
// {{{ setAsidesCommunEnSavoirPlus()
/** method permettant d'éviter de dupliquer du code à différents endroits
*
*/
private function setAsidesCommunEnSavoirPlus()
{
// new array pour v2
$idextranetuser = null;
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$idextranetuser = $this->context['session']->getIdextranetuser();
}
$auteurs_menu_genre = array(
'presentation' => array(
'name' => 'Présentation',
'key_genre' => 'presentation',
)
);
if (!$this->contents->getAssociateContent($this->idobject, $this->type_object, 'class_presentation_structure')) {
unset($auteurs_menu_genre['presentation']);
}
if (isset($this->view->articles)) {
$this->context['view']->morearticle = true;
}
$this->asides->load(['bio_files' => array(
'exec' => array(
'alone' => true,
'color' => 'context'
)
)]);
$this->asides->load(['url_lists_alone,bio_lists_new' => array(
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $auteurs_menu_genre,
'url' => '/contacts/{v_url_clean}/key_genre',
'params' => array(
'activate' => $this->context['action']
)
)
)]);
$this->asides->load(['textes_menu_educ' => array(
'exec' => array(
'alone' => true,
'color' => 'context'
),
)]);
// aside
$this->asides->load('contact_pres_modif');
// $this->asides->load('contact_modifier_log');
//Uniquement pour les contacts écoles
if ($this->infosobject['idtypestructure'] == 'EC') {
$this->asides->load('ecoles_generic');
}
$this->asides->load('common_participer_contacts');
}
// {{{ action get aside pour les audios
/**
*
*/
public function getAsidesAudios($activate_aside_podcast = false, $aside_spectacle_audios = true)
{
$totalSpectaclesPodcasts = 0;
if ($aside_spectacle_audios) {
if (empty($this->context['view']->nb_spectacles_in_audio)) {
$this->action_spectacles(null, false, ['filtre_type' => 'audio', 'get_spectacles_with_audios' => true]);
}
$this->asides->load(['url_lists_alone,emissions' => [
'exec' => ['color' => 'audios'],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => [
// 'podcasts-textes '=> array(
// 'name' => 'Textes à l\'affiche',
// 'key_type' => 'podcasts-textes',
// ),
'podcasts-spectacles' => array(
'name' => 'Spectacles à venir',
'key_cat' => 'podcasts-spectacles',
'key_type' => 'in',
'count' => ($this->context['view']->nb_spectacles_in_audio + $totalSpectaclesPodcasts)
),
'podcasts-spectacles-anciens' => array(
'name' => 'Spectacles passés',
'key_cat' => 'podcasts-spectacles-anciens',
'key_type' => 'anciens',
'count' => $this->context['view']->nb_spectacles_anciens_audio
),
'podcasts-spectacles-coprod' => array(
'name' => 'Productions en scène',
'key_cat' => 'podcasts-spectacles-coprod',
'key_type' => 'coprod',
'count' => $this->context['view']->nb_spectacles_coprod_audio
),
'podcasts-spectacles-tous' => array(
'name' => 'Toutes les productions',
'key_cat' => 'podcasts-spectacles-tous',
'key_type' => 'prod',
'count' => ($this->context['view']->nb_spectacles_prod_audio + $totalSpectaclesPodcasts)
),
'podcasts-spectacles-selections' => array(
'name' => 'Spectacles sélectionnés',
'key_cat' => 'podcasts-spectacles-selections',
'key_type' => 'selections',
'count' => (isset($this->context['view']->nb_spectacles_selections_audio)) ? $this->context['view']->nb_spectacles_selections_audio + $totalSpectaclesPodcasts : $totalSpectaclesPodcasts
)
],
'url' => '/contacts/{v_url_clean}/key_action/cat/key_cat/type/key_type',
'params' => array(
'key_action' => 'emissions',
'activate' => (!empty($this->context['view']->cat)) ? $this->context['view']->cat : ''
),
),
'title' => 'ÉMISSIONS ASSOCIÉES'
]]);
}
if (in_array($this->idobject, [595, 5222])) {
$activate = $this->context['view']->url_clean;
$urls = [
'podcasts' => [
'name' => 'Toutes les émissions',
'url' => '/audios/emissions/',
],
[
'name' => 'Les émissions critiques',
'url' => '/critiques/audios'
],
[
'name' => 'France Culture',
'url' => '/contacts/France-Culture/podcasts/',
'key' => 'France-Culture'
],
[
'name' => 'France Inter',
'url' => '/contacts/France-Inter/podcasts/',
'key' => 'France-Inter'
],
];
} else {
$activate = '';
if ($activate_aside_podcast) {
$activate = 'all';
foreach (['emission', 'podcast'] as $value) {
if (!empty($this->context['params'][$value])) {
$activate = $this->context['params'][$value];
break;
}
}
}
$countAllPodcasts = (int)$this->em->getRepository(Podcasts::class)->countPodcasts('contacts', $this->idobject);
$countFranceCulturePodcasts = (int)$this->em->getRepository(Podcasts::class)->countPodcasts('contacts', $this->idobject, ['type_franceinter' => 0]);
$countFranceInterPodcasts = (int)$this->em->getRepository(Podcasts::class)->countPodcasts('contacts', $this->idobject, ['type_franceinter' => 1]);
$countSoundcloudPodcasts = (int)$this->em->getRepository(Podcasts::class)->countPodcasts('contacts', $this->idobject, 'soundcloud');
$urls = [
'podcasts' => [
'name' => 'Toutes les émissions',
'url' => '/contacts/{v_url_clean}/podcasts/',
'kety_activate' => 'all',
'count' => $countAllPodcasts
],
[
'name' => 'France Culture',
'url' => '/contacts/{v_url_clean}/podcasts/podcast/key_emission',
'key_emission' => 'franceculture',
'count' => $countFranceCulturePodcasts
],
[
'name' => 'France Inter',
'url' => '/contacts/{v_url_clean}/podcasts/podcast/key_emission',
'key_emission' => 'franceinter',
'count' => $countFranceInterPodcasts
],
[
'name' => 'Soundcloud',
'url' => '/contacts/{v_url_clean}/podcasts/podcast/soundcloud',
'key_emission' => 'soundcloud',
'count' => $countSoundcloudPodcasts
],
];
}
// if ($countAllPodcasts + $countFranceCulturePodcasts + $countFranceInterPodcasts + $countSoundcloudPodcasts > 0) {
$this->asides->load(['url_lists_alone,podcasts' => array(
'exec' => ['color' => 'audios'],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $urls,
'url' => '/key_url/',
'params' => array(
'activate' => $activate
),
),
'title' => html_entity_decode('écouter'),
)]);
// }
if (in_array($this->idobject, [595, 5222])) {
$this->asides->load([
'contact_franceculture_menu' => [
'php' => [
'method' => 'asidesPodcasts',
'params' => [
'station' => ($this->idobject == 5222) ? 'franceinter' : 'franceculture',
'em' => $this->em
]
]
]
]);
} else if ($this->context['action'] == 'podcasts') {
$this->asides->load([
'contact_franceculture_menu,franceculture' => [
'custom_url_clean' => 'France-Culture',
'title_custom' => 'France Culture',
'logo_custom' => 'france-culture'
]
]);
$this->asides->load([
'contact_franceculture_menu,franceinter' => [
'custom_url_clean' => 'France-Inter',
'title_custom' => 'France Inter',
'logo_custom' => 'france-inter'
]
]);
$this->asides->load([
'contact_franceculture_menu,autres' => [
'php' => [
'method' => 'asidesPodcasts',
'params' => [
'station' => 'soundcloud',
'em' => $this->em
]
]
]
]);
} else {
$this->asides->load(['common_carrer_informations' => [
'exec' => ['color' => 'spectacles'],
]]);
}
$this->asides->load(['common_participer_contacts' => array(
'exec' => ['color' => 'spectacles'],
)]);
}
// {{{ action get aside pour les videos
/**
*
*/
public function getAsidesVideos($nb_videos_partenariats = null, $filtre_captation = null)
{
$multimedias = $this->em->getRepository(Multimedias::class);
if (is_null($nb_videos_partenariats)) {
$params_query_commun = array(
'object' => array($this->idobject => ['contacts']),
'where' => array(array('multimedias', 'audio_video', 2)),
'order' => array('multimedias.date'),
'limit' => array('all'),
'dbg' => array('last_commun', 'Vidéos en partenariat du contact'),
);
$sql_dates_multimedias = $multimedias->getSQLMultimedias($params_query_commun, false);
$total = $multimedias->queryAll($sql_dates_multimedias);
$nb_videos_partenariats = count($total);
}
if (empty($this->context['view']->nb_spectacles_anciens)) {
$this->action_spectacles(null, false);
}
//La liste des menu qui sera affiché à travers les asides
$this->context['view']->menu_videos = array(
'in' => array(
'name' => 'Spectacles à venir',
'key_url' => 'contacts/{v_url_clean}/videos',
'key_type' => 'in',
'count' => $this->context['view']->nb_spectacles_in
),
'anciens' => array(
'name' => 'Spectacles passés',
'key_url' => 'contacts/{v_url_clean}/videos/type/key_type',
'key_type' => 'anciens',
'spectacle_anciens' => array('anciens' => true),
'count' => $this->context['view']->nb_spectacles_anciens
),
'coprod' => array(
'name' => 'Productions en scène',
'key_url' => 'contacts/{v_url_clean}/videos/type/key_type',
'key_type' => 'coprod',
'count' => $this->context['view']->nb_spectacles_coprod
),
'prod' => array(
'name' => 'Toutes les productions',
'key_url' => 'contacts/{v_url_clean}/videos/type/key_type',
'key_type' => 'prod',
'spectacle_anciens' => array('anciens' => true),
'count' => $this->context['view']->nb_spectacles_coprod
),
'partenariat' => array(
'name' => 'Toutes les vidéos en partenariat',
'key_url' => 'contacts/{v_url_clean}/videos/type/key_type',
'key_type' => 'partenariat',
// 'spectacle_anciens' => array('anciens' => true),
'count' => $nb_videos_partenariats
),
);
$count_dvds = $this->getDvds(true);
$podcasts = $this->em->getRepository(Podcasts::class);
$culturebox_params = array(
'special' => array(
'type_podcast' => 'culturebox', //commun
'is_integrale' => true, //commun
'idcontacts' => $this->idobject,
'current' => true
),
'dbg' => array('culturebox_data', 'Les replay culturebox'),
);
$nb_captations = $podcasts->countListPodcasts($culturebox_params);
$culturebox_params_vod = array(
'special' => array(
'type_podcast' => 'culturebox', //commun
'idcontacts' => $this->idobject,
'type_diffusion' => 1
),
'dbg' => array('culturebox_data', 'Les vods culturebox'),
);
$nb_vod = $podcasts->countListPodcasts($culturebox_params_vod);
$culturebox_params_vod['special']['type_diffusion'] = 2;
$nb_svod = $podcasts->countListPodcasts($culturebox_params_vod);
$contact_dvd = array(
'dvd' => array(
'name' => 'DVD',
'key_url' => '/contacts/' . $this->context['view']->url_clean . '/dvd',
'count' => $count_dvds,
'key_type' => 'dvd_'
),
'captations' => array(
'name' => 'Captation(s) en streaming (gratuit)',
'key_url' => '/contacts/' . $this->context['view']->url_clean . '/captations',
'count' => $nb_captations,
'key_type' => 'captations_'
),
'vod' => array(
'name' => 'VOD',
'key_url' => '/contacts/' . $this->context['view']->url_clean . '/captations/type/vod',
'count' => $nb_vod,
'key_type' => 'captations_vod'
),
'svod' => array(
'name' => 'SVOD',
'key_url' => '/contacts/' . $this->context['view']->url_clean . '/captations/type/svod',
'count' => $nb_svod,
'key_type' => 'captations_svod'
)
);
$this->asides->load(['url_lists' => array(
'exec' => array(
'htmlstart' => true,
'htmlend' => (in_array($this->context['view']->type_spectacle, ['anciens', 'partenariat']) && (!in_array($this->context['action'], ['captations', 'dvd']))) ? false : true,
'color' => 'videos',
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_videos,
'url' => '/key_url/',
'params' => array(
'activate' => (!in_array($this->context['action'], ['captations', 'dvd'])) ? $this->context['view']->type_spectacle : ''
),
),
'title' => html_entity_decode('Voir'),
)]);
if (in_array($this->context['view']->type_spectacle, ['anciens', 'partenariat']) && (!in_array($this->context['action'], ['captations', 'dvd']))) {
$this->asides->load(['par_saison' => array(
'exec' => array(
'htmlend' => true,
'color' => 'videos',
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/videos/type/key_type/',
'params' => array(
'key_type' => $this->context['view']->type_spectacle
)
),
'title' => html_entity_decode('Recherche par période')
)]);
}
if (empty($this->view->subaside_action)) {
$this->view->subaside_action = null;
}
if ($count_dvds > 0 || $nb_captations > 0) {
$this->asides->load(['url_lists_alone,contact_dvd' => array(
'exec' => ['alone' => true, 'color' => 'videos'],
'php' => [
'method' => 'asidesUrlLists',
'urls' => $contact_dvd,
'url' => 'key_url',
'params' => array(
'activate' => $this->context['action'] . '_' . $this->view->subaside_action
)
],
'title' => 'Films & Captations'
)]);
}
if (!empty($this->context['view']->filtre_culturebox)) {
$this->asides->load(['url_lists_alone' => array(
'exec' => ['alone' => true, 'color' => 'videos'],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->filtre_culturebox,
'url' => '/contacts/' . $this->context['view']->url_clean . '/captations/filtre/key_type',
'params' => array(
'key_type' => 'auto_key',
'activate' => $filtre_captation,
)
),
'title' => 'Filtres'
)]);
$this->asides->load('common_partenaire_culturebox');
}
$this->asides->load(['common_participer_contacts' => array(
'exec' => ['color' => 'videos']
)]);
}
// {{{ action get aside pour les spectacles
/**
*
*/
public function getAsidesSpectacles(bool $noAsideSearchByPeriod = false)
{
$type_spectacle = '';
if (!in_array($this->context['action'], ['podcasts', 'etudiants-spectacles-tous', 'calendrier', 'emissions'])) {
if (!empty($this->context['params']['cat'])) {
$type_spectacle = $this->context['params']['cat'];
} else if (!empty($this->context['view']->periode_spectacle)) {
$type_spectacle = $this->context['view']->periode_spectacle;
} else if (!empty($this->context['view']->type_spectacle)) {
$type_spectacle = $this->context['view']->type_spectacle;
}
}
// Liste aside pour contacts/spectacles @TODO remplire URL? + activate
$this->context['view']->menu_spectacles = array(
array(
'name' => 'Spectacles à venir',
'key_url' => 'contacts/{v_url_clean}/spectacles',
'key_type' => 'in',
'count' => $this->context['view']->nb_spectacles_in
),
array(
'name' => 'Spectacles passés',
'key_url' => 'contacts/{v_url_clean}/spectacles/type/key_type',
'key_type' => 'anciens',
'count' => $this->context['view']->nb_spectacles_anciens
),
array(
'name' => 'Productions en scène',
'key_url' => 'contacts/{v_url_clean}/spectacles/type/key_type',
'key_type' => 'coprod',
'count' => $this->context['view']->nb_spectacles_coprod
),
array(
'name' => 'Toutes les productions',
'key_url' => 'contacts/{v_url_clean}/spectacles/type/key_type',
'key_type' => 'prod',
'count' => $this->context['view']->nb_spectacles_prod
),
array(
'name' => 'Diffusés',
'key_url' => 'contacts/{v_url_clean}/spectacles/type/key_type',
'key_type' => 'diffusions',
'count' => $this->context['view']->nb_spectacles_diffusions
)
);
if (!isset($this->context['view']->all_en_scene)) {
$this->context['view']->all_en_scene = $this->countEnScene(['affiche' => true]);
}
if (!isset($this->context['view']->anciens_en_scene)) {
$this->context['view']->anciens_en_scene = $this->countEnScene(['anciens' => true]);
}
// aside
if ($this->context['view']->total_spectacle > 0) {
$this->asides->load(['url_lists,menu_principal' => array(
'exec' => array(
'htmlstart' => true,
'htmlend' => true,
'color' => 'spectacles',
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_spectacles,
'url' => '/key_url/',
'params' => array(
'activate' => $type_spectacle
),
),
'title' => html_entity_decode('Voir'),
)]);
if (!isset($this->context['params']['cat'])) {
$this->context['params']['cat'] = null;
}
if ($this->context['action'] != 'calendrier' && !in_array($type_spectacle, ['in', 'coprod', 'affiche', 'soutiens', 'anciens-textes', 'etudiants-spectacles-tous', 'podcasts-spectacles-tous']) && !in_array($this->context['action'], ['podcasts', 'etudiants-spectacles-tous']) && !in_array($this->context['params']['cat'], ['podcasts-spectacles'])) {
$this->asides->load(['par_saison' => array(
'exec' => array(
'htmlstart' => true,
'htmlend' => true,
'color' => 'spectacles'
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/{v_current_page}/type/{v_type_spectacle}',
),
'title' => 'Recherche par période'
)]);
}
}
$totalSpectaclesPodcasts = 0;
//Si on est chez France Culture
if (in_array($this->idobject, [595, 5222])) {
$params_sql = $this->setCommonSearchSpectacles(array(
'special' => array(
'textfictif' => 0,
'plus_proche' => true,
'podcasts' => [
'type_podcast' => 'franceculture'
]
),
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont un podcast'),
));
$params_sql['special']['type_franceinter'] = null;
if ($this->idobject == 5222) {
$params_sql['special']['type_franceinter'] = 1;
}
$totalProchainsSpectaclesPodcasts = $this->em->getRepository(Spectacles::class)->countListSpectacles($params_sql);
unset($params_sql['special']['plus_proche']);
$totalSpectaclesPodcasts = $this->em->getRepository(Spectacles::class)->countListSpectacles($params_sql);
}
//Si le total des spectacles audios n'existe pas
if (!isset($this->context['view']->nb_spectacles_in_audio)) {
$this->action_spectacles($this->slug, false);
}
$schedules = $this->em->getRepository(Schedules::class);
$ids_spectacle_prod = $this->obj->getSpectaclesProd($this->idobject);
$ids_spectacle_structures_diffusions = $this->obj->getSpectaclesProd($this->idobject, false, null, 77);
$ids_spectacles = array_merge($ids_spectacle_prod, $ids_spectacle_structures_diffusions);
$biographies_dates_demains = [];
if (!empty($ids_spectacles)) {
$biographies_dates_demains = $schedules->getDateBySpectaclesDemain($ids_spectacles, 1000, null, 'old', ['idcontact' => $this->idobject, 'count' => true]);
}
$urls = [];
if ($biographies_dates_demains && !empty($ids_spectacles)) {
$urls[] = [
'name' => 'Spectacles dans le lieu',
'count' => $schedules->getDateBySpectaclesDemain($ids_spectacles, 1000, null, 'old', ['idcontact' => $this->idobject, 'count' => true]),
'key_type' => 'structure',
];
};
if (!empty($ids_spectacles)) {
$urls[] = [
'name' => 'Productions en scène',
'count' => $schedules->getDateBySpectaclesDemain($ids_spectacles, 1000, null, 'old', ['count' => true]),
'key' => 'prod',
'url' => '/contacts/{v_url_clean}/calendrier/',
];
};
if ($biographies_dates_demains && !empty($ids_spectacles)) {
$this->asides->load(['url_lists,calendrier' => [
'exec' => array(
'color' => 'spectacles',
'htmlstart' => true,
'htmlend' => ($this->context['action'] == 'calendrier') ? false : true
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $urls,
'url' => '/contacts/{v_url_clean}/key_action/type/key_type',
'params' => array(
'key_action' => 'calendrier',
'activate' => (!empty($this->context['view']->type_calendrier)) ? $this->context['view']->type_calendrier : null
),
),
'title' => 'Calendrier'
]]);
}
if ($this->context['action'] == 'calendrier') {
$this->asides->load(['url_lists,filtre' => array(
'exec' => [
'color' => 'spectacles',
'htmlend' => true,
],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => (!empty($this->context['view']->menu_aside_mois)) ? $this->context['view']->menu_aside_mois : [],
'url' => '/contacts/{v_url_clean}/calendrier/#params',
),
'title' => 'Recherche par période'
)]);
}
$aides = $this->em->getRepository(Aides::class);
$params_sql_aides = array(
'special' => array(
'aides' => array(
'idcontacts' => $this->infosobject['idcontact'],
),
'type_aide' => 2, // Prix et distinctions
),
'dbg' => array('nombre_prix', 'Nombre de prix'),
);
//vaeur par défauts
$categorie_arrays = array(
'nominations' => array(
'title_aside' => 'Voir',
'title_page' => 'nommés ou lauréats',
'type_aide' => 2,
),
'soutiens' => array(
'title_aside' => 'Soutiens ',
'title_page' => 'soutenus',
'type_aide' => 1,
),
'selections' => array(
'title_aside' => 'Sélections',
'title_page' => 'sélectionnés',
'type_aide' => 4,
),
);
$type = 0;
if (!empty($this->context['params']['type'])) {
$type = $this->context['params']['type'];
}
foreach ($categorie_arrays as $kcategorie => $vcategorie) {
$sub_title = 'nominations';
$params_sql_aides['special']['type_aide'] = $vcategorie['type_aide']; // soutiens
$params_sql_aides['dbg'] = array('nombre_' . $kcategorie, 'Nombre de soutiens');
if ($count_aides_soutiens = $aides->countAides($params_sql_aides) > 0) {
if (isset($type) && $vcategorie['type_aide'] == $type) {
$this->view->categorie_title = $vcategorie['title_page'];
}
$filtre_nb_spectacles = $kcategorie;
if ($kcategorie == 'nominations') {
$filtre_nb_spectacles = 'laureats_nominations';
}
$spectacles_avenir = $this->context['view']->{'nb_spectacles_' . $filtre_nb_spectacles};
$avenir = $this->countEnScene(['type_aide' => $vcategorie['type_aide'], 'prochains' => true, 'without_lecture' => true]);
$ancien = $this->countEnScene(['type_aide' => $vcategorie['type_aide'], 'anciens' => true]);
if ($spectacles_avenir || $avenir > 0 || $ancien > 0) {
//On récupère la valeur du paramètre
$params_asides_nomsoutsec = (!empty($this->context['params']['periode'])) ? $this->context['params']['periode'] : $this->context['params']['type'];
$this->asides->load(['url_lists,menu_' . $kcategorie => array(
'exec' => array(
'htmlstart' => true,
'color' => 'spectacles',
'htmlend' => true
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => [
$kcategorie . '_' . $type => array(
'name' => 'Spectacles à l\'affiche',
'url' => '/contacts/{v_url_clean}/spectacles/type/key_categorie',
'key_periode' => 'soutiens',
'key_valide' => $kcategorie . '_' . $kcategorie,
'count' => $spectacles_avenir
),
'affiche_' . $kcategorie => array(
'name' => 'Textes en scène à venir',
'key_periode' => 'affiche',
'key_valide' => 'affiche_' . $vcategorie['type_aide'],
'count' => $avenir
),
'anciens-textes_' . $kcategorie => array(
'name' => 'Tous les textes en scène',
'key_periode' => 'anciens-textes',
'key_valide' => 'anciens-textes_' . $vcategorie['type_aide'],
'count' => $ancien
)
],
'url' => '/contacts/{v_url_clean}/key_action/periode/key_periode/type/key_type',
'params' => array(
'activate' => $params_asides_nomsoutsec . '_' . $type,
'key_action' => 'en-scene',
'key_type' => $vcategorie['type_aide'],
'key_categorie' => $kcategorie
),
),
'title' => html_entity_decode($vcategorie['title_aside']),
)]);
}
}
}
if (!in_array($type_spectacle, ['in', 'coprod', 'prod', 'affiche', 'soutiens', 'anciens']) && !in_array($this->context['action'], ['etudiants-spectacles-tous', 'calendrier', 'emissions'])) {
$aside_date_load = false;
if (in_array($type_spectacle, ['podcasts-spectacles', 'in', 'coprod', 'prod', 'affiche']) && empty($this->context['view']->menu_jours)) {
$this->context['view']->menu_jours = [
array(
'name' => 'dans les 7 prochains jours',
'key_day' => '7',
),
array(
'name' => 'dans les 30 prochains jours',
'key_day' => '30',
),
array(
'name' => 'dans les 3 prochains mois',
'key_day' => '90',
),
array(
'name' => 'dans les 12 prochains mois',
'key_day' => '365',
)
];
$this->asides->load(['url_lists,menu_days' => array(
'exec' => array(
'htmlstart' => true,
'color' => 'spectacles'
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_jours,
'url' => '/contacts/{v_url_clean}/{v_current_page}/generate_params',
'structure' => array(
// 'photo' => $this->__getView('photo'),
// 'role' => $this->__getView('role'),
'cat' => $this->context['params']['cat'],
'type' => $this->context['params']['type'],
'structure_classic' => array(
'd' => 'key_day',
's' => 'v_saison'
)
),
'params' => array(
'activate' => (!empty($_GET['d'])) ? (int)$_GET['d'] : ''
),
),
'title' => 'Recherche par période'
)]);
$aside_date_load = true;
}
if (!$noAsideSearchByPeriod) {
$this->asides->load(['par_saison,test' => array(
'exec' => array(
'htmlstart' => ($aside_date_load) ? false : true,
'htmlend' => true,
'color' => 'spectacles'
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/{v_current_page}/periode/{p_periode}'
),
// 'title' => 'Recherche par période'
)]);
}
}
if ($totalEtudiantAside = $this->em->getRepository(PersonEcole::class)->countEleves($this->infosobject['idcontact'])) {
$this->asides->load(['url_lists,menu_etudiants' => array(
'exec' => array(
'htmlstart' => true,
'color' => 'spectacles',
'htmlend' => ($this->context['action'] == 'etudiants-spectacles-tous') ? false : true
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => [
[
'name' => html_entity_decode('Anciens à l\'affiche'),
'key_type' => 'etudiants-spectacles-tous',
'count' => $totalEtudiantAside
]
],
'url' => '/contacts/{v_url_clean}/key_type',
'params' => array(
'activate' => $this->context['action']
),
),
'title' => (isset($this->view->is_jtn) && $this->view->is_jtn) ? 'anciens artistes JTN' : 'anciens étudiants',
)]);
if ($this->context['action'] == 'etudiants-spectacles-tous') {
$default_date = null;
if (!empty($this->context['view']->days)) {
$default_date = $this->context['view']->days;
} else if (!empty($this->view->current_saison)) {
$default_date = $this->view->current_saison;
}
if (!empty($this->context['view']->menu_jours)) {
$this->asides->load(['url_lists,menu_days' => array(
'exec' => array(
'alone' => false
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_jours,
'url' => '/contacts/{v_url_clean}/etudiants-spectacles-tous/generate_params',
'params' => array(
'activate' => $default_date
),
'structure' => array(
// 'photo' => $this->__getView('photo'),
// 'role' => $this->__getView('role'),
'sexe' => $this->__getView('sexe'),
'structure_classic' => array(
'd' => 'v_key',
's' => 'v_saison'
)
)
),
'title' => 'Recherche par période'
)]);
}
$this->asides->load(['recherche_par_periode' => array(
'exec' => array(
'alone' => false,
'htmlend' => true
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/etudiants-spectacles-tous/',
),
'structure' => array(
// 'photo' => $this->__getView('photo'),
// 'role' => $this->__getView('role'),
// 'sexe' => $this->__getView('sexe'),
'structure_classic' => array(
's' => 'v_saison'
)
),
'title' => (empty($this->context['view']->menu_jours)) ? 'Recherche par période' : false
)]);
}
}
if (!in_array($type_spectacle, ['anciens-textes', 'affiche'])) {
$this->asides->load(['common_carrer_informations' => [
'exec' => ['color' => 'spectacles'],
]]);
}
// if(!in_array($type_spectacle, ['in','anciens','prod','coprod'])){
// $this->asides->load(['recherche_par_periode' => array(
// 'exec' => array(
// 'alone' => false
// ),
// 'php' => array(
// 'method' => 'asidesUrlListsForms',
// 'url' => '/contacts/{v_url_clean}/{v_current_page}/type/{v_type_spectacle}'
// ),
// 'title' => 'Recherche par période'
// )]);
// }
$this->asides->load(['common_participer_contacts' => array(
'exec' => ['color' => 'spectacles'],
)]);
}
// }}}
// {{{ action get aside pour les etudiants
/**
*
*/
public function getAsidesEtudiants($activate = 'etudiants')
{
$this->view->{'page_' . $activate} = true;
if ((isset($this->view->is_jtn) && !$this->view->is_jtn) || $activate == 'anciens-etudiants') {
$this->asides->load('ecoles_nb_etudiants');
}
if (isset($this->view->is_jtn) && $this->view->is_jtn) {
$label_aside = 'artistes JTN';
} else {
$label_aside = 'étudiants';
}
$ecoles_type = array('EC', 'LE', 'JT');
$person_ecole = $this->em->getRepository(PersonEcole::class);
$nb_eleves = $person_ecole->countEleves($this->infosobject['idcontact']);
$nb_eleves_current = $person_ecole->countEleves($this->infosobject['idcontact'], array('current' => true));
$nb_eleves_old = $nb_eleves - $nb_eleves_current;
$all_type_etudiants = array(
array(
'name' => (isset($this->view->is_jtn) && $this->view->is_jtn) ? 'Artistes JTN' : html_entity_decode('Étudiants'),
'key_type' => 'etudiants',
'count' => $nb_eleves_current
),
array(
'name' => html_entity_decode('Anciens ' . $label_aside),
'key_type' => 'anciens-etudiants',
'count' => $nb_eleves_old
),
// array(
// 'name' => html_entity_decode('Anciens à l\'affiche'),
// 'key_type' => 'etudiants-spectacles',
// 'count' => $nb_eleves_old
// ),
);
$this->asides->load(['url_lists_alone,voir_all_type' => array(
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $all_type_etudiants,
'url' => '/contacts/{v_url_clean}/key_type',
'params' => array(
'activate' => $activate
)
),
'title' => html_entity_decode('Voir'),
)]);
$config_asides_etudiants = array(
'etudiants-spectacles' => array(
'external' => 'etudiants-spectacles-tous',
'url_external' => '/contacts/' . $this->view->url_clean . '/etudiants-spectacles-tous/',
'url' => '/contacts/' . $this->view->url_clean . '/etudiants-spectacles/'
),
'etudiants-spectacles-tous' => array(
'external' => 'etudiants-spectacles',
'url_external' => '/contacts/' . $this->view->url_clean . '/etudiants-spectacles/',
'url' => '/contacts/' . $this->view->url_clean . '/etudiants-spectacles-tous/'
),
//uniquement pour les dates
'anciens-etudiants' => array(
'external' => 'anciens-etudiants',
'url' => '/contacts/' . $this->view->url_clean . '/anciens-etudiants/'
)
);
if (!empty($config_asides_etudiants[$activate])) {
$config = $config_asides_etudiants[$activate];
if ($activate == 'etudiants-spectacles' || $activate == 'etudiants-spectacles-tous') {
$menu_menu_etudiants = array(
array(
'name' => 'Afficher par ' . $label_aside,
'url' => $config_asides_etudiants['etudiants-spectacles-tous']['url_external'] . 'generate_params',
'key' => 'etudiants-spectacles'
),
array(
'name' => 'Afficher par spectacles',
'url' => $config_asides_etudiants['etudiants-spectacles']['url_external'] . 'generate_params',
'key' => 'etudiants-spectacles-tous'
),
);
$this->asides->load(['url_lists,menu_etudiants' => array(
'exec' => array(
'htmlstart' => true
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $menu_menu_etudiants,
'url' => $config['url'] . 'generate_params',
'params' => array(
'activate' => $this->context['action']
),
'structure' => array(
// 'role' => $this->__getView('role'),
// 'photo' => $this->__getView('photo'),
'sexe' => $this->__getView('sexe'),
'structure_classic' => array(
'd' => 'v_key',
's' => 'v_saison'
)
)
),
'subtitle' => 'Type d\'affichage',
)]);
if ($this->__getView('current_saison')) {
$this->context['view']->menu_jours[] = array(
'name' => 'au cours de la saison ' . $this->view->current_saison,
'key_url' => '/contacts/' . $this->view->url_clean . '/etudiants-spectacles',
'v_saison' => $this->__getView('current_saison')
);
}
}
// $default_date = null;
// if(!empty($this->context['view']->days)){
// $default_date = $this->context['view']->days;
// }
// else if(!empty($this->view->current_saison)){
// $default_date = $this->view->current_saison;
// }
// $this->asides->load(['url_lists,menu_days' => array(
// 'exec' => array(
// 'htmlstart' => true
// ),
// 'php' => array(
// 'method' => 'asidesUrlLists',
// 'urls' => $this->context['view']->menu_jours,
// 'url' => $config['url'].'generate_params',
// 'params' => array(
// 'activate' => $default_date
// ),
// 'structure' => array(
// // 'photo' => $this->__getView('photo'),
// // 'role' => $this->__getView('role'),
// 'sexe' => $this->__getView('sexe'),
// 'structure_classic' => array(
// 'd' => 'v_key',
// 's' => 'v_saison'
// )
// )
// ),
// 'subtitle' => 'Par période'
// )]);
}
if ($activate == 'etudiants-spectacles' || $activate == 'etudiants-spectacles-tous') {
$this->asides->load(['par_saison' => array(
'exec' => array(
'alone' => false
),
'action' => $config['url'],
'structure' => array(
// 'photo' => $this->__getView('photo'),
// 'role' => $this->__getView('role'),
'sexe' => $this->__getView('sexe'),
'structure_classic' => array(
's' => 'v_saison'
)
)
)]);
$this->asides->load(['recherche_par_periode' => array(
'exec' => array(
'alone' => false
),
'action' => $config['url'],
'structure' => array(
// 'photo' => $this->__getView('photo'),
// 'role' => $this->__getView('role'),
'sexe' => $this->__getView('sexe'),
'structure_classic' => array(
's' => 'v_saison'
)
)
)]);
}
}
// }}}
// {{{ action_image_profil()
/** Changer/ajouter l'image de profil
*
*
* @access public
* @return void
*/
public function action_image_profil()
{
$this->extra_locate = $this->extra_title = 'Image de profil';
$this->style_more[] = array(
'/navigation/js/Jcrop/css/jquery.Jcrop.css',
'/navigation/js/upload/fineuploader.css'
);
$this->js_more[] = '/Jcrop/js/jquery.Jcrop.min.js';
$this->js_more[] = 'upload/jquery.fineuploader-3.0.min.js';
}
// }}}
// {{{ action_bandeau()
/** Changer/ajouter le bandeau
*
* @Route("/contacts/{slug}/bandeau/", name="contact_bandeau")
*
* @access public
* @return void
*/
public function action_bandeau($slug = null, UploadUtils $edit_utils, FilesController $files_utils, Request $request)
{
$GLOBALS['rub_courante'] = 'contacts';
$this->InitController($slug, 'bandeau');
// si connecté, instancier la classe utilitaires d'édition
if ($this->getUser() instanceof Extranetusers) {
// paramètre d'instanciation
$params_edit = array(
'idobject' => $this->idobject,
'object' => 'contacts',
);
$url_redirect = '/contacts/' . $this->infosobject['urlClean'] . '/';
// controlleur pour l'edition
$edit_utils->load($this->context, $params_edit);
// les droits
$this->view->object_rights = $object_rights = $edit_utils->checkObjectRights();
// checker si la personne connectée à les droits sur cette fiche
if (empty($object_rights['update'])) {
return $this->redirect($url_redirect . 'autorisation/');
}
} else { // personne non loguée
// rediriger vers montheatre/connexion
return $this->redirectToRoute('app_login', ['urifrom' => '/contacts/' . $this->infosobject['urlClean'] . '/bandeau', 'entete_connexion' => 'contacts']);
}
$this->extra_locate = $this->extra_title = 'Bandeau';
$this->style_more[] = array(
'/navigation/js/Jcrop/css/jquery.Jcrop.css',
'/navigation/js/upload/fineuploader.css'
);
$this->js_more[] = '/Jcrop/js/jquery.Jcrop.min.js';
$this->js_more[] = 'upload/jquery.fineuploader-3.0.min.js';
return $this->view('contacts/bandeau.html.twig');
}
// }}}
// {{{ action_documents_edit()
/** Ajouter des documents à la structure
*
* @Route("/contacts/{slug}/documents-edit/", name="contact_documents_edit")
* @Route("/contacts/{slug}/documents-edit/idfile/{idfile}", name="contact_documents_edit_idfile")
*
* @access public
* @return void
*/
public function action_documents_edit($idfile = null, $slug = null, UploadUtils $edit_utils, FilesController $files_utils, Request $request, EditUtils $editUtils)
{
$GLOBALS['rub_courante'] = 'contacts';
$this->InitController($slug, 'documents');
$this->context['params']['idfile'] = $idfile;
// paramètre d'instanciation
$params_edit = array(
'idobject' => $this->idobject,
'object' => 'contacts',
);
// si connecté, instancier la classe utilitaires d'édition
if ($this->getUser() instanceof Extranetusers) {
// controlleur pour l'edition
$edit_utils->load($this->context, $params_edit);
// les droits
$object_rights = $edit_utils->checkObjectRights();
$this->view->object_rights = $object_rights;
// checker si la personne connectée à les droits sur cette fiche
// if(!empty($object_rights['update'])) {
// pour la gestion des fichiers
$files_utils->InitFilesController($this->context, $params_edit);
$this->context['view']->data_object = $this->infosobject;
$response = $files_utils->documents_edit($request, $editUtils);
if ($response instanceof RedirectResponse) {
return $response;
}
// } else { // la personne n'a pas les droits => renvoi sur le formulaire de demande
// actionRedirect($context['view']->data_object['url_folder'].'/autorisation/');
// }
} else { // personne non loguée
// rediriger vers montheatre/connexion
return $this->redirectToRoute('app_login', [
'urifrom' => $request->getRequestUri(),
'entete_connexion' => $params_edit['object']]
);
}
/* géré par Files_edit */
$this->extra_locate = $this->extra_title = 'Ajouter/modifier un document';
$this->view->style_more[] = '/navigation/js/upload/fineuploader.css';
$this->view->js_more[] = 'upload/jquery.fineuploader-3.0.min.js';
// style et js en plus pour les champs de relation
$this->view->style_more[] = 'relat.css';
$this->view->js_more[] = 'ajax.relation.js';
$this->context['view']->jquery_cal = 'datepicker';
return $this->view('contacts/documents-edit.html.twig', [
'form' => $files_utils->context['form']->createView()
]);
}
// }}}
// {{{
// {{{ action_documents_delete()
/** Ajouter des documents à la structure
*
* @Route("/contacts/{slug}/documents-delete/idfile/{idfile}", name="contact_documents_delete_idfile")
*
* @access public
* @return void
*/
public function action_documents_delete($idfile = null, $slug = null, UploadUtils $edit_utils, FilesController $files_utils, Request $request)
{
$GLOBALS['rub_courante'] = 'contacts';
$this->InitController($slug, 'documents');
$this->context['params']['idfile'] = $idfile;
// paramètre d'instanciation
$params_edit = array(
'idobject' => $this->idobject,
'object' => 'contacts',
);
// si connecté, instancier la classe utilitaires d'édition
if ($this->getUser() instanceof Extranetusers) {
// controlleur pour l'edition
$edit_utils->load($this->context, $params_edit);
// les droits
$object_rights = $edit_utils->checkObjectRights();
$this->view->object_rights = $object_rights;
// checker si la personne connectée à les droits sur cette fiche
// if(!empty($object_rights['update'])) {
// pour la gestion des fichiers
$files_utils->InitFilesController($this->context, $params_edit);
$this->context['view']->data_object = $this->infosobject;
$response = $files_utils->documents_delete($request);
if ($response instanceof RedirectResponse) {
return $response;
}
// } else { // la personne n'a pas les droits => renvoi sur le formulaire de demande
// actionRedirect($context['view']->data_object['url_folder'].'/autorisation/');
// }
} else { // personne non loguée
// rediriger vers montheatre/connexion
return $this->redirectToRoute('app_login', ['urifrom' => $this->context['view']->data_object['url_folder'] . '/documents-edit', 'entete_connexion' => $params_edit['object']]);
}
$this->extra_locate = $this->extra_title = 'Ajouter/modifier un document';
return $this->view('contacts/documents-delete.html.twig', [
// 'form' => $files_utils->context['form']->createView()
]);
}
// {{{ action_documents()
/** Les documents lié à la structure
*
* @Route("/contacts/{slug}/documents", name="contact_documents")
*
* @access public
* @return void
*/
public function action_documents($slug = null, UploadUtils $edit_utils, FilesController $files_utils, Request $request)
{
$GLOBALS['rub_courante'] = 'contacts';
$this->InitController($slug, 'documents');
// paramètre d'instanciation
$params_edit = array(
'idobject' => $this->idobject,
'object' => 'contacts',
);
// si connecté, instancier la classe utilitaires d'édition
if ($this->getUser() instanceof Extranetusers) {
// controlleur pour l'edition
$edit_utils->load($this->context, $params_edit);
// les droits
$object_rights = $edit_utils->checkObjectRights();
// checker si la personne connectée à les droits sur cette fiche
if (!empty($object_rights['update'])) {
$this->context['formFactory'] = $this->get('form.factory')->createBuilder(FormType::class, null, [
'attr' => [
'id' => 'masterform',
'novalidate' => true
]
]);
// pour la gestion des fichiers
$files_utils->InitFilesController($this->context, $params_edit);
$files_utils->documents($request);
$this->view->form = $files_utils->context['form']->createView();
} else { // la personne n'a pas les droits => renvoi sur le formulaire de demande
return $this->redirect($this->infosobject['url_folder'] . '/autorisation/');
}
} else { // personne non loguée
// rediriger vers montheatre/connexion
return $this->redirectToRoute('app_login', ['urifrom' => $this->infosobject['url_folder'] . '/documents', 'entete_connexion' => $params_edit['object']]);
}
/* géré par Files_edit */
$this->extra_locate = $this->extra_title = 'Documents associés';
// style et js en plus pour les champs de relation
$this->view->style_more[] = 'relat';
$this->view->js_more[] = 'ajax.relation.js';
return $this->view('contacts/documents.html.twig');
}
// }}}
// {{{ action_telechargements()
/** Les documents lié à la structure
*
* @Route("/contacts/{slug}/telechargements", name="contact_telechargements")
*
* @access public
* @return void
*/
public function action_telechargements($slug = null)
{
$this->InitController($slug, 'telechargements');
$this->extra_locate = $this->extra_title = 'Documents associés';
// saison courante
$this->context['view']->current_saison = Date_time::getLastSaison();
// une saison ?
$this->context['view']->saison = Date_time::getSaisonParam();
if ($this->context['view']->saison == $this->context['view']->current_saison) {
$this->context['view']->is_current_saison = true;
}
$files = $this->em->getRepository(Files::class);
$classifications = $this->em->getRepository(Classifications::class);
// classifications des contacts
$classifications_contact_list = $classifications->getClassificationList('files', 'contacts', null, array(1), 'get_value');
// classifications des spectacles
$classifications_spectacle_list = $classifications->getClassificationList('files', 'spectacles', null, array(1), 'get_value');
// joindre les deux
$classifications_list = array_merge($classifications_contact_list, $classifications_spectacle_list);
// liste des fichiers
$params_object_files = array(
'valid' => 1,
'publish' => 1,
'force_mode' => 'file',
'debug_sql_associate' => false
);
$object_files = $files->getObjectFiles($this->idobject, 'contacts', $classifications_list, $params_object_files);
if (!empty($object_files)) {
// trouver toutes les saisons
foreach ($object_files as $k => $v) {
if (!empty($v['saison'])) {
$saisons[$v['saison']] = $v['saison'];
}
}
// classement du tableau
if (!empty($saisons)) {
krsort($saisons);
$this->getCommonSearch([
'saisons_annees' => array(
'saisons' => $saisons,
)
]);
$this->getCommonSearchView();
// première saison
if (empty($this->context['view']->saison)) {
foreach ($saisons as $k => $v) {
$this->context['view']->saison = $v;
break;
}
}
}
foreach ($object_files as $k => $v) {
if (!empty($v['saison']) && $v['saison'] == $this->context['view']->saison) {
if (array_key_exists($v['idclassification'], $classifications_spectacle_list)) {
// infos sur le spectacle => trouver le spectacle
$classifications = $this->em->getRepository(Classifications::class);
$sql = 'SELECT idobject
FROM object_file
WHERE idfile=' . $v['idfile'] . '
AND object=\'spectacles\' ';
$idspectacle = $classifications->queryOne($sql);
if (!empty($idspectacle)) {
$params_sql_spectacle = array(
'special' => array(
'idspectacle' => $idspectacle,
'publish' => 'all',
'join' => true, // jointure gauche avec schedules
'plus_proche' => true,
),
'params' => array(
'order' => ['s.dateinsert', 'DESC'],
'limit' => array(0, 100),
'where' => ' AND s.statut != 4',
),
'dbg' => array('spectacles_list', 'Liste des spectacles'),
);
// affichage
$params_display = array(
'stylemore' => array('imagep' => 'width:65px', 'descsp' => 'width:310px;'),
);
$spectacles = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql_spectacle, $params_display);
foreach ($spectacles as $s) {
$v['objects']['spectacles'][] = $s;
}
//$this->context['view']->files['spectacles'][$idspectacle]['files'][$v['idfile']] = $v;
$this->context['view']->files['spectacles'][$k] = $v;
}
}
if (array_key_exists($v['idclassification'], $classifications_contact_list)) {
$this->context['view']->files['general'][$k] = $v;
}
}
}
$this->context['view']->is_file = true;
if (!empty($saisons)) {
//setDebug($saisons);
}
}
$this->js_more[] = 'jquery.matchHeight-min.js';
//aside
$this->asides->load('contact_telechargement_infos');
return $this->view('contacts/telechargements.html.twig');
}
// }}}
// {{{ action_presentation_edit()
/** Modifier la présentation textuelle de la structure
*
* @Route("/contacts/{slug}/presentation-edit", name="contact_presentation_edit")
*
* @access public
* @return void
*/
public function action_presentation_edit($slug = null, UploadUtils $uploadUtils, Request $request, TheatreMail $TheatreMail, UtilsEdit $utilsEdit, EditUtils $editUtils)
{
return $this->redirectToRoute('index', [], Response::HTTP_MOVED_PERMANENTLY);
}
// }}}
// {{{ action_infos_generales()
/** Informations générales sur la structure
*
* @Route("/contacts/{slug}/infos-generales", name="contact_infos_generales")
*
* @access public
*/
public function action_infos_generales($slug = null, Request $request, TheatreMail $TheatreMail, EditUtils $editUtils)
{
$this->InitController($slug, 'infos-generales');
$this->extra_locate = $this->extra_title = 'Modifier vos informations';
$idcontact = $this->infosobject['idcontact'];
if (isset($_GET['update_success'])) {
$this->view->reponse['save_ok'] = 'Vos informations ont bien été enregistrées';
}
// si connecté, instancier la classe utilitaires d'édition
if ($this->getUser() instanceof Extranetusers) {
// paramètre d'instanciation
$params_edit = array(
'idobject' => $idcontact,
'object' => 'contacts',
'em' => $this->em
);
$url_redirect = '/contacts/' . $this->infosobject['urlClean'] . '/';
$object_fields = array(
'url',
'facebook',
'twitter',
'instagram',
'url_ticket',
'organisation',
'nom_suite',
'idtypestructure',
'license',
'address1',
'address2',
'zip',
'city',
'country',
'phone1',
'phone2',
'fax',
'email1',
'email2',
'email1_online',
'email2_online',
);
$editUtils->setParams($this->context, $params_edit);
// les droits
$object_rights = $editUtils->checkObjectRights();
$this->view->object_rights = $object_rights;
// checker si la personne connectée à les droits sur cette fiche
if (!empty($object_rights['update'])) {
$data = $this->infosobject;
$GLOBALS['from_id'] = $data['idmultimedia'];
// les champs
$fields = array('text', 'link', 'facebook', 'twitter', 'instagram');
$form = $this->get('form.factory')->createBuilder(FormType::class, $this->infosobject, [
'attr' => [
'id' => 'masterform'
]
]);
$form->add('organisation', TextType::class, [
'label' => 'Nom court',
'constraints' => [
new NotBlank([
'message' => 'Nom court : veuillez préciser le nom de votre structure'
])
],
'attr' => [
'size' => '45',
'id' => 'organisation'
]
]);
$form->add('nom_suite', TextType::class, [
'label' => 'Nom complet',
'required' => false,
'attr' => [
'size' => '45',
'id' => 'nom_suite'
]
]);
// select type structure
$typesstructures = $this->em->getRepository(Typesstructures::class);
$typestructure_list = $typesstructures->getTypeStructureList(true);
$typestructurenames_list = $typesstructures->getTypeStructureList(true, false, array(), true);
$typestructureselect_list = [];
foreach ($typestructure_list as $key => $value) {
$typestructureselect_list[$value] = $typestructurenames_list[$key];
}
$form->add('idtypestructure', ChoiceType::class, [
'label' => 'Type de structure',
'choices' => array_flip($typestructureselect_list),
'placeholder' => 'Choisissez dans la liste',
'required' => false,
'attr' => [
'class' => 'select_typestructure',
'id' => 'idtypestructure'
]
]);
$form->add('license', TextType::class, [
'label' => 'Licence de spectacle',
'required' => false,
'attr' => [
'size' => '45',
'id' => 'license'
]
]);
$form->add('address1', TextType::class, [
'label' => 'Adresse',
'constraints' => [
new NotBlank([
'message' => 'Adresse : veuillez préciser l\'adresse'
])
],
'attr' => [
'size' => '45',
'id' => 'address1'
]
]);
$form->add('address2', TextType::class, [
'label' => 'Adresse suite',
'required' => false,
'attr' => [
'size' => '45',
'id' => 'address2'
]
]);
$form->add('zip', TextType::class, [
'label' => 'Code postal',
'constraints' => [
new NotBlank([
'message' => 'Code postal : veuillez préciser le code postal'
])
],
'attr' => [
'size' => '45',
'id' => 'zip'
]
]);
$form->add('city', TextType::class, [
'label' => 'Ville',
'constraints' => [
new NotBlank([
'message' => 'Ville : veuillez préciser la ville'
])
],
'attr' => [
'size' => '45',
'id' => 'city'
]
]);
$form->add('country', ChoiceType::class, [
'label' => 'Pays',
'choices' => $this->em->getRepository(Contacts::class)->getCountryList(),
'constraints' => [
new NotBlank([
'message' => 'Pays : veuillez préciser le pays'
])
],
'attr' => [
'id' => 'country'
]
]);
$form->add('phone1', TextType::class, [
'label' => 'Téléphone général',
'required' => false,
'attr' => [
'size' => '45',
'id' => 'phone1'
]
]);
$form->add('phone2', TextType::class, [
'label' => 'Téléphone location',
'required' => false,
'attr' => [
'size' => '45',
'id' => 'phone2'
]
]);
$form->add('fax', TextType::class, [
'label' => 'Télécopie',
'required' => false,
'attr' => [
'size' => '45',
'id' => 'fax'
]
]);
$form->add('email1', TextType::class, [
'label' => 'Email général',
'required' => false,
'constraints' => [
// new NotBlank([
// 'message' => 'Email : veuillez préciser un email'
// ]),
new Email([
'message' => 'Email général : l\'adresse email principale semble incorrecte'
])
],
'attr' => [
'size' => '45',
'id' => 'email1'
]
]);
$form->add('email2', TextType::class, [
'label' => 'Email location',
'required' => false,
'constraints' => [
new Email([
'message' => 'Email location : l\'adresse email de location semble incorrecte'
])
],
'attr' => [
'size' => '45',
'id' => 'email2'
]
]);
// masquer les adresses ?
$form->add('email1_online', ChoiceType::class, [
'placeholder' => false,
'label' => 'Email général visible',
'expanded' => true,
'multiple' => false,
'choices' => [
'oui' => 1,
'non' => 0
],
'required' => false,
]);
$form->add('email2_online', ChoiceType::class, [
'placeholder' => false,
'label' => 'Email location visible',
'expanded' => true,
'multiple' => false,
'choices' => [
'oui' => 1,
'non' => 0
],
'required' => false,
]);
$form->add('url_ticket', TextType::class, [
'label' => 'Billetterie en ligne',
'required' => false,
'constraints' => [
new Url([
'protocols' => ['http', 'https'],
'message' => 'Billetterie : l\'adresse du site semble incorrecte(elle doit commencer par http://)'
])
],
'attr' => [
'size' => '45',
'id' => 'link'
]
]);
$form->add('url', TextType::class, [
'label' => 'Site internet',
'required' => false,
'constraints' => [
new Url([
'protocols' => ['http', 'https'],
'message' => 'Site internet : l\'adresse du site semble incorrecte (elle doit commencer par https://)'
]),
new CheckWebsite([
'message' => 'Site Internet : le site Internet que vous avez précisé ne semble pas disponible ! Vérifiez qu\'il s\'agit bien de la bonne adresse'
])
],
'attr' => [
'size' => '45',
'id' => 'link'
]
]);
$form->add('facebook', TextType::class, [
'label' => 'Profil Facebook',
'required' => false,
'constraints' => [
new Url([
'protocols' => ['http', 'https'],
'message' => 'Profil Facebook : l\'adresse du profil facebook semble incorrecte (elle doit commencer par httpss://)'
])
],
'attr' => [
'size' => '45',
'id' => 'facebook'
]
]);
$form->add('twitter', TextType::class, [
'label' => 'Profil Twitter',
'required' => false,
'constraints' => [
new Url([
'protocols' => ['http', 'https'],
'message' => 'Profil Twitter : l\'adresse du profil twitter semble incorrecte (elle doit commencer par httpss://)'
])
],
'attr' => [
'size' => '45',
'id' => 'twitter'
]
]);
$form->add('instagram', TextType::class, [
'label' => 'Profil Instagram',
'required' => false,
'constraints' => [
new Url([
'protocols' => ['http', 'https'],
'message' => 'Profil Instagram : l\'adresse du profil instagram semble incorrecte (elle doit commencer par httpss://)'
])
],
'attr' => [
'size' => '45',
'id' => 'instagram'
]
]);
// choix de la vidéo de tête
$form->add('idmultimedia', RelationsType::class, [
'label' => 'Vidéo de tête',
'type_object' => 'form',
'type_dbdo' => 'multimedias',
'dbdo' => 'contacts',
'relat' => 'simple'
]);
$form->add('validation', SubmitType::class, [
'label' => 'Enregistrer les informations',
'attr' => [
'class' => 'boutform boutbig'
]
]); // validation
$form = $form->getForm();
$form->handleRequest($request);
// enregistrement des informations
if ($form->isSubmitted() && $form->isValid()) {
foreach ($object_fields as $f) {
if ($form->has($f)) {
$values[$f] = $this->escape($form->get($f)->getData());
}
}
// enregistrer la dernière version validée par un administrateur (fige)
// les versions intermédiaires ne seront pas enregistrées
if (!empty($data['valid_version'])) {
$values['other_versions'] = serialize($data);
$values['valid_version'] = 0;// remettre à zero la valid version
}
// un multimedia sélectionné ?
$idmultimedia = $form->get('idmultimedia')->getViewData();
$values['idmultimedia'] = 0;
if (!empty($idmultimedia)) {
$values['idmultimedia'] = $idmultimedia;
}
// enregistrer les nouvelles versions
$editUtils->obj->setUpdateFields($values);
if ($editUtils->obj->setData($idcontact)) {
// envoyer un mail à l'admin
$editUtils->sendAlerte($idcontact, 'update', 'Mise à jour des informations générales', $TheatreMail);
// $edit_utils->logAction($idcontact,null,'contacts',$this->getUser()->getIdextranetuser());
// prévenir du success
$reponse['save_ok'] = 'Vos informations ont bien été enregistrées';
return $this->redirect('/contacts/' . $data['url_clean'] . '/infos-generales?update_success');
// les nouvelles valeurs
$data = $values;
// pour le pays
$data['country_code'] = $data['country'];
} else {
$this->logger->error('Pb pendant l\'enregistrement d\'un contact');
}
}
if (!$form->isSubmitted()) {
$form->get('email1_online')->setData(0);
if ($this->infosobject['email1Online']) {
$form->get('email1_online')->setData($this->infosobject['email1Online']);
}
$form->get('email2_online')->setData(0);
if ($this->infosobject['email2Online']) {
$form->get('email2_online')->setData($this->infosobject['email2Online']);
}
if (empty($data['country_code'])) {
$form->get('country')->setData(array('FR'));
} else {
$form->get('country')->setData(strtoupper($data['country_code']));
}
if (empty($data['idtypestructure'])) {
$form->get('idtypestructure')->setData(0);
} else {
$form->get('idtypestructure')->setData($data['idtypestructure']);
}
if (!empty($data['urlTicket'])) {
$form->get('url_ticket')->setData($data['urlTicket']);
}
if (!empty($data['idmultimedia'])) {
$form->get('idmultimedia')->setData($data['idmultimedia']);
}
}
} else { // la personne n'a pas les droits => renvoi sur le formulaire de demande
return $this->redirect($url_redirect . 'autorisation/');
}
} else { // personne non loguée
// rediriger vers montheatre/connexion
return $this->redirect('/montheatre/connexion?urifrom=/contacts/' . $this->context['view']->url_clean . '/infos-generales&entete_connexion=contacts');
}
$this->view->js_more[] = 'ajax.relation.js';
return $this->view('contacts/infos-generales.html.twig', [
'form' => $form->createView()
]);
}
// }}}
// {{{ action_equipe()
/** Les équipes
*
*
* @access public
* @return void
*/
public function action_equipe()
{
// style et js en plus pour les champs de relation
$this->style_more[] = 'relat';
$this->js_more[] = 'ajax.relation.js';
$this->extra_locate = $this->extra_title = 'Equipe';
}
// }}}
// {{{ action_eleves()
/** Les éléves
*
*
* @access public
* @return void
*/
public function action_eleves()
{
if ($this->idobject == 3914) { // pour le JTN
$this->extra_locate = $this->extra_title = 'Artistes';
} else {
$this->extra_locate = $this->extra_title = 'Élèves';
}
}
// }}}
// {{{ action_eleves_edit()
/** Les éléves ajout/modification
*
*
* @access public
* @return void
*/
public function action_eleves_edit()
{
// style et js en plus pour les champs de relation
$this->style_more[] = 'relat';
$this->js_more[] = 'ajax.relation.js';
$this->extra_locate = $this->extra_title = 'Élèves - Ajout/modification';
}
// }}}
// {{{ action_dossiers()
/** Les dossiers de presse
*
*
* @access public
* @return void
*/
public function action_dossiers()
{
// style et js en plus pour les champs de relation
/*$this->style_more[] = 'relat';
$this->js_more[] = 'ajax.relation.js'; */
$dossiers = $this->contents->getAssociateContents($this->idobject, $this->type_object, 'class_dossier_presse', array('no_by_lang' => true, 'get_files' => true));
$this->view->dossiers = $dossiers;
$this->style_more[] = array('/navigation/js/upload/fileuploader.css');
$this->js_more[] = 'upload/fileuploader.js';
$this->extra_locate = $this->extra_title = 'Dossiers de presse';
}
// }}}
// {{{ action_ecole()
/** Anciens élèves
*
*
* @access public
* @return void
*/
public function action_ecole()
{
if ($this->idobject == 3914) { // pour le JTN
$this->extra_locate = $this->extra_title = 'Artistes';
$this->context['view']->is_artiste = true;
} else {
$this->extra_locate = $this->extra_title = 'Anciens élèves';
}
}
// }}}
// {{{ action_laureats()
/** Lauréats d'un prix
*
* @Route("/contacts/{slug}/laureats", name="contact_laureats")
* @Route("/contacts/{slug}/laureats/type/{p_type}", name="contact_laureats_type")
* @Route("/contacts/{slug}/laureats/type/{p_type}/idaide/{p_idaide}", name="contact_laureats_type_idaide")
*
* @access public
* @return void
*/
public function action_laureats($slug = null, $p_type = null, $p_idaide = null)
{
$this->context['params']['type'] = $p_type;
$this->context['params']['idaide'] = $p_idaide;
$this->InitController($slug, 'laureats');
$this->context['view']->current_page = 'laureats';
$this->context['view']->show_prix = false;
$this->getContactAides(2);
$this->context['view']->title_type = 'Lauréat';
$this->context['view']->menu_title_type = 'lauréats';
$this->asides->load(['url_lists' => array(
'exec' => array(
'htmlstart' => true
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_types_object,
'url' => '/contacts/{v_url_clean}/{v_current_page}/type/key_type?y={v_year}',
'params' => array(
'key_type' => 'auto_key'
)
),
'title' => 'Voir'
)]);
$this->asides->load(['par_annee' => array(
'exec' => array(
'htmlend' => true
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/{v_current_page}'
),
'title' => 'Recherche par période'
)]);
// $this->asides->load('laureat_nbscene');
$this->asides->load('contact_list_aidecontacts');
$this->asides->load('laureat_prix_list');
$this->asides->load('laureat_signaler');
$this->asides->load('contact_chartreuse');
return $this->view('contacts/laureats.html.twig');
}
// {{{ action_nominations()
/** Nominations d'un prix
*
* @Route("/contacts/{slug}/nominations/", name="contact_nominations")
* @Route("/contacts/{slug}/nominations/type/{p_type}", name="contact_nominationsç_type")
* @Route("/contacts/{slug}/nominations/type/{p_type}/idaide/{p_idaide}", name="contact_nominations_type_idaide")
*
* @access public
* @return void
*/
public function action_nominations($slug = null, $p_type = null, $p_idaide = null)
{
$this->InitController($slug, 'nominations');
$this->context['view']->current_page = 'nominations';
$this->context['view']->show_prix = false;
$this->context['params']['type'] = $p_type;
$this->context['params']['idaide'] = $p_idaide;
$this->getContactAides(array(2, 3));
if (!empty($this->context['view']->filtres_aides_categories[$this->context['view']->params_filtre])) {
$this->context['view']->aside_aide_contact_soutiens = $this->em->getRepository(Aides::class)->getListAides([
'special' => array(
'aides' => array(
'idcontacts' => $this->idobject
),
'idaidecontact' => $this->context['view']->filtres_aides_categories[$this->context['view']->params_filtre],
'type_aide' => array(2, 3)
)
]);
}
$this->context['view']->title_type = 'Nomination';
$this->context['view']->menu_title_type = 'nominés';
$this->getAsideContent(['show_aides_contacts']);
$this->asides->load('contact_chartreuse');
return $this->view('contacts/nominations.html.twig');
}
// }}}
// {{{ action_prix()
/** Redirection des prix vers l'accueil (arnaque simplifié)
*
* @Route("/contacts/{slug}/prix", name="contact_prix")
*
* @access public
* @return void
*/
public function action_prix($slug = null)
{
$this->InitController($slug, 'aides');
return $this->redirectToRoute('contact_view', ['slug' => $this->context['view']->url_clean]);
}
// {{{ action_soutiens()
/** Soutien à quelque chose
*
* @Route("/contacts/{slug}/soutiens", name="contact_soutiens")
* @Route("/contacts/{slug}/soutiens/type/{type}", name="contact_soutiens_type")
* @Route("/contacts/{slug}/soutiens/type/{type}/idaide/{idaide}", name="contact_soutiens_type_idaide")
*
* @access public
* @return void
*/
public function action_soutiens($slug = null, $type = null, $idaide = null)
{
$this->context['params']['type'] = $type;
$this->context['params']['idaide'] = $idaide;
$this->InitController($slug, 'soutiens');
// $tthis->conetext['view']->type_object
//on supprime l'affichage de la date et de la ville
$this->context['view']->noshow = true;
$this->context['view']->current_page = 'soutiens';
$this->perPage = 20;
$this->getContactAides(array(1));
$this->context['view']->title_type = 'Soutien';
$this->context['view']->menu_title_type = 'soutenus';
$this->asides->load(['url_lists' => array(
'exec' => array(
'htmlstart' => true,
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_types_object,
'url' => '/contacts/{v_url_clean}/{v_current_page}/type/key_type',
'params' => array(
'key_type' => 'auto_key'
)
),
'title' => 'Voir'
)]);
$this->asides->load(['par_annee' => array(
'exec' => array(
'htmlend' => true,
'color' => ($this->context['action'] == 'selections') ? 'textes' : 'context',
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/{v_current_page}'
),
'title' => 'Recherche par periode'
)]);
$this->asides->load('contact_list_aidecontacts');
$this->asides->load('contact_chartreuse');
return $this->view('contacts/soutiens.html.twig');
}
// }}}
// {{{ action_selections()
/** Sélection de quelques choses
*
* @Route("/contacts/{slug}/selections", name="contact_selections")
* @Route("/contacts/{slug}/selections/type/{type}/", name="contact_selections_type")
* @Route("/contacts/{slug}/selections/type/{type}/idaide/{idaide}", name="contact_selections_type_idaide")
*
* @access public
* @return void
*/
public function action_selections($slug = null, $type = null, $idaide = null)
{
$this->context['params']['type'] = $type;
$this->context['params']['idaide'] = $idaide;
$this->InitController($slug, 'selections');
$this->getContactAides(array(4));
$this->context['view']->title_type = 'Sélection';
$this->context['view']->menu_title_type = 'sélectionnés';
// $this->getAsideContent();
$this->asides->load(['url_lists' => array(
'exec' => array(
'htmlstart' => true,
'color' => ($this->context['action'] == 'selections') ? 'textes' : 'context',
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_types_object,
'url' => '/contacts/{v_url_clean}/{v_current_page}/type/key_type',
'params' => array(
'key_type' => 'auto_key'
)
),
'title' => 'Voir'
)]);
$this->asides->load(['par_annee' => array(
'exec' => array(
'htmlend' => true,
'color' => ($this->context['action'] == 'selections') ? 'textes' : 'context',
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/selections'
),
'title' => 'Recherche par periode'
)]);
$this->asides->load(['contact_list_aidecontacts' => array(
'exec' => ['color' => 'textes']
)]);
$this->asides->load('laureat_signaler');
$this->asides->load('contact_chartreuse');
$this->context['view']->current_page = 'selections';
$this->context['view']->pagination['totalItems'] = $this->context['view']->pagination['total'];
$this->context['view']->pagination['custom'] = true;
$this->context['view']->pagination['custom_name'] = "selections";
// $this->context['view']->pagination['perpage'] = 25;
return $this->view('contacts/selections.html.twig');
}
// }}}
// {{{ action_auteurs()
/** Nominations d'un auteur
*
* @Route("/contacts/{slug}/auteurs", name="contact_auteurs")
*
* @access public
* @return void
*/
public function action_auteurs($slug = null)
{
$this->InitController($slug, 'auteurs');
$this->context['view']->current_page = 'auteurs';
$this->getContactAides(array(2, 3));
$this->context['view']->noshowtexteoriginal = true;
$title_types = array(
'selections' => 'aux sélections',
'laureats' => 'aux lauréats',
'nominations' => 'aux nominations',
'soutiens' => 'aux soutiens',
);
// si on vient de la page autre
if (!empty($_REQUEST['from_page_aide']) && !empty($title_types[$_REQUEST['from_page_aide']])) {
$_SESSION['from_page_aide'] = $_REQUEST['from_page_aide'];
}
if (!empty($_SESSION['from_page_aide'])) {
$this->context['view']->title_type = $title_types[$_SESSION['from_page_aide']];
$this->context['view']->from_page_aide = $_SESSION['from_page_aide'];
}
$this->context['view']->title_type = 'Les textes par leurs auteurs';
$this->context['view']->menu_title_type = 'Nominations des textes par l\'auteur';
$nav_textes_auteurs = array(
array(
'name' => 'Tous les textes par leurs auteurs',
'key_url' => '/textes/edition/auteurs-spectacles/periode/affiche'
)
);
//asides
$this->asides->load(['url_lists' => array(
'exec' => ['color' => 'videos', 'htmlstart' => true],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $nav_textes_auteurs,
'url' => 'key_url'
),
'title' => 'Voir'
)]);
$this->asides->load(['par_annee' => array(
'exec' => ['color' => 'videos', 'htmlend' => true],
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/auteurs/'
),
'title' => 'Recherche par période'
)]);
return $this->view('contacts/auteurs.html.twig');
}
// }}}
// {{{ action_etudiants_spectacles_tous()
/** Anciens élèves
*
* @access public
* @return void
*/
public function action_etudiants_spectacles_tous($slug = null)
{
$this->action_spectacles($slug, false);
$this->perPage = 20;
require_once PATH_LIBS . 'Controllers/Ecoles_folder.php';
$ecoles_folder = new Ecoles_folder($this->context, array(
'idcontact' => $this->idobject,
));
// classes
$person_ecole = $this->em->getRepository(PersonEcole::class);
// compter mes élèves
if ($person_ecole->countEleves($this->idobject) > 0) {
$spectacles = $this->em->getRepository(Spectacles::class);
// les élèves
$list_idpersons = $person_ecole->getPersons($this->idobject, array('get_ids' => true));
$where_idperson = 'sp.`idperson` IN (' . join(',', $list_idpersons) . ') ';
$params_sql = array(
'params' => array(
'where' => ' AND (' . $where_idperson . ') ',
'limit' => 'all',
),
'special' => array(
'plus_proche' => true,
// les élèves du contact
'get_eleves' => array(
'idcontact' => $this->idobject,
),
),
'dbg' => array('scenes', 'Les spectacles à l\'affiche'),
);
// trouver les spectacle avec la classification JTN
if (!empty($idclassification_specifique)) {
$params_sql = array(
'params' => array(
'limit' => 'all',
),
'special' => array(
'plus_proche' => true,
'by_classification' => $idclassification_specifique,
'eleves_from_idcontact' => $this->idobject,
),
'dbg' => array('etudiants_spectacles_tous', 'Les spectacles à l\'affiche des étudiants'),
);
}
// recherche par saison
if (!empty($this->context['view']->saison)) {
$params_sql['special']['saison'] = $this->context['view']->saison;
} elseif (!empty($this->context['view']->year)) { // recherche par année
$params_sql['special']['year'] = $this->context['view']->year;
} elseif (!empty($this->context['view']->datestart) && !empty($this->context['view']->dateend)) { // par période
$params_sql['special']['period'] = array(
'start' => $this->context['view']->datestart,
'end' => $this->context['view']->dateend,
);
} else { // prochains jours
$params_sql['special']['prochains'] = $this->context['view']->days;
}
//paginations
$this->context['view']->pagination = $this->getPagination(
$spectacles->countListSpectacles($params_sql), //Total de spectacle
$this->perPage, //Nombre max de résultat
[
//Nombre total des représentations pour cette liste de spectacles
'total_dates' => $spectacles->countListSchedules($params_sql),
]
);
$this->context['view']->pagination['spectacle'] = true;
$this->context['view']->pagination['representation_spectacle'] = true;
//Application des limites pour le nombre de spectacles
$params_sql['params']['limit'] = array($this->getLimitStart(), $this->perPage);
//On récupère la listes
$this->context['view']->spectacles = $spectacles->getListSpectacles($params_sql, null, false, ['allauthors' => true]);
}
$this->getAsidesSpectacles('etudiants-spectacles-tous');
}
// }}}
// {{{ action_stats()
/** l'action par défault
*
* @Route("/contacts/{slug}/stats", name="contact_stats")
*
*/
public function action_stats($slug = null)
{
$this->InitController($slug, 'stats');
if ($this->infosobject['stats_access'] == 1) {
$utilscontacts = new UtilsContacts(array(
'idcontact' => $this->idobject,
'contacts' => $this->em->getRepository(Contacts::class)
));
// champs de recherche
// $this->context['form']->addElement('text', 'from', 'Entre', array('size'=>'7','id'=>'from'));
// $this->context['form']->addElement('text', 'to', 'et', array('size'=>'7','id'=>'to'));
// les dates des spectacles de tous les spectacles associés à ce contact
$listdates = $utilscontacts->getDatesCoprod();
// récupérer la liste des années et des saisons et générer les listes déroulantes
if (!empty($listdates)) {
$annees_saisons = $this->getListSeasonsYears($listdates);
// liste des saisons
$this->view->saisons = $annees_saisons['saisons'];
// $this->context['form']->addElement('select', 's', 'Saisons', array_merge(array('' => 'Choisissez une saison...'),$annees_saisons['saisons']), array('id' => 'saisons'));
// liste des annees
$this->view->annees = $annees_saisons['annees'];
// $this->context['form']->addElement('select', 'y', 'Années', array_diff_key(array(0 => 'Choisissez une année...'),$annees_saisons['annees'])+$annees_saisons['annees'], array('id' => 'annees'));
}
// les totaux
// le nombre de représentation au total soutenus par la structure
$this->context['view']->nb_dates = $utilscontacts->countDatesCoprod();
// le nombre de représentation au total soutenus par la structure en France
$this->context['view']->nb_dates_fr = $utilscontacts->countFranceDatesCoprod();
// le nombre de représentation au total soutenus par la structure à l'étranger
$this->context['view']->nb_dates_i8n = $utilscontacts->countInternationalDatesCoprod();
// le nombre de pays différents (hors France)
$this->context['view']->nb_countries = $utilscontacts->countCountriesDatesCoprod();
// le nombre de spectacles au total soutenus par la structure
$this->context['view']->nb_spectacles = $utilscontacts->countSpectaclesCoprod();
// le nombre total de représentations dans les différents type de structure (T, CDN...) = un tableau
$this->context['view']->nb_dates_typestructure = $utilscontacts->countTypestructureDatesCoprod();
// compter par rapport au différent type de structure
if (!empty($this->context['view']->nb_dates_typestructure)) {
$this->context['view']->total_dates_typestructure = $utilscontacts->getTotal($this->context['view']->nb_dates_typestructure, false);
// le nombre de représentations dans les autres type de structure
if ($this->context['view']->nb_dates > $this->context['view']->total_dates_typestructure) {
$this->context['view']->nb_dates_alltypestructure = $this->context['view']->nb_dates - $this->context['view']->total_dates_typestructure;
} else {
$this->context['view']->nb_dates_alltypestructure = $this->context['view']->total_dates_typestructure - $this->context['view']->nb_dates;
}
}
// classe des dates
// require_once PATH_LIBS.'Date/Date_time.php';
// recherche une année ?
$current_year = $this->getYear();
// une saison ?
$saison = $this->getSaison();
// une période
$from = $this->getFrom();
$to = $this->getTo();
if (!Date_time::checkStartEndFormat($from, $to) && !empty($annees_saisons)) {
// si aucune recherche par année, par période ou par saison => recherche par saison
if (empty($current_year) && empty($saison)) {
// prendre la dernière saison
$saison = Date_time::getLastSaison($annees_saisons['saisons']);
}
// recherche par saison
if (!empty($saison)) {
$annees_saison = explode('-', $saison);
if (count($annees_saison) == 2) {
$from = Date_time::getSaisonDatestart((int)$annees_saison[0]);
$to = Date_time::getSaisonDateend((int)$annees_saison[1]);
}
// saison de recherche
$this->view->saison = $saison;
// saison précédente / suivante
$this->view->saisons_nav = $this->getSaisonsNav($annees_saisons['saisons'], $saison);
}
// recherche par annee
if (!empty($current_year)) { // recherche par année
$from = date('Y-m-d', mktime(0, 0, 0, 1, 1, $current_year));
$to = date('Y-m-d', mktime(0, 0, 0, 12, 31, $current_year));
// annee de recherche
$this->view->current_year = $current_year;
}
}
// au final, il doit y avoir une recherche période
if (!empty($from) && !empty($to)) {
if (!Date_time::checkStartEndFormat($from, $to)) {
$this->context['error'][] = 'Paramètres de recherche inccorect';
} else {
$utilscontacts->setPeriodeRecherche($from, $to);
$this->context['view']->from = $utilscontacts->contacts->getFormeDate($from, '%d/%m/%Y', true);
$this->context['view']->to = $utilscontacts->contacts->getFormeDate($to, '%d/%m/%Y', true);
}
}
// le nombre de spectacles soutenus par la structure sur la période
$this->context['view']->nb_spectacles_periode = $utilscontacts->countSpectaclesCoprod();
// le nombre de représentation soutenus par la structure sur la période
$this->context['view']->nb_dates_periode = $utilscontacts->countDatesCoprod();
// le nombre de représentations dans les différents type de structure (T, CDN...) sur la période
// en paramètre => les totaux calculés précédement
$this->context['view']->nb_dates_typestructure_periode = $utilscontacts->countTypestructureDatesCoprod($this->context['view']->nb_dates_typestructure);
// compter par rapport au différent type de structure
if (!empty($this->context['view']->nb_dates_typestructure_periode)) {
$this->context['view']->total_dates_typestructure_periode = $utilscontacts->getTotal($this->context['view']->nb_dates_typestructure_periode, true);
// le nombre de représentations dans les autres type de structure
if ($this->context['view']->nb_dates_periode > $this->context['view']->total_dates_typestructure_periode) {
$this->context['view']->nb_dates_alltypestructure_periode = $this->context['view']->nb_dates_periode - $this->context['view']->total_dates_typestructure_periode;
} else {
$this->context['view']->nb_dates_alltypestructure_periode = $this->context['view']->total_dates_typestructure_periode - $this->context['view']->nb_dates_periode;
}
}
// le nombre de représentation soutenus par la structure en France sur la période
$this->context['view']->nb_dates_fr_periode = $utilscontacts->countFranceDatesCoprod();
// le nombre de représentation soutenus par la structure à l'étranger sur la période
$this->context['view']->nb_dates_i8n_periode = $utilscontacts->countInternationalDatesCoprod();
// le nombre de pays différents (hors France)
$this->context['view']->nb_countries_periode = $utilscontacts->countCountriesDatesCoprod();
// jquery
$this->context['view']->jquery_cal = 'datepicker';
/*$data_charts_string = '<script type="text/javascript">';
//var data_'.$d.' = ['.join(',', $$d).'];';
$data_charts_string .= '
var data_evolution_multimedias = ['.join(',', $evolution_multimedias).'];
var data_date_evolution_multimedias = ['.join(',', $date_evolution_multimedias).'];';
$data_charts_string .= '</script>';
$this->view->data_charts = $data_charts_string;*/
} else {
$this->context['error'][] = 'Nos excuses mais les statistiques sont réservées aux abonnés premium';
}
return $this->view('contacts/stats.html.twig');
}
// }}}
// {{{ getAsideContent()
/** Function aside pour des actions diff
*
*
* @access public
* @return void
*/
public function getAsideContent($params_page = array())
{
$htmlend = true;
if (isset($this->context['view']->menu_nb_scene)) {
if ($this->context['action'] == 'soutiens') {
$htmlend = false;
} else {
$htmlend = false;
}
} else {
//on, force la fermeture de l'aside quand on se trouve dans nominations
if ($this->context['action'] == 'nominations') {
$htmlend = false;
}
}
$this->asides->load(['url_lists' => array(
'exec' => array(
'htmlstart' => true,
'htmlend' => $htmlend,
'color' => ($this->context['action'] == 'selections') ? 'textes' : 'context',
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_types_object,
'url' => '/contacts/{v_url_clean}/{v_current_page}/type/key_type?y={v_year}',
'params' => array(
'key_type' => 'auto_key'
)
),
'title' => 'Voir'
)]);
if (isset($this->context['view']->menu_nb_scene)) {
$this->asides->load(['url_lists,laureat_nbscene' => array(
'exec' => array(
// 'htmlend' => true,
'color' => ($this->context['action'] == 'selections') ? 'textes' : 'context',
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_nb_scene,
'url' => 'key_url',
'params' => array(
'key_type' => 'auto_key'
)
)
)]);
}
$this->asides->load(['par_annee' => array(
'exec' => array(
'htmlend' => true,
'color' => ($this->context['action'] == 'selections') ? 'textes' : 'context',
),
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/contacts/{v_url_clean}/{v_current_page}'
),
'title' => 'Recherche par periode'
)]);
if ($this->context['view']->list_aidecontacts) {
$this->asides->load(['laureat_prix_list' => array(
'exec' => array(
'alone' => true,
// 'htmlstart' => ($this->context['action'] == 'soutiens') ? false : true,
'color' => ($this->context['action'] == 'selections') ? 'textes' : 'context',
)
)]);
}
if (empty($params_page['show_aides_contacts'])) {
$this->asides->load('contact_list_aidecontacts');
}
$this->asides->load('laureat_signaler');
}
// }}}
// {{{ action_calendrier()
/** page des calendrier pour les contacts
*
* @Route("/contacts/{slug}/calendrier/", name="contact_calendrier")
* @Route("/contacts/{slug}/calendrier/type/{p_type}", name="contact_calendrier_type")
*
* @access public
* @return void
*/
public function action_calendrier($slug = null, $p_type = null)
{
$this->context['params']['type'] = $p_type;
$this->InitController($slug, 'calendrier');
$this->action_spectacles($slug, false);
$schedules = $this->em->getRepository(Schedules::class);
$ids_spectacles = array_merge($this->ids_spectacle_prod, $this->ids_spectacle_structures_diffusions);
$type = 'prod';
$params = [];
if (!empty($this->context['params']['type']) && $this->context['params']['type'] == 'structure') {
$ids_spectacles = array_merge($this->ids_spectacle_in, $this->ids_spectacle_structures_diffusions);
$type = 'structure';
$params = [
'idcontact' => $this->idobject
];
}
$this->context['view']->{$type . '_calendrier'} = true;
$this->context['view']->type_calendrier = $type;
// $cache_critiques = Theatre_quick_cache::cacheAccess('calendrier_'.$type.'_'.$this->idobject,'lists','contacts');
// $cache_critiques_menu = Theatre_quick_cache::cacheAccess('calendrier_'.$type.'_menu_'.$this->idobject,'lists','contacts');
// $total = $schedules->getDateBySpectaclesDemain($ids_spectacles, 1000, null, 'old', ['count' => true]);
// $totalStructure = $schedules->getDateBySpectaclesDemain($ids_spectacles, 1000, null, 'old', ['idcontact' => $this->idobject, 'count' => true]);
// $cached_data_menu = $cache_critiques_menu->get();
// if (Theatre_quick_cache::useCache() && $cached_data = $cache_critiques->get() && $cached_data_menu) { // on récupère les données du cache
// $this->context['view']->schedules_dates_demains_par_mois = unserialize($cached_data);
// $this->context['view']->menu_aside_mois = unserialize($cached_data_menu);
// } else {
$biographies_dates_demains = $schedules->getDateBySpectaclesDemain($ids_spectacles, 1000, null, 'old', $params);
if (!$biographies_dates_demains) {
return $this->redirectToRoute("contact_view", [
"slug" => $this->slug
]);
}
$menu_aside = array();
$biographies_dates_demains_reconstruction = array();
foreach ($biographies_dates_demains as $k => $v) {
$date_month = $schedules->getFormeDate($k, "%B %Y", true);
$date_month_hastag = $schedules->getFormeDate($k, "%B_%Y", true);
if (empty($biographies_dates_demains_reconstruction[$date_month_hastag])) {
$menu_aside[$date_month_hastag] = [
'name' => $date_month,
'params' => $date_month_hastag,
];
$biographies_dates_demains_reconstruction[$date_month_hastag] = $menu_aside[$date_month_hastag];
}
$biographies_dates_demains_reconstruction[$date_month_hastag]['datas'][$k] = $v;
foreach ($biographies_dates_demains_reconstruction[$date_month_hastag]['datas'][$k]['datas'] as $idata => $data) {
$biographies_dates_demains_reconstruction[$date_month_hastag]['datas'][$k]['datas'][$idata]['spectacle'] = $this->em->getRepository(Spectacles::class)->getInfosSpectacle($data['idspectacle'], ['get_vignette' => true]);
}
}
$this->context['view']->schedules_dates_demains_par_mois = $biographies_dates_demains_reconstruction;
// $cache_critiques->save(serialize($this->context['view']->schedules_dates_demains_par_mois));
//
$this->context['view']->menu_aside_mois = $menu_aside;
// $cache_critiques_menu->save(serialize($this->context['view']->menu_aside_mois));
// }
$this->getAsidesSpectacles(); //appels asides communs
return $this->view('contacts/calendrier.html.twig');
}
// }}}
// {{{ action_en_scene()
/** trouver les textes à l'affiche qui ont un soutien de la structure
*
* @Route("/contacts/{slug}/en-scene/", name="contact_en_scene")
* @Route("/contacts/{slug}/en-scene/periode/{periode}/", name="contact_en_scene_periode")
* @Route("/contacts/{slug}/en-scene/periode/{periode}/type/{type}", name="contact_en_scene_periode_type")
* @Route("/contacts/{slug}/en-scene/periode/{periode}/type/{type}/area/{p_area}", name="contact_en_scene_periode_type_area")
*
* @access public
* @return void
*/
public function action_en_scene($slug = null, $periode = null, $type = null, $p_area = null)
{
$this->context['params']['periode'] = $periode;
$this->context['params']['type'] = $type;
$this->context['params']['area'] = $p_area;
$this->InitController($slug, 'en-scene');
$this->action_spectacles($slug, false);
$this->perPage = 20;
$default_type_spectacle = 'affiche';
$this->context['view']->current_page = 'en-scene';
// tous les spectacles ou ceux à l'affiche
$this->context['view']->periode_spectacle = $default_type_spectacle;
// if(!empty($this->context['params']['periode']) && !empty($this->context['view']->menu_spectacles_soutiens[$this->context['params']['periode']]) && $this->context['view']->menu_spectacles_soutiens[$this->context['params']['periode']]['count'] > 0) {
if (!empty($this->context['params']['periode'])) {
$this->context['view']->periode_spectacle = $this->context['params']['periode'];
}
// On ajoute une condition pour afficher le titre dans la view selon l'url
if ($this->context['view']->url_clean == 'Artcena') {
$this->context['view']->is_artcena_affiche = true;
}
$type = '';
if (!empty($this->context['params']['type'])) {
$type = $this->context['params']['type'];
}
//Tous les contenus hors podcasts france culture (sélection, soutiens, nomminatione etc.)
// marquer l'élément actif
$this->context['view']->menu_periodes[$this->context['view']->periode_spectacle]['active'] = 'on';
$this->context['view']->{'periode_' . $this->context['view']->periode_spectacle} = true;
$this->getCommonSearch(array(
'saisons_annees' => Date_time::getListSaisons(2000, (date('Y') + 1)),
//'default_saison' => Date_time::getLastSaison(),
'inverse_periode' => true,
'nb_days' => 720,
));
$this->getCommonSearchView();
$spectacles = $this->em->getRepository(Spectacles::class);
$texts = $this->em->getRepository(Texts::class);
// les spectacles à l'affiche avec des textes nonfictif
$params_sql = $this->setCommonSearchSpectacles(array(
'params' => [
'where' => ' AND (s.title IS NULL OR s.title = \'\') '
],
'special' => array(
//'get_text'
'textfictif' => 0,
'aide' => array(
'idcontact' => $this->idobject,
'type_aide' => $type
),
'text_aide' => true,
'plus_proche' => true,
),
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont reçu une aide'),
));
if (!empty($params_sql['special']['area'])) {
$spectacles->setZoneRecherche($this->em->getRepository(Regions::class)->getZipCode($params_sql['special']['area'])); // définir la zone de recherche
}
//order d'affichage par defaut commune à différents filtres
$params_sql['params']['order'] = ['creation_date', 'DESC'];
if ($this->context['view']->periode_spectacle == 'all') {
//unset($params_sql['special']['saison']);
unset($params_sql['special']['prochains']);
unset($params_sql['special']['plus_proche']);
unset($this->context['view']->days);
$this->context['view']->detail_annee_creation_spectacle = true;
$this->context['view']->noshow_detail_periode = true;
} else if ($this->context['view']->periode_spectacle == 'anciens-textes') {
//unset($params_sql['special']['saison']);
$this->context['view']->is_anciens_textes = true;
$params_sql['special']['anciens'] = true;
$params_sql['special']['anciens_stricts'] = true;
unset($params_sql['special']['prochains']);
unset($params_sql['special']['plus_proche']);
unset($this->context['view']->days);
$this->context['view']->detail_annee_creation_spectacle = true;
$this->context['view']->noshow_detail_periode = true;
} else if ($this->context['view']->periode_spectacle == 'affiche') {
//ordre d'aaffiche propre au filtre à l'affiche
// $params_sql['params']['order'] = array(
// 'classement' => tru
// );
$params_sql['params']['order'] = ['sc.date', 'ASC'];
} else {
return $this->redirectToRoute("contact_en_scene", [
"slug" => $slug
]);
}
$this->context['view']->nb_spectacles_total = $spectacles->countListSpectacles($params_sql);
$this->context['view']->nb_dates_total = $spectacles->countListSchedules($params_sql);
$params_sql['params']['limit'] = array($this->getLimitStart(), $this->perPage);
$list_spectacles = $spectacles->getListSpectacles($params_sql);
foreach ($list_spectacles as $idspectacle => $spectacle) {
if (!empty($spectacle['creation_date'])) {
$list_spectacles[$idspectacle]['annee_creation'] = $spectacles->getFormeDate($spectacle['creation_date'], '%Y', true);
}
}
$params_display['vignette_format'] = array('width' => $_ENV['VIGN_TEXT_WIDTH'], 'height' => $_ENV['VIGN_TEXT_HEIGHT'], 'direction' => 'thumb');
if (!empty($list_spectacles)) {
$this->context['view']->texts = $texts->getTextsFromSpectacles($list_spectacles, array(), $params_display);
}
$this->context['view']->pagination = $this->getPagination($this->context['view']->nb_spectacles_total, 10, array(
'total_dates' => $this->context['view']->nb_dates_total,
));
$this->context['view']->pagination['spectacle'] = true;
$this->context['view']->pagination['representation_spectacle'] = true;
$title_types = array(
'selections' => 'aux sélections',
'laureats' => 'aux lauréats',
'nominations' => 'aux nominations',
'soutiens' => 'aux soutiens',
);
// si on vient de la page autre
if (!empty($_REQUEST['from_page_aide']) && !empty($title_types[$_REQUEST['from_page_aide']])) {
$_SESSION['from_page_aide'] = $_REQUEST['from_page_aide'];
}
if (!empty($_SESSION['from_page_aide'])) {
$this->context['view']->title_type = $title_types[$_SESSION['from_page_aide']];
$this->context['view']->from_page_aide = $_SESSION['from_page_aide'];
}
// ajouter masonery
$this->context['view']->js_more[] = 'jquery.masonry.min.js';
$this->extra_locate = $this->extra_title = 'Textes en scène';
$this->context['view']->show_prix = false;
if (!empty($this->context['view']->texts) || !empty($this->context['view']->spectacles)) {
$this->context['view']->contents = true;
} //Si c'est France Culture on opte pour une redirection vers le contenu directement
else if (in_array($this->idobject, [595, 5222]) && empty($this->context['params']['periode'])) {
$params_sql = $this->setCommonSearchSpectacles(array(
'special' => array(
'textfictif' => 0,
'plus_proche' => true,
'podcasts' => [
'type_podcast' => 'franceculture'
]
),
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont un podcast'),
));
$params_sql['special']['type_franceinter'] = null;
if ($this->idobject == 5222) {
$params_sql['special']['type_franceinter'] = 1;
}
$totalProchainsSpectaclesPodcasts = $this->em->getRepository(Spectacles::class)->countListSpectacles($params_sql);
unset($params_sql['special']['plus_proche']);
$totalSpectaclesPodcasts = $this->em->getRepository(Spectacles::class)->countListSpectacles($params_sql);
if ($totalSpectaclesPodcasts > 0) {
return $this->redirectToRoute('contact_emissions_cat_type', ['slug'=> $this->context['view']->url_clean, 'params_cat' => 'podcasts-spectacles', 'type' => 'in']);
} else if ($totalProchainsSpectaclesPodcasts > 0) {
return $this->redirectToRoute('contact_emissions_cat_type', ['slug'=> $this->context['view']->url_clean, 'params_cat' => 'podcasts-spectacles', 'type' => 'anciens']);
}
}
//action en scène
$this->getAsidesSpectacles(true); //appels asides communs
return $this->view('contacts/en-scene.html.twig');
}
// }}}
// {{{ getInfosContact()
/** Les infos sur le contact
*
*/
public function getInfosContact()
{
return $this->infosobject;
}
// }}}
// {{{ getLocate()
/** Ou se trouve t'on (getter)
*
*/
public function getLocate()
{
return $this->locate;
}
// }}}
// {{{ getTitlePage()
/** Titre de la page (getter)
*
*/
public function getTitlePage()
{
return $this->title_page;
}
// }}}
// {{{ getStyleMore()
/** Style en plus (getter)
*
*/
public function getStyleMore()
{
return $this->style_more;
}
// }}}
// {{{ getMetaKeywords()
/** Keywords (getter)
*
*/
public function getMetaKeywords()
{
return $this->meta_keywords;
}
// }}}
// {{{ getMetaDescription()
/** Description (getter)
*
*/
public function getMetaDescription()
{
return $this->meta_description;
}
// }}}
// {{{ getMtinfos()
/** Infos mon théâtre
*
*/
public function getMtinfos()
{
return $this->mtinfos;
}
// }}}
// {{{ setOtherDimensions()
/** Taille maxi des vidéos
*
*/
public function setOtherDimensions($other_dimensions)
{
$this->other_dimensions = $other_dimensions;
}
// }}}
// {{{ getMultimediasIn()
/** Récupérer les ids des vidéos des spectacles coproduits par le lieu
*
* @param array ids_spectacle_in Liste des ids des spectacles joués dans le lieu
*/
public function getMultimediasIn($ids_spectacle_in = array(), $count = false, $exclude_ids_multimedia = array())
{
// les vidéos de spectacles joués dans ce lieu
if (empty($ids_spectacle_in)) {
if ($count) return 0; else return array();
}
if ($count) {
$sql = 'SELECT COUNT(DISTINCT(multimedias.idmultimedia)) ';
} else {
$sql = 'SELECT DISTINCT(multimedias.idmultimedia) ';
}
// requete commune
$sql .= 'FROM object_multimedia, multimedias
WHERE object_multimedia.idmultimedia=multimedias.idmultimedia
AND multimedias.publish=1
AND object_multimedia.object=\'spectacles\'
AND object_multimedia.idobject IN (' . join(',', $ids_spectacle_in) . ')';
// exclure des ids ?
if (!empty($exclude_ids_multimedia)) {
$sql .= ' AND object_multimedia.idmultimedia NOT IN (' . join(',', $exclude_ids_multimedia) . ')';
}
if ($count) {
$ids_multimedia_in = $this->obj->queryOne($sql);
} else {
$ids_multimedia_in = $this->obj->queryCol($sql);
}
return $ids_multimedia_in;
}
// }}}
// {{{ getMultimediasProd()
/** Récupérer les ids des vidéos des spectacles coproduits par le lieu
*
* @param array ids_spectacle_prod Liste des ids des spectacles coproduit par la structure
* @return array
*/
public function getMultimediasProd($ids_spectacle_prod = array(), $count = false, $exclude_ids_multimedia = array())
{
// les vidéos de spectacle coproduit par ce contact
if (empty($ids_spectacle_prod)) {
if ($count) return 0; else return array();
}
if ($count) {
$sql = 'SELECT COUNT(DISTINCT(multimedias.idmultimedia)) ';
} else {
$sql = 'SELECT DISTINCT(multimedias.idmultimedia) ';
}
// requete commune
$sql .= 'FROM object_multimedia, multimedias
WHERE object_multimedia.idmultimedia=multimedias.idmultimedia
AND multimedias.publish=1
AND object_multimedia.object=\'spectacles\'
AND object_multimedia.idobject IN (' . join(',', $ids_spectacle_prod) . ')';
// exclure des ids ?
if (!empty($exclude_ids_multimedia)) {
$sql .= ' AND object_multimedia.idmultimedia NOT IN (' . join(',', $exclude_ids_multimedia) . ')';
}
if ($count) {
$ids_multimedia_prod = $this->obj->queryOne($sql);
} else {
$ids_multimedia_prod = $this->obj->queryCol($sql);
}
return $ids_multimedia_prod;
}
// }}}
// {{{ getMultimediasContact()
/** Récupérer les ids des vidéos autres
*
* @param bool $count Compter seulement
* @return array
*/
public function getMultimediasContact($count = false, $exclude_ids_multimedia = array(), $exclude_ids_spectacle = array())
{
// les vidéos de spectacle associées (en partenariat) à ce contact
if ($count) {
$sql = 'SELECT COUNT(DISTINCT(multimedias.idmultimedia)) ';
} else {
$sql = 'SELECT DISTINCT(multimedias.idmultimedia) ';
}
// requete commune
$sql .= 'FROM object_multimedia, multimedias
WHERE object_multimedia.idmultimedia=multimedias.idmultimedia
AND multimedias.publish=1
AND object_multimedia.object=\'contacts\'
AND object_multimedia.idobject=' . $this->idobject;
// exclure des ids multimedias ?
if (!empty($exclude_ids_multimedia)) {
$sql .= ' AND object_multimedia.idmultimedia NOT IN (' . join(',', $exclude_ids_multimedia) . ')';
}
// exclure les vidéos de spectacle
if (!empty($exclude_ids_spectacle)) {
//$sql .= ' AND (object_multimedia.object=\'spectacles\' AND object_multimedia.idobject NOT IN ('.join(',', $exclude_ids_spectacle).'))';
$sql .= ' AND object_multimedia.idobject NOT IN (
SELECT object_multimedia.idobject FROM object_multimedia WHERE
object_multimedia.object=\'spectacles\' AND object_multimedia.idobject IN (' . join(',', $exclude_ids_spectacle) . ')
)';
}
if ($count) {
$ids_multimedia_contact = $this->obj->queryOne($sql);
} else {
$ids_multimedia_contact = $this->obj->queryCol($sql);
}
return $ids_multimedia_contact;
}
// }}}
// {{{ countAllSpectacles()
/** Compter le nb total de spectacles
*
* @return int
*/
public function countAllSpectacles()
{
// les spectacles DANS ce lieu
$this->ids_spectacle_in = $this->obj->getSpectaclesIn($this->idobject);
$this->context['view']->nb_spectacles_in = count($this->ids_spectacle_in);
// les spectacles coproduits ou lieu de crée ou compagnie
$this->ids_spectacle_prod = $this->obj->getSpectaclesProd($this->idobject);
$this->context['view']->nb_spectacles_prod = count($this->ids_spectacle_prod);
$this->ids_spectacle_structures_diffusions = $this->obj->getSpectaclesProd($this->idobject, false, null, 77);
$this->context['view']->nb_spectacles_structures_diffusions = count($this->ids_spectacle_structures_diffusions);
/*
// spectacles co-produit non joué dans le lieu
foreach($this->ids_spectacle_prod as $k=>$v) {
$p = false;
foreach($this->ids_spectacle_in as $kb=>$vb) {
if($v==$vb) {
$p = true;
}
}
if(!$p) echo "non présent";
}
exit;
*/
// les spectacles avec une aide
$this->ids_spectacle_aide = $this->obj->getSpectaclesAide($this->idobject);
$this->context['view']->nb_spectacles_aide = count($this->ids_spectacle_aide);
// les spectacles avec lauréagts/nominattions
$this->ids_spectacle_laureats_nominations = $this->obj->getSpectaclesAide($this->idobject, null, array(2, 3));
$this->context['view']->nb_spectacles_laureats_nominations = count($this->ids_spectacle_laureats_nominations);
// les spectacles avec soutiens
$this->ids_spectacle_soutiens = $this->obj->getSpectaclesAide($this->idobject, null, array(1));
$this->context['view']->nb_spectacles_soutiens = count($this->ids_spectacle_soutiens);
// les spectacles avec sélection
$this->ids_spectacle_selections = $this->obj->getSpectaclesAide($this->idobject, null, array(4));
$this->context['view']->nb_spectacles_selections = count($this->ids_spectacle_selections);
// tous les spectacles
$this->ids_spectacle_all = array_unique(array_merge($this->ids_spectacle_prod, $this->ids_spectacle_in, $this->ids_spectacle_aide, $this->ids_spectacle_structures_diffusions));
$ids_spectacle_anciens = $this->ids_spectacle_all;
$ids_spectacle_anciens = array_diff_key($ids_spectacle_anciens, $this->ids_spectacle_in);
$this->ids_spectacle_anciens = $ids_spectacle_anciens;
// cas du JTN => les spectacles avec le soutien de
if (!empty($this->idclassification_soutien)) {
$this->ids_spectacle_soutien = $this->obj->getSpectaclesSoutien($this->idclassification_soutien);
$this->context['view']->nb_spectacles_soutien = count($this->ids_spectacle_soutien);
$this->ids_spectacle_all = array_unique(array_merge($this->ids_spectacle_all, $this->ids_spectacle_soutien));
}
// cas d'un éditeur
if ($this->infosobject['idtypestructure'] == 'ED') {
$this->ids_spectacle_publisher = $this->obj->getSpectaclesPublisher($this->idobject);
$this->context['view']->nb_spectacles_publisher = count($this->ids_spectacle_publisher);
$this->ids_spectacle_all = array_unique(array_merge($this->ids_spectacle_all, $this->ids_spectacle_publisher));
}
$this->context['view']->nb_spectacles_all = count($this->ids_spectacle_all);
return count($this->ids_spectacle_all);
}
// }}}
// {{{ countAllMultimedias()
/** Compter le nb total de documents vidéos
*
* @return int
*/
public function countAllMultimedias()
{
$sql = '
SELECT COUNT(DISTINCT(multimedias.idmultimedia))
FROM multimedias
WHERE
multimedias.`publish`=1
AND (';
if (count($this->ids_spectacle_in) > 0 || count($this->ids_spectacle_prod) > 0) {
$sql .= 'multimedias.`idmultimedia` IN (
SELECT multimedias.`idmultimedia`
FROM object_multimedia JOIN multimedias ON object_multimedia.`idmultimedia`=multimedias.`idmultimedia`
AND object_multimedia.`object` IN (\'contacts\', \'spectacles\')
AND object_multimedia.idobject IN (' . join(',', array_merge($this->ids_spectacle_in, $this->ids_spectacle_prod)) . ')
) OR ';
}
$sql .= 'multimedias.`idmultimedia` IN (
SELECT multimedias.idmultimedia
FROM object_multimedia JOIN multimedias ON object_multimedia.`idmultimedia`=multimedias.`idmultimedia`
AND object_multimedia.object IN (\'contacts\')
AND object_multimedia.idobject=' . $this->idobject . '
)
)';
/*
* TODO:
* pour récupérer les spectacles partenaires, mettre 'contacts' à la place de spectacles pour object_multimedia.object
*/
return $this->obj->queryOne($sql);
/*$nb_multimedias = $this->getMultimediasIn($this->ids_spectacle_in,true)+$this->getMultimediasProd($this->ids_spectacle_prod,true)+$this->getMultimediasContact(true);
return $nb_multimedias;*/
}
// }}}
// {{{ countAllCritiques()
/** Compter le nb de critiques
*
* @return int
*/
public function countAllCritiques($params = array())
{
$cacheKey = "contact_count_all_critiques_{$this->idobject}_";
$sql = '
SELECT COUNT(DISTINCT(ct.`idcontent`))
FROM schedules sc
JOIN spectacles s ON s.`idspectacle`=sc.`idspectacle`
JOIN object_content oc ON s.`idspectacle`=oc.`idobject`
JOIN contents ct ON oc.`idcontent`=ct.`idcontent`
JOIN content_classification cc ON ct.`idcontent`=cc.`idcontent`
WHERE s.`publish`=1 AND s.`valid`=1
AND ct.`publish`=1 AND ct.`valid`=1
AND cc.`idclassification`=101 ';
if (!empty($this->ids_spectacle_all) && empty($params['all'])) {
$sql .= ' AND (
sc.`idspectacle` IN (' . $this->obj->arrayToIn($this->ids_spectacle_all) . ')
OR (
sc.`idcontact`=' . $this->idobject . ' OR sc.`idcontact_festival`=' . $this->idobject . '
)
)';
$cacheKey .= "all_" . implode('-', $this->ids_spectacle_all);
} else {
$sql .= ' AND (
sc.`idcontact`=' . $this->idobject . ' OR sc.`idcontact_festival`=' . $this->idobject . '
)';
}
$date = date('Y-m-d');
if (!empty($params['anciens'])) {
$cacheKey .= "_anciens_$date";
$sql .= " AND sc.date < '$date' ";
}
if (!empty($params['prochains'])) {
$cacheKey .= "_prochains_$date";
$sql .= " AND sc.date >= '$date' ";
}
$cacheItem = $this->cache->getItem($cacheKey);
if (! $cacheItem->isHit()) {
$res = $this->obj->queryOne($sql);
$cacheItem->set($res)
->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
$this->cache->save($cacheItem);
}
if (!empty($res)) {
// si pas de résultat, compter les critiques associés à ids_spectacle_all
return $res;
} else {
return 0;
}
}
// }}}
// {{{ countAllEduc()
/** Compter le nb total de spectacles éduc
*
* @return int
*/
public function countAllEduc()
{
$idclassification = 125;
// les spectacles DANS ce lieu
$cacheItem = $this->cache->getItem("contact_countAllEduc_getSpectaclesIn_{$this->idobject}_$idclassification");
if (! $cacheItem->isHit()) {
$res = $this->obj->getSpectaclesIn($this->idobject, true, $idclassification);
$cacheItem->set($res)
->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
$this->cache->save($cacheItem);
}
$nb_spectacles_in = $cacheItem->get();
// les spectacles coproduits ou lieu de crée ou compagnie
$nb_spectacles_prod = $this->obj->getSpectaclesProd($this->idobject, true, $idclassification);
$nb_spectacles_prod = 0;
$nb_spectacles_all = $nb_spectacles_in + $nb_spectacles_prod;
// cas du JTN => les spectacles avec le soutien de
/*if(!empty($this->idclassification_soutien)) {
$nb_spectacles_soutien = $this->obj->getSpectaclesSoutien($this->idclassification_soutien,$idclassification);
$nb_spectacles_all = $nb_spectacles_all+$nb_spectacles_soutien;
}*/
// cas d'un éditeur
if ($this->infosobject['idtypestructure'] == 'ED') {
$nb_spectacles_publisher = $this->obj->getSpectaclesPublisher($this->idobject, true, $idclassification);
$nb_spectacles_all = $nb_spectacles_all + $nb_spectacles_publisher;
}
return $nb_spectacles_all;
}
// }}}
// {{{ getSpectaclesDirectors()
/** Trouver les metteurs en scènes associés aux spectacles de la structure
*
* @param int $idspectacles Les identifiants des spectacles
* @return array
*/
private function getSpectaclesDirectors($idspectacles = array())
{
if (empty($idspectacles)) {
$idspectacles = $this->ids_spectacle_all;
}
// recherche les metteurs en scène à partir de la liste des tous les spectacles du contact
$sql_directors = 'SELECT persons.url_clean, persons.idperson, persons.lastname, persons.firstname
FROM persons, spectacle_person, spectacles
WHERE persons.idperson=spectacle_person.idperson
AND spectacles.idspectacle=spectacle_person.idspectacle
AND spectacles.publish=1
AND spectacle_person.idrole=1
AND spectacle_person.idspectacle IN (' . join(',', $idspectacles) . ')
ORDER BY persons.lastname';
$directors = $this->obj->queryAll($sql_directors);
return $directors;
}
// }}}
// {{{ getSpectaclesAuthors()
/** Trouver les auteurs et les auteurs de traduction
*
* @param int $idspectacles Les identifiants des spectacles
* @return array
*/
public function getSpectaclesAuthors($idspectacles = array())
{
if (empty($idspectacles)) {
$idspectacles = $this->ids_spectacle_all;
}
// les auteurs des textes traduits
$sql_authors_traduction = 'SELECT persons.url_clean, persons.idperson, persons.lastname, persons.firstname
FROM persons, text_traduction, text_author, text_spectacle, spectacles
WHERE persons.idperson=text_author.idperson
AND spectacles.idspectacle=text_spectacle.idspectacle
AND text_spectacle.idtext=text_traduction.idtexttraduction
AND text_traduction.idtext=text_author.idtext
AND spectacles.publish=1
AND spectacles.idspectacle IN (' . join(',', $idspectacles) . ')
ORDER BY persons.lastname';
$authors_traduction = $this->obj->queryAll($sql_authors_traduction);
// trouver les auteurs des textes originaux
$sql_authors = 'SELECT persons.url_clean, persons.idperson, persons.lastname, persons.firstname
FROM persons, text_spectacle, text_author, spectacles
WHERE persons.idperson=text_author.idperson
AND spectacles.idspectacle=text_spectacle.idspectacle
AND text_spectacle.idtext=text_author.idtext
AND spectacles.publish=1
AND spectacles.idspectacle IN (' . join(',', $idspectacles) . ')
ORDER BY persons.lastname';
$authors = $this->obj->queryAll($sql_authors);
// on merge les 2
if (!empty($authors_traduction)) {
$authors = array_merge($authors, $authors_traduction);
}
return $authors;
}
// }}}
// {{{ getSpectaclesDates()
/** Récupere la liste des dates des spectacles à partir de la liste de tous les spectacles
*
* @param bool $critique Les dates des critiques
* @param int $idspectacles Les identifiants des spectacles
* @return array
*/
public function getSpectaclesDates($critique = false, $idspectacles = array())
{
if (empty($idspectacles)) {
if (!empty($this->ids_spectacle_all)) {
$idspectacles = $this->ids_spectacle_all;
} else {
return null;
}
}
$cacheKey = "contact_spectacles_dates_{$this->idobject}";
$sql_annees = '
SELECT sc.`date`, YEAR(sc.`date`) as annee
FROM schedules sc
JOIN spectacles s ON s.`idspectacle`=sc.`idspectacle`
JOIN object_content oc ON s.`idspectacle`=oc.`idobject`
JOIN contents ct ON oc.`idcontent`=ct.`idcontent`
JOIN content_classification cc ON ct.`idcontent`=cc.`idcontent`
WHERE s.`publish`=1 AND s.`valid`=1
AND ct.`publish`=1 AND ct.`valid`=1
AND (sc.`idcontact`=' . $this->idobject . ' OR sc.`idcontact_festival`=' . $this->idobject . ')
ORDER BY sc.`date`';
// uniquement les spectacles avec une critique
if ($critique) {
$cacheKey .= "_critique_" . implode('-', $idspectacles);
$sql_annees = '
SELECT sc.`date`, YEAR(sc.`date`) as annee
FROM schedules sc
JOIN spectacles s ON s.`idspectacle`=sc.`idspectacle`
JOIN object_content oc ON s.`idspectacle`=oc.`idobject`
JOIN contents ct ON oc.`idcontent`=ct.`idcontent`
JOIN content_classification cc ON ct.`idcontent`=cc.`idcontent`
WHERE s.`publish`=1 AND s.`valid`=1
AND ct.`publish`=1 AND ct.`valid`=1
AND cc.`idclassification`=101
AND
(
sc.`idspectacle` IN (' . implode(',', $idspectacles) . ')
OR (sc.`idcontact`=' . $this->idobject . ' OR sc.`idcontact_festival`=' . $this->idobject . ')
)
ORDER BY sc.`date`';
}
$cacheItem = $this->cache->getItem($cacheKey);
if (! $cacheItem->isHit()) {
$res = $this->obj->queryAll($sql_annees);
$cacheItem->set($res)
->expiresAt((new \DateTime('now'))->add(\DateInterval::createFromDateString('7 hours')));
$this->cache->save($cacheItem);
}
$listdates = $cacheItem->get();
// liste des saisons et des années
if (empty($listdates)) {
//echo $listdates->getDebugInfos();
return array();
} else {
return $listdates;
}
}
// }}}
// {{{ getListSpectaclesProd()
/** Productteur (17), coprod (18), prod délégué (19). Recherche sur spectacle_contact+idrole
* prochains spectacles coproduit PAR ce lieu mais pas dans ce lieu puisque en tournée
*
* @param string $where_idcontact La chaine SQL de recherche
* @param int $idperson_author Identifiant de l'auteur recherché
* @param array $params_display Paramètre d'affichage en plus (par exemple array('api' => true) pour formater pour API)
* @param array $params_sql_more Paramètre SQL en plus
* @param array $idclassification Recherche les spectacles avec une classification particulière
* @return array
*/
public function getListSpectaclesProd($where_idcontact, $idperson_author = null, $params_display = array(), $params_sql_more = array(), $idclassification = null)
{
$params_sql = array(
'params' => array(
'from' => 'TheatreCore\Entity\SpectacleContact sct',
'where' => $where_idcontact . '
AND s.publish=1
AND sct.idspectacle=s.idspectacle
AND sct.idrole IN (17,18,19)
AND (sct.idcontact=' . $this->idobject . ' OR s.idcontactProduction=' . $this->idobject . ') ',
'limit' => $this->getLimit(null, true),
//'classement' => 'DESC',
),
//AND (sct.idcontact='.$this->idobject.' OR s.idcontact_production='.$this->idobject.') ',
'special' => array(//'plus_proche' => true,
),
'dbg' => array('prod', 'Spectacles prod/coprod/prod deleg de ce contact')
);
// cas => uniquement les spectacles avec un contenu éduc
if (!empty($idclassification)) {
$params_sql['special']['idclassification'] = $idclassification;
}
// cas auteur
if (!empty($idperson_author)) {
$params_sql['special']['join_author'] = true;
$params_sql['special']['idperson_author'] = $idperson_author;
}
// ajouter des paramètres
if ($params_sql_more) {
$params_sql = $this->addParamsSql($params_sql, $params_sql_more);
}
// executer
return $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, $this->format_vignette, false, $params_display);
}
// }}}
// {{{ getListSpectaclesIn()
/** Liste des spectacles dans le lieu
*
* @param string $where_idcontact La chaine SQL de recherche
* @param int $idperson_author Identifiant de l'auteur recherché
* @param array $params_display Paramètre d'affichage en plus (par exemple array('api' => true) pour formater pour API)
* @param array $params_sql_more Paramètre supplémentaire pour la requpete SQL
* @param array $idclassification Recherche les spectacles avec une classification particulière
* @return array
*/
public function getListSpectaclesIn($where_idcontact, $idperson_author = null, $params_display = array(), $params_sql_more = array(), $idclassification = null)
{
$params_sql = array(
'params' => array(
'where' => $where_idcontact . ' AND s.publish=1 AND ' . $this->getWhereIdcontact(),
'limit' => $this->getLimit(null, true),
'classement' => $this->getOrder(),
),
'special' => array(
"prochains" => true,
"order" => true
),
'dbg' => array('in', 'Spectacles dans le lieu'),
);
if (isset($_REQUEST['get_texts'])) {
if ($_REQUEST['get_texts'] == true) {
$params_sql['special']['get_texts'] = true;
}
}
if ($this->isSearchArea()) {
$params_sql['special']['carte_version'] = 'bigregions';
$params_sql['special']['area'] = $this->getArea();
$params_sql['special']['get_schedule_ville'] = $this->getArea();
}
if ($this->isSearchSeason()) {
unset($params_sql['special']['prochains']);
}
// cas => uniquement les spectacles avec un contenu éduc
if (!empty($idclassification)) {
$params_sql['special']['idclassification'] = $idclassification;
}
// cas auteur
if (!empty($idperson_author)) {
$params_sql['special']['join_author'] = true;
$params_sql['special']['idperson_author'] = $idperson_author;
}
// cas festival
if (!empty($this->infosobject['is_festival'])) {
$params_sql['special']['type_contact'] = 'idcontactFestival';
}
// ajouter des paramètres
if ($params_sql_more) {
$params_sql = $this->addParamsSql($params_sql, $params_sql_more);
}
return $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, $this->format_vignette, false, $params_display);
}
// }}}
// {{{ getListSpectaclesEleve()
/** Liste des spectacles des eleves
*
* @param string $where_idcontact La chaine SQL de recherche
* @param int $idperson_author Identifiant de l'auteur recherché
* @param array $params_display Paramètre d'affichage en plus (par exemple array('api' => true) pour formater pour API)
* @param array $params_display Paramètre supplémentaire pour la requpete SQL
* @return array
*/
public function getListSpectaclesEleve($where_idcontact, $idperson_author = null, $params_display = array(), $params_sql_more = array())
{
$params_sql = array(
'params' => array(
'from' => 'person_ecole pe',
'where' => $where_idcontact . ' AND s.publish=1 AND pe.`idperson`=sp.`idperson` AND pe.`idcontact`=' . (int)$this->idobject . ' ',
'limit' => $this->getLimit(null, true),
'classement' => $this->getOrder(),
),
'special' => array(
'plus_proche' => true,
),
'dbg' => array('in', 'Eleves à l\'affiche'),
);
// cas auteur
if (!empty($idperson_author)) {
$params_sql['special']['join_author'] = true;
$params_sql['special']['idperson_author'] = $idperson_author;
}
// ajouter des paramètres
if ($params_sql_more) {
$params_sql = $this->addParamsSql($params_sql, $params_sql_more);
}
$datas = $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, $this->format_vignette, false, $params_display);
// parcourir les spectacles trouvé
foreach ($datas as $s) {
// les élèves et leur role
$list_eleves = $this->getPersonByContactSpectacle($this->idobject, $s['idspectacle']);
// dans le array
if (!empty($list_eleves)) {
$new_list_eleves = array();
foreach ($list_eleves as $k => $v) {
if (!isset($new_list_eleves[$v['idperson']])) {
$new_list_eleves[$v['idperson']] = $v;
}
$new_list_eleves[$v['idperson']]['roles'][$v['idrole']] = array($v['role_string']);
}
foreach ($new_list_eleves as $t => $e) {
$new_list_eleves[$t]['roles'] = noPunct($e['roles']);
}
$datas[$s['idspectacle']]['eleves'] = noPunct($new_list_eleves);
}
}
return $datas;
}
// }}}
// {{{ getListSpectaclesSoutien()
/** Liste des spectacles avec le soutien de la structure
*
* @param string $where_idcontact La chaine SQL de recherche
* @param int $idperson_author Identifiant de l'auteur recherché
* @param array $params_display Paramètre d'affichage en plus (par exemple array('api' => true) pour formater pour API)
* @param array $params_sql_more Paramètre SQL en plus
* @param array $idclassification Recherche les spectacles avec une classification particulière
* @return array
*/
public function getListSpectaclesSoutien($where_idcontact, $idperson_author = null, $params_display = array(), $params_sql_more = array(), $idclassification = null)
{
$params_sql = array(
'params' => array(
'where' => $where_idcontact . ' AND s.publish=1',
'limit' => $this->getLimit(null, true),
'select' => 'sc.date',
),
'special' => array(
// 'by_classification' => $this->idclassification_soutien,
'aide' => true,
'spectacle_aide' => [
'idcontact' => $this->idobject,
'end' => date('Y-m-d')
],
// récup des élèves
'get_eleves' => array(
'idcontact' => $this->idobject
),
),
'dbg' => array('spectacle_soutien', 'Les spectacles avec le soutien du contact'),
);
// cas => uniquement les spectacles avec un contenu éduc
if (!empty($idclassification)) {
$params_sql['special']['idclassification'] = $idclassification;
}
// cas auteur
if (!empty($idperson_author)) {
$params_sql['special']['join_author'] = true;
$params_sql['special']['idperson_author'] = $idperson_author;
}
// ajouter des paramètres
if ($params_sql_more) {
$params_sql = $this->addParamsSql($params_sql, $params_sql_more);
}
return $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, $this->format_vignette, false, $params_display);
}
// }}}
// {{{ getListSpectaclesAide()
/** Liste des spectacles avec une aide associée à la structure
*
* @param string $where_idcontact La chaine SQL de recherche
* @param int $idperson_author Identifiant de l'auteur recherché
* @param array $params_display Paramètre d'affichage en plus (par exemple array('api' => true) pour formater pour API)
* @param array $params_sql_more Paramètre SQL en plus
* @param array $idclassification Recherche les spectacles avec une classification particulière
* @return array
*/
public function getListSpectaclesAide($where_idcontact, $idperson_author = null, $params_display = array(), $params_sql_more = array(), $idclassification = null)
{
$params_sql = array(
'params' => array(
'where' => $where_idcontact . ' AND s.publish=1 ',
'limit' => $this->getLimit(null, true),
),
'special' => array(
'plus_proche' => true,
// avec une aides
'spectacle_aide' => true,
'aide' => array(
'idcontact' => $this->idobject
),
// récup des élèves
'get_eleves' => array(
'idcontact' => $this->idobject
),
),
'dbg' => array('aide', 'Les spectacles avec une aide du contact'),
);
// cas => uniquement les spectacles avec un contenu éduc
if (!empty($idclassification)) {
$params_sql['special']['idclassification'] = $idclassification;
}
// cas auteur
if (!empty($idperson_author)) {
$params_sql['special']['join_author'] = true;
$params_sql['special']['idperson_author'] = $idperson_author;
}
// ajouter des paramètres
if ($params_sql_more) {
$params_sql = $this->addParamsSql($params_sql, $params_sql_more);
}
return $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, $this->format_vignette, false, $params_display);
}
// }}}
// {{{ getListSpectaclesTextAideContact()
/** Rechercher les spectacles monté à partir de textes ayant reçu une aide spécifique
*
* @param string $idcontact le contact recherché
* @param int $idperson_author Identifiant de l'auteur recherché
* @param array $params_display Paramètre d'affichage en plus (par exemple array('api' => true) pour formater pour API)
* @param array $params_sql_more Paramètre SQL en plus
* @param array $idclassification Recherche les spectacles avec une classification particulière
* @return array
*/
public function getListSpectaclesTextAideContact($where_idcontact, $idperson_author = null, $params_display = array(), $params_sql_more = array(), $idclassification = null)
{
/*
'special' => array(
'textfictif' => 0,
'aide' => array(
'idcontact' => $this->idobject,
),
'text_aide' => true,
),
'dbg' => array('menu_list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont reçu une aide'),
*/
$params_sql = array(
'params' => array(
'where' => $where_idcontact . ' AND s.`publish`=1 ',
'limit' => $this->getLimit(null, true),
),
'special' => array(
'textfictif' => 0,
'aide' => array(
'idcontact' => $this->idobject,
),
'text_aide' => true,
//'plus_proche' => true,
),
'dbg' => array('list_textes_aide_affiche', 'Liste des spectacles avec textes non fictifs qui ont reçu une aide'),
);
// ajouter des paramètres
if ($params_sql_more) {
$params_sql = $this->addParamsSql($params_sql, $params_sql_more);
}
// on souhaite également les infos sur le texte
if (isset($_REQUEST['get_texts'])) {
$params_sql['special']['get_text'] = array(
'get_illustration' => array(
'format' => array('width' => 300, 'height' => 300, 'direction' => 'thumb')
)
);
}
// executer
return $this->em->getRepository(Spectacles::class)->getListSpectacles($params_sql, $this->format_vignette, false, $params_display);
}
// }}}
// {{{ getPersonByContactSpectacle()
/** Les élèves d'une école pour un spectacle
*
* @param string $idcontact Le contact
* @param int $idspectacle Le spectacle
* @return array
*/
public function getPersonByContactSpectacle($idcontact, $idspectacle)
{
// trouver les élèves qui ont participé et leur rôle
$sql_role = 'SELECT DISTINCT(spectacle_person.`idspectacle`), spectacle_person.*, persons.`firstname`, persons.`lastname`, persons.`url_clean`, langterms.`fr` as role_string
FROM spectacle_person
INNER JOIN persons ON spectacle_person.`idperson`=persons.`idperson`
INNER JOIN person_ecole ON person_ecole.`idperson`=spectacle_person.`idperson`
INNER JOIN roles ON spectacle_person.`idrole`=roles.`idrole`
INNER JOIN langterms ON langterms.`id`=roles.`role`
WHERE spectacle_person.`idspectacle`=' . (int)$idspectacle . '
AND person_ecole.`idcontact`=' . (int)$idcontact;
$results = $this->em->getRepository(Spectacles::class)->queryAll($sql_role);
if (!empty($results) && !PEAR::isError($results)) {
return $results;
} else {
return array();
}
}
// }}}
// {{{ getContactAides()
/** Récupérer les laureats et nominations et les soutiens et les sélection
*
*
* @access public
* @param $type_aide int
* @return void
*/
public function getContactAides($type_aide, $params = array())
{
$show_url_text_by_author = false;
if (!empty($this->context['view']->current_page)) {
$this->context['view']->{'page_' . $this->context['view']->current_page} = true;
}
// menu type
$this->context['view']->menu_types_object = array(
//'tous' => array('name' => 'Tous les lauréats'),
'text' => array('name' => 'Tous les textes'),
'spectacle' => array('name' => 'Tous les spectacles'),
'person' => array('name' => 'Tous les artistes'),
'contact' => array('name' => 'Toutes les structures')
);
$this->context['view']->filtres_aides_categories = array(
'spectacle' => 107, //résident de création
'text' => 106 //résident d'écriture
);
// chercher une aide précise
if (!empty($this->context['params']['idaide'])) {
$idaide = (int)$this->context['params']['idaide'];
$this->context['view']->{'texts_' . $idaide} = true;
}
if (!empty($this->context['params']['type']) && !empty($this->context['view']->menu_types_object[$this->context['params']['type']])) {
$type_object = $this->context['params']['type'];
} else {
$type_object = 'text';
}
foreach ($this->context['view']->menu_types_object as $t => $v) {
// récupèrer les prix associés au contact
$object_aide = $this->em->getRepository('TheatreCore\Entity\\' . ucfirst($t) . 'Aide');
if (!is_array($type_aide)) {
$type_aide = array($type_aide);
}
//playlists table
//idperson = 7051
//idtext = 24291
$params_sql_aide = array(
'special' => array(
'aides' => array(
'idcontacts' => $this->infosobject['idcontact'],
'type_aides' => $type_aide,
),
),
'dbg' => array($t . '_aide_count', 'Nombre de ' . $t . ' lauréats'),
);
// compter le nombre total de lauréats
$this->context['view']->menu_types_object[$t]['nb'] = $object_aide->{'countList' . ucfirst($t) . 'Aide'}($params_sql_aide);
if ($this->context['view']->menu_types_object[$t]['nb'] == 0) {
unset($this->context['view']->menu_types_object[$t]);
} else {
$this->context['view']->menu_types_object[$t]['params_sql'] = $params_sql_aide;
$this->context['view']->menu_types_object[$t]['object_aide'] = $object_aide;
}
}
if (!empty($this->context['view']->menu_types_object)) {
// si type_object est vide, chercher un autre
if (!isset($this->context['view']->menu_types_object[$type_object])) {
foreach ($this->context['view']->menu_types_object as $t => $v) {
$type_object = $t;
break;
}
}
if (empty($this->context['params']['idaide'])) {
$this->context['view']->menu_types_object[$type_object]['active'] = 'on';
}
$this->context['view']->params_filtre = $type_object;
if ($type_object == 'contact') {
$this->perPage = 50;
}
$aidecontacts = $this->em->getRepository(Aidecontacts::class);
$this->context['view']->aide_type_object = $type_object;
foreach ($this->context['view']->menu_types_object as $t => $v) {
// si on est dans le contexte
if ($type_object == $t) {
// il faut retrouver les différents aidecontact
$params_sql_aidecontact = array(
'where' => array(
array($t . '_aide', 'publish', 1),
),
'special' => array(
'object' => $t,
'aides' => array(
'idcontacts' => $this->idobject,
'no_empty' => true,
'type_aides' => $type_aide,
),
),
'limit' => array(0, 100),
'dbg' => array('list_aidecontacts_' . $t, 'Liste des catégories d\'aide pour ' . $t),
);
$this->context['view']->list_aidecontacts = $aidecontacts->getListAidecontacts($params_sql_aidecontact);
if (count($this->context['view']->list_aidecontacts) == 1 && !empty($idaide)) {
foreach ($this->context['view']->list_aidecontacts as $k => $value) {
$this->context['view']->categorie_aidecontact = $value;
}
}
$object_aide = $this->context['view']->menu_types_object[$t]['object_aide'];
$params_sql_aide = $this->context['view']->menu_types_object[$t]['params_sql'];
$params_sql_aide['where'][] = array($t . '_aide', 'publish', 1);
// trouver les années où il y a eu des lauréats pour toutes les aides
$this->getCommonSearch(array(
'saisons_annees' => array(
'annees' => $object_aide->getYears($params_sql_aide),
)
)
);
$this->getCommonSearchView();
if (!empty($this->context['view']->year)) {
$params_sql_aide['special']['period']['year'] = $this->context['view']->year;
}
// cherche une aide précise
if (!empty($idaide)) {
$params_sql_aide['special']['aides']['idaide'] = $idaide;
// par courir les aides et marquer l'active
foreach ($this->context['view']->list_aidecontacts as $ka => $va) {
foreach ($va['aides'] as $kb => $vb) {
if (empty($vb[''])) {
$this->context['view']->list_aidecontacts[$ka]['aides'][$kb]['mention_contacts'] = $aidecontacts->wikiTransform($vb['mention_contacts']);
}
if ($vb['idaide'] == $idaide) {
$this->context['view']->list_aidecontacts[$ka]['aides'][$kb]['active'] = true;
$this->context['view']->list_aidecontacts[$ka]['active'] = true;
}
}
}
}
$params_display = array();
// texte style
if ($type_object == 'text') {
$params_display['vignette_format'] = array('width' => $_ENV['VIGN_TEXT_WIDTH'], 'height' => $_ENV['VIGN_TEXT_HEIGHT'], 'direction' => $_ENV['VIGN_TEXT_DIRECT']);
//suppression de la condition qui n'est utile que pour la V1
$params_display['stylemore'] = array('imagep' => 'width:60px;', 'desctxt' => 'width:210px;');
$params_display['publisher_first_inverse'] = true;
$params_sql_aide['get_texts_with_aides'] = true;
}
// pour les contacts
if ($type_object == 'contact') {
$params_sql_aide['get_contacts_with_aides'] = true;
}
// pour les spectacles
if ($type_object == 'spectacle') {
$params_sql_aide['get_spectacles_with_aides'] = true;
}
$this->context['view']->{'nb_list_aides_' . $t} = $object_aide->{'countList' . ucfirst($t) . 'Aide'}($params_sql_aide);
if (!empty($params['limit'])) {
$params_sql_aide['limit'] = array($params['limit'][0], $params['limit'][1]);
} else {
$params_sql_aide['limit'] = array($this->getLimitStart(), $this->perPage);
}
$params_sql_aide['dbg'] = array($t . '_aide_list', 'Les ' . $t . ' lauréats');
$list = $object_aide->{'getList' . ucfirst($t) . 'Aide'}($params_sql_aide, $params_display);
$this->context['view']->noshow = false;
//on récupère les playlists pour la page 'texts par l'auteur'
if ($type_object == 'text' && ($this->context['action'] == 'auteurs' || !empty($params['vignette_video'])) || ($this->context['action'] == 'nominations' && !$show_url_text_by_author)) {
$first_boucle = false;
foreach ($list as $key => $val) {
if (!empty($val['texts'])) {
foreach ($val['texts'] as $skey => $sval) {
$sql = 'SELECT p.idplaylist
FROM playlists p
LEFT JOIN playlist_classification pc ON p.idplaylist = pc.idplaylist
WHERE pc.idclassification = 144 AND p.idtext = ' . $sval['idtext'] . '
GROUP BY p.idtext';
if ($type_object == 'text' && ($this->context['action'] == 'auteurs' || !empty($params['vignette_video']))) {
if (!$first_boucle) {
$this->context['view']->{'nb_list_aides_' . $t} = 0;
$first_boucle = true;
}
if ($x = $this->obj->queryOne($sql)) {
$playlists = $this->em->getRepository(Playlists::class);
$playlist = $playlists->getInfosPlaylist(
$x,
array(
'all' => true,
'multimedias' => true,
'format_vignette' => array('width' => $_ENV['VIGN_VIDEO_WIDTH'], 'height' => $_ENV['VIGN_VIDEO_HEIGHT'], 'fleche' => 'none', 'ratio' => '169')
),
array('format_vignette' => true)
);
$video = (array_shift($playlist['multimedias']));
$list[$key]['texts'][$sval['idtext']]['vignette'] = $video['image_media'];
$list[$key]['texts'][$sval['idtext']]['thtv'] = true;
$list[$key]['texts'][$sval['idtext']]['thtv_permalink'] = $video['permalink'];
$list[$key]['texts'][$sval['idtext']]['url_clean_video'] = $playlist['urlClean'];
$this->context['view']->{'nb_list_aides_' . $t}++;
} else {
unset($list[$key]['texts'][$skey]);
}
} else {
$show_url_text_by_author = true;
$this->context['view']->tag_text_by_author = 1;
}
}
}
}
}
if (!empty($this->context['view']->list_aidecontacts)) {
$nb_aidecontacts = 0;
foreach ($this->context['view']->list_aidecontacts as $k => $v) {
if (empty($v['aides'])) {
$nb_aidecontacts = $nb_aidecontacts + count($v['aides']);
}
}
}
// si pas de sous-catégorie/aide, afficher la catégorie/aidecontact
if (empty($this->context['view']->list_aidecontacts) || $nb_aidecontacts == 1) {
if (!empty($nb_aide) && $nb_aide == 1) {
unset($this->context['view']->list_aidecontacts);
}
foreach ($list as $k => $v) {
$this->context['view']->aidecontact = $v['aide']['aidecontact'];
break;
}
}
// groupement par année
$list_by_year = array();
if (empty($params['no_year_array'])) {
foreach ($list as $k => $v) {
if (!empty($v[$t . 's'])) {
$list_by_year[$v['year_start']][$v['idaide']]['description'] = $v['aide'];
foreach ($v[$t . 's'] as $kb => $vb) {
$list_by_year[$v['year_start']][$v['idaide']][$t . 's'][] = $vb;
}
}
}
// dans les années, groupement par type d'aide
$this->context['view']->{'list_aides_' . $t} = $list_by_year;
} // aucun groupement par année, array simple, textes
else {
foreach ($list as $k => $v) {
if (!empty($v['texts'])) {
$idtext = key($v['texts']);
$list_texts[$idtext] = reset($v['texts']);
$list_texts[$idtext]['aides'] = $v['aide'];
}
}
if (!empty($list_texts)) {
$this->context['view']->{'list_aides_' . $t} = $list_texts;
}
}
$this->context['view']->pagination = $this->getPagination($this->context['view']->{'nb_list_aides_' . $t});
}
}
}
// ajouter masonery
//$this->context['view']->js_more[] = 'jquery.masonry.min.js';
}
// }}}
// {{{ addParamsSql()
/** Ajouter/supprimer des paramètres pour getListSpectacles
*
* @param array $params_sql tableau orginal
* @param array $params_sql tableau complété
* @return array
*/
public function addParamsSql($params_sql, $params_sql_more)
{
// ajouter des paramètres
unset($params_sql['params']['limit']);
unset($params_sql['special']['plus_proche']);
$params_sql = array_merge_recursive($params_sql, $params_sql_more);
return $params_sql;
}
// }}}
// {{{ getWhereIdcontact()
/** Définir le pattern de recherche en fonction du type (festival ou structure classique)
*
* @return string
*/
public function getWhereIdcontact()
{
if (!empty($this->infosobject['is_festival'])) {
return ' (sc.`idcontact`=' . (int)$this->idobject . ' OR sc.`idcontactFestival`=' . (int)$this->idobject . ') ';
} else if ($this->infosobject['idtypestructure'] == 'ED' || $this->infosobject['idtypestructure'] == 'RV') {
return ' t.`idcontact_publisher`=' . (int)$this->idobject . ' ';
} else {
return ' sc.`idcontact`=' . (int)$this->idobject . ' ';
}
}
// }}}
// {{{ getDvds()
/** Les dvds et la VOD associées à ce spectacle
*
* @param bool $count_only Compter seulement
* @return array|int
*
*/
public function getDvds($count_only = false)
{
$params_sql = array(
'dbg' => array('dvds_contact', 'Les dvds associés aux spectacles coproduits par la structure'),
'special' => array(
'idspectacles' => $this->ids_spectacle_prod,
)
);
if (empty($this->ids_spectacle_prod)) {
$params_sql['special']['idcontacts'] = $this->idobject;
}
if ($count_only) {
$params_sql['count_only'] = true;
$params_sql['limit'] = array('all');
} else {
$params_sql['limit'] = array(0, 100);
}
return $this->em->getRepository(Dvds::class)->getListDvds($params_sql);
}
// }}}
// {{{ countVod()
/** Compter le nb de VOD
*
* @param bool $count_only Compter seulement
* @return array|int
*
*/
public function countVod()
{
$params_sql = array(
'dbg' => array('vods_contact', 'Compter les VODs'),
'count_only' => true,
'special' => array(
'vods' => true,
'idspectacles' => $this->ids_spectacle_prod,
)
);
if (empty($this->ids_spectacle_prod)) {
$params_sql['special']['idcontacts'] = $this->idobject;
}
return count($this->em->getRepository(Dvds::class)->getListDvds($params_sql));
}
// }}}
// {{{ countTelechargements()
/** Compter le nb de fichiers
*
* @return int
*
*/
public function countTelechargements()
{
$files = $this->em->getRepository(Files::class);
$classifications = $this->em->getRepository(Classifications::class);
// classifications des contacts
$classifications_contact_list = $classifications->getClassificationList('files', 'contacts', null, array(1), 'get_value');
// classifications des spectacles
$classifications_spectacle_list = $classifications->getClassificationList('files', 'spectacles', null, array(1), 'get_value');
// joindre les deux
$classifications_list = array_merge($classifications_contact_list, $classifications_spectacle_list);
// liste des fichiers
$params_object_files = array(
'valid' => 1,
'publish' => 1,
'force_mode' => 'file',
'debug_sql_associate' => false
);
return $files->countObjectFiles($this->idobject, 'contacts', $classifications_list, $params_object_files);
}
// }}}
// {{{ countEnScene()
/** Compter le nb de fichiers
*
* @return int
*
*/
public function countEnScene($params = array())
{
$this->getCommonSearch(array(
// 'saisons_annees' => Date_time::getListSaisons(2000,(date('Y')+1)),
//'default_saison' => Date_time::getLastSaison(),
'inverse_periode' => true,
'nb_days' => 720,
));
$params_sql = $this->setCommonSearchSpectacles(array(
'special' => array(
//'get_text'
'textfictif' => 0,
'aide' => array(
'idcontact' => $this->idobject,
),
'text_aide' => true,
'plus_proche' => true
),
'dbg' => array('list_textes_affiche', 'Liste des spectacles avec textes non fictifs qui ont reçu une aide'),
));
if (!empty($params['all'])) {
unset($params_sql['special']['prochains']);
unset($params_sql['special']['plus_proche']);
} else if (!empty($params['anciens'])) {
unset($params_sql['special']['prochains']);
unset($params_sql['special']['plus_proche']);
$params_sql['special']['anciens'] = true;
$params_sql['special']['anciens_stricts'] = true;
}
if (!empty($params['type_aide'])) {
$params_sql['special']['aide']['type_aide'] = (is_array($params['type_aide'])) ? $params['type_aide'] : [$params['type_aide']];
}
if (!empty($params['without_lecture'])) {
$params_sql['params']['where'] = ' AND s.`idtypespectacle` != 1';
}
return $this->em->getRepository(Spectacles::class)->countListSpectacles($params_sql);
}
// }}}
/** Les asides communs aux pages biographies
*
*/
public function get_asides_biographies($type_page = 'tous')
{
$menu_biographies = array(
'auteurs' => array(
'name' => 'Tous les auteurs',
'key_filtre' => 'auteurs',
// 'count' => $spectacles_counts['prochains']
),
// 'traducteurs' => array(
// 'name' => 'Tous les traducteurs',
// 'key_filtre' => 'traducteurs',
// // 'count' => $spectacles_counts['prochains']
// ),
// 'auteurs-affiche' => array(
// 'name' => 'Les auteurs à l\'affiche',
// 'key_filtre' => 'auteurs_affiche',
// 'url' => '/editions/{v_url_clean}/auteurs/type/key_filtre/generate_params'
// // 'count' => $spectacles_counts['tous']
// ),
'decouverte-auteurs' => array(
'name' => 'Les auteurs par eux-mêmes',
'key_filtre' => 'decouverte-auteurs',
'url' => '/editions/{v_url_clean}/decouverte-auteurs',
),
);
//Tous les menus
$this->asides->load(['url_lists' => array(
'exec' => [
'color' => 'biographies',
'htmlstart' => true,
'htmlend' => (isset($this->view->menu_jours_auteurs)) ? false : true
],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $menu_biographies,
'url' => '/editions/{v_url_clean}/biographies/type/key_filtre/generate_params',
'params' => array(
'activate' => $this->view->type,
),
'structure' => array(
'structure_classic' => array(
'd' => 'v_days',
)
)
),
'title' => 'Voir'
)]);
if (isset($this->view->menu_jours_auteurs)) {
$this->asides->load(['url_lists,menu_days' => array(
'exec' => [
'color' => 'biographies',
'htmlend' => true
],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->view->menu_jours,
'url' => '/editions/{v_url_clean}/auteurs/type/key_filtre/generate_params',
'params' => array(
'key_filtre' => $this->view->type,
'activate' => $this->context['view']->days
),
'structure' => array(
'structure_classic' => array(
'd' => 'key_day',
)
)
),
'title' => 'Recherche par période'
)]);
}
// $this->asides->load(['recherche_texte.inc' => array(
// 'exec' => ['htmlstart' => true, 'color'=>'biographies'],
// 'action' => '/editions/editeurs'
// )]);
if (!empty($this->view->alphabet)) {
$this->asides->load(['recherche_alphabetique' => array(
'exec' => array(
'htmlstart' => true,
'htmlend' => true,
'color' => 'biographies'
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->view->alphabet,
'url' => '/editions/{v_url_clean}/biographies?lettre=key_letter',
'params' => [
'key_letter' => 'auto_key'
]
),
'title_seconds' => 'Recherche alphabétique'
)]);
}
// $this->get_asides_common('biographies');
}
// }}}
/** Les asides communs à toutes les plusieurs pages
*
*/
public function get_asides_common($color = 'editions', $params_asides = array())
{
$params_carte_common = array(
'exec' => ['color' => $color],
);
if (!empty($params_asides['carte_url_custom'])) {
$params_carte_common['url'] = $params_asides['carte_url_custom'];
}
if (!in_array($this->context['action'], array('textes', 'biographies')) && (!empty($params_asides['no_show_map']) && $params_asides['no_show_map'])) {
$this->asides->load(['common_carte' => $params_carte_common]);
}
$this->asides->load(['common_participer_contacts' => array(
'url_custom_edit' => '/contacts/' . $this->view->url_clean . '/infos-generales'
)]);
}
// }}}
}