namespace Wallabag\CoreBundle\Helper;
-use JMS\Serializer;
+use Html2Text\Html2Text;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use PHPePub\Core\EPub;
use PHPePub\Core\Structure\OPF\DublinCore;
use Symfony\Component\HttpFoundation\Response;
+use Wallabag\CoreBundle\Entity\Entry;
/**
* This class doesn't have unit test BUT it's fully covered by a functional test with ExportControllerTest.
*/
public function updateAuthor($method)
{
- $this->author = $method.' authors';
+ if ('entry' !== $method) {
+ $this->author = $method . ' authors';
- if ('entry' === $method) {
- $publishedBy = $this->entries[0]->getPublishedBy();
- if (!empty($publishedBy)) {
- $this->author = implode(', ', $this->entries[0]->getPublishedBy());
- } else {
- $this->author = $this->entries[0]->getDomainName();
- }
+ return $this;
+ }
+
+ $this->author = $this->entries[0]->getDomainName();
+
+ $publishedBy = $this->entries[0]->getPublishedBy();
+ if (!empty($publishedBy)) {
+ $this->author = implode(', ', $publishedBy);
}
return $this;
$bar = str_repeat('=', 100);
foreach ($this->entries as $entry) {
$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";
+ $html = new Html2Text($entry->getContent(), ['do_links' => 'none', 'width' => 100]);
+ $content .= $html->getText();
}
return Response::create(
*
* @param string $format
*
- * @return Serializer
+ * @return string
*/
private function prepareSerializingContent($format)
{