diff options
Diffstat (limited to 'src/Wallabag/CoreBundle')
5 files changed, 44 insertions, 25 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index 6191d5d7..79653cfe 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php | |||
@@ -4,8 +4,10 @@ namespace Wallabag\CoreBundle\Controller; | |||
4 | 4 | ||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | ||
7 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | 8 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
8 | use Wallabag\CoreBundle\Entity\Entry; | 9 | use Wallabag\CoreBundle\Entity\Entry; |
10 | use Wallabag\CoreBundle\Entity\Tag; | ||
9 | 11 | ||
10 | /** | 12 | /** |
11 | * The try/catch can be removed once all formats will be implemented. | 13 | * The try/catch can be removed once all formats will be implemented. |
@@ -51,15 +53,24 @@ class ExportController extends Controller | |||
51 | * | 53 | * |
52 | * @return \Symfony\Component\HttpFoundation\Response | 54 | * @return \Symfony\Component\HttpFoundation\Response |
53 | */ | 55 | */ |
54 | public function downloadEntriesAction($format, $category) | 56 | public function downloadEntriesAction(Request $request, $format, $category) |
55 | { | 57 | { |
56 | $method = ucfirst($category); | 58 | $method = ucfirst($category); |
57 | $methodBuilder = 'getBuilderFor'.$method.'ByUser'; | 59 | $methodBuilder = 'getBuilderFor'.$method.'ByUser'; |
58 | $entries = $this->getDoctrine() | 60 | |
59 | ->getRepository('WallabagCoreBundle:Entry') | 61 | if ($category == 'tag_entries') { |
60 | ->$methodBuilder($this->getUser()->getId()) | 62 | $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneBySlug($request->query->get('tag')); |
61 | ->getQuery() | 63 | |
62 | ->getResult(); | 64 | $entries = $this->getDoctrine() |
65 | ->getRepository('WallabagCoreBundle:Entry') | ||
66 | ->findAllByTagId($this->getUser()->getId(), $tag->getId()); | ||
67 | } else { | ||
68 | $entries = $this->getDoctrine() | ||
69 | ->getRepository('WallabagCoreBundle:Entry') | ||
70 | ->$methodBuilder($this->getUser()->getId()) | ||
71 | ->getQuery() | ||
72 | ->getResult(); | ||
73 | } | ||
63 | 74 | ||
64 | try { | 75 | try { |
65 | return $this->get('wallabag_core.helper.entries_export') | 76 | return $this->get('wallabag_core.helper.entries_export') |
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index e50c68a6..4bf292a4 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php | |||
@@ -8,7 +8,6 @@ use JMS\Serializer\SerializerBuilder; | |||
8 | use PHPePub\Core\EPub; | 8 | use PHPePub\Core\EPub; |
9 | use PHPePub\Core\Structure\OPF\DublinCore; | 9 | use PHPePub\Core\Structure\OPF\DublinCore; |
10 | use Symfony\Component\HttpFoundation\Response; | 10 | use Symfony\Component\HttpFoundation\Response; |
11 | use Craue\ConfigBundle\Util\Config; | ||
12 | 11 | ||
13 | /** | 12 | /** |
14 | * This class doesn't have unit test BUT it's fully covered by a functional test with ExportControllerTest. | 13 | * This class doesn't have unit test BUT it's fully covered by a functional test with ExportControllerTest. |
@@ -27,12 +26,12 @@ class EntriesExport | |||
27 | </div>'; | 26 | </div>'; |
28 | 27 | ||
29 | /** | 28 | /** |
30 | * @param Config $craueConfig CraueConfig instance to get wallabag instance url from database | 29 | * @param string $wallabagUrl Wallabag instance url |
31 | * @param string $logoPath Path to the logo FROM THE BUNDLE SCOPE | 30 | * @param string $logoPath Path to the logo FROM THE BUNDLE SCOPE |
32 | */ | 31 | */ |
33 | public function __construct(Config $craueConfig, $logoPath) | 32 | public function __construct($wallabagUrl, $logoPath) |
34 | { | 33 | { |
35 | $this->wallabagUrl = $craueConfig->get('wallabag_url'); | 34 | $this->wallabagUrl = $wallabagUrl; |
36 | $this->logoPath = $logoPath; | 35 | $this->logoPath = $logoPath; |
37 | } | 36 | } |
38 | 37 | ||
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 614488a6..90a2419e 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml | |||
@@ -55,6 +55,7 @@ services: | |||
55 | '.fok.nl': 'Googlebot/2.1' | 55 | '.fok.nl': 'Googlebot/2.1' |
56 | 'getpocket.com': 'PHP/5.2' | 56 | 'getpocket.com': 'PHP/5.2' |
57 | 'iansommerville.com': 'PHP/5.2' | 57 | 'iansommerville.com': 'PHP/5.2' |
58 | '.slashdot.org': 'PHP/5.2' | ||
58 | calls: | 59 | calls: |
59 | - [ setLogger, [ "@logger" ] ] | 60 | - [ setLogger, [ "@logger" ] ] |
60 | tags: | 61 | tags: |
@@ -91,7 +92,7 @@ services: | |||
91 | wallabag_core.helper.entries_export: | 92 | wallabag_core.helper.entries_export: |
92 | class: Wallabag\CoreBundle\Helper\EntriesExport | 93 | class: Wallabag\CoreBundle\Helper\EntriesExport |
93 | arguments: | 94 | arguments: |
94 | - "@craue_config" | 95 | - '@=service(''craue_config'').get(''wallabag_url'')' |
95 | - src/Wallabag/CoreBundle/Resources/public/themes/_global/img/appicon/apple-touch-icon-152.png | 96 | - src/Wallabag/CoreBundle/Resources/public/themes/_global/img/appicon/apple-touch-icon-152.png |
96 | 97 | ||
97 | wallabag.operator.array.matches: | 98 | wallabag.operator.array.matches: |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig index f19f2922..5d657c7e 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig | |||
@@ -53,19 +53,23 @@ | |||
53 | <!-- Export --> | 53 | <!-- Export --> |
54 | <aside id="download-form"> | 54 | <aside id="download-form"> |
55 | {% set currentRoute = app.request.attributes.get('_route') %} | 55 | {% set currentRoute = app.request.attributes.get('_route') %} |
56 | {% set currentTag = '' %} | ||
57 | {% if tag is defined %} | ||
58 | {% set currentTag = tag %} | ||
59 | {% endif %} | ||
56 | {% if currentRoute == 'homepage' %} | 60 | {% if currentRoute == 'homepage' %} |
57 | {% set currentRoute = 'unread' %} | 61 | {% set currentRoute = 'unread' %} |
58 | {% endif %} | 62 | {% endif %} |
59 | <h2>{{ 'entry.list.export_title'|trans }}</h2> | 63 | <h2>{{ 'entry.list.export_title'|trans }}</h2> |
60 | <a href="javascript: void(null);" id="download-form-close" class="close-button--popup close-button">×</a> | 64 | <a href="javascript: void(null);" id="download-form-close" class="close-button--popup close-button">×</a> |
61 | <ul> | 65 | <ul> |
62 | {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub' }) }}">EPUB</a></li>{% endif %} | 66 | {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub', 'tag' : currentTag }) }}">EPUB</a></li>{% endif %} |
63 | {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi' }) }}">MOBI</a></li>{% endif %} | 67 | {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi', 'tag' : currentTag }) }}">MOBI</a></li>{% endif %} |
64 | {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf' }) }}">PDF</a></li>{% endif %} | 68 | {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf', 'tag' : currentTag }) }}">PDF</a></li>{% endif %} |
65 | {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json' }) }}">JSON</a></li>{% endif %} | 69 | {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json', 'tag' : currentTag }) }}">JSON</a></li>{% endif %} |
66 | {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv' }) }}">CSV</a></li>{% endif %} | 70 | {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv', 'tag' : currentTag }) }}">CSV</a></li>{% endif %} |
67 | {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt' }) }}">TXT</a></li>{% endif %} | 71 | {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt', 'tag' : currentTag }) }}">TXT</a></li>{% endif %} |
68 | {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml' }) }}">XML</a></li>{% endif %} | 72 | {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml', 'tag' : currentTag }) }}">XML</a></li>{% endif %} |
69 | </ul> | 73 | </ul> |
70 | </aside> | 74 | </aside> |
71 | 75 | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index 5c7cfd65..1225e680 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig | |||
@@ -99,18 +99,22 @@ | |||
99 | <!-- Export --> | 99 | <!-- Export --> |
100 | <div id="export" class="side-nav fixed right-aligned"> | 100 | <div id="export" class="side-nav fixed right-aligned"> |
101 | {% set currentRoute = app.request.attributes.get('_route') %} | 101 | {% set currentRoute = app.request.attributes.get('_route') %} |
102 | {% set currentTag = '' %} | ||
103 | {% if tag is defined %} | ||
104 | {% set currentTag = tag %} | ||
105 | {% endif %} | ||
102 | {% if currentRoute == 'homepage' %} | 106 | {% if currentRoute == 'homepage' %} |
103 | {% set currentRoute = 'unread' %} | 107 | {% set currentRoute = 'unread' %} |
104 | {% endif %} | 108 | {% endif %} |
105 | <h4 class="center">{{ 'entry.list.export_title'|trans }}</h4> | 109 | <h4 class="center">{{ 'entry.list.export_title'|trans }}</h4> |
106 | <ul> | 110 | <ul> |
107 | {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub' }) }}">EPUB</a></li>{% endif %} | 111 | {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub', 'tag' : currentTag }) }}">EPUB</a></li>{% endif %} |
108 | {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi' }) }}">MOBI</a></li>{% endif %} | 112 | {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi', 'tag' : currentTag }) }}">MOBI</a></li>{% endif %} |
109 | {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf' }) }}">PDF</a></li>{% endif %} | 113 | {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf', 'tag' : currentTag }) }}">PDF</a></li>{% endif %} |
110 | {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json' }) }}">JSON</a></li>{% endif %} | 114 | {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json', 'tag' : currentTag }) }}">JSON</a></li>{% endif %} |
111 | {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv' }) }}">CSV</a></li>{% endif %} | 115 | {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv', 'tag' : currentTag }) }}">CSV</a></li>{% endif %} |
112 | {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt' }) }}">TXT</a></li>{% endif %} | 116 | {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt', 'tag' : currentTag }) }}">TXT</a></li>{% endif %} |
113 | {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml' }) }}">XML</a></li>{% endif %} | 117 | {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml', 'tag' : currentTag }) }}">XML</a></li>{% endif %} |
114 | </ul> | 118 | </ul> |
115 | </div> | 119 | </div> |
116 | 120 | ||