aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/WallabagV1Import.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 0dac6203..c54e73b2 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -8,20 +8,23 @@ use Doctrine\ORM\EntityManager;
8use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\UserBundle\Entity\User; 9use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Tools\Utils; 10use Wallabag\CoreBundle\Tools\Utils;
11use Wallabag\CoreBundle\Helper\ContentProxy;
11 12
12class WallabagV1Import implements ImportInterface 13class WallabagV1Import implements ImportInterface
13{ 14{
14 protected $user; 15 protected $user;
15 protected $em; 16 protected $em;
16 protected $logger; 17 protected $logger;
18 protected $contentProxy;
17 protected $skippedEntries = 0; 19 protected $skippedEntries = 0;
18 protected $importedEntries = 0; 20 protected $importedEntries = 0;
19 protected $filepath; 21 protected $filepath;
20 22
21 public function __construct(EntityManager $em) 23 public function __construct(EntityManager $em, ContentProxy $contentProxy)
22 { 24 {
23 $this->em = $em; 25 $this->em = $em;
24 $this->logger = new NullLogger(); 26 $this->logger = new NullLogger();
27 $this->contentProxy = $contentProxy;
25 } 28 }
26 29
27 public function setLogger(LoggerInterface $logger) 30 public function setLogger(LoggerInterface $logger)
@@ -124,6 +127,9 @@ class WallabagV1Import implements ImportInterface
124 { 127 {
125 $i = 1; 128 $i = 1;
126 129
130 //Untitled in all languages from v1. This should never have been translated
131 $untitled = array('Untitled', 'Sans titre', 'podle nadpisu', 'Sin título', 'با عنوان', 'per titolo', 'Sem título', 'Без названия', 'po naslovu', 'Без назви', 'No title found', '');
132
127 foreach ($entries as $importedEntry) { 133 foreach ($entries as $importedEntry) {
128 $existingEntry = $this->em 134 $existingEntry = $this->em
129 ->getRepository('WallabagCoreBundle:Entry') 135 ->getRepository('WallabagCoreBundle:Entry')
@@ -137,12 +143,16 @@ class WallabagV1Import implements ImportInterface
137 // @see ContentProxy->updateEntry 143 // @see ContentProxy->updateEntry
138 $entry = new Entry($this->user); 144 $entry = new Entry($this->user);
139 $entry->setUrl($importedEntry['url']); 145 $entry->setUrl($importedEntry['url']);
140 $entry->setTitle($importedEntry['title']); 146 if (in_array($importedEntry['title'], $untitled)) {
147 $entry = $this->contentProxy->updateEntry($entry, $importedEntry['url']);
148 } else {
149 $entry->setContent($importedEntry['content']);
150 $entry->setTitle($importedEntry['title']);
151 $entry->setReadingTime(Utils::getReadingTime($importedEntry['content']));
152 $entry->setDomainName(parse_url($importedEntry['url'], PHP_URL_HOST));
153 }
141 $entry->setArchived($importedEntry['is_read']); 154 $entry->setArchived($importedEntry['is_read']);
142 $entry->setStarred($importedEntry['is_fav']); 155 $entry->setStarred($importedEntry['is_fav']);
143 $entry->setContent($importedEntry['content']);
144 $entry->setReadingTime(Utils::getReadingTime($importedEntry['content']));
145 $entry->setDomainName(parse_url($importedEntry['url'], PHP_URL_HOST));
146 156
147 $this->em->persist($entry); 157 $this->em->persist($entry);
148 ++$this->importedEntries; 158 ++$this->importedEntries;