X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FEntriesExport.php;h=9cde27c68bc041fa5a6c463456943f67c982ee13;hb=4944703edc7cdd2c8cd645b785603b4405d2a288;hp=6082f6b9c47f444a6c5abad61dd167032d8f815b;hpb=5de17117a1a8c974458be2c128dc8f9d6912fb8c;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 6082f6b9..9cde27c6 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -85,7 +85,7 @@ class EntriesExport public function updateAuthor($method) { if ('entry' !== $method) { - $this->author = $method . ' authors'; + $this->author = 'Various authors'; return $this; } @@ -173,6 +173,8 @@ class EntriesExport } $entryIds = []; + $entryCount = \count($this->entries); + $i = 0; /* * Adding actual entries @@ -180,28 +182,41 @@ class EntriesExport // set tags as subjects foreach ($this->entries as $entry) { + ++$i; foreach ($entry->getTags() as $tag) { $book->setSubject($tag->getLabel()); } + $filename = sha1($entry->getTitle()); - // the reader in Kobo Devices doesn't likes special caracters - // in filenames, we limit to A-z/0-9 - $filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle()); + $publishedBy = $entry->getPublishedBy(); + if (!empty($publishedBy)) { + $authors = implode(',', $publishedBy); + } else { + $authors = $this->translator->trans('export.unknown'); + } - $titlepage = $content_start . '

' . $entry->getTitle() . '

' . $this->getExportInformation('PHPePub') . $bookEnd; - $book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD); + $titlepage = $content_start . + '

' . $entry->getTitle() . '

' . + '
' . + '
' . $this->translator->trans('entry.view.published_by') . '
' . $authors . '
' . + '
' . $this->translator->trans('entry.metadata.reading_time') . '
' . $this->translator->trans('entry.metadata.reading_time_minutes_short', ['%readingTime%' => $entry->getReadingTime()]) . '
' . + '
' . $this->translator->trans('entry.metadata.added_on') . '
' . $entry->getCreatedAt()->format('Y-m-d') . '
' . + '
' . $this->translator->trans('entry.metadata.address') . '
' . $entry->getUrl() . '
' . + '
' . + $bookEnd; + $book->addChapter("Entry {$i} of {$entryCount}", "{$filename}_cover.html", $titlepage, true, EPub::EXTERNAL_REF_ADD); $chapter = $content_start . $entry->getContent() . $bookEnd; - $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD); $entryIds[] = $entry->getId(); + $book->addChapter($entry->getTitle(), "{$filename}.html", $chapter, true, EPub::EXTERNAL_REF_ADD); } + $book->addChapter('Notices', 'Cover2.html', $content_start . $this->getExportInformation('PHPePub') . $bookEnd); + // Could also be the ISBN number, prefered for published books, or a UUID. $hash = sha1(sprintf('%s:%s', $this->wallabagUrl, implode(',', $entryIds))); $book->setIdentifier(sprintf('urn:wallabag:%s', $hash), EPub::IDENTIFIER_URI); - $book->buildTOC(); - return Response::create( $book->getBook(), 200,