aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Import')
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php25
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV2Import.php32
3 files changed, 34 insertions, 25 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 4499ce69..f598e611 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -68,7 +68,7 @@ class PocketImport implements ImportInterface
68 * 68 *
69 * @param string $redirectUri Redirect url in case of error 69 * @param string $redirectUri Redirect url in case of error
70 * 70 *
71 * @return string request_token for callback method 71 * @return string|false request_token for callback method
72 */ 72 */
73 public function getRequestToken($redirectUri) 73 public function getRequestToken($redirectUri)
74 { 74 {
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 173a587f..82160bae 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -7,7 +7,6 @@ use Psr\Log\NullLogger;
7use Doctrine\ORM\EntityManager; 7use 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;
11use Wallabag\CoreBundle\Helper\ContentProxy; 10use Wallabag\CoreBundle\Helper\ContentProxy;
12 11
13class WallabagV1Import implements ImportInterface 12class WallabagV1Import implements ImportInterface
@@ -153,19 +152,25 @@ class WallabagV1Import implements ImportInterface
153 continue; 152 continue;
154 } 153 }
155 154
156 // @see ContentProxy->updateEntry 155 $data = [
157 $entry = new Entry($this->user); 156 'title' => $importedEntry['title'],
158 $entry->setUrl($importedEntry['url']); 157 'html' => $importedEntry['content'],
158 'url' => $importedEntry['url'],
159 'content_type' => '',
160 'language' => '',
161 ];
159 162
163 // force content to be refreshed in case on bad fetch in the v1 installation
160 if (in_array($importedEntry['title'], $untitled)) { 164 if (in_array($importedEntry['title'], $untitled)) {
161 $entry = $this->contentProxy->updateEntry($entry, $importedEntry['url']); 165 $data = [];
162 } else {
163 $entry->setContent($importedEntry['content']);
164 $entry->setTitle($importedEntry['title']);
165 $entry->setReadingTime(Utils::getReadingTime($importedEntry['content']));
166 $entry->setDomainName(parse_url($importedEntry['url'], PHP_URL_HOST));
167 } 166 }
168 167
168 $entry = $this->contentProxy->updateEntry(
169 new Entry($this->user),
170 $importedEntry['url'],
171 $data
172 );
173
169 if (array_key_exists('tags', $importedEntry) && $importedEntry['tags'] != '') { 174 if (array_key_exists('tags', $importedEntry) && $importedEntry['tags'] != '') {
170 $this->contentProxy->assignTagsToEntry( 175 $this->contentProxy->assignTagsToEntry(
171 $entry, 176 $entry,
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
index 0a32864e..b31d63a3 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
@@ -47,25 +47,29 @@ class WallabagV2Import extends WallabagV1Import implements ImportInterface
47 continue; 47 continue;
48 } 48 }
49 49
50 // @see ContentProxy->updateEntry 50 $importedEntry['html'] = $importedEntry['content'];
51 $entry = new Entry($this->user); 51 $importedEntry['content_type'] = $importedEntry['mimetype'];
52 $entry->setUrl($importedEntry['url']); 52
53 $entry->setTitle($importedEntry['title']); 53 $entry = $this->contentProxy->updateEntry(
54 $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead); 54 new Entry($this->user),
55 $entry->setStarred($importedEntry['is_starred']); 55 $importedEntry['url'],
56 $entry->setContent($importedEntry['content']); 56 $importedEntry
57 $entry->setReadingTime($importedEntry['reading_time']); 57 );
58 $entry->setDomainName($importedEntry['domain_name']); 58
59 if (isset($importedEntry['mimetype'])) { 59 if (array_key_exists('tags', $importedEntry) && !empty($importedEntry['tags'])) {
60 $entry->setMimetype($importedEntry['mimetype']); 60 $this->contentProxy->assignTagsToEntry(
61 } 61 $entry,
62 if (isset($importedEntry['language'])) { 62 $importedEntry['tags']
63 $entry->setLanguage($importedEntry['language']); 63 );
64 } 64 }
65
65 if (isset($importedEntry['preview_picture'])) { 66 if (isset($importedEntry['preview_picture'])) {
66 $entry->setPreviewPicture($importedEntry['preview_picture']); 67 $entry->setPreviewPicture($importedEntry['preview_picture']);
67 } 68 }
68 69
70 $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead);
71 $entry->setStarred($importedEntry['is_starred']);
72
69 $this->em->persist($entry); 73 $this->em->persist($entry);
70 ++$this->importedEntries; 74 ++$this->importedEntries;
71 75