diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-02-11 16:47:58 +0100 |
---|---|---|
committer | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-02-11 16:47:58 +0100 |
commit | 6896ae1dda1e399ce39111b28f8f6fbc1d71e14f (patch) | |
tree | e0d68f956723c30c91411913f09f22c95fbddf7d /src/Wallabag/ImportBundle/Import | |
parent | 6e2ca4d8256f9e5b14c56e68cd0f0afadfcd28dd (diff) | |
parent | eaf9dad777e84d50e8b3e5877b05605ad9138fee (diff) | |
download | wallabag-6896ae1dda1e399ce39111b28f8f6fbc1d71e14f.tar.gz wallabag-6896ae1dda1e399ce39111b28f8f6fbc1d71e14f.tar.zst wallabag-6896ae1dda1e399ce39111b28f8f6fbc1d71e14f.zip |
Merge pull request #1666 from wallabag/v2-reimport-v1-articles-if-not-fetched
reimport v1 entries if they were not fetched
Diffstat (limited to 'src/Wallabag/ImportBundle/Import')
-rw-r--r-- | src/Wallabag/ImportBundle/Import/WallabagV1Import.php | 20 |
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; | |||
8 | use Wallabag\CoreBundle\Entity\Entry; | 8 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\UserBundle\Entity\User; | 9 | use Wallabag\UserBundle\Entity\User; |
10 | use Wallabag\CoreBundle\Tools\Utils; | 10 | use Wallabag\CoreBundle\Tools\Utils; |
11 | use Wallabag\CoreBundle\Helper\ContentProxy; | ||
11 | 12 | ||
12 | class WallabagV1Import implements ImportInterface | 13 | class 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; |