X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FEntriesExport.php;h=ea5a03cf365d7f84e6cbe30b26159d87eb2b94e3;hb=edd1825b5832303b714bec37b8796b9077e7ddc0;hp=6082f6b9c47f444a6c5abad61dd167032d8f815b;hpb=bf22266a6230be105ec9a91eccf00e489108405c;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 6082f6b9..ea5a03cf 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -173,6 +173,8 @@ class EntriesExport } $entryIds = []; + $entryCount = \count($this->entries); + $i = 0; /* * Adding actual entries @@ -180,28 +182,24 @@ class EntriesExport // set tags as subjects foreach ($this->entries as $entry) { + ++$i; foreach ($entry->getTags() as $tag) { $book->setSubject($tag->getLabel()); } - - // 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()); + $filename = sha1($entry->getTitle()); $titlepage = $content_start . '

' . $entry->getTitle() . '

' . $this->getExportInformation('PHPePub') . $bookEnd; - $book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD); + $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); } // 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,