-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request afup#1528 from stakovicz/feat-1180-plan-du-site
afup#1180 plan du site
- Loading branch information
Showing
4 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{% extends ':site:base.html.twig' %} | ||
|
||
{% block title %}Plan du site de l'AFUP{% endblock %} | ||
|
||
{% macro list(items) %} | ||
<ul> | ||
{% for item in items %} | ||
<li><a href="{{ item.url }}">{{ item.name }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% endmacro %} | ||
|
||
{% block content %} | ||
<div class="mw1400p center" id="container"> | ||
<div class="line" id="main"> | ||
<h1>Plan du site</h1> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
{{ _self.list(pages) }} | ||
|
||
<h2><a href="{{ path('become_member') }}">Adhérer à l'AFUP</a></h2> | ||
<ul> | ||
<li><a href="{{ path('legacy_inscription') }}">Adhérer en tant que particulier</a></li> | ||
<li><a href="{{ path('company_membership') }}">Adhérer en tant qu'entreprise</a></li> | ||
<li><a href="{{ path('admin_login') }}">Se connecter</a></li> | ||
</ul> | ||
|
||
<h2><a href="{{ path('talks_list') }}">Historique des conférences</a></h2> | ||
{{ _self.list(talks) }} | ||
</div> | ||
<div class="col-md-6"> | ||
<h2>Association</h2> | ||
{{ _self.list(association) }} | ||
|
||
<h2><a href="{{ path('company_public_profile_list') }}">Entreprises adhérentes</a></h2> | ||
{{ _self.list(members) }} | ||
|
||
<h2><a href="{{ path('news_list') }}">Actualités</a></h2> | ||
{{ _self.list(news) }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace AppBundle\Controller; | ||
|
||
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 HtmlSitemapController extends SiteBaseController | ||
{ | ||
/** @var UrlGeneratorInterface */ | ||
private $urlGenerator; | ||
|
||
public function __construct(UrlGeneratorInterface $urlGenerator) | ||
{ | ||
$this->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(), | ||
'talks' => $this->talks(), | ||
] | ||
); | ||
} | ||
|
||
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; | ||
} | ||
|
||
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; | ||
} | ||
} |