From 3f3fbef11f86968a991426c2a052ad42e0c16d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 7 Aug 2015 18:17:23 +0200 Subject: Add tags list display --- .../CoreBundle/Controller/TagController.php | 33 ++++++++++++++++++++++ .../CoreBundle/Repository/TagRepository.php | 18 ++++++++++++ .../CoreBundle/Resources/views/Tag/tags.html.twig | 27 ++++++++++++++++++ .../CoreBundle/Resources/views/base.html.twig | 2 +- .../Resources/views/themes/material/base.html.twig | 2 +- 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 src/Wallabag/CoreBundle/Controller/TagController.php create mode 100644 src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php new file mode 100644 index 00000000..89284231 --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -0,0 +1,33 @@ +getDoctrine() + ->getRepository('WallabagCoreBundle:Tag') + ->findTags($this->getUser()->getId()); + + return $this->render( + 'WallabagCoreBundle:Tag:tags.html.twig', + array( + 'tags' => $tags + ) + ); + } + +} diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 52f319f1..51f1cd42 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -3,7 +3,25 @@ namespace Wallabag\CoreBundle\Repository; use Doctrine\ORM\EntityRepository; +use Pagerfanta\Adapter\DoctrineORMAdapter; +use Pagerfanta\Pagerfanta; class TagRepository extends EntityRepository { + /** + * Find Tags. + * + * @param int $userId + * + * @return array + */ + public function findTags($userId) + { + $qb = $this->createQueryBuilder('t') + ->where('t.user =:userId')->setParameter('userId', $userId); + + $pagerAdapter = new DoctrineORMAdapter($qb); + + return new Pagerfanta($pagerAdapter); + } } diff --git a/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig new file mode 100644 index 00000000..7c2a9f45 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig @@ -0,0 +1,27 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title "Tags" %} + +{% block content %} + {% block pager %} + {% if tags is not empty %} +
+
{{ tags.count }} {% trans %}tags{% endtrans %}
+ +
+ {% endif %} + {% endblock %} + + {% if tags is empty %} +

{% trans %}No tags found.{% endtrans %}

+ {% else %} + {% for tag in tags %}{{tag.title}} + {% endfor %} + {% endif %} +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index 4f27f413..223e8433 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -71,7 +71,7 @@
  • {% trans %}unread{% endtrans %}
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • -
  • {% trans %}tags{% endtrans %}
  • +
  • {% trans %}tags{% endtrans %}
  • {% trans %}save a link{% endtrans %}
  • {% trans %}search{% endtrans %}
  • {% trans %}unread{% endtrans %}
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • -
  • {% trans %}tags{% endtrans %}
  • +
  • {% trans %}tags{% endtrans %}
  • {% trans %}config{% endtrans %}
  • {% trans %}logout{% endtrans %}
  • -- cgit v1.2.3