diff options
Diffstat (limited to 'src/Wallabag')
4 files changed, 36 insertions, 52 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index f2ca58c6..be2dff98 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php | |||
@@ -84,28 +84,11 @@ class TagController extends Controller | |||
84 | */ | 84 | */ |
85 | public function showTagAction() | 85 | public function showTagAction() |
86 | { | 86 | { |
87 | $repository = $this->get('wallabag_core.entry_repository'); | ||
88 | $tags = $this->get('wallabag_core.tag_repository') | 87 | $tags = $this->get('wallabag_core.tag_repository') |
89 | ->findAllTags($this->getUser()->getId()); | 88 | ->findAllFlatTagsWithNbEntries($this->getUser()->getId()); |
90 | |||
91 | $flatTags = []; | ||
92 | |||
93 | foreach ($tags as $tag) { | ||
94 | $nbEntries = $repository->countAllEntriesByUserIdAndTagId( | ||
95 | $this->getUser()->getId(), | ||
96 | $tag->getId() | ||
97 | ); | ||
98 | |||
99 | $flatTags[] = [ | ||
100 | 'id' => $tag->getId(), | ||
101 | 'label' => $tag->getLabel(), | ||
102 | 'slug' => $tag->getSlug(), | ||
103 | 'nbEntries' => $nbEntries, | ||
104 | ]; | ||
105 | } | ||
106 | 89 | ||
107 | return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ | 90 | return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ |
108 | 'tags' => $flatTags, | 91 | 'tags' => $tags, |
109 | ]); | 92 | ]); |
110 | } | 93 | } |
111 | 94 | ||
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 7f35bb9a..d70d6ca6 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -330,26 +330,6 @@ class EntryRepository extends EntityRepository | |||
330 | } | 330 | } |
331 | 331 | ||
332 | /** | 332 | /** |
333 | * Count all entries for a tag and a user. | ||
334 | * | ||
335 | * @param int $userId | ||
336 | * @param int $tagId | ||
337 | * | ||
338 | * @return int | ||
339 | */ | ||
340 | public function countAllEntriesByUserIdAndTagId($userId, $tagId) | ||
341 | { | ||
342 | $qb = $this->createQueryBuilder('e') | ||
343 | ->select('count(e.id)') | ||
344 | ->leftJoin('e.tags', 't') | ||
345 | ->where('e.user=:userId')->setParameter('userId', $userId) | ||
346 | ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId) | ||
347 | ; | ||
348 | |||
349 | return (int) $qb->getQuery()->getSingleScalarResult(); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Remove all entries for a user id. | 333 | * Remove all entries for a user id. |
354 | * Used when a user want to reset all informations. | 334 | * Used when a user want to reset all informations. |
355 | * | 335 | * |
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 213283e5..5c45211f 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php | |||
@@ -63,6 +63,27 @@ class TagRepository extends EntityRepository | |||
63 | } | 63 | } |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Find all tags (flat) per user with nb entries. | ||
67 | * | ||
68 | * @param int $userId | ||
69 | * | ||
70 | * @return array | ||
71 | */ | ||
72 | public function findAllFlatTagsWithNbEntries($userId) | ||
73 | { | ||
74 | return $this->createQueryBuilder('t') | ||
75 | ->select('t.id, t.label, t.slug, count(e.id) as nbEntries') | ||
76 | ->distinct(true) | ||
77 | ->leftJoin('t.entries', 'e') | ||
78 | ->where('e.user = :userId') | ||
79 | ->groupBy('t.id') | ||
80 | ->orderBy('t.slug') | ||
81 | ->setParameter('userId', $userId) | ||
82 | ->getQuery() | ||
83 | ->getArrayResult(); | ||
84 | } | ||
85 | |||
86 | /** | ||
66 | * Used only in test case to get a tag for our entry. | 87 | * Used only in test case to get a tag for our entry. |
67 | * | 88 | * |
68 | * @return Tag | 89 | * @return Tag |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index ab1b3d63..c8e6cf6c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -32,7 +32,7 @@ menu: | |||
32 | save_link: 'Zapisz link' | 32 | save_link: 'Zapisz link' |
33 | back_to_unread: 'Powrót do nieprzeczytanych artykułów' | 33 | back_to_unread: 'Powrót do nieprzeczytanych artykułów' |
34 | users_management: 'Zarządzanie użytkownikami' | 34 | users_management: 'Zarządzanie użytkownikami' |
35 | # site_credentials: 'Site credentials' | 35 | site_credentials: 'Poświadczenia strony' |
36 | top: | 36 | top: |
37 | add_new_entry: 'Dodaj nowy wpis' | 37 | add_new_entry: 'Dodaj nowy wpis' |
38 | search: 'Szukaj' | 38 | search: 'Szukaj' |
@@ -94,7 +94,7 @@ config: | |||
94 | unread: 'Nieprzeczytane' | 94 | unread: 'Nieprzeczytane' |
95 | starred: 'Oznaczone gwiazdką' | 95 | starred: 'Oznaczone gwiazdką' |
96 | archive: 'Archiwum' | 96 | archive: 'Archiwum' |
97 | # all: 'All' | 97 | all: 'Wszystkie' |
98 | rss_limit: 'Link do RSS' | 98 | rss_limit: 'Link do RSS' |
99 | form_user: | 99 | form_user: |
100 | two_factor_description: "Włączenie autoryzacji dwuetapowej oznacza, że będziesz otrzymywał maile z kodem przy każdym nowym, niezaufanym połączeniu" | 100 | two_factor_description: "Włączenie autoryzacji dwuetapowej oznacza, że będziesz otrzymywał maile z kodem przy każdym nowym, niezaufanym połączeniu" |
@@ -526,20 +526,20 @@ user: | |||
526 | placeholder: Filtruj po nazwie użytkownika lub adresie e-mail | 526 | placeholder: Filtruj po nazwie użytkownika lub adresie e-mail |
527 | 527 | ||
528 | site_credential: | 528 | site_credential: |
529 | # page_title: Site credentials management | 529 | page_title: Zarządzanie poświadczeniami strony |
530 | # new_site_credential: Create a credential | 530 | new_site_credential: Stwórz nowe poświadczenie |
531 | # edit_site_credential: Edit an existing credential | 531 | edit_site_credential: Edytuj istniejące poświadczenie |
532 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | 532 | description: "Tutaj możesz zarządzać wszystkim poświadczeniami wymaganymi przez strony (stwórz, edytuj i usuń ), takie jak paywall, autentykacja, itp." |
533 | list: | 533 | list: |
534 | actions: Akcje | 534 | actions: Akcje |
535 | edit_action: Edytuj | 535 | edit_action: Edytuj |
536 | yes: Tak | 536 | yes: Tak |
537 | no: Nie | 537 | no: Nie |
538 | # create_new_one: Create a new credential | 538 | create_new_one: Stwórz nowe poświadczenie |
539 | form: | 539 | form: |
540 | # username_label: 'Username' | 540 | username_label: 'Nazwa użytkownika' |
541 | # host_label: 'Host' | 541 | host_label: 'Host' |
542 | # password_label: 'Password' | 542 | password_label: 'Hasło' |
543 | save: Zapisz | 543 | save: Zapisz |
544 | delete: Usuń | 544 | delete: Usuń |
545 | delete_confirm: Jesteś pewien? | 545 | delete_confirm: Jesteś pewien? |
@@ -599,6 +599,6 @@ flashes: | |||
599 | deleted: 'Użytkownik "%username%" usunięty' | 599 | deleted: 'Użytkownik "%username%" usunięty' |
600 | site_credential: | 600 | site_credential: |
601 | notice: | 601 | notice: |
602 | # added: 'Site credential for "%host%" added' | 602 | added: 'Poświadczenie dla "%host%" dodane' |
603 | # updated: 'Site credential for "%host%" updated' | 603 | updated: 'Poświadczenie dla "%host%" zaktualizowane' |
604 | # deleted: 'Site credential for "%host%" deleted' | 604 | deleted: 'Poświadczenie dla "%host%" usuniętę' |