aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Form
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Form')
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ConfigType.php8
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php18
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/NewTagType.php11
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/SearchEntryType.php29
4 files changed, 64 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php
index 0bac2874..7e3b9dd4 100644
--- a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php
@@ -7,6 +7,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType; 7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8use Symfony\Component\Form\FormBuilderInterface; 8use Symfony\Component\Form\FormBuilderInterface;
9use Symfony\Component\OptionsResolver\OptionsResolver; 9use Symfony\Component\OptionsResolver\OptionsResolver;
10use Wallabag\CoreBundle\Entity\Config;
10 11
11class ConfigType extends AbstractType 12class ConfigType extends AbstractType
12{ 13{
@@ -48,6 +49,13 @@ class ConfigType extends AbstractType
48 'config.form_settings.reading_speed.400_word' => '2', 49 'config.form_settings.reading_speed.400_word' => '2',
49 ], 50 ],
50 ]) 51 ])
52 ->add('action_mark_as_read', ChoiceType::class, [
53 'label' => 'config.form_settings.action_mark_as_read.label',
54 'choices' => [
55 'config.form_settings.action_mark_as_read.redirect_homepage' => Config::REDIRECT_TO_HOMEPAGE,
56 'config.form_settings.action_mark_as_read.redirect_current_page' => Config::REDIRECT_TO_CURRENT_PAGE,
57 ],
58 ])
51 ->add('language', ChoiceType::class, [ 59 ->add('language', ChoiceType::class, [
52 'choices' => array_flip($this->languages), 60 'choices' => array_flip($this->languages),
53 'label' => 'config.form_settings.language_label', 61 'label' => 'config.form_settings.language_label',
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
index a3e36fdd..ee66c728 100644
--- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
@@ -11,6 +11,7 @@ use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType;
11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; 11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
12use Symfony\Component\Form\AbstractType; 12use Symfony\Component\Form\AbstractType;
13use Symfony\Component\Form\FormBuilderInterface; 13use Symfony\Component\Form\FormBuilderInterface;
14use Symfony\Component\HttpFoundation\Response;
14use Symfony\Component\OptionsResolver\OptionsResolver; 15use Symfony\Component\OptionsResolver\OptionsResolver;
15use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 16use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
16 17
@@ -89,12 +90,27 @@ class EntryFilterType extends AbstractType
89 if (strlen($value) <= 2 || empty($value)) { 90 if (strlen($value) <= 2 || empty($value)) {
90 return; 91 return;
91 } 92 }
92 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%')); 93 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%'.$value.'%')));
93 94
94 return $filterQuery->createCondition($expression); 95 return $filterQuery->createCondition($expression);
95 }, 96 },
96 'label' => 'entry.filters.domain_label', 97 'label' => 'entry.filters.domain_label',
97 ]) 98 ])
99 ->add('httpStatus', TextFilterType::class, [
100 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
101 $value = $values['value'];
102 if (false === array_key_exists($value, Response::$statusTexts)) {
103 return;
104 }
105
106 $paramName = sprintf('%s', str_replace('.', '_', $field));
107 $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName);
108 $parameters = array($paramName => $value);
109
110 return $filterQuery->createCondition($expression, $parameters);
111 },
112 'label' => 'entry.filters.http_status_label',
113 ])
98 ->add('isArchived', CheckboxFilterType::class, [ 114 ->add('isArchived', CheckboxFilterType::class, [
99 'label' => 'entry.filters.archived_label', 115 'label' => 'entry.filters.archived_label',
100 ]) 116 ])
diff --git a/src/Wallabag/CoreBundle/Form/Type/NewTagType.php b/src/Wallabag/CoreBundle/Form/Type/NewTagType.php
index 3db4105f..e830ade4 100644
--- a/src/Wallabag/CoreBundle/Form/Type/NewTagType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/NewTagType.php
@@ -3,6 +3,7 @@
3namespace Wallabag\CoreBundle\Form\Type; 3namespace Wallabag\CoreBundle\Form\Type;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\SubmitType;
6use Symfony\Component\Form\Extension\Core\Type\TextType; 7use Symfony\Component\Form\Extension\Core\Type\TextType;
7use Symfony\Component\Form\FormBuilderInterface; 8use Symfony\Component\Form\FormBuilderInterface;
8use Symfony\Component\OptionsResolver\OptionsResolver; 9use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -12,7 +13,15 @@ class NewTagType extends AbstractType
12 public function buildForm(FormBuilderInterface $builder, array $options) 13 public function buildForm(FormBuilderInterface $builder, array $options)
13 { 14 {
14 $builder 15 $builder
15 ->add('label', TextType::class, ['required' => true]) 16 ->add('label', TextType::class, [
17 'required' => true,
18 'attr' => [
19 'placeholder' => 'tag.new.placeholder',
20 ],
21 ])
22 ->add('add', SubmitType::class, [
23 'label' => 'tag.new.add',
24 ])
16 ; 25 ;
17 } 26 }
18 27
diff --git a/src/Wallabag/CoreBundle/Form/Type/SearchEntryType.php b/src/Wallabag/CoreBundle/Form/Type/SearchEntryType.php
new file mode 100644
index 00000000..b56cae8e
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/SearchEntryType.php
@@ -0,0 +1,29 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\TextType;
7use Symfony\Component\Form\FormBuilderInterface;
8use Symfony\Component\OptionsResolver\OptionsResolver;
9
10class SearchEntryType extends AbstractType
11{
12 public function buildForm(FormBuilderInterface $builder, array $options)
13 {
14 $builder
15 ->setMethod('GET')
16 ->add('term', TextType::class, [
17 'required' => true,
18 'label' => 'entry.new.form_search.term_label',
19 ])
20 ;
21 }
22
23 public function configureOptions(OptionsResolver $resolver)
24 {
25 $resolver->setDefaults([
26 'csrf_protection' => false,
27 ]);
28 }
29}