aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig15
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php40
13 files changed, 64 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 7ad5c100..f8526cfe 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -45,6 +45,7 @@ footer:
45 # social: 'Social' 45 # social: 'Social'
46 # powered_by: 'powered by' 46 # powered_by: 'powered by'
47 about: 'Om' 47 about: 'Om'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Opsætning' 51 page_title: 'Opsætning'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index 650e4761..b0abe0cd 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'Soziales' 45 social: 'Soziales'
46 powered_by: 'angetrieben von' 46 powered_by: 'angetrieben von'
47 about: 'Über' 47 about: 'Über'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Einstellungen' 51 page_title: 'Einstellungen'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index d5842cc5..02fbd507 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'Social' 45 social: 'Social'
46 powered_by: 'powered by' 46 powered_by: 'powered by'
47 about: 'About' 47 about: 'About'
48 stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Config' 51 page_title: 'Config'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index bd691c1c..b7f6ab24 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'Social' 45 social: 'Social'
46 powered_by: 'funciona por' 46 powered_by: 'funciona por'
47 about: 'Acerca de' 47 about: 'Acerca de'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Configuración' 51 page_title: 'Configuración'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index a9989a83..e195a8c5 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'شبکه‌های اجتماعی' 45 social: 'شبکه‌های اجتماعی'
46 powered_by: 'توانمند با' 46 powered_by: 'توانمند با'
47 about: 'درباره' 47 about: 'درباره'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'پیکربندی' 51 page_title: 'پیکربندی'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index b70ca64d..9fe1855d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'Social' 45 social: 'Social'
46 powered_by: 'propulsé par' 46 powered_by: 'propulsé par'
47 about: 'À propos' 47 about: 'À propos'
48 stats: Depuis le %user_creation% vous avez lu %nb_archives% articles. Ce qui fait %per_day% par jour !
48 49
49config: 50config:
50 page_title: 'Configuration' 51 page_title: 'Configuration'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index 118098fe..34254813 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'Social' 45 social: 'Social'
46 powered_by: 'powered by' 46 powered_by: 'powered by'
47 about: 'About' 47 about: 'About'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Configurazione' 51 page_title: 'Configurazione'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index 93467dac..f6cea17f 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -45,9 +45,10 @@ footer:
45 social: 'Social' 45 social: 'Social'
46 powered_by: 'propulsat per' 46 powered_by: 'propulsat per'
47 about: 'A prepaus' 47 about: 'A prepaus'
48 page_title: 'Configuracion' 48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
49 49
50config: 50config:
51 page_title: 'Configuracion'
51 tab_menu: 52 tab_menu:
52 settings: 'Paramètres' 53 settings: 'Paramètres'
53 rss: 'RSS' 54 rss: 'RSS'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index 27507a81..5fd12b10 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'Społeczność' 45 social: 'Społeczność'
46 powered_by: 'Kontrolowany przez' 46 powered_by: 'Kontrolowany przez'
47 about: 'O nas' 47 about: 'O nas'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Konfiguracja' 51 page_title: 'Konfiguracja'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index 7c77ffb7..9002b724 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -45,6 +45,7 @@ footer:
45 # social: 'Social' 45 # social: 'Social'
46 # powered_by: 'powered by' 46 # powered_by: 'powered by'
47 about: 'Despre' 47 about: 'Despre'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Configurație' 51 page_title: 'Configurație'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index 8bc0c4b9..1121a2ef 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -45,6 +45,7 @@ footer:
45 social: 'Sosyal' 45 social: 'Sosyal'
46 powered_by: 'powered by' 46 powered_by: 'powered by'
47 about: 'Hakkımızda' 47 about: 'Hakkımızda'
48 # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
48 49
49config: 50config:
50 page_title: 'Yapılandırma' 51 page_title: 'Yapılandırma'
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
index df05e2a4..b2d77c2e 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -122,8 +122,19 @@
122 <footer class="page-footer cyan darken-2"> 122 <footer class="page-footer cyan darken-2">
123 <div class="footer-copyright"> 123 <div class="footer-copyright">
124 <div class="container"> 124 <div class="container">
125 <p>{{ 'footer.wallabag.powered_by'|trans }} <a target="_blank" href="https://wallabag.org" class="grey-text text-lighten-4">wallabag</a></p> 125 <div class="row">
126 <a class="grey-text text-lighten-4 right" href="{{ path('about') }}">{{ 'footer.wallabag.about'|trans }}</a> 126 <div class="col s8">
127 <p>
128 {{ display_stats() }}
129 </p>
130 </div>
131 <div class="col s4">
132 <p>
133 {{ 'footer.wallabag.powered_by'|trans }} <a target="_blank" href="https://wallabag.org" class="grey-text text-lighten-4">wallabag</a> –
134 <a class="grey-text text-lighten-4" href="{{ path('about') }}">{{ 'footer.wallabag.about'|trans|lower }}</a>
135 </p>
136 </div>
137 </div>
127 </div> 138 </div>
128 </div> 139 </div>
129 </footer> 140 </footer>
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index fb4c7412..783cde3e 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Twig;
5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
6use Wallabag\CoreBundle\Repository\EntryRepository; 6use Wallabag\CoreBundle\Repository\EntryRepository;
7use Wallabag\CoreBundle\Repository\TagRepository; 7use Wallabag\CoreBundle\Repository\TagRepository;
8use Symfony\Component\Translation\TranslatorInterface;
8 9
9class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface 10class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
10{ 11{
@@ -12,13 +13,15 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
12 private $entryRepository; 13 private $entryRepository;
13 private $tagRepository; 14 private $tagRepository;
14 private $lifeTime; 15 private $lifeTime;
16 private $translator;
15 17
16 public function __construct(EntryRepository $entryRepository = null, TagRepository $tagRepository = null, TokenStorageInterface $tokenStorage = null, $lifeTime = 0) 18 public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator)
17 { 19 {
18 $this->entryRepository = $entryRepository; 20 $this->entryRepository = $entryRepository;
19 $this->tagRepository = $tagRepository; 21 $this->tagRepository = $tagRepository;
20 $this->tokenStorage = $tokenStorage; 22 $this->tokenStorage = $tokenStorage;
21 $this->lifeTime = $lifeTime; 23 $this->lifeTime = $lifeTime;
24 $this->translator = $translator;
22 } 25 }
23 26
24 public function getFilters() 27 public function getFilters()
@@ -33,6 +36,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
33 return array( 36 return array(
34 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']), 37 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']),
35 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']), 38 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']),
39 new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']),
36 ); 40 );
37 } 41 }
38 42
@@ -107,6 +111,40 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
107 return $this->tagRepository->countAllTags($user->getId()); 111 return $this->tagRepository->countAllTags($user->getId());
108 } 112 }
109 113
114 /**
115 * Display a single line about reading stats.
116 *
117 * @return string
118 */
119 public function displayStats()
120 {
121 $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
122
123 if (null === $user || !is_object($user)) {
124 return 0;
125 }
126
127 $query = $this->entryRepository->getBuilderForArchiveByUser($user->getId())
128 ->select('e.id')
129 ->groupBy('e.id')
130 ->getQuery();
131
132 $query->useQueryCache(true);
133 $query->useResultCache(true);
134 $query->setResultCacheLifetime($this->lifeTime);
135
136 $nbArchives = count($query->getArrayResult());
137
138 $interval = $user->getCreatedAt()->diff(new \DateTime('now'));
139 $nbDays = (int) $interval->format('%a') ?: 1;
140
141 return $this->translator->trans('footer.stats', [
142 '%user_creation%' => $user->getCreatedAt()->format('F jS, Y'),
143 '%nb_archives%' => $nbArchives,
144 '%per_day%' => round($nbArchives / $nbDays, 2),
145 ]);
146 }
147
110 public function getName() 148 public function getName()
111 { 149 {
112 return 'wallabag_extension'; 150 return 'wallabag_extension';