From 07320a2bd25c6ace1f9b1aa06b1b08e8dbf4f4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Gilli?= Date: Sat, 8 Jul 2017 17:55:58 +0200 Subject: Use the article domain as author for export files When exporting an entry, use the domain name as author name for epub, mobi and pdf formats, instead of 'wallabag'. Change the author from array to string, because for now, there is always only one author. --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/Wallabag/CoreBundle/Helper') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index cd74cc4f..d749dcf9 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -18,7 +18,7 @@ class EntriesExport private $logoPath; private $title = ''; private $entries = []; - private $authors = ['wallabag']; + private $author = 'wallabag'; private $language = ''; private $footerTemplate = '

Produced by wallabag with %EXPORT_METHOD%

@@ -72,6 +72,24 @@ class EntriesExport return $this; } + /** + * Sets the author for just one entry. + * + * @param string $method Method to get articles + * + * @return EntriesExport + */ + public function updateAuthor($method) + { + $this->author = $method.' authors'; + + if ('entry' === $method) { + $this->author = $this->entries[0]->getDomainName(); + } + + return $this; + } + /** * Sets the output format. * @@ -128,9 +146,7 @@ class EntriesExport $book->setLanguage($this->language); $book->setDescription('Some articles saved on my wallabag'); - foreach ($this->authors as $author) { - $book->setAuthor($author, $author); - } + $book->setAuthor($this->author, $this->author); // I hope this is a non existant address :) $book->setPublisher('wallabag', 'wallabag'); @@ -196,7 +212,7 @@ class EntriesExport * Book metadata */ $content->set('title', $this->title); - $content->set('author', implode($this->authors)); + $content->set('author', $this->author); $content->set('subject', $this->title); /* @@ -247,7 +263,7 @@ class EntriesExport * Book metadata */ $pdf->SetCreator(PDF_CREATOR); - $pdf->SetAuthor('wallabag'); + $pdf->SetAuthor($this->author); $pdf->SetTitle($this->title); $pdf->SetSubject('Articles via wallabag'); $pdf->SetKeywords('wallabag'); -- cgit v1.2.3