From 0254848d3916974ff34c3de140a78372e01c467d Mon Sep 17 00:00:00 2001 From: afornerot Date: Sun, 3 Nov 2024 14:47:30 +0100 Subject: [PATCH] svg --- config/packages/twig.yaml | 1 + config/routes.yaml | 25 +++++---- src/Controller/CategoryController.php | 2 +- src/Controller/HomeController.php | 73 ++++++++++++++++++++++++++- src/Entity/User.php | 36 +++++++++++++ templates/Home/feed.xml.twig | 8 +-- templates/Home/home.html.twig | 2 +- templates/Home/user.html.twig | 2 +- 8 files changed, 130 insertions(+), 19 deletions(-) diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 9d4a3a2..5843f8e 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -15,3 +15,4 @@ twig: appNinegateactivate: '%appNinegateactivate%' appNinegateurl: '%appNinegateurl%' appNinegatemoderegistration: '%appNinegatemoderegistration%' + protocole: '%protocole%' diff --git a/config/routes.yaml b/config/routes.yaml index b60c243..a44dd3c 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -3,9 +3,14 @@ app_home: path: / defaults: { _controller: App\Controller\HomeController:home } -app_feed: - path: /feed/{nb} - defaults: { _controller: App\Controller\HomeController:feed, nb: 0 } + +app_feedhome: + path: /feedhome/{nb} + defaults: { _controller: App\Controller\HomeController:feedhome, nb: 0 } + +app_feeduser: + path: /feeduser/{userpseudo}/{nb} + defaults: { _controller: App\Controller\HomeController:feeduser, nb: 0 } app_admin: path: /admin/home @@ -167,15 +172,15 @@ app_user_category: defaults: { _controller: App\Controller\CategoryController:listuser } app_category_submit: - path: /admin/category/submit/{by}/{userid} + path: /user/category/submit/{by}/{userid} defaults: { _controller: App\Controller\CategoryController:submit } app_category_update: - path: /admin/category/update/{id}/{by} + path: /user/category/update/{id}/{by} defaults: { _controller: App\Controller\CategoryController:update } app_category_delete: - path: /admin/category/delete/{id}/{by} + path: /user/category/delete/{id}/{by} defaults: { _controller: App\Controller\CategoryController:delete } #== Illustration ================================================================================================== @@ -225,19 +230,19 @@ app_webzine_submit: defaults: { _controller: App\Controller\WebzineController:submit } app_webzine_update: - path: /admin/webzine/update/{id}/{by} + path: /user/webzine/update/{id}/{by} defaults: { _controller: App\Controller\WebzineController:update } app_webzine_delete: - path: /admin/webzine/delete/{id}/{by} + path: /user/webzine/delete/{id}/{by} defaults: { _controller: App\Controller\WebzineController:delete } app_webzine_crop: - path: /admin/webzine/crop/{type}/{reportinput} + path: /user/webzine/crop/{type}/{reportinput} defaults: { _controller: App\Controller\CropController:crop02 } app_webzine_upload: - path: /admin/webzine/upload + path: /user/webzine/upload defaults: { _controller: App\Controller\WebzineController:upload } app_webzine_view: diff --git a/src/Controller/CategoryController.php b/src/Controller/CategoryController.php index c7592d3..205fec1 100755 --- a/src/Controller/CategoryController.php +++ b/src/Controller/CategoryController.php @@ -179,7 +179,7 @@ class CategoryController extends AbstractController return $this->redirectToRoute("app_home"); } if($by!="admin"&&$by!="update") { - if($this->getUser()!=$data->getCategory()->getUser()&&!$this->getUser()->hasRole("ROLE_ADMIN")) + if($this->getUser()!=$data->getUser()&&!$this->getUser()->hasRole("ROLE_ADMIN")) return $this->redirectToRoute("app_home"); } diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index d8ee847..4bd2fa5 100755 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -72,7 +72,7 @@ class HomeController extends AbstractController } - public function feed($nb) + public function feedhome($nb) { $feeds=[]; @@ -123,12 +123,81 @@ class HomeController extends AbstractController $columns = array_column($feeds, 'pubtime'); array_multisort($columns, SORT_DESC, $feeds); - $response = new Response($this->renderView('Home/feed.xml.twig',["feeds" => $feeds])); + $response = new Response($this->renderView('Home/feed.xml.twig',["by"=>"home","feeds" => $feeds])); $response->headers->set('Content-Type', 'application/xml; charset=utf-8'); return $response; } + public function feeduser($userpseudo,$nb) + { + $feeds=[]; + + $em = $this->getDoctrine()->getManager(); + + $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'); + if($nb!=0) $qb->setMaxResults($nb); + $illustrations=$qb->getQuery()->getResult(); + foreach($illustrations as $illustration) { + $tmp["path"] = "app_illustration_view"; + $tmp["type"] = "illustration"; + $tmp["idcat"] = $illustration->getCategory()->getId(); + $tmp["cat"] = $illustration->getCategory()->getName(); + $tmp["id"] = $illustration->getId(); + $tmp["name"] = $illustration->getName(); + $tmp["illustration"] = $illustration->getIllustration(); + $tmp["pubtime"] = $illustration->getSubmittime(); + $tmp["description"] = $illustration->getDescription(); + + array_push($feeds,$tmp); + } + + + + $qb = $em ->createQueryBuilder() + ->select('w') + ->from("App:Webzine", 'w') + ->from("App:User", 'u') + ->Where('u=w.user') + ->andWhere('u.slug=:userpseudo') + ->setParameter('userpseudo',$userpseudo) + ->orderBy('w.submittime','DESC'); + if($nb!=0) $qb->setMaxResults($nb); + $webzines=$qb->getQuery()->getResult(); + foreach($webzines as $webzine) { + if($webzine->getWebzinepages()) { + $tmp["path"] = "app_webzine_view"; + $tmp["type"] = "webzine"; + $tmp["idcat"] = $webzine->getId(); + $tmp["cat"] = "Webzine".($webzine->getSet()?" - ".$webzine->getSet():""); + $tmp["id"] = $webzine->getWebzinepages()[0]->getId(); + $tmp["name"] = $webzine->getName(); + $tmp["illustration"] = $webzine->getWebzinepages()[0]->getIllustration(); + $tmp["pubtime"] = $webzine->getSubmittime(); + $tmp["description"] = $webzine->getDescription(); + + array_push($feeds,$tmp); + } + } + + $columns = array_column($feeds, 'pubtime'); + array_multisort($columns, SORT_DESC, $feeds); + + $response = new Response($this->renderView('Home/feed.xml.twig',["by"=>"user","feeds" => $feeds])); + + $response->headers->set('Content-Type', 'application/xml; charset=utf-8'); + return $response; + } + public function admin() { return $this->render('Home/admin.html.twig',[ diff --git a/src/Entity/User.php b/src/Entity/User.php index ce612de..33df0c9 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -111,6 +111,11 @@ class User implements UserInterface, \Serializable */ private $links; + /** + * @ORM\OneToMany(targetEntity="Config", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) + */ + private $configs; + public function __construct() { $this->groups = new ArrayCollection(); @@ -119,6 +124,7 @@ class User implements UserInterface, \Serializable $this->illustrations = new ArrayCollection(); $this->webzines = new ArrayCollection(); $this->links = new ArrayCollection(); + $this->configs = new ArrayCollection(); } public function getUsername(): ?string @@ -387,6 +393,36 @@ class User implements UserInterface, \Serializable return $this; } + + /** + * @return Collection|Config[] + */ + public function getConfigs(): Collection + { + return $this->configs; + } + + public function addConfig(Config $config): self + { + if (!$this->configs->contains($config)) { + $this->configs[] = $config; + $config->setUser($this); + } + + return $this; + } + + public function removeConfig(Config $config): self + { + if ($this->configs->removeElement($config)) { + // set the owning side to null (unless already changed) + if ($config->getUser() === $this) { + $config->setUser(null); + } + } + + return $this; + } public function getPseudo(): ?string { diff --git a/templates/Home/feed.xml.twig b/templates/Home/feed.xml.twig index 18c0459..765a91f 100755 --- a/templates/Home/feed.xml.twig +++ b/templates/Home/feed.xml.twig @@ -7,7 +7,7 @@ {{ absolute_url(path("app_home")) }} {{ app.session.get('appname') }} - {{app.session.get('appsubname') }} {% for feed in feeds %} -{% set url = absolute_url(path(feed.path,{"idcat":feed.idcat,"id":feed.id}))|replace({'http://': 'https://'}) %} +{% set url = absolute_url(path(feed.path,{"by":by, "idcat":feed.idcat,"id":feed.id}))|replace({'http://': protocole~'://'}) %} {{ app.session.get('appname') }} - {{feed.name}} @@ -16,7 +16,7 @@ {{feed.pubtime|date('D, d M Y H:i:s O')}}

+

{{feed.name}}

{% autoescape 'html' %} @@ -26,8 +26,8 @@ {% endautoescape %} ]]>
- - + +
{% endfor %} diff --git a/templates/Home/home.html.twig b/templates/Home/home.html.twig index 2e1ae79..85dc0c8 100644 --- a/templates/Home/home.html.twig +++ b/templates/Home/home.html.twig @@ -172,7 +172,7 @@ {% if app.session.get('youtube') is not empty %} {% endif %} - +
diff --git a/templates/Home/user.html.twig b/templates/Home/user.html.twig index 22d7897..eb2cfe7 100644 --- a/templates/Home/user.html.twig +++ b/templates/Home/user.html.twig @@ -188,7 +188,7 @@ {% if config.youtube is not empty %} {% endif %} - +