From 8d2970959c149447cab464608a446542b04d259d Mon Sep 17 00:00:00 2001 From: afornerot Date: Sun, 3 Nov 2024 18:32:47 +0100 Subject: [PATCH] svg --- config/routes.yaml | 2 +- src/Controller/SlideController.php | 233 ++----------------------- templates/Home/user.html.twig | 10 +- templates/Illustration/slide.html.twig | 26 ++- 4 files changed, 42 insertions(+), 229 deletions(-) diff --git a/config/routes.yaml b/config/routes.yaml index a44dd3c..8728143 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -269,7 +269,7 @@ app_link_delete: #== Slide ===================================================================================================== app_slide: - path: /slide + path: /slide/{userpseudo} defaults: { _controller: App\Controller\SlideController:slide } #== Home USer================================================================================================== diff --git a/src/Controller/SlideController.php b/src/Controller/SlideController.php index 9668db1..fcfeae5 100755 --- a/src/Controller/SlideController.php +++ b/src/Controller/SlideController.php @@ -17,229 +17,30 @@ class SlideController extends AbstractController private $render = "Illustration/"; private $entity = "App:Illustration"; - public function slide(Request $request) + public function slide($userpseudo,Request $request) { $em = $this->getDoctrine()->getManager(); - $datas = $em->getRepository($this->entity)->findAll(); + $user=$em->getRepository("App:User")->findOneBy(["slug"=>$userpseudo]); + if(!$user) return $this->redirectToRoute("app_home"); + + $qb = $em ->createQueryBuilder() + ->select('i') + ->from("App:Illustration", 'i') + ->from("App:Category", 'c') + ->from("App:User",'u') + ->Where('c=i.category') + ->andWhere('u=c.user') + ->andWhere('u.slug=:userpseudo') + ->setParameter('userpseudo',$userpseudo) + ->orderBy('i.submittime','DESC'); + $illustrations=$qb->getQuery()->getResult(); return $this->render($this->render.'slide.html.twig',[ - $this->data."s" => $datas, + $this->data."s" => $illustrations, "useheader" => false, "usesidebar" => false, "usemonocolor" => true, + "user" => $user, ]); } - - public function view($idcat,$id,Request $request) - { - $em = $this->getDoctrine()->getManager(); - $data=$em->getRepository($this->entity)->find($id); - - $datanext=$this->getDataAllNext($idcat,$id); - $dataprev=$this->getDataAllPrev($idcat,$id); - - $pathinfo=pathinfo($data->getIllustration()); - - if(!$data) return $this->redirectToRoute('app_home'); - - return $this->render($this->render.'view.html.twig', array( - $this->data => $data, - "prev" => $dataprev, - "next" => $datanext, - "pathinfo" => $pathinfo, - "usemonocolor" => true, - )); - } - - - public function submit($by, Request $request) - { - // Initialisation de l'enregistrement - $em = $this->getDoctrine()->getManager(); - $data = new Entity(); - - // Création du formulaire - $form = $this->createForm(Form::class,$data,array("mode"=>"submit")); - - // Récupération des data du formulaire - $form->handleRequest($request); - - // Sur erreur - $this->getErrorForm(null,$form,$request,$data,"submit"); - - // Sur validation - if ($form->get('submit')->isClicked() && $form->isValid()) { - $data = $form->getData(); - $data->setSubmittime(new \DateTime()); - $em->persist($data); - $em->flush(); - - // Retour à la liste - if($by=="console") - return $this->redirectToRoute($this->route); - else - return $this->redirectToRoute("app_home"); - } - - // Affichage du formulaire - return $this->render($this->render.'edit.html.twig', [ - 'useheader' => true, - 'usesidebar' => false, - $this->data => $data, - 'mode' => 'submit', - 'form' => $form->createView(), - 'by' => $by, - ]); - } - - public function update($id,$by,Request $request) - { - // Initialisation de l'enregistrement - $em = $this->getDoctrine()->getManager(); - $data=$em->getRepository($this->entity)->find($id); - - // Création du formulaire - $form = $this->createForm(Form::class,$data,array("mode"=>"update")); - - // Récupération des data du formulaire - $form->handleRequest($request); - - // Sur erreur - $this->getErrorForm($id,$form,$request,$data,"update"); - - // Sur validation - if ($form->get('submit')->isClicked() && $form->isValid()) { - $data = $form->getData(); - $em->persist($data); - $em->flush(); - - // Retour à l'illustration - if($by=="console") - return $this->redirectToRoute($this->route); - else - return $this->redirectToRoute($this->route.'_view',array("idcat"=>$data->getCategory()->getId(),"id"=> $id)); - } - - // Affichage du formulaire - return $this->render($this->render.'edit.html.twig', [ - 'useheader' => true, - 'usesidebar' => false, - $this->data => $data, - 'mode' => 'update', - 'form' => $form->createView(), - 'by' => $by, - ]); - } - - public function delete($id,$by,Request $request) - { - // Initialisation de l'enregistrement - $em = $this->getDoctrine()->getManager(); - $data=$em->getRepository($this->entity)->find($id); - - // Controle avant suppression - $error=false; - if($id<0) $error=true; - - if($error) - return $this->redirectToRoute($this->route."_update",["id"=>$id]); - else { - $em->remove($data); - $em->flush(); - - // Retour à la liste - if($by=="console") - return $this->redirectToRoute($this->route); - else - return $this->redirectToRoute("app_home"); - } - } - - public function upload() - { - return $this->render($this->render.'upload.html.twig'); - } - - - - - protected function getDataAllNext($idcat,$id) - { - $em = $this->getDoctrine()->getManager(); - $data = $em->createQueryBuilder() - ->select('e') - ->from($this->entity, 'e') - ->where('e.id>:id') - ->andWhere('e.category=:idcat') - ->getQuery() - ->setParameter("id", $id) - ->setParameter("idcat", $idcat) - ->setMaxResults(1) - ->getResult(); - - // Si pas de suivant on recherche le premier - if(!$data) { - $data = $em->createQueryBuilder() - ->select('e') - ->from($this->entity, 'e') - ->Where('e.category=:idcat') - ->getQuery() - ->setParameter("idcat", $idcat) - ->setMaxResults(1) - ->getResult(); - } - - return $data; - } - - protected function getDataAllPrev($idcat,$id) - { - $em = $this->getDoctrine()->getManager(); - $data = $em->createQueryBuilder() - ->select('e') - ->from($this->entity, 'e') - ->where('e.id<:id') - ->andWhere('e.category=:idcat') - ->orderBy('e.id','DESC') - ->getQuery() - ->setParameter("id", $id) - ->setParameter("idcat", $idcat) - ->setMaxResults(1) - ->getResult(); - - // Si pas de précedent on recherche le dernier - if(!$data) { - $data = $em->createQueryBuilder() - ->select('e') - ->from($this->entity, 'e') - ->Where('e.category=:idcat') - ->orderBy('e.id','DESC') - ->getQuery() - ->setParameter("idcat", $idcat) - ->setMaxResults(1) - ->getResult(); - } - - return $data; - } - - protected function getErrorForm($id,$form,$request,$data,$mode) { - if ($form->get('submit')->isClicked()&&$mode=="delete") { - } - - if ($form->get('submit')->isClicked() && $mode=="submit") { - } - - if ($form->get('submit')->isClicked() && ($mode=="submit" || $mode=="update")) { - } - - if ($form->get('submit')->isClicked() && !$form->isValid()) { - $this->get('session')->getFlashBag()->clear(); - - $errors = $form->getErrors(); - foreach( $errors as $error ) { - $request->getSession()->getFlashBag()->add("error", $error->getMessage()); - } - } - } } diff --git a/templates/Home/user.html.twig b/templates/Home/user.html.twig index 96a45bc..9cbd7b1 100644 --- a/templates/Home/user.html.twig +++ b/templates/Home/user.html.twig @@ -189,6 +189,7 @@ {% endif %} + @@ -355,14 +356,15 @@ {% if not config.appsubname is empty %} {{ config.appsubname }}
{%endif%} + {% if not config.appdescription is empty %} -
{{ config.appdescription|raw }}

