use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use PHPePub\Core\EPub;
-use Html2Text\Html2Text;
use PHPePub\Core\Structure\OPF\DublinCore;
use Symfony\Component\HttpFoundation\Response;
use Craue\ConfigBundle\Util\Config;
case 'xml':
return $this->produceXML();
+
case 'txt':
return $this->produceTXT();
}
'Content-Disposition' => 'attachment; filename="'.$this->title.'.epub"',
'Content-Transfer-Encoding' => 'binary',
)
- )->send();
+ );
}
/**
'Content-Disposition' => 'attachment; filename="'.$this->title.'.mobi"',
'Content-Transfer-Encoding' => 'binary',
)
- )->send();
+ );
}
/**
'Content-Disposition' => 'attachment; filename="'.$this->title.'.pdf"',
'Content-Transfer-Encoding' => 'binary',
)
- )->send();
+ );
}
/**
'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"',
'Content-Transfer-Encoding' => 'UTF-8',
)
- )->send();
+ );
}
private function produceJSON()
'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"',
'Content-Transfer-Encoding' => 'UTF-8',
)
- )->send();
+ );
}
private function produceXML()
'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"',
'Content-Transfer-Encoding' => 'UTF-8',
)
- )->send();
+ );
}
private function produceTXT()
{
$content = '';
+ $bar = str_repeat('=', 100);
foreach ($this->entries as $entry) {
- $content .= $entry->getTitle();
- $content .= strip_tags($entry->getContent());
+ $content .= "\n\n".$bar."\n\n".$entry->getTitle()."\n\n".$bar."\n\n";
+ $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent())))."\n\n";
}
+
return Response::create(
$content,
200,
'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).
*