소스 검색

affichage list + structuration controller/route

v1
Charly 3 년 전
부모
커밋
831f21b46f
14개의 변경된 파일285개의 추가작업 그리고 212개의 파일을 삭제
  1. +0
    -7
      assets/app/backend/common/common.js
  2. +9
    -9
      config/routes.yaml
  3. +11
    -0
      src/Controller/Frontend/AboutController.php
  4. +126
    -0
      src/Controller/Frontend/CartoController.php
  5. +59
    -0
      src/Controller/Frontend/ContactController.php
  6. +23
    -0
      src/Controller/Frontend/ContribuateController.php
  7. +2
    -188
      src/Controller/Frontend/DefaultController.php
  8. +12
    -0
      src/Controller/Frontend/HomeController.php
  9. +23
    -0
      src/Controller/Frontend/MentionController.php
  10. +1
    -1
      src/Entity/Dream.php
  11. +1
    -1
      src/Entity/ProjectBoost.php
  12. +1
    -1
      src/Entity/ProjectInspiring.php
  13. +1
    -1
      src/Entity/Revolt.php
  14. +16
    -4
      templates/frontend/carto-liste.html.twig

+ 0
- 7
assets/app/backend/common/common.js 파일 보기

@@ -10,18 +10,11 @@ $(document).ready(function () {
setSubtheme($(select));
$(select).trigger('change');
})
//setSubtheme();
// $(document).on('click', '.theme option', function (e) {
// alert('test');
// $(this).closest('.form-widget-compound').find('.subtheme option').show();
// $(this).closest('.form-widget-compound').find('.subtheme option[data-class]').not("[data-class='" + $(this).data('class') + "']").hide();
// });
});


