aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/EntriesExport.php
diff options
context:
space:
mode:
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 *