- {%endif%} -
- + {% if user.email is not empty or config.facebook is not empty or config.instagram is not empty or config.twitter is not empty or config.google is not empty or config.youtube is not empty %} +

+ {% endif %} + {% if user.email is not empty %} Email = {{ user.email }}
{% endif %} diff --git a/templates/Illustration/slide.html.twig b/templates/Illustration/slide.html.twig index 183eb2f..465ba13 100755 --- a/templates/Illustration/slide.html.twig +++ b/templates/Illustration/slide.html.twig @@ -20,8 +20,17 @@ /*box-shadow: 0px 0px 5px 1px rgba(255, 255, 255, 0.45);*/ } - - +
+
+ +
+
+ +

{{user.pseudo}}

+ {% set qrCode = qr_code_result(absolute_url(path("app_home_user",{userpseudo:user.slug}))) %} + +
+
{% endblock %} {% block localjavascript %} @@ -47,17 +56,15 @@ } function resizeImage() { - console.log("resize") - height=$(window).height()-70; + height=$(window).height()-35; + $("#content").height($(window).height()-35); $("#illustration_illustration_img").css({height:height,width:'auto'}); width=$(window).width()-90; if($("#illustration_illustration_img").width()>width) $("#illustration_illustration_img").css({width:width,height:'auto'}); - height=$("#illustration_illustration_img").height(); - $("#bigright").css({height:height,"line-height":height+"px"}); - $("#bigleft").css({height:height,"line-height":height+"px"}); + height=$("#illustration_illustration_img").height(); } $(document).ready(function() { @@ -65,7 +72,9 @@ tbimg.push("{{illustration.illustration}}"); {% endfor %} - tbimg=shuffle(tbimg) + tbimg=shuffle(tbimg); + total=tbimg.length; + console.log(total); $('body').imagesLoaded(function() { resizeImage(); $("#illustration_illustration_img").fadeIn(); @@ -73,6 +82,7 @@ var intervalId = window.setInterval(function(){ posImg++; + if(posImg>=total) posImg=0; img=tbimg[posImg]; console.log(img); url="/{{ appAlias }}/uploads/illustration/xxx";