X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FEntriesExport.php;h=d3b7ee3e7265dcf3d2ac59ba6658ffe7b93c72b4;hb=3b07d019379106d6786121b3208d0e396e1ae40a;hp=965a40b6a1ec190bb06c4f0bb0956fcd0f709ada;hpb=27c837dcd1640a7f5f0ed197e882eefd53ba8273;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 965a40b6..d3b7ee3e 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -99,6 +99,8 @@ class EntriesExport case 'xml': return $this->produceXML(); + case 'txt': + return $this->produceTXT(); } throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format)); @@ -359,6 +361,25 @@ class EntriesExport )->send(); } + private function produceTXT() + { + $content = ''; + foreach ($this->entries as $entry) { + $content .= "\n\n" . str_repeat("=",100) . "\n\n" . $entry->getTitle() . "\n\n" . str_repeat("=",100) . "\n\n"; + $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n"; + } + return Response::create( + $content, + 200, + array( + 'Content-type' => 'text/plain', + 'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"', + 'Content-Transfer-Encoding' => 'UTF-8', + ) + )->send(); + } + + /** * Return a Serializer object for producing processes that need it (JSON & XML). *