mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-11 18:26:28 +00:00
Mark all imported articles as read
This commit is contained in:
parent
7d12fd0628
commit
fe8b37c137
6 changed files with 29 additions and 2 deletions
|
@ -21,12 +21,14 @@ class WallabagV1Controller extends Controller
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$file = $form->get('file')->getData();
|
$file = $form->get('file')->getData();
|
||||||
|
$markAsRead = $form->get('mark_as_read')->getData();
|
||||||
$name = $this->getUser()->getId().'.json';
|
$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)) {
|
if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
|
||||||
$res = $wallabag
|
$res = $wallabag
|
||||||
->setUser($this->getUser())
|
->setUser($this->getUser())
|
||||||
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
|
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
|
||||||
|
->setMarkAsRead($markAsRead)
|
||||||
->import();
|
->import();
|
||||||
|
|
||||||
$message = 'Import failed, please try again.';
|
$message = 'Import failed, please try again.';
|
||||||
|
|
|
@ -21,12 +21,14 @@ class WallabagV2Controller extends Controller
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$file = $form->get('file')->getData();
|
$file = $form->get('file')->getData();
|
||||||
|
$markAsRead = $form->get('mark_as_read')->getData();
|
||||||
$name = $this->getUser()->getId().'.json';
|
$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)) {
|
if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
|
||||||
$res = $wallabag
|
$res = $wallabag
|
||||||
->setUser($this->getUser())
|
->setUser($this->getUser())
|
||||||
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
|
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
|
||||||
|
->setMarkAsRead($markAsRead)
|
||||||
->import();
|
->import();
|
||||||
|
|
||||||
$message = 'Import failed, please try again.';
|
$message = 'Import failed, please try again.';
|
||||||
|
|
|
@ -6,6 +6,7 @@ use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
|
||||||
class UploadImportType extends AbstractType
|
class UploadImportType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -13,6 +14,10 @@ class UploadImportType extends AbstractType
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('file', FileType::class)
|
->add('file', FileType::class)
|
||||||
|
->add('mark_as_read', CheckboxType::class, array(
|
||||||
|
'label' => 'Mark all as read',
|
||||||
|
'required' => false,
|
||||||
|
))
|
||||||
->add('save', SubmitType::class)
|
->add('save', SubmitType::class)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ class WallabagV1Import implements ImportInterface
|
||||||
protected $skippedEntries = 0;
|
protected $skippedEntries = 0;
|
||||||
protected $importedEntries = 0;
|
protected $importedEntries = 0;
|
||||||
protected $filepath;
|
protected $filepath;
|
||||||
|
protected $markAsRead;
|
||||||
|
|
||||||
public function __construct(EntityManager $em, ContentProxy $contentProxy)
|
public function __construct(EntityManager $em, ContentProxy $contentProxy)
|
||||||
{
|
{
|
||||||
|
@ -120,6 +121,18 @@ class WallabagV1Import implements ImportInterface
|
||||||
return $this;
|
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
|
* @param $entries
|
||||||
*/
|
*/
|
||||||
|
@ -160,7 +173,7 @@ class WallabagV1Import implements ImportInterface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry->setArchived($importedEntry['is_read']);
|
$entry->setArchived($importedEntry['is_read'] || $this->markAsRead);
|
||||||
$entry->setStarred($importedEntry['is_fav']);
|
$entry->setStarred($importedEntry['is_fav']);
|
||||||
|
|
||||||
$this->em->persist($entry);
|
$this->em->persist($entry);
|
||||||
|
|
|
@ -51,7 +51,7 @@ class WallabagV2Import extends WallabagV1Import implements ImportInterface
|
||||||
$entry = new Entry($this->user);
|
$entry = new Entry($this->user);
|
||||||
$entry->setUrl($importedEntry['url']);
|
$entry->setUrl($importedEntry['url']);
|
||||||
$entry->setTitle($importedEntry['title']);
|
$entry->setTitle($importedEntry['title']);
|
||||||
$entry->setArchived($importedEntry['is_archived']);
|
$entry->setArchived($importedEntry['is_archived'] || $this->markAsRead);
|
||||||
$entry->setStarred($importedEntry['is_starred']);
|
$entry->setStarred($importedEntry['is_starred']);
|
||||||
$entry->setContent($importedEntry['content']);
|
$entry->setContent($importedEntry['content']);
|
||||||
$entry->setReadingTime($importedEntry['reading_time']);
|
$entry->setReadingTime($importedEntry['reading_time']);
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
<input class="file-path validate" type="text">
|
<input class="file-path validate" type="text">
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
<div class="hidden">{{ form_rest(form) }}</div>
|
<div class="hidden">{{ form_rest(form) }}</div>
|
||||||
<button class="btn waves-effect waves-light" type="submit" name="action">
|
<button class="btn waves-effect waves-light" type="submit" name="action">
|
||||||
|
|
Loading…
Reference in a new issue