aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/EntriesExport.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-02-04 20:53:42 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-02-04 20:53:42 +0100
commit22a267aeffa9e5b7d63e6a149501f9a1448e925f (patch)
treeb1aa51f9a0f128cd3e364118b55f1335058a84f0 /src/Wallabag/CoreBundle/Helper/EntriesExport.php
parent27c837dcd1640a7f5f0ed197e882eefd53ba8273 (diff)
parenteb15061d0b98491d581f9ad0b76671bfcbdd40f1 (diff)
downloadwallabag-22a267aeffa9e5b7d63e6a149501f9a1448e925f.tar.gz
wallabag-22a267aeffa9e5b7d63e6a149501f9a1448e925f.tar.zst
wallabag-22a267aeffa9e5b7d63e6a149501f9a1448e925f.zip
Merge pull request #1633 from wallabag/exporttxt
Exporttxt
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 *