Skip to content
Snippets Groups Projects
Commit f1114d50 authored by Pierre Fleutot's avatar Pierre Fleutot
Browse files

Début Page accueil

parent 321bb36b
No related branches found
No related tags found
No related merge requests found
Showing
with 358 additions and 77 deletions
public/assets/images/library.jpg

59 KiB

public/assets/images/library.png

290 KiB

......@@ -64,7 +64,7 @@ class HeadwordController extends AppBaseController
$headword = $this->newHeadword($word, $this->getLanguage());
$this->createEntryInNewWordsLexicon($headword);
$this->addFlash('success', sprintf("Le mot « %s » a été ajouté à l'Agora des nouveaux mots.", $word));
$this->addFlash('success', sprintf("Le mot « %s » a été ajouté à l'Agora Des Néologismes.", $word));
return $this->render("closeModalAndReload.html.twig");
}
......
......@@ -14,27 +14,14 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerInterface;
class IndexController extends AbstractController
class IndexController extends AppBaseController
{
/**
* @var ManagerRegistry
*/
private $doctrine;
public function __construct(ManagerRegistry $doctrine)
{
$this->doctrine = $doctrine;
}
/**
* @Route("/", name="app_index")
*/
public function index(WiktionaryManager $wiktionaryManager): Response
{
$baseEntrySchema = json_decode(file_get_contents(__DIR__ . "/../JsonSchema/baseEntrySchema.json"), true);
$baseEntrySchema['Headword'] = 'rr';
return $this->render('index/index.html.twig', []);
return $this->render('home.html.twig', []);
}
/**
......
......@@ -295,7 +295,7 @@ class LabelController extends AppBaseController
return $this->render('closeModalAndReload.html.twig');
} else {
$displayForceValidation = true;
$this->addFlash('warning', sprintf("Le mot «%s» n'existe ni dans Balex ni dans le wiktionnaire. Voulez-vous le proposer dans l'Agora des nouveaux mots ?", $word));
$this->addFlash('warning', sprintf("Le mot «%s» n'existe ni dans Balex ni dans le wiktionnaire. Voulez-vous le proposer dans l'Agora Des Néologismes ?", $word));
}
}
}
......
......@@ -78,6 +78,32 @@ class LexiconController extends AppBaseController
'sortingOrder' => $sortingOrder,
]);
}
/**
* @Route("/new-words/{id}", name="app_lexicon_new_words", methods={"GET"})
*/
public function showNewWordsLexicon(ManagerRegistry $doctrine, Request $request, Lexicon $lexicon): Response
{
$em = $doctrine->getManager();
$sortingColumn = null;
$sortingOrder = null;
$this->getSortingParameters($request, $sortingColumn, $sortingOrder, 'lexicon_new_words_show');
$form = $this->createForm(SearchStringType::class,null, array('method' => 'GET'));
$form->handleRequest($request);
$filter = $form->getData();
$filter['lexicon'] = $lexicon;
$entries = $em->getRepository(Entry::class)->filter($filter, 'createdAt', 'DESC');
return $this->render('lexicon/showNewWords.html.twig', [
'entries' => $entries,
'lexicon' => $lexicon,
'form' => $form->createView(),
'sortingColumn' => $sortingColumn,
'sortingOrder' => $sortingOrder,
]);
}
/**
* @Route("/{id}/choose-label-for-selection/{category}", name="app_lexicon_choose_label")
......
......@@ -149,7 +149,7 @@ class Lexicon
public function getMaster()
{
if ($this->getUser() && ! $this->getGroup()) return Label::MASTER_PERSONAL;
if ($this->getGroup() && $this->getUser()) return Label::MASTER_GROUP;
if ($this->getGroup() && ! $this->getUser()) return Label::MASTER_GROUP;
throw new \LogicException("Cannot determine lexicon masters type");
}
......
......@@ -49,6 +49,12 @@ class LabelManager
) > 0;
}
// Retourne les 5 derniers labels visibles par un user classés par date de création DESC
public function getLastLabels(User $user)
{
return $this->doctrine->getRepository(Label::class)->getLastVisiblesByUser($user);
}
// Retourne les labels visibles dans un lexique pour un user (pour une catégorie si renseignée)
public function getVisibleLabels(Lexicon $lexicon, User $user, $category = null)
{
......
......@@ -7,11 +7,13 @@ use App\Entity\Label;
use App\Entity\Lexicon;
use App\Entity\User;
use App\Languages\LanguagesIso;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Persistence\ManagerRegistry;
use JsonSchema\Validator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerInterface;
......@@ -22,9 +24,15 @@ class LexiconManager
*/
protected $doctrine;
public function __construct(ManagerRegistry $doctrine)
/**
* @var Security
*/
private $security;
public function __construct(ManagerRegistry $doctrine, Security $security)
{
$this->doctrine = $doctrine;
$this->security = $security;
}
/**
......@@ -40,8 +48,45 @@ class LexiconManager
* @param $language
* @return Lexicon|null
*/
public function getNewWordsLexicon($language)
public function getNewWordsLexicon($language = null)
{
$language = $language ? : $this->security->getUser()->getFirstStudiedLanguage();
return $this->doctrine->getRepository(Lexicon::class)->findOneBy(['language' => $language, 'category' => Lexicon::TYPE_NEW_WORDS]);
}
/**
* @param $language
* @return integer
*/
public function getNewWordsNb($language = null)
{
$newWordsLexicon = $this->getNewWordsLexicon($language);
return $this->doctrine->getRepository(Entry::class)->count([
'lexicon' => $newWordsLexicon
]);
}
/**
* @param Lexicon $lexicon
* @return integer
*/
public function getEntriesNb(Lexicon $lexicon)
{
return $this->doctrine->getRepository(Entry::class)->count([
'lexicon' => $lexicon
]);
}
/**
* @param $language
* @return integer
*/
public function getLastNewWords($language = null)
{
$newWordsLexicon = $this->getNewWordsLexicon($language);
return $this->doctrine->getRepository(Entry::class)->getLastEntries($newWordsLexicon);
}
}
......@@ -3,6 +3,7 @@
namespace App\Repository;
use App\Entity\Entry;
use App\Entity\Lexicon;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
......@@ -91,6 +92,20 @@ class EntryRepository extends ServiceEntityRepository
}
}
/**
* @return Entry[]
*/
public function getLastEntries(Lexicon $lexicon): array
{
return $this->createQueryBuilder('e')
->andWhere('e.lexicon = :lexicon')
->setParameter('lexicon', $lexicon)
->setMaxResults(5)
->getQuery()
->getResult()
;
}
/**
* @return Entry[] Returns an array of Entry objects
*/
......
......@@ -6,6 +6,7 @@ use App\Entity\Label;
use App\Entity\Lexicon;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
/**
......@@ -103,6 +104,34 @@ class LabelRepository extends ServiceEntityRepository
;
}
/**
* @param User $user
* @return QueryBuilder
*/
public function queryVisiblesByUser(User $user)
{
$qb = $this->createQueryBuilder('l')
->andWhere('l.master != :personal OR l.user = :user')
->setParameter('personal', Label::MASTER_PERSONAL)
->setParameter('user', $user)
->orderBy('l.createdAt', 'DESC')
;
return $qb;
}
/**
* @return Label[] Returns an array of Label objects
*/
public function getLastVisiblesByUser(User $user): array
{
return $this->queryVisiblesByUser($user)
->setMaxResults(5)
->getQuery()
->getResult()
;
}
// public function findOneBySomeField($value): ?Label
// {
// return $this->createQueryBuilder('l')
......
<ul class="nav nav-tabs mt-3">
{% for lexicon in app.user.myLexicons %}
{% set entryWithSameHeadwordInThisLexicon = lexicon.getEntryForHeadword(entry.headword) %}
<li class="nav-item dropdown">
<a class="nav-link {{ lexicon == entry.lexicon ? 'active' }} {{ entryWithSameHeadwordInThisLexicon ? 'tab-pink' : 'tab-grey' }} dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">{{ lexicon }}</a>
<ul class="dropdown-menu">
{% if entryWithSameHeadwordInThisLexicon %}
{% if lexicon != entry.lexicon %}
<li><a class="dropdown-item" href="{{ path('app_entry_show', {id: entryWithSameHeadwordInThisLexicon.id}) }}">{{ "Voir l'entrée dans ce lexique"|trans }}</a></li>
{% endif %}
{% set backUrl = (lexicon == entry.lexicon ? path('app_lexicon_show', {id: entry.lexicon.id}) : path('app_entry_show', {id: entry.id})) %}
<li><a class="dropdown-item" href="#"
data-href="{{ path('app_entry_delete', {id: entryWithSameHeadwordInThisLexicon.id, backUrl: backUrl}) }}"
data-confirm="{{ "Confirmer la suppression ?"|trans }}" data-bs-toggle="modal" data-bs-target="#confirm-dialog">
{{ "Supprimer l'entrée dans ce lexique"|trans }}
</a></li>
{% endif %}
{% if lexicon != entry.lexicon %}
{% if entryWithSameHeadwordInThisLexicon %}
<li><a class="dropdown-item" href="#" data-href="{{ path('app_entry_copy', {id: entry.id, lexiconId: lexicon.id}) }}"
data-confirm="{{ "Confirmer la copie ? Une entrée similaire existe déjà dans le lexique que vous avez sélectionné. Si vous copiez celle-ci, le contenu de l'autre sera perdue"|trans }}" data-bs-toggle="modal" data-bs-target="#confirm-dialog">
{{ "Copier l'entrée dans ce lexique"|trans }}
</a></li>
{% else %}
<li><a class="dropdown-item" href="{{ path('app_entry_copy', {id: entry.id, lexiconId: lexicon.id}) }}">{{ "Copier l'entrée dans ce lexique"|trans }}</a></li>
{% endif %}
{% endif %}
</ul>
</li>
{% endfor %}
{% if not entry.lexicon.isNewWords %}
{% set zeroLexicon = lexicon_manager.zeroLexicon(entry.language) %}
{% set entryZero = zeroLexicon.getEntryForHeadword(entry.headword) %}
<li class="nav-item">
<a class="nav-link {{ zeroLexicon == entry.lexicon ? 'active' }} tab-dark-pink" href="{{ path('app_entry_show', {id: entryZero.id}) }}">{{ "Wiktionnaire"|trans }}</a>
</li>
{% endif %}
</ul>
\ No newline at end of file
......@@ -10,70 +10,36 @@
<div class="col-md-12">
<h1 class="">
{% if not wiktionnaryLexicon %}
<a href="{{ path('app_lexicon_show', {id: entry.lexicon.id}) }}" class="btn btn-dark"><i class="bi bi-arrow-90deg-left"></i></a>
{% if entry.lexicon.newWords %}
<a href="{{ path('app_lexicon_new_words', {id: entry.lexicon.id}) }}" class="btn btn-dark"><i class="bi bi-arrow-90deg-left"></i></a>
{% else %}
{% if not wiktionnaryLexicon %}
<a href="{{ path('app_lexicon_show', {id: entry.lexicon.id}) }}" class="btn btn-dark"><i class="bi bi-arrow-90deg-left"></i></a>
{% endif %}
{{ entry|capitalize }}
{% set known = entry.headword.knownByUser(app.user) %}
<a title="{{ known ? 'Mot-vedette connu. Cliquer pour modifier'|trans : 'Mot-vedette non connu. Cliquer pour modifier'|trans }}" href="#"
class="ajax-link" data-method="GET" data-url="{{ path('app_headword_toggle_known', {id: entry.headword.id, userId: app.user.id, lexiconId: entry.lexicon.id}) }}">
{% if known %}<i class="fa fa-circle text-success"></i>{% else %}<i class="fa fa-circle text-warning"></i>{% endif %}
</a>
{% endif %}
{{ entry|capitalize }}
{% set known = entry.headword.knownByUser(app.user) %}
<a title="{{ known ? 'Mot-vedette connu. Cliquer pour modifier'|trans : 'Mot-vedette non connu. Cliquer pour modifier'|trans }}" href="#"
class="ajax-link" data-method="GET" data-url="{{ path('app_headword_toggle_known', {id: entry.headword.id, userId: app.user.id, lexiconId: entry.lexicon.id}) }}">
{% if known %}<i class="fa fa-circle text-success"></i>{% else %}<i class="fa fa-circle text-warning"></i>{% endif %}
</a>
</h1>
<ul class="nav nav-tabs mt-3">
{% for lexicon in app.user.myLexicons %}
{% set entryWithSameHeadwordInThisLexicon = lexicon.getEntryForHeadword(entry.headword) %}
<li class="nav-item dropdown">
<a class="nav-link {{ lexicon == entry.lexicon ? 'active' }} {{ entryWithSameHeadwordInThisLexicon ? 'tab-pink' : 'tab-grey' }} dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">{{ lexicon }}</a>
<ul class="dropdown-menu">
{% if entryWithSameHeadwordInThisLexicon %}
{% if lexicon != entry.lexicon %}
<li><a class="dropdown-item" href="{{ path('app_entry_show', {id: entryWithSameHeadwordInThisLexicon.id}) }}">{{ "Voir l'entrée dans ce lexique"|trans }}</a></li>
{% endif %}
{% set backUrl = (lexicon == entry.lexicon ? path('app_lexicon_show', {id: entry.lexicon.id}) : path('app_entry_show', {id: entry.id})) %}
<li><a class="dropdown-item" href="#"
data-href="{{ path('app_entry_delete', {id: entryWithSameHeadwordInThisLexicon.id, backUrl: backUrl}) }}"
data-confirm="{{ "Confirmer la suppression ?"|trans }}" data-bs-toggle="modal" data-bs-target="#confirm-dialog">
{{ "Supprimer l'entrée dans ce lexique"|trans }}
</a></li>
{% endif %}
{% if lexicon != entry.lexicon %}
{% if entryWithSameHeadwordInThisLexicon %}
<li><a class="dropdown-item" href="#" data-href="{{ path('app_entry_copy', {id: entry.id, lexiconId: lexicon.id}) }}"
data-confirm="{{ "Confirmer la copie ? Une entrée similaire existe déjà dans le lexique que vous avez sélectionné. Si vous copiez celle-ci, le contenu de l'autre sera perdue"|trans }}" data-bs-toggle="modal" data-bs-target="#confirm-dialog">
{{ "Copier l'entrée dans ce lexique"|trans }}
</a></li>
{% else %}
<li><a class="dropdown-item" href="{{ path('app_entry_copy', {id: entry.id, lexiconId: lexicon.id}) }}">{{ "Copier l'entrée dans ce lexique"|trans }}</a></li>
{% endif %}
{% endif %}
</ul>
</li>
{% if not entry.lexicon.newWords %}
{% include "entry/_lexiconsTabs.html.twig" %}
{% endfor %}
{% if not entry.lexicon.isNewWords %}
{% set zeroLexicon = lexicon_manager.zeroLexicon(entry.language) %}
{% set entryZero = zeroLexicon.getEntryForHeadword(entry.headword) %}
<li class="nav-item">
<a class="nav-link {{ zeroLexicon == entry.lexicon ? 'active' }} tab-dark-pink" href="{{ path('app_entry_show', {id: entryZero.id}) }}">{{ "Wiktionnaire"|trans }}</a>
</li>
{% endif %}
</ul>
<div id="tabContent" class="{{ wiktionnaryLexicon ? 'tab-wiktionnary' }}">
<div id="tabContent" class="{{ wiktionnaryLexicon ? 'tab-wiktionnary' }}">
<div class="row">
<div class="col-sm-6">
{% include "entry/_entryLabels.html.twig" %}
<div class="row">
<div class="col-sm-6">
{% include "entry/_entryLabels.html.twig" %}
</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
</div>
......
{% extends 'base.html.twig' %}
{% block container %}container-fluid{% endblock %}
{% block title %}{{ "Accueil"|trans }}{% endblock %}
{% block body %}
<div class="row m-2 mb-5">
<div class="col-md-12">
<div class="d-inline-block text-center" id="appLinksZone">
<i class="fa fa-gamepad fa-4x"></i>
<br>MagicWorld
</div>
<div class="row align-items-start">
<div class="col mt-5">
<h1>{{ "Mes lexiques"|trans }}</h1>
<div class="card mt-3">
<div class="card-header">
<div class="card-title pt-2 d-flex justify-content-between align-items-start">
<a href="{{ path('app_lexicon_show', {id: app.user.lexicon.id}) }}">{{ app.user.lexicon|badge }} {{ "Lexique personnel"|trans }}</a>
<span>{{ lexicon_manager.entriesNb(app.user.lexicon) }}</span>
</div>
</div>
<div class="card-body d-flex justify-content-between align-items-start">
{% for lexicon in app.user.myLexicons %}
{% if lexicon.masterGroup %}
<a href="{{ path('app_lexicon_show', {id: app.user.lexicon.id}) }}">{{ lexicon|badge }} {{ "Lexique du groupe"|trans }} « {{ lexicon }} »</a>
<span>{{ lexicon_manager.entriesNb(lexicon) }}</span>
{% endif %}
{% endfor %}
</div>
</div>
<h1>{{ "Labels récents"|trans }}</h1>
<div class="card mt-3">
<div class="card-body d-flex justify-content-between align-items-end">
<span>
{% for label in label_manager.lastLabels(app.user) %}
<p>
<a href="{{ path('app_label_show', {id: label.id}) }}">{% include "label/_labelBadge.html.twig" %}</a>
</p>
{% endfor %}
</span>
<h3><a href="{{ path('app_label_index') }}">Voir tous</a></h3>
</div>
</div>
<h1>{{ "Agora Des Néologismes"|trans }}</h1>
{% set newWordsLexicon = lexicon_manager.newWordsLexicon %}
<div class="card mt-3">
<div class="card-body d-flex justify-content-between align-items-end">
<span>
<p>
<i><strong>{{ lexicon_manager.newWordsNb }} propositions en cours :</strong></i>
</p>
{% for entry in lexicon_manager.lastNewWords %}
<p>
<a href="{{ path('app_entry_show', {id: entry.id}) }}">{{ entry }}</a>
</p>
{% endfor %}
</span>
<h3><a href="{{ path('app_lexicon_new_words', {id: newWordsLexicon.id}) }}">Voir tous</a></h3>
</div>
</div>
</div>
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
</div>
</div>
</div>
{% endblock %}
......@@ -2,7 +2,7 @@
{% import 'macros.html.twig' as macros %}
{% block container %}container-fluid{% endblock %}
{% block title %}{{ "Lexique"|trans }} {{ lexicon.id }}{% endblock %}
{% block title %}{{ "Lexique"|trans }} {{ lexicon|capitalize }}{% endblock %}
{% block body %}
......
{% extends 'base.html.twig' %}
{% import 'macros.html.twig' as macros %}
{% block container %}container-fluid{% endblock %}
{% block title %}{{ "Agora Des Néologismes"|trans }}{% endblock %}
{% block body %}
<div class="row justify-content-center m-lg-5 m-sm-3">
<div class="col-md-12">
<h1 class="">
{{ lexicon|badgeXl }} {{ "Agora Des Néologismes"|trans }}
</h1>
<div class="row mt-4">
<div class="col-sm-3">
{{ form_start(form) }}
<div class="d-flex justify-content-between">
{{ form_widget(form.searchString) }}
<button type="submit" title="{{ "Filtrer"|trans }}" class="btn btn-block btn-dark" style="margin-left: 10px">
<i class="fa fa-search"></i>
</button>
<a href="{{ path('app_lexicon_show', {id: lexicon.id}) }}" title="{{ "Réinitialiser"|trans }}" class="btn btn-block btn-light" style="margin-left: 10px">
<i class="fa fa-times"></i>
</a>
</div>
{{ form_end(form) }}
</div>
</div>
<div class="row mt-4">
<div class="col-md-12">
{# <form name="entries_selection" id="entriesSelection" action="{{ path('app_lexicon_process_selected_entries', {id: lexicon.id}) }}" method="post" novalidate="novalidate" autocomplete="off">#}
<table class="table table-bordered">
<thead>
<tr>
<th class="">
{{ macros.sorting_column_with_filter("Mot-vedette"|trans, 'value', _context, {id: lexicon.id}) }}
</th>
<th>
{{ macros.sorting_column_with_filter("Date de création"|trans, 'value', _context, {id: lexicon.id}) }}
</th>
<th>
{{ macros.sorting_column_with_filter("Auteur"|trans, 'value', _context, {id: lexicon.id}) }}
</th>
<th></th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
{# @var entry \App\Entity\Entry #}
<tr>
<td>{{ entry }}</td>
<td>{{ entry.createdAt|date('d/m/Y') }}</td>
<td>{{ entry.createdBy }}</td>
<td>
{# {% for pos, definition in entry.formattedDefinitions %}#}
{# <a class="text-decoration-none" data-bs-toggle="collapse" href="#def-{{ entry.id }}-{{ loop.index }}" role="button" aria-expanded="false" aria-controls="collapseExample">#}
{# <span class="badge bg-definition text-black"><i class="bi-caret-right-fill"></i> {{ pos }}</span>#}
{# </a>#}
{# <div class="collapse" id="def-{{ entry.id }}-{{ loop.index }}">#}
{# <div class="card card-body card-definition">#}
{# {{ definition }}#}
{# </div>#}
{# </div>#}
{# {% endfor %}#}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment