<?php
namespace App\Controller;
use App\Entity\Accueil;
use App\Entity\User;
use UserEntity\Stacks;
use App\Entity\StackTransit;
use App\Entity\StackZones;
use App\Entity\StackCategories;
use App\Entity\StackSequences;
use App\Entity\StackTimer;
use App\Entity\Commentaires;
use App\Entity\Statistiques;
use App\Repository\AccueilRepository;
use App\Repository\UserRepository;
use App\Repository\StacksRepository;
use App\Repository\StackTransitRepository;
use App\Repository\StackZonesRepository;
use App\Repository\StackCategoriesRepository;
use App\Repository\StackSequencesRepository;
use App\Repository\StackTimerRepository;
use App\Repository\CommentairesRepository;
use App\Repository\StatistiquesRepository;
use App\Form\AccueilType;
use App\Form\StackTimerType;
use App\Form\StacksType;
use App\Form\StacksEditType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Address;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\String\Slugger\SluggerInterface;
use Symfony\Component\Security\Core\Security;
use Doctrine\Common\Collections\ArrayCollection;
class CdromController extends AbstractController
{
public $parPage = 5;
private $stacksRepo;
public function __construct(StatistiquesRepository $statRepo, CommentairesRepository $commRep, StackCategoriesRepository $catRep, StackSequencesRepository $seqRep, StackZonesRepository $stackZoneRepo, StacksRepository $stacksRepo, AccueilRepository $accRepo, SluggerInterface $slugger, EntityManagerInterface $em)
{
$this->statRepo = $statRepo;
$this->commRep = $commRep;
$this->catRep = $catRep;
$this->seqRep = $seqRep;
$this->stackZoneRepo = $stackZoneRepo;
$this->stacksRepo = $stacksRepo;
$this->accRepo = $accRepo;
$this->slugger = $slugger;
$this->em = $em;
}
public function mouche($action, $id)
{
$stat = new Statistiques();
$macard = $this->stacksRepo->find($id);
$stat->setIp($_SERVER['REMOTE_ADDR']);
$stat->setOs($_SERVER['HTTP_USER_AGENT']);
$stat->setAction($action);
$stat->setCard($macard);
$stat->setDateCrea(new \DateTime());
$this->em->persist($stat);
$this->em->flush();
}
/**
* @Route("/cdromNatif", name="front_cdromBifNatif")
*/
public function front_cdromBifNatif(): Response
{
// recupere la stack
$stack = $this->stacksRepo->find(1);
// mouche
$this->mouche("visite", "début");
return $this->render('cdrom/homeNatif.html.twig', [
'controller_name' => 'front_cdromBifNatif',
'stack' => $stack,
'zindex' => 500,
]);
}
/**
* @Route("/cdromAgrandi", name="front_cdromBifAgrandi")
*/
public function front_cdromBifAgrandi(): Response
{
// recupere la stack
$stack = $this->stacksRepo->find(1);
// mouche
$this->mouche("visite", "début");
return $this->render('cdrom/homeAgrandi.html.twig', [
'controller_name' => 'front_cdromBifAgrandi',
'stack' => $stack,
'zindex' => 500,
]);
}
// -------------------------------- projo640bif
/**
* @Route("/cdromNatif/bif", name="front_cdromNatifBif")
*/
public function front_cdromNatifBif(): Response
{
// recupere la stack
$stack = $this->stacksRepo->find(1);
// mouche
$this->mouche("visite", "début");
return $this->render('cdrom/projo640bif/index.html.twig', [
'controller_name' => 'front_cdromNatifBif',
'stack' => $stack,
'zindex' => 500,
]);
}
/**
* @Route("/cdromNatif/bif/{id}", name="front_cdrom_640_ciblebif")
*/
public function cdrom_640Ciblebif($id): Response
{
// recupere la stack
$stack = $this->stacksRepo->find($id);
// mouche
$this->mouche("visite", "début");
return $this->render('cdrom/projo640bif/index.html.twig', [
'controller_name' => 'front_cdrom_640_ciblebif',
'stack' => $stack,
'zindex' => 500,
]);
}
// -------------------------------- projo900bif
/*
* @Route("/cdrom/bif", name="front_cdromBif")
public function cdrombif(): Response
{
// recupere la stack
$stack = $this->stacksRepo->find(1);
// mouche
$this->mouche("visite", "début");
return $this->render('cdrom/projo900bif/index.html.twig', [
'controller_name' => 'front_cdromBif',
'stack' => $stack,
'zindex' => 500,
]);
}
*/
/**
* @Route("/cdrom/bif/{id}", name="front_cdrom_900_ciblebif")
*/
public function cdrom_900Ciblebif($id): Response
{
// recupere la stack
$stack = $this->stacksRepo->find($id);
// mouche
$this->mouche("visite", "début");
return $this->render('cdrom/projo900bif/index.html.twig', [
'controller_name' => 'front_cdrom_900_ciblebif',
'stack' => $stack,
'zindex' => 500,
]);
}
// -------------------------------- xxxx
/**
* @Route("/recupStackProjo2bif", name="projo_stacks_recupStack2bif", methods={"POST"})
*/
public function recupStackProjo2bif(): Response
{
// recupere datas de l'ajax
$id = utf8_decode(htmlspecialchars($_POST["id"]));
$zindex = utf8_decode(htmlspecialchars($_POST["zindex"]));
$stackSize = $_POST["size"];
$oldStack = $_POST["oldStack"];
$oldRetourBiff = $_POST["oldRetourBiff"];
// recupere l'objet de la stack à afficher
$stack = $this->stacksRepo->find($id);
dump($stack->getId());
// mouche
$this->mouche("visite", $id);
// recupere les zones
$mesrolls = $this->stackZoneRepo->recupRollOver($stack->getId());
// recup l'objet de la stack menu index
if ( $stack->getSsequence()->getNom() == "Index" ){
$stackMenuIndex = $this->stacksRepo->find(92);
}
else{
$stackMenuIndex = "0";
}
// Navigations
// recupere la stack de destination du btn nav H
if ( $stack->getNavH() !== null ) {
$stackNavH = $this->stacksRepo->find($stack->getNavH());
} else {
$stackNavH = null;
}
// recupere la stack de destination du btn nav G
if ( $stack->getNavG() !== null ) {
$stackNavG = $this->stacksRepo->find($stack->getNavG());
} else {
$stackNavG = null;
}
// recupere la stack de destination du btn nav G
if ( $stack->getNavD() !== null ) {
$stackNavD = $this->stacksRepo->find($stack->getNavD());
} else {
$stackNavD = null;
}
// recupere la stack de destination du btn nav BG
if ( $stack->getNavBG() !== null ) {
$stackNavBG = $this->stacksRepo->find($stack->getNavBG());
} else {
$stackNavBG = null;
}
// recupere la stack de destination du btn nav BD
if ( $stack->getNavBD() !== null ) {
$stackNavBD = $this->stacksRepo->find($stack->getNavBD());
} else {
$stackNavBD = null;
}
dump($stackSize);
// rendu
if($stackSize == 640){
return $this->render('cdrom/projo640bif/divStack.html.twig', [
'controller_name' => 'projo640_stacks_recupStack2bif',
'stack' => $stack,
'stackSize' => $stackSize,
'mesrolls' => $mesrolls,
'zindex' => $zindex,
'oldStack' => $oldStack,
'oldRetourBiff' => $oldRetourBiff,
'stackNavH' => $stackNavH,
'stackNavG' => $stackNavG,
'stackNavD' => $stackNavD,
'stackNavBG' => $stackNavBG,
'stackNavBD' => $stackNavBD,
'stackMenuIndex' => $stackMenuIndex,
]);
}
else {
return $this->render('cdrom/projo900bif/divStack.html.twig', [
'controller_name' => 'projo900_stacks_recupStack2bif',
'stack' => $stack,
'stackSize' => $stackSize,
'mesrolls' => $mesrolls,
'zindex' => $zindex,
'oldStack' => $oldStack,
'oldRetourBiff' => $oldRetourBiff,
'stackNavH' => $stackNavH,
'stackNavG' => $stackNavG,
'stackNavD' => $stackNavD,
'stackNavBG' => $stackNavBG,
'stackNavBD' => $stackNavBD,
'stackMenuIndex' => $stackMenuIndex,
]);
}
}
/**
* @Route("/recupImgbif", name="front_stacks_recupImgRollo", methods={"POST"})
*/
public function recupImgFRollo(): Response
{
// recupere datas de l'ajax
$id = $_POST["id"];
$idParent = $_POST["idParent"];
$stackSize = $_POST["size"];
$oldRetourBiff = $_POST["oldRetourBiff"];
// recupere la stack à afficher
$stack = $this->stacksRepo->find($id);
// mouche
$this->mouche("rollover", $id);
// nombre de zones de la stack à afficher
$mesZones = $stack->getZones();
// recupere les zones
$mesrolls = $this->stackZoneRepo->recupRollOver22($mesZones);
//$mesrolls = $this->stackZoneRepo->recupRollOver($stack->getZones());
//$service = $repository->findBy(array('name' => 'Registration'),array('name' => 'ASC'));
//$mesrolls = $this->stackZoneRepo->findBy(array('name' => 'Registration'), array('name' => 'ASC'));
//$mesrolls = $this->stackZoneRepo->findBy(array('name' => 'Registration'), array('name' => 'ASC'));
//$service = $repository->findBy(array('name' => 'Registration'),array('name' => 'ASC'));
// recupere la zone du parent actif
$mesrollsParent = $this->stackZoneRepo->recupZoneParentActive($idParent, $stack->getId());
//$parent = $this->stacksRepo->find($mesrollsParent->getStacks());
$parent = $this->stacksRepo->find($idParent);
//
return $this->render('cdrom/projo900bif/divStack_imageRollo.html.twig', [
'controller_name' => 'front_stacks_recupImg',
'stack' => $stack,
'stackSize' => $stackSize,
'mesrolls' => $mesrolls,
'idParent' => $idParent,
'parent' => $parent,
'mesrollsParent' => $mesrollsParent,
'oldRetourBiff' => $oldRetourBiff,
]);
}
/**
* @Route("/recupImgbif2", name="front_stacks_recupImgRollo2", methods={"POST"})
*/
public function recupImgFRollo2(): Response
{
// recupere datas de l'ajax
$id = $_POST["id"];
$idParent = $_POST["idParent"];
$stackSize = $_POST["size"];
// recupere la stack à afficher
$stack = $this->stacksRepo->find($id);
// mouche
$this->mouche("rollover2", $id);
//
return $this->render('cdrom/projo900bif/divStack_imageRollo2.html.twig', [
'controller_name' => 'front_stacks_recupImg',
'stack' => $stack,
'stackSize' => $stackSize,
]);
}
/**
* @Route("/recupImg", name="front_stacks_recupImg", methods={"POST"})
*/
public function recupImgF(): Response
{
// recupere datas de l'ajax
$id = $_POST["id"];
$stackSize = $_POST["size"];
//dump($stackSize);
// recupere la stack à afficher
$stack = $this->stacksRepo->find($id);
// mouche
$this->mouche("recupImgF", $id);
//
return $this->render('cdrom/projo900bif/divStack_imageRollo.html.twig', [
'controller_name' => 'front_stacks_recupImg',
'stack' => $stack,
'stackSize' => $stackSize,
]);
}
}