From: Nicolas LÅ“uillet Date: Fri, 7 Aug 2015 16:17:23 +0000 (+0200) Subject: Add tags list display X-Git-Tag: 2.0.0-alpha.0~52^2~2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=3f3fbef11f86968a991426c2a052ad42e0c16d44;p=github%2Fwallabag%2Fwallabag.git Add tags list display --- 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 %}