From 5f54fa8b623c16e52e81fd360b51d07e0f36101b Mon Sep 17 00:00:00 2001 From: Albin Date: Sat, 24 Aug 2024 21:03:28 +0200 Subject: [PATCH 1/2] afup#1180 plan du site --- app/Resources/views/site/sitemap.html.twig | 41 +++++++ app/config/routing/global.yml | 6 ++ app/config/services.yml | 3 + .../Controller/SitemapController.php | 101 ++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 app/Resources/views/site/sitemap.html.twig create mode 100644 sources/AppBundle/Controller/SitemapController.php diff --git a/app/Resources/views/site/sitemap.html.twig b/app/Resources/views/site/sitemap.html.twig new file mode 100644 index 000000000..0717248b6 --- /dev/null +++ b/app/Resources/views/site/sitemap.html.twig @@ -0,0 +1,41 @@ +{% extends ':site:base.html.twig' %} + +{% block title %}Plan du site de l'AFUP{% endblock %} + +{% macro list(items) %} + +{% endmacro %} + +{% block content %} +
+
+

Plan du site

+
+ +
+

Association

+ {{ _self.list(association) }} + +

Entreprises adhérentes

+ {{ _self.list(members) }} + +

Actualités

+ {{ _self.list(news) }} +
+
+
+
+{% endblock %} diff --git a/app/config/routing/global.yml b/app/config/routing/global.yml index dedee729b..5afc63e16 100644 --- a/app/config/routing/global.yml +++ b/app/config/routing/global.yml @@ -7,3 +7,9 @@ home: become_sponsor_latest: path: /become-sponsor defaults: {_controller: AppBundle:Lead:becomeSponsorLatest} + +sitemap: + path: /plan-du-site + defaults: { _controller: AppBundle:Sitemap:display } + options: + sitemap: true \ No newline at end of file diff --git a/app/config/services.yml b/app/config/services.yml index 4fe997027..4c4a43b4c 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -110,6 +110,9 @@ services: AppBundle\Controller\LeadController: autowire: true + AppBundle\Controller\SitemapController: + autowire: true + AppBundle\Controller\SpeakerSuggestionController: autowire: true diff --git a/sources/AppBundle/Controller/SitemapController.php b/sources/AppBundle/Controller/SitemapController.php new file mode 100644 index 000000000..765e219ad --- /dev/null +++ b/sources/AppBundle/Controller/SitemapController.php @@ -0,0 +1,101 @@ +urlGenerator = $urlGenerator; + } + + public function displayAction() + { + $branche = new Branche(); + + return $this->render( + ':site:sitemap.html.twig', + [ + 'pages' => $this->buildLeafs($branche, Feuille::ID_FEUILLE_HEADER), + 'association' => $this->buildLeafs($branche, Feuille::ID_FEUILLE_ANTENNES), + 'members' => $this->members(), + 'news' => $this->news(), + ] + ); + } + + private function buildLeafs(Branche $branche, int $id): array + { + $leafs = $branche->feuillesEnfants($id); + + $pages = []; + foreach ($leafs as $leaf) { + if (!$leaf['lien'] || starts_with($leaf['lien'], 'http')) { + continue; + } + $pages[] = [ + 'name' => $leaf['nom'], + 'url' => $leaf['lien'], + ]; + } + + return $pages; + } + + private function members(): array + { + /** + * @var CompanyMemberRepository $companyRepository + */ + $companyRepository = $this->get('ting')->get(CompanyMemberRepository::class); + $displayableCompanies = $companyRepository->findDisplayableCompanies(); + + $members = []; + foreach ($displayableCompanies as $member) { + $url = $this->urlGenerator->generate('company_public_profile', [ + 'id' => $member->getId(), + 'slug' => $member->getSlug(), + ]); + + $members[] = [ + 'name' => $member->getCompanyName(), + 'url' => $url + ]; + } + return $members; + } + + private function news(): array + { + $itemPerPage = 100; + $page = 1; + + $repository = $this->get('ting')->get(ArticleRepository::class); + + $news = []; + do { + $newsList = $repository->findPublishedNews($page++, $itemPerPage, []); + foreach ($newsList as $newsItem) { + $url = $this->urlGenerator->generate('news_display', [ + 'code' => $newsItem->getSlug(), + ]); + + $news[] = [ + 'name' => $newsItem->getTitle(), + 'url' => $url + ]; + } + } while (count($newsList) >= $itemPerPage); + + return $news; + } +} From 96c97d62e56b656ea1e01046b9969f1e75bc38e1 Mon Sep 17 00:00:00 2001 From: Albin Date: Sun, 1 Sep 2024 20:38:19 +0200 Subject: [PATCH 2/2] =?UTF-8?q?afupf#1180=20ajout=20des=20conf=C3=A9rences?= =?UTF-8?q?=20et=20renommage=20de=20la=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Resources/views/site/sitemap.html.twig | 5 +++- app/config/routing/global.yml | 2 +- app/config/services.yml | 2 +- ...ntroller.php => HtmlSitemapController.php} | 28 ++++++++++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) rename sources/AppBundle/Controller/{SitemapController.php => HtmlSitemapController.php} (77%) diff --git a/app/Resources/views/site/sitemap.html.twig b/app/Resources/views/site/sitemap.html.twig index 0717248b6..1fabeebff 100644 --- a/app/Resources/views/site/sitemap.html.twig +++ b/app/Resources/views/site/sitemap.html.twig @@ -18,12 +18,15 @@

