+ fputcsv(
+ $handle,
+ array(
+ $entry->getTitle(),
+ $entry->getURL(),
+ // remove new line to avoid crazy results
+ str_replace(array("\r\n", "\r", "\n"), '', $entry->getContent()),
+ implode(', ', $entry->getTags()->toArray()),
+ $entry->getMimetype(),
+ $entry->getLanguage(),
+ ),
+ $delimiter,
+ $enclosure
+ );
+ }
+
+ rewind($handle);
+ $output = stream_get_contents($handle);
+ fclose($handle);
+
+ return Response::create(
+ $output,
+ 200,
+ array(
+ 'Content-type' => 'application/csv',
+ 'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"',
+ 'Content-Transfer-Encoding' => 'UTF-8',
+ )
+ )->send();
+ }
+
+ private function produceJSON()
+ {
+ return Response::create(
+ $this->prepareSerializingContent('json'),
+ 200,
+ array(
+ 'Content-type' => 'application/json',
+ 'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"',
+ 'Content-Transfer-Encoding' => 'UTF-8',
+ )
+ )->send();
+ }
+
+ private function produceXML()
+ {
+ return Response::create(
+ $this->prepareSerializingContent('xml'),
+ 200,
+ array(
+ 'Content-type' => 'application/xml',
+ 'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"',
+ 'Content-Transfer-Encoding' => 'UTF-8',
+ )
+ )->send();
+ }
+
+ /**
+ * Return a Serializer object for producing processes that need it (JSON & XML).
+ *
+ * @return Serializer
+ */
+ private function prepareSerializingContent($format)
+ {
+ $serializer = SerializerBuilder::create()->build();
+
+ return $serializer->serialize(
+ $this->entries,
+ $format,
+ SerializationContext::create()->setGroups(array('entries_for_user'))
+ );
+ }
+
+ /**
+ * Return a kind of footer / information for the epub.
+ *
+ * @param string $type Generator of the export, can be: tdpdf, PHPePub, PHPMobi
+ *
+ * @return string
+ */
+ private function getExportInformation($type)
+ {
+ $info = str_replace('%EXPORT_METHOD%', $type, $this->footerTemplate);
+
+ if ('tcpdf' === $type) {
+ return str_replace('%IMAGE%', '<img src="'.$this->logoPath.'" />', $info);