mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-22 17:18:37 +00:00
Merge pull request #3047 from wallabag/add-notmatches-operator
Added notmatches operator for tagging rule
This commit is contained in:
commit
9c09c253fe
32 changed files with 126 additions and 51 deletions
|
@ -36,6 +36,13 @@ class LoadTaggingRuleData extends AbstractFixture implements OrderedFixtureInter
|
|||
|
||||
$manager->persist($tr3);
|
||||
|
||||
$tr4 = new TaggingRule();
|
||||
$tr4->setRule('content notmatches "basket"');
|
||||
$tr4->setTags(['foot']);
|
||||
$tr4->setConfig($this->getReference('admin-config'));
|
||||
|
||||
$manager->persist($tr4);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class TaggingRule
|
|||
* @Assert\Length(max=255)
|
||||
* @RulerZAssert\ValidRule(
|
||||
* allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"},
|
||||
* allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches"}
|
||||
* allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"}
|
||||
* )
|
||||
* @ORM\Column(name="rule", type="string", nullable=false)
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ class TaggingRule
|
|||
/**
|
||||
* Set tags.
|
||||
*
|
||||
* @param array<string> $tags
|
||||
* @param array <string> $tags
|
||||
*
|
||||
* @return TaggingRule
|
||||
*/
|
||||
|
|
25
src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php
Normal file
25
src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Operator\Doctrine;
|
||||
|
||||
/**
|
||||
* Provides a "notmatches" operator used for tagging rules.
|
||||
*
|
||||
* It asserts that a given pattern is not contained in a subject, in a
|
||||
* case-insensitive way.
|
||||
*
|
||||
* This operator will be used to compile tagging rules in DQL, usable
|
||||
* by Doctrine ORM.
|
||||
* It's registered in RulerZ using a service (wallabag.operator.doctrine.notmatches);
|
||||
*/
|
||||
class NotMatches
|
||||
{
|
||||
public function __invoke($subject, $pattern)
|
||||
{
|
||||
if ($pattern[0] === "'") {
|
||||
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
|
||||
}
|
||||
|
||||
return sprintf('UPPER(%s) NOT LIKE UPPER(%s)', $subject, $pattern);
|
||||
}
|
||||
}
|
21
src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php
Normal file
21
src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Operator\PHP;
|
||||
|
||||
/**
|
||||
* Provides a "notmatches" operator used for tagging rules.
|
||||
*
|
||||
* It asserts that a given pattern is not contained in a subject, in a
|
||||
* case-insensitive way.
|
||||
*
|
||||
* This operator will be used to compile tagging rules in PHP, usable
|
||||
* directly on Entry objects for instance.
|
||||
* It's registered in RulerZ using a service (wallabag.operator.array.notmatches);
|
||||
*/
|
||||
class NotMatches
|
||||
{
|
||||
public function __invoke($subject, $pattern)
|
||||
{
|
||||
return stripos($subject, $pattern) === false;
|
||||
}
|
||||
}
|
|
@ -125,6 +125,16 @@ services:
|
|||
tags:
|
||||
- { name: rulerz.operator, target: doctrine, operator: matches, inline: true }
|
||||
|
||||
wallabag.operator.array.notmatches:
|
||||
class: Wallabag\CoreBundle\Operator\PHP\NotMatches
|
||||
tags:
|
||||
- { name: rulerz.operator, target: native, operator: notmatches }
|
||||
|
||||
wallabag.operator.doctrine.notmatches:
|
||||
class: Wallabag\CoreBundle\Operator\Doctrine\NotMatches
|
||||
tags:
|
||||
- { name: rulerz.operator, target: doctrine, operator: notmatches, inline: true }
|
||||
|
||||
wallabag_core.helper.redirect:
|
||||
class: Wallabag\CoreBundle\Helper\Redirect
|
||||
arguments:
|
||||
|
|
|
@ -155,7 +155,7 @@ config:
|
|||
# or: 'One rule OR another'
|
||||
# and: 'One rule AND another'
|
||||
# matches: 'Tests that a <i>subject</i> is matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
|
||||
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
entry:
|
||||
page_titles:
|
||||
# unread: 'Unread entries'
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: 'Eine Regel ODER die andere'
|
||||
and: 'Eine Regel UND eine andere'
|
||||
matches: 'Testet, ob eine <i>Variable</i> auf eine <i>Suche</i> zutrifft (Groß- und Kleinschreibung wird nicht berücksichtigt).<br />Beispiel: <code>title matches "Fußball"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: 'One rule OR another'
|
||||
and: 'One rule AND another'
|
||||
matches: 'Tests that a <i>subject</i> is matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
|
||||
notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: 'Una regla U otra'
|
||||
and: 'Una regla Y la otra'
|
||||
matches: 'Prueba si un <i>sujeto</i> corresponde a una <i>búsqueda</i> (insensible a mayusculas).<br />Ejemplo : <code>title matches "fútbol"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
# or: 'One rule OR another'
|
||||
# and: 'One rule AND another'
|
||||
# matches: 'Tests that a <i>subject</i> is matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: "Une règle OU l’autre"
|
||||
and: "Une règle ET l’autre"
|
||||
matches: "Teste si un <i>sujet</i> correspond à une <i>recherche</i> (non sensible à la casse).<br />Exemple : <code>title matches \"football\"</code>"
|
||||
notmatches: "Teste si un <i>sujet</i> ne correspond pas à une <i>recherche</i> (non sensible à la casse).<br />Exemple : <code>title notmatches \"football\"</code>"
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: "Una regola O un'altra"
|
||||
and: "Una regola E un'altra"
|
||||
matches: 'Verifica che un <i>oggetto</i> risulti in una <i>ricerca</i> (case-insensitive).<br />Esempio: <code>titolo contiene "football"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: "Una règla O l'autra"
|
||||
and: "Una règla E l'autra"
|
||||
matches: 'Teste se un <i>subjècte</i> correspond a una <i>recerca</i> (non sensibla a la cassa).<br />Exemple : <code>title matches \"football\"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: 'Jedna reguła LUB inna'
|
||||
and: 'Jedna reguła I inna'
|
||||
matches: 'Sprawdź czy <i>temat</i> pasuje <i>szukaj</i> (duże lub małe litery).<br />Przykład: <code>tytuł zawiera "piłka nożna"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: 'Uma regra OU outra'
|
||||
and: 'Uma regra E outra'
|
||||
matches: 'Testa que um <i>assunto</i> corresponde a uma <i>pesquisa</i> (maiúscula ou minúscula).<br />Exemplo: <code>título corresponde a "futebol"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
# or: 'One rule OR another'
|
||||
# and: 'One rule AND another'
|
||||
# matches: 'Tests that a <i>subject</i> is matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -155,6 +155,7 @@ config:
|
|||
or: 'Bir kural veya birbaşkası'
|
||||
and: 'Bir kural ve diğeri'
|
||||
# matches: 'Tests that a <i>subject</i> is matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
|
||||
# notmatches: 'Tests that a <i>subject</i> is not matches a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
|
||||
|
||||
entry:
|
||||
page_titles:
|
||||
|
|
|
@ -413,8 +413,8 @@
|
|||
<tr>
|
||||
<td>domainName</td>
|
||||
<td>{{ 'config.form_rules.faq.variable_description.domainName'|trans }}</td>
|
||||
<td>matches</td>
|
||||
<td>{{ 'config.form_rules.faq.operator_description.matches'|trans|raw }}</td>
|
||||
<td>matches<br />notmaches</td>
|
||||
<td>{{ 'config.form_rules.faq.operator_description.matches'|trans|raw }}<br />{{ 'config.form_rules.faq.operator_description.notmatches'|trans|raw }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue