aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php2
-rw-r--r--src/Wallabag/ImportBundle/Form/Type/UploadImportType.php5
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php15
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV2Import.php2
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig5
6 files changed, 29 insertions, 2 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
index 35fe620f..8b27144b 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
@@ -21,12 +21,14 @@ class WallabagV1Controller extends Controller
21 21
22 if ($form->isValid()) { 22 if ($form->isValid()) {
23 $file = $form->get('file')->getData(); 23 $file = $form->get('file')->getData();
24 $markAsRead = $form->get('mark_as_read')->getData();
24 $name = $this->getUser()->getId().'.json'; 25 $name = $this->getUser()->getId().'.json';
25 26
26 if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 27 if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
27 $res = $wallabag 28 $res = $wallabag
28 ->setUser($this->getUser()) 29 ->setUser($this->getUser())
29 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 30 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
31 ->setMarkAsRead($markAsRead)
30 ->import(); 32 ->import();
31 33
32 $message = 'Import failed, please try again.'; 34 $message = 'Import failed, please try again.';
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
index 2e6225f2..6dcd204a 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
@@ -21,12 +21,14 @@ class WallabagV2Controller extends Controller
21 21
22 if ($form->isValid()) { 22 if ($form->isValid()) {
23 $file = $form->get('file')->getData(); 23 $file = $form->get('file')->getData();
24 $markAsRead = $form->get('mark_as_read')->getData();
24 $name = $this->getUser()->getId().'.json'; 25 $name = $this->getUser()->getId().'.json';
25 26
26 if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 27 if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
27 $res = $wallabag 28 $res = $wallabag
28 ->setUser($this->getUser()) 29 ->setUser($this->getUser())
29 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 30 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
31 ->setMarkAsRead($markAsRead)
30 ->import(); 32 ->import();
31 33
32 $message = 'Import failed, please try again.'; 34 $message = 'Import failed, please try again.';
diff --git a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
index 2e6b59cb..bbc3661a 100644
--- a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
+++ b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
@@ -6,6 +6,7 @@ use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface; 6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType; 7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8use Symfony\Component\Form\Extension\Core\Type\FileType; 8use Symfony\Component\Form\Extension\Core\Type\FileType;
9use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
9 10
10class UploadImportType extends AbstractType 11class UploadImportType extends AbstractType
11{ 12{
@@ -13,6 +14,10 @@ class UploadImportType extends AbstractType
13 { 14 {
14 $builder 15 $builder
15 ->add('file', FileType::class) 16 ->add('file', FileType::class)
17 ->add('mark_as_read', CheckboxType::class, array(
18 'label' => 'Mark all as read',
19 'required' => false,
20 ))
16 ->add('save', SubmitType::class) 21 ->add('save', SubmitType::class)
17 ; 22 ;
18 } 23 }
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 05bdb401..1d773d3b 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -19,6 +19,7 @@ class WallabagV1Import implements ImportInterface
19 protected $skippedEntries = 0; 19 protected $skippedEntries = 0;
20 protected $importedEntries = 0; 20 protected $importedEntries = 0;
21 protected $filepath; 21 protected $filepath;
22 protected $markAsRead;
22 23
23 public function __construct(EntityManager $em, ContentProxy $contentProxy) 24 public function __construct(EntityManager $em, ContentProxy $contentProxy)
24 { 25 {
@@ -121,6 +122,18 @@ class WallabagV1Import implements ImportInterface
121 } 122 }
122 123
123 /** 124 /**
125 * Set whether articles must be all marked as read.
126 *
127 * @param bool $markAsRead
128 */
129 public function setMarkAsRead($markAsRead)
130 {
131 $this->markAsRead = $markAsRead;
132
133 return $this;
134 }
135
136 /**
124 * @param $entries 137 * @param $entries
125 */ 138 */
126 protected function parseEntries($entries) 139 protected function parseEntries($entries)
@@ -160,7 +173,7 @@ class WallabagV1Import implements ImportInterface
160 ); 173 );
161 } 174 }
162 175
163 $entry->setArchived($importedEntry['is_read']); 176 $entry->setArchived($importedEntry['is_read'] || $this->markAsRead);
164 $entry->setStarred($importedEntry['is_fav']); 177 $entry->setStarred($importedEntry['is_fav']);
165 178
166 $this->em->persist($entry); 179 $this->em->persist($entry);
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
index 7125eabc..c4bac561 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
@@ -51,7 +51,7 @@ class WallabagV2Import extends WallabagV1Import implements ImportInterface
51 $entry = new Entry($this->user); 51 $entry = new Entry($this->user);
52 $entry->setUrl($importedEntry['url']); 52 $entry->setUrl($importedEntry['url']);
53 $entry->setTitle($importedEntry['title']); 53 $entry->setTitle($importedEntry['title']);
54 $entry->setArchived($importedEntry['is_archived']); 54 $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead);
55 $entry->setStarred($importedEntry['is_starred']); 55 $entry->setStarred($importedEntry['is_starred']);
56 $entry->setContent($importedEntry['content']); 56 $entry->setContent($importedEntry['content']);
57 $entry->setReadingTime($importedEntry['reading_time']); 57 $entry->setReadingTime($importedEntry['reading_time']);
diff --git a/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig
index 1359f2e4..a418ed1c 100644
--- a/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig
@@ -22,6 +22,11 @@
22 <input class="file-path validate" type="text"> 22 <input class="file-path validate" type="text">
23 </div> 23 </div>
24 </div> 24 </div>
25 <div class="input-field col s6 with-checkbox">
26 <h6>{% trans %}Mark all as read ?{% endtrans %}</h6>
27 {{ form_widget(form.mark_as_read) }}
28 <label for="upload_import_file_mark_as_read">{% trans %}Mark all imported entries as read{% endtrans %}</label>
29 </div>
25 </div> 30 </div>
26 <div class="hidden">{{ form_rest(form) }}</div> 31 <div class="hidden">{{ form_rest(form) }}</div>
27 <button class="btn waves-effect waves-light" type="submit" name="action"> 32 <button class="btn waves-effect waves-light" type="submit" name="action">