Association

diff --git a/app/config/routing/global.yml b/app/config/routing/global.yml index 5afc63e16..88bcb98ba 100644 --- a/app/config/routing/global.yml +++ b/app/config/routing/global.yml @@ -10,6 +10,6 @@ become_sponsor_latest: sitemap: path: /plan-du-site - defaults: { _controller: AppBundle:Sitemap:display } + defaults: { _controller: AppBundle:HtmlSitemap:display } options: sitemap: true \ No newline at end of file diff --git a/app/config/services.yml b/app/config/services.yml index 4c4a43b4c..837558121 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -110,7 +110,7 @@ services: AppBundle\Controller\LeadController: autowire: true - AppBundle\Controller\SitemapController: + AppBundle\Controller\HtmlSitemapController: autowire: true AppBundle\Controller\SpeakerSuggestionController: diff --git a/sources/AppBundle/Controller/SitemapController.php b/sources/AppBundle/Controller/HtmlSitemapController.php similarity index 77% rename from sources/AppBundle/Controller/SitemapController.php rename to sources/AppBundle/Controller/HtmlSitemapController.php index 765e219ad..50dc3f2f1 100644 --- a/sources/AppBundle/Controller/SitemapController.php +++ b/sources/AppBundle/Controller/HtmlSitemapController.php @@ -5,10 +5,12 @@ use Afup\Site\Corporate\Branche; use Afup\Site\Corporate\Feuille; use AppBundle\Association\Model\Repository\CompanyMemberRepository; +use AppBundle\Event\Model\Repository\TalkRepository; +use AppBundle\Event\Model\Talk; use AppBundle\Site\Model\Repository\ArticleRepository; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -class SitemapController extends SiteBaseController +class HtmlSitemapController extends SiteBaseController { /** @var UrlGeneratorInterface */ private $urlGenerator; @@ -29,6 +31,7 @@ public function displayAction() 'association' => $this->buildLeafs($branche, Feuille::ID_FEUILLE_ANTENNES), 'members' => $this->members(), 'news' => $this->news(), + 'talks' => $this->talks(), ] ); } @@ -98,4 +101,27 @@ private function news(): array return $news; } + + private function talks(): array + { + $repository = $this->get('ting')->get(TalkRepository::class); + + $talks = []; + $talkList = $repository->getAllPastTalks((new \DateTime())->setTime(29,59,59)); + + /** @var Talk $talk */ + foreach ($talkList as $talk) { + $url = $this->urlGenerator->generate( + 'talks_show', + ['id' => $talk->getId(), 'slug' => $talk->getSlug()] + ); + + $talks[] = [ + 'name' => $talk->getTitle(), + 'url' => $url + ]; + } + + return $talks; + } }