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..c9aac6e5 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -99,6 +99,8 @@ class EntriesExport
99 99
100 case 'xml': 100 case 'xml':
101 return $this->produceXML(); 101 return $this->produceXML();
102 case 'txt':
103 return $this->produceTXT();
102 } 104 }
103 105
104 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format)); 106 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format));
@@ -359,6 +361,26 @@ class EntriesExport
359 )->send(); 361 )->send();
360 } 362 }
361 363
364 private function produceTXT()
365 {
366 $content = '';
367 $bar = str_repeat('=', 100);
368 foreach ($this->entries as $entry) {
369 $content .= "\n\n".$bar."\n\n".$entry->getTitle()."\n\n".$bar."\n\n";
370 $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent())))."\n\n";
371 }
372
373 return Response::create(
374 $content,
375 200,
376 array(
377 'Content-type' => 'text/plain',
378 'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
379 'Content-Transfer-Encoding' => 'UTF-8',
380 )
381 )->send();
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 *