if ($form->isValid()) {
$file = $form->get('file')->getData();
+ $markAsRead = $form->get('mark_as_read')->getData();
$name = $this->getUser()->getId().'.json';
if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $wallabag
->setUser($this->getUser())
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
+ ->setMarkAsRead($markAsRead)
->import();
$message = 'Import failed, please try again.';
if ($form->isValid()) {
$file = $form->get('file')->getData();
+ $markAsRead = $form->get('mark_as_read')->getData();
$name = $this->getUser()->getId().'.json';
if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $wallabag
->setUser($this->getUser())
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
+ ->setMarkAsRead($markAsRead)
->import();
$message = 'Import failed, please try again.';
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
class UploadImportType extends AbstractType
{
{
$builder
->add('file', FileType::class)
+ ->add('mark_as_read', CheckboxType::class, array(
+ 'label' => 'Mark all as read',
+ 'required' => false,
+ ))
->add('save', SubmitType::class)
;
}
protected $skippedEntries = 0;
protected $importedEntries = 0;
protected $filepath;
+ protected $markAsRead;
public function __construct(EntityManager $em, ContentProxy $contentProxy)
{
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
*/
);
}
- $entry->setArchived($importedEntry['is_read']);
+ $entry->setArchived($importedEntry['is_read'] || $this->markAsRead);
$entry->setStarred($importedEntry['is_fav']);
$this->em->persist($entry);
$entry = new Entry($this->user);
$entry->setUrl($importedEntry['url']);
$entry->setTitle($importedEntry['title']);
- $entry->setArchived($importedEntry['is_archived']);
+ $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead);
$entry->setStarred($importedEntry['is_starred']);
$entry->setContent($importedEntry['content']);
$entry->setReadingTime($importedEntry['reading_time']);
<input class="file-path validate" type="text">
</div>
</div>
+ <div class="input-field col s6 with-checkbox">
+ <h6>{% trans %}Mark all as read ?{% endtrans %}</h6>
+ {{ form_widget(form.mark_as_read) }}
+ <label for="upload_import_file_mark_as_read">{% trans %}Mark all imported entries as read{% endtrans %}</label>
+ </div>
</div>
<div class="hidden">{{ form_rest(form) }}</div>
<button class="btn waves-effect waves-light" type="submit" name="action">