diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-07-11 09:21:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 09:21:49 +0200 |
commit | f39152ad6e62f1ea43f501e88a8839526d77ef6c (patch) | |
tree | 5bdf25175149ad32c99d956028cd81c1eed56642 /src/Wallabag/CoreBundle/Helper | |
parent | c7fcca533d90f2c285b64ce7b2f1186273719fe7 (diff) | |
parent | eeabca8090ebf9a084b6b823ddf7c6493b956d4c (diff) | |
download | wallabag-f39152ad6e62f1ea43f501e88a8839526d77ef6c.tar.gz wallabag-f39152ad6e62f1ea43f501e88a8839526d77ef6c.tar.zst wallabag-f39152ad6e62f1ea43f501e88a8839526d77ef6c.zip |
Merge pull request #3266 from egilli/export-domain-as-author
Use the article publisher as author for exported files
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/EntriesExport.php | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index cd74cc4f..64d82193 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php | |||
@@ -18,7 +18,7 @@ class EntriesExport | |||
18 | private $logoPath; | 18 | private $logoPath; |
19 | private $title = ''; | 19 | private $title = ''; |
20 | private $entries = []; | 20 | private $entries = []; |
21 | private $authors = ['wallabag']; | 21 | private $author = 'wallabag'; |
22 | private $language = ''; | 22 | private $language = ''; |
23 | private $footerTemplate = '<div style="text-align:center;"> | 23 | private $footerTemplate = '<div style="text-align:center;"> |
24 | <p>Produced by wallabag with %EXPORT_METHOD%</p> | 24 | <p>Produced by wallabag with %EXPORT_METHOD%</p> |
@@ -73,6 +73,33 @@ class EntriesExport | |||
73 | } | 73 | } |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Sets the author for one entry or category. | ||
77 | * | ||
78 | * The publishers are used, or the domain name if empty. | ||
79 | * | ||
80 | * @param string $method Method to get articles | ||
81 | * | ||
82 | * @return EntriesExport | ||
83 | */ | ||
84 | public function updateAuthor($method) | ||
85 | { | ||
86 | if ('entry' !== $method) { | ||
87 | $this->author = $method . ' authors'; | ||
88 | |||
89 | return $this; | ||
90 | } | ||
91 | |||
92 | $this->author = $this->entries[0]->getDomainName(); | ||
93 | |||
94 | $publishedBy = $this->entries[0]->getPublishedBy(); | ||
95 | if (!empty($publishedBy)) { | ||
96 | $this->author = implode(', ', $publishedBy); | ||
97 | } | ||
98 | |||
99 | return $this; | ||
100 | } | ||
101 | |||
102 | /** | ||
76 | * Sets the output format. | 103 | * Sets the output format. |
77 | * | 104 | * |
78 | * @param string $format | 105 | * @param string $format |
@@ -128,9 +155,7 @@ class EntriesExport | |||
128 | $book->setLanguage($this->language); | 155 | $book->setLanguage($this->language); |
129 | $book->setDescription('Some articles saved on my wallabag'); | 156 | $book->setDescription('Some articles saved on my wallabag'); |
130 | 157 | ||
131 | foreach ($this->authors as $author) { | 158 | $book->setAuthor($this->author, $this->author); |
132 | $book->setAuthor($author, $author); | ||
133 | } | ||
134 | 159 | ||
135 | // I hope this is a non existant address :) | 160 | // I hope this is a non existant address :) |
136 | $book->setPublisher('wallabag', 'wallabag'); | 161 | $book->setPublisher('wallabag', 'wallabag'); |
@@ -196,7 +221,7 @@ class EntriesExport | |||
196 | * Book metadata | 221 | * Book metadata |
197 | */ | 222 | */ |
198 | $content->set('title', $this->title); | 223 | $content->set('title', $this->title); |
199 | $content->set('author', implode($this->authors)); | 224 | $content->set('author', $this->author); |
200 | $content->set('subject', $this->title); | 225 | $content->set('subject', $this->title); |
201 | 226 | ||
202 | /* | 227 | /* |
@@ -247,7 +272,7 @@ class EntriesExport | |||
247 | * Book metadata | 272 | * Book metadata |
248 | */ | 273 | */ |
249 | $pdf->SetCreator(PDF_CREATOR); | 274 | $pdf->SetCreator(PDF_CREATOR); |
250 | $pdf->SetAuthor('wallabag'); | 275 | $pdf->SetAuthor($this->author); |
251 | $pdf->SetTitle($this->title); | 276 | $pdf->SetTitle($this->title); |
252 | $pdf->SetSubject('Articles via wallabag'); | 277 | $pdf->SetSubject('Articles via wallabag'); |
253 | $pdf->SetKeywords('wallabag'); | 278 | $pdf->SetKeywords('wallabag'); |