function setSubtheme($select) {
$select.on('change', function (e) {
SovTools.log($(e.target).find('option:selected').data('class'));
$(e.target).closest('.form-widget-compound').find('.subtheme option').prop('disabled', false);
$(e.target).closest('.form-widget-compound').find('.subtheme option[data-class]').not("[data-class='" + $(e.target).find('option:selected').data('class') + "']").prop('disabled', true);
SovWidgets.setSelect2($(this).closest('.form-widget-compound').find('.subtheme'));

+ 9
- 9
config/routes.yaml 파일 보기

@@ -12,36 +12,36 @@ app_admin_dashboard_animator:

app_homepage:
path: /
controller: App\Controller\Frontend\DefaultController:home
controller: App\Controller\Frontend\HomeController:home

app_legal_mention:
path: /mentions-legales
controller: App\Controller\Frontend\DefaultController::mention
controller: App\Controller\Frontend\MentionController::mention

app_carto_interactive:
path: /cartographie-interactive
controller: App\Controller\Frontend\DefaultController::cartoInteractive
controller: App\Controller\Frontend\CartoController::cartoInteractive

app_carto_liste:
path: /cartographie-list
controller: App\Controller\Frontend\DefaultController::cartoListe
controller: App\Controller\Frontend\CartoController::cartoListe

app_carto_carte:
path: /cartographie-carte
controller: App\Controller\Frontend\DefaultController::cartoCarte
controller: App\Controller\Frontend\CartoController::cartoCarte

app_contact:
path: /contact
controller: App\Controller\Frontend\DefaultController::contact
controller: App\Controller\Frontend\ContactController::contact

app_contact_form:
path: /contact-form
controller: App\Controller\Frontend\DefaultController::contactForm
controller: App\Controller\Frontend\ContactController::contactForm

app_about:
path: /a-propos
controller: App\Controller\Frontend\DefaultController::about
controller: App\Controller\Frontend\AboutController::about

app_contribuate:
path: /contribution-individuel
controller: App\Controller\Frontend\DefaultController::contribuate
controller: App\Controller\Frontend\ContribuateController::contribuate

+ 11
- 0
src/Controller/Frontend/AboutController.php 파일 보기

@@ -0,0 +1,11 @@
<?php

namespace App\Controller\Frontend;

class AboutController extends DefaultController
{
public function about()
{
return $this->render('frontend/about.html.twig');
}
}

+ 126
- 0
src/Controller/Frontend/CartoController.php 파일 보기

@@ -0,0 +1,126 @@
<?php

namespace App\Controller\Frontend;

use App\Entity\Dream;
use App\Entity\ProjectBoost;
use App\Entity\ProjectInspiring;
use App\Entity\Revolt;
use App\Form\ContactForm;
use App\Form\IndividualForm;
use App\Form\SearchListForm;
use App\Repository\DreamStore;
use App\Repository\ProjectBoostStore;
use App\Repository\ProjectInspiringStore;
use App\Repository\RevoltStore;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use App\Entity\Site\Page;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\HttpFoundation\Request;

class CartoController extends DefaultController
{
protected EntityManagerInterface $em;
protected DreamStore $dreamStore;
protected RevoltStore $revoltStore;
protected ProjectBoostStore $projectBoostStore;
protected ProjectInspiringStore $projectInspiringStore;
protected PaginatorInterface $paginator;

public function __construct(
EntityManagerInterface $em,
DreamStore $dreamStore,
RevoltStore $revoltStore,
ProjectBoostStore $projectBoostStore,
ProjectInspiringStore $projectInspiringStore,
PaginatorInterface $paginator
) {
$this->em = $em;
$this->dreamStore = $dreamStore;
$this->revoltStore = $revoltStore;
$this->projectBoostStore = $projectBoostStore;
$this->projectInspiringStore = $projectInspiringStore;
$this->paginator = $paginator;
}

public function cartoInteractive()
{
return $this->render(
'frontend/carto-int.html.twig',
[
'nbContrib' => $this->countContrib()
]
);
}

public function cartoListe(Request $request)
{
$dreamArray = $revoltArray = $projectBoostArray = $projectInspiringArray = $resultArray = $resultArrayPagination = array();

$form = $this->createForm(SearchListForm::class);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$page = $data['page'];
$description = $data['search'];
$categoryArray = $data['category'];
$territoryArray = $data['territory'];
$thematicArray = $data['thematic'];

if (in_array('dream', $categoryArray) || empty($categoryArray)) {
$dreamArray = $this->dreamStore->filterSearch($description, $territoryArray, $thematicArray);
}
if (in_array('revolt', $categoryArray) || empty($categoryArray)) {
$revoltArray = $this->revoltStore->filterSearch($description, $territoryArray, $thematicArray);
}
if (in_array('projectBoost', $categoryArray) || empty($categoryArray)) {
$projectBoostArray = $this->projectBoostStore->filterSearch(
$description,
$territoryArray,
$thematicArray
);
}
if (in_array('projectInspiring', $categoryArray) || empty($categoryArray)) {
$projectInspiringArray = $this->projectInspiringStore->filterSearch(
$description,
$territoryArray,
$thematicArray
);
}

$resultArray = array_merge($dreamArray, $revoltArray, $projectBoostArray, $projectInspiringArray);

$resultArrayPagination = $this->paginator->paginate(
$resultArray,
$page,
10
);
}

return $this->render(
'frontend/carto-liste.html.twig',
[
'form' => $form->createView(),
'nbContrib' => $this->countContrib(),
'resultArray' => $resultArrayPagination
]
);
}

public function cartoCarte()
{
return $this->render(
'frontend/carto-carte.html.twig',
[
'nbContrib' => $this->countContrib()
]
);
}

}

+ 59
- 0
src/Controller/Frontend/ContactController.php 파일 보기

@@ -0,0 +1,59 @@
<?php

namespace App\Controller\Frontend;

use App\Form\ContactForm;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\HttpFoundation\Request;

class ContactController extends DefaultController
{
public function contact()
{
$form = $this->createForm(ContactForm::class, null, array(
'action' => $this->generateUrl('app_contact_form')
));

return $this->render('frontend/contact.html.twig', [
'form' => $form->createView()
]);
}

public function contactForm(Request $request, MailerInterface $mailer)
{
$form = $this->createForm(ContactForm::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid() && $form->get('lccap')->getData() == 'blop') {
$message = '<p>De : ' . $form->get('firstname')->getData() . ' ' . $form->get('lastname')->getData(
) . '<br />Email : ' . $form->get('email')->getData() . '<br />Objet : ' . $form->get(
'object'
)->getData() . '</p><p>' . $form->get('message')->getData() . '</p>';

$email = (new Email())
->from('charly@laclic.fr')
->from('nepasrepondre@laclic.fr')
->replyTo($form->get('email')->getData())
// ->to('agir@lacooperativedescitoyens.fr')
->to('charly@laclic.fr')
->subject('Message de contact sur Aux Actes Citoyens !')
->text(strip_tags($message))
->html($message);

$mailer->send($email);

return new JsonResponse(
[
'status' => 'success'
]
);
}
return new JsonResponse(
[
'status' => 'error'
]
);
}

}

+ 23
- 0
src/Controller/Frontend/ContribuateController.php 파일 보기

@@ -0,0 +1,23 @@
<?php

namespace App\Controller\Frontend;


use App\Form\IndividualForm;

class ContribuateController extends DefaultController
{

public function contribuate()
{
$form = $this->createForm(IndividualForm::class);

return $this->render(
'frontend/contribuate.html.twig',
[
'nbContrib' => $this->countContrib(),
'form' => $form->createView()
]
);
}
}

+ 2
- 188
src/Controller/Frontend/DefaultController.php 파일 보기

@@ -6,206 +6,20 @@ use App\Entity\Dream;
use App\Entity\ProjectBoost;
use App\Entity\ProjectInspiring;
use App\Entity\Revolt;
use App\Form\ContactForm;
use App\Form\IndividualForm;
use App\Form\SearchListForm;
use App\Repository\DreamStore;
use App\Repository\ProjectBoostStore;
use App\Repository\ProjectInspiringStore;
use App\Repository\RevoltStore;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use App\Entity\Site\Page;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends AbstractController
{
protected EntityManagerInterface $em;
protected DreamStore $dreamStore;
protected RevoltStore $revoltStore;
protected ProjectBoostStore $projectBoostStore;
protected ProjectInspiringStore $projectInspiringStore;
protected PaginatorInterface $paginator;

public function __construct(
EntityManagerInterface $em,
DreamStore $dreamStore,
RevoltStore $revoltStore,
ProjectBoostStore $projectBoostStore,
ProjectInspiringStore $projectInspiringStore,
PaginatorInterface $paginator
EntityManagerInterface $em
) {
$this->em = $em;
$this->dreamStore = $dreamStore;
$this->revoltStore = $revoltStore;
$this->projectBoostStore = $projectBoostStore;
$this->projectInspiringStore = $projectInspiringStore;
$this->paginator = $paginator;
}

public function home()
{
return $this->render('frontend/home.html.twig');
}

public function cartoInteractive()
{
return $this->render(
'frontend/carto-int.html.twig',
[
'nbContrib' => $this->countContrib()
]
);
}

public function cartoListe(Request $request)
{
$dreamArray = $revoltArray = $projectBoostArray = $projectInspiringArray = $resultArray = $resultArrayPagination = array();

$form = $this->createForm(SearchListForm::class);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$page = $data['page'];
$description = $data['search'];
$categoryArray = $data['category'];
$territoryArray = $data['territory'];
$thematicArray = $data['thematic'];

if (in_array('dream', $categoryArray) || empty($categoryArray)) {
$dreamArray = $this->dreamStore->filterSearch($description, $territoryArray, $thematicArray);
}
if (in_array('revolt', $categoryArray) || empty($categoryArray)) {
$revoltArray = $this->revoltStore->filterSearch($description, $territoryArray, $thematicArray);
}
if (in_array('projectBoost', $categoryArray) || empty($categoryArray)) {
$projectBoostArray = $this->projectBoostStore->filterSearch(
$description,
$territoryArray,
$thematicArray
);
}
if (in_array('projectInspiring', $categoryArray) || empty($categoryArray)) {
$projectInspiringArray = $this->projectInspiringStore->filterSearch(
$description,
$territoryArray,
$thematicArray
);
}

$resultArray = array_merge($dreamArray, $revoltArray, $projectBoostArray, $projectInspiringArray);

$resultArrayPagination = $this->paginator->paginate(
$resultArray,
$page,
10
);
}

return $this->render(
'frontend/carto-liste.html.twig',
[
'form' => $form->createView(),
'nbContrib' => $this->countContrib(),
'resultArray' => $resultArrayPagination
]
);
}

public function cartoCarte()
{
return $this->render(
'frontend/carto-carte.html.twig',
[
'nbContrib' => $this->countContrib()
]
);
}

public function contactForm(Request $request, MailerInterface $mailer)
{
$form = $this->createForm(ContactForm::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid() && $form->get('lccap')->getData() == 'blop') {
$message = '<p>De : ' . $form->get('firstname')->getData() . ' ' . $form->get('lastname')->getData(
) . '<br />Email : ' . $form->get('email')->getData() . '<br />Objet : ' . $form->get(
'object'
)->getData() . '</p><p>' . $form->get('message')->getData() . '</p>';

$email = (new Email())
->from('charly@laclic.fr')
->from('nepasrepondre@laclic.fr')
->replyTo($form->get('email')->getData())
// ->to('agir@lacooperativedescitoyens.fr')
->to('charly@laclic.fr')
->subject('Message de contact sur Aux Actes Citoyens !')
->text(strip_tags($message))
->html($message);

$mailer->send($email);

return new JsonResponse(
[
'status' => 'success'
]
);
}
return new JsonResponse(
[
'status' => 'error'
]
);
}

public function contact()
{
$form = $this->createForm(ContactForm::class, null, array(
'action' => $this->generateUrl('app_contact_form')
));

return $this->render('frontend/contact.html.twig', [
'form' => $form->createView()
]);
}

public function about()
{
return $this->render('frontend/about.html.twig');
}

public function contribuate()
{
$form = $this->createForm(IndividualForm::class);

return $this->render(
'frontend/contribuate.html.twig',
[
'nbContrib' => $this->countContrib(),
'form' => $form->createView()
]
);
}

public function mention(): Response
{
$pageRepository = $this->em->getRepository(Page::class);

return $this->render(
'page/page.html.twig',
[
'controller_name' => 'IndexController',
'page' => $pageRepository->findOneByDevAlias('legal-mention')
]
);
}

private function countContrib(): int
protected function countContrib(): int
{
$dreamRepository = $this->em->getRepository(Dream::class);
$revoltRepository = $this->em->getRepository(Revolt::class);

+ 12
- 0
src/Controller/Frontend/HomeController.php 파일 보기

@@ -0,0 +1,12 @@
<?php

namespace App\Controller\Frontend;


class HomeController extends DefaultController
{
public function home()
{
return $this->render('frontend/home.html.twig');
}
}

+ 23
- 0
src/Controller/Frontend/MentionController.php 파일 보기

@@ -0,0 +1,23 @@
<?php

namespace App\Controller\Frontend;


use App\Entity\Site\Page;
use Symfony\Component\HttpFoundation\Response;

class MentionController extends DefaultController
{
public function mention(): Response
{
$pageRepository = $this->em->getRepository(Page::class);

return $this->render(
'page/page.html.twig',
[
'controller_name' => 'IndexController',
'page' => $pageRepository->findOneByDevAlias('legal-mention')
]
);
}
}

+ 1
- 1
src/Entity/Dream.php 파일 보기

@@ -34,7 +34,7 @@ class Dream implements DescriptionProjectInterface, EntityInterface

public function __toString()
{
return $this->description;
return "Nos rêves";
}

public function getId(): ?int

+ 1
- 1
src/Entity/ProjectBoost.php 파일 보기

@@ -34,7 +34,7 @@ class ProjectBoost implements DescriptionProjectInterface, EntityInterface

public function __toString()
{
return $this->description;
return "Les actions à booster";
}

public function getId(): ?int

+ 1
- 1
src/Entity/ProjectInspiring.php 파일 보기

@@ -34,7 +34,7 @@ class ProjectInspiring implements DescriptionProjectInterface, EntityInterface

public function __toString()
{
return $this->description;
return "Les actions inspirantes";
}

public function getId(): ?int

+ 1
- 1
src/Entity/Revolt.php 파일 보기

@@ -34,7 +34,7 @@ class Revolt implements DescriptionProjectInterface, EntityInterface

public function __toString()
{
return $this->description;
return "Nos révoltes";
}

public function getId(): ?int

+ 16
- 4
templates/frontend/carto-liste.html.twig 파일 보기

@@ -49,10 +49,22 @@
<tbody>
{% for result in resultArray %}
<tr>
<td>{{ result }}</td>
<td>{{ result }}</td>
<td>{{ result }}</td>
<td>{{ result }}</td>
<td>
{{ result }}
</td>
<td>
{{ result.thematic }}
</td>
<td>
{{ result.subthematic }}
</td>
<td>
{% if result.individualData is not empty %}
{{ result.individualData.territory }}
{% elseif result.collectifData is not empty %}
{{ result.collectifData.territory }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>

Loading…
취소
저장