aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/EntriesExport.php
diff options
context:
space:
mode:
authorThomas Citharel <citharel@info21-27.iut45.univ-orleans.fr>2016-01-25 17:31:45 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-02-04 20:30:51 +0100
commit6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b (patch)
treece5149ae9b19dce99b499cae3fcfaf200c41226a /src/Wallabag/CoreBundle/Helper/EntriesExport.php
parent27c837dcd1640a7f5f0ed197e882eefd53ba8273 (diff)
downloadwallabag-6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b.tar.gz
wallabag-6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b.tar.zst
wallabag-6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b.zip
add txt export
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/EntriesExport.php')
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 965a40b6..79fe6eaa 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -6,6 +6,7 @@ use JMS\Serializer;
6use JMS\Serializer\SerializationContext; 6use JMS\Serializer\SerializationContext;
7use JMS\Serializer\SerializerBuilder; 7use JMS\Serializer\SerializerBuilder;
8use PHPePub\Core\EPub; 8use PHPePub\Core\EPub;
9use Html2Text\Html2Text;
9use PHPePub\Core\Structure\OPF\DublinCore; 10use PHPePub\Core\Structure\OPF\DublinCore;
10use Symfony\Component\HttpFoundation\Response; 11use Symfony\Component\HttpFoundation\Response;
11use Craue\ConfigBundle\Util\Config; 12use Craue\ConfigBundle\Util\Config;
@@ -99,6 +100,8 @@ class EntriesExport
99 100
100 case 'xml': 101 case 'xml':
101 return $this->produceXML(); 102 return $this->produceXML();
103 case 'txt':
104 return $this->produceTXT();
102 } 105 }
103 106
104 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format)); 107 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format));
@@ -359,6 +362,25 @@ class EntriesExport
359 )->send(); 362 )->send();
360 } 363 }
361 364
365 private function produceTXT()
366 {
367 $content = '';
368 foreach ($this->entries as $entry) {
369 $content .= $entry->getTitle();
370 $content .= strip_tags($entry->getContent());
371 }
372 return Response::create(
373 $content,
374 200,
375 array(
376 'Content-type' => 'text/plain',
377 'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
378 'Content-Transfer-Encoding' => 'UTF-8',
379 )
380 )->send();
381 }
382
383
362 /** 384 /**
363 * Return a Serializer object for producing processes that need it (JSON & XML). 385 * Return a Serializer object for producing processes that need it (JSON & XML).
364 * 386 *