]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ImportBundle/Import/WallabagV1Import.php
Convert english translation file
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Import / WallabagV1Import.php
index c54e73b2c8d53dce1616592b289b8668e345c90b..173a587f1cd6ea4c472f6ce78ff4112e50da493b 100644 (file)
@@ -19,6 +19,7 @@ class WallabagV1Import implements ImportInterface
     protected $skippedEntries = 0;
     protected $importedEntries = 0;
     protected $filepath;
+    protected $markAsRead;
 
     public function __construct(EntityManager $em, ContentProxy $contentProxy)
     {
@@ -66,7 +67,7 @@ class WallabagV1Import implements ImportInterface
      */
     public function getDescription()
     {
-        return 'This importer will import all your wallabag v1 articles. On your config page, click on "JSON export" in the "Export your wallabag data" section. You will have a "wallabag-export-1-xxxx-xx-xx.json" file.';
+        return 'import.wallabag_v1.description';
     }
 
     /**
@@ -120,6 +121,18 @@ class WallabagV1Import implements ImportInterface
         return $this;
     }
 
+    /**
+     * Set whether articles must be all marked as read.
+     *
+     * @param bool $markAsRead
+     */
+    public function setMarkAsRead($markAsRead)
+    {
+        $this->markAsRead = $markAsRead;
+
+        return $this;
+    }
+
     /**
      * @param $entries
      */
@@ -143,6 +156,7 @@ class WallabagV1Import implements ImportInterface
             // @see ContentProxy->updateEntry
             $entry = new Entry($this->user);
             $entry->setUrl($importedEntry['url']);
+
             if (in_array($importedEntry['title'], $untitled)) {
                 $entry = $this->contentProxy->updateEntry($entry, $importedEntry['url']);
             } else {
@@ -151,7 +165,15 @@ class WallabagV1Import implements ImportInterface
                 $entry->setReadingTime(Utils::getReadingTime($importedEntry['content']));
                 $entry->setDomainName(parse_url($importedEntry['url'], PHP_URL_HOST));
             }
-            $entry->setArchived($importedEntry['is_read']);
+
+            if (array_key_exists('tags', $importedEntry) && $importedEntry['tags'] != '') {
+                $this->contentProxy->assignTagsToEntry(
+                    $entry,
+                    $importedEntry['tags']
+                );
+            }
+
+            $entry->setArchived($importedEntry['is_read'] || $this->markAsRead);
             $entry->setStarred($importedEntry['is_fav']);
 
             $this->em->persist($entry);