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 From c57f69d967dea05e507e997193a783fed991de8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Gilli?= Date: Sun, 9 Jul 2017 18:33:14 +0200 Subject: Use the article publisher as author for export When exporting an entry, use the publishedBy field as author name for epub, mobi and pdf formats. Fallback to domain name if empty. --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Helper') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index d749dcf9..e16168b1 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -73,7 +73,9 @@ class EntriesExport } /** - * Sets the author for just one entry. + * Sets the author for one entry or category. + * + * The publishers are used, or the domain name if empty. * * @param string $method Method to get articles * @@ -84,7 +86,12 @@ class EntriesExport $this->author = $method.' authors'; if ('entry' === $method) { - $this->author = $this->entries[0]->getDomainName(); + $publishedBy = $this->entries[0]->getPublishedBy(); + if (!empty($publishedBy)) { + $this->author = implode(', ', $this->entries[0]->getPublishedBy()); + } else { + $this->author = $this->entries[0]->getDomainName(); + } } return $this; -- cgit v1.2.3 From eeabca8090ebf9a084b6b823ddf7c6493b956d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Gilli?= Date: Mon, 10 Jul 2017 09:58:18 +0200 Subject: Make updateAuthor code simpler to read --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Wallabag/CoreBundle/Helper') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index e16168b1..64d82193 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -83,15 +83,17 @@ class EntriesExport */ 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; -- cgit v1.2.3