X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FEntriesExport.php;h=4bf292a4f815c0a32b4f26be31ea9cd76d9ce135;hb=5a619812ca3eb05a82a023ccdaee13501eb8d45f;hp=0cf835b48be00ee1a35566f461fd570f47e2e37e;hpb=4094ea47712efbe58624ff74daeb1f77c9b0edcf;p=github%2Fwallabag%2Fwallabag.git
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 0cf835b4..4bf292a4 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -8,7 +8,6 @@ use JMS\Serializer\SerializerBuilder;
use PHPePub\Core\EPub;
use PHPePub\Core\Structure\OPF\DublinCore;
use Symfony\Component\HttpFoundation\Response;
-use Craue\ConfigBundle\Util\Config;
/**
* This class doesn't have unit test BUT it's fully covered by a functional test with ExportControllerTest.
@@ -21,19 +20,18 @@ class EntriesExport
private $entries = [];
private $authors = ['wallabag'];
private $language = '';
- private $tags = [];
private $footerTemplate = '
Produced by wallabag with %EXPORT_METHOD%
Please open an issue if you have trouble with the display of this E-Book on your device.
-
';
/**
- * @param Config $craueConfig CraueConfig instance to get wallabag instance url from database
+ * @param string $wallabagUrl Wallabag instance url
* @param string $logoPath Path to the logo FROM THE BUNDLE SCOPE
*/
- public function __construct(Config $craueConfig, $logoPath)
+ public function __construct($wallabagUrl, $logoPath)
{
- $this->wallabagUrl = $craueConfig->get('wallabag_url');
+ $this->wallabagUrl = $wallabagUrl;
$this->logoPath = $logoPath;
}
@@ -53,10 +51,6 @@ class EntriesExport
$this->entries = $entries;
- foreach ($entries as $entry) {
- $this->tags[] = $entry->getTags();
- }
-
return $this;
}
@@ -159,12 +153,16 @@ class EntriesExport
// set tags as subjects
foreach ($this->entries as $entry) {
- foreach ($this->tags as $tag) {
- $book->setSubject($tag['value']);
+ 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());
+
$chapter = $content_start.$entry->getContent().$bookEnd;
- $book->addChapter($entry->getTitle(), htmlspecialchars($entry->getTitle()).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
+ $book->addChapter($entry->getTitle(), htmlspecialchars($filename).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
}
return Response::create(
@@ -261,8 +259,8 @@ class EntriesExport
* Adding actual entries
*/
foreach ($this->entries as $entry) {
- foreach ($this->tags as $tag) {
- $pdf->SetKeywords($tag['value']);
+ foreach ($entry->getTags() as $tag) {
+ $pdf->SetKeywords($tag->getLabel());
}
$pdf->AddPage();
@@ -298,7 +296,7 @@ class EntriesExport
$enclosure = '"';
$handle = fopen('php://memory', 'rb+');
- fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language'], $delimiter, $enclosure);
+ fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language', 'Creation date'], $delimiter, $enclosure);
foreach ($this->entries as $entry) {
fputcsv(
@@ -311,6 +309,7 @@ class EntriesExport
implode(', ', $entry->getTags()->toArray()),
$entry->getMimetype(),
$entry->getLanguage(),
+ $entry->getCreatedAt()->format('d/m/Y h:i:s'),
],
$delimiter,
$enclosure