aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/InstapaperImport.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/InstapaperImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index e4f0970c..f7bee9ef 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -62,7 +62,7 @@ class InstapaperImport extends AbstractImport
62 } 62 }
63 63
64 $entries = []; 64 $entries = [];
65 $handle = fopen($this->filepath, 'rb'); 65 $handle = fopen($this->filepath, 'r');
66 while (false !== ($data = fgetcsv($handle, 10240))) { 66 while (false !== ($data = fgetcsv($handle, 10240))) {
67 if ('URL' === $data[0]) { 67 if ('URL' === $data[0]) {
68 continue; 68 continue;
@@ -79,7 +79,6 @@ class InstapaperImport extends AbstractImport
79 $entries[] = [ 79 $entries[] = [
80 'url' => $data[0], 80 'url' => $data[0],
81 'title' => $data[1], 81 'title' => $data[1],
82 'status' => $data[3],
83 'is_archived' => 'Archive' === $data[3] || 'Starred' === $data[3], 82 'is_archived' => 'Archive' === $data[3] || 'Starred' === $data[3],
84 'is_starred' => 'Starred' === $data[3], 83 'is_starred' => 'Starred' === $data[3],
85 'html' => false, 84 'html' => false,
@@ -94,6 +93,10 @@ class InstapaperImport extends AbstractImport
94 return false; 93 return false;
95 } 94 }
96 95
96 // most recent articles are first, which means we should create them at the end so they will show up first
97 // as Instapaper doesn't export the creation date of the article
98 $entries = array_reverse($entries);
99
97 if ($this->producer) { 100 if ($this->producer) {
98 $this->parseEntriesForProducer($entries); 101 $this->parseEntriesForProducer($entries);
99 102
@@ -108,6 +111,18 @@ class InstapaperImport extends AbstractImport
108 /** 111 /**
109 * {@inheritdoc} 112 * {@inheritdoc}
110 */ 113 */
114 public function validateEntry(array $importedEntry)
115 {
116 if (empty($importedEntry['url'])) {
117 return false;
118 }
119
120 return true;
121 }
122
123 /**
124 * {@inheritdoc}
125 */
111 public function parseEntry(array $importedEntry) 126 public function parseEntry(array $importedEntry)
112 { 127 {
113 $existingEntry = $this->em 128 $existingEntry = $this->em
@@ -135,7 +150,7 @@ class InstapaperImport extends AbstractImport
135 ); 150 );
136 } 151 }
137 152
138 $entry->setArchived($importedEntry['is_archived']); 153 $entry->updateArchived($importedEntry['is_archived']);
139 $entry->setStarred($importedEntry['is_starred']); 154 $entry->setStarred($importedEntry['is_starred']);
140 155
141 $this->em->persist($entry); 156 $this->em->persist($entry);