diff options
| author | 2025-01-25 09:16:13 +0100 | |
|---|---|---|
| committer | 2025-01-25 09:16:13 +0100 | |
| commit | d6c2daee51fa90f000c106492141baf3824931d2 (patch) | |
| tree | 98357a95438a55c9399cc1e1520c96996536b9c6 /app/Models/EntryDAO.php | |
| parent | 22b74b0a5790360d81088a83addab1f98b7f7947 (diff) | |
Add search operator intext: (#7228)
* Add search operator intext:
fix https://github.com/FreshRSS/FreshRSS/issues/6188
https://github.com/FreshRSS/FreshRSS/discussions/7220
* Add example to doc
Diffstat (limited to 'app/Models/EntryDAO.php')
| -rw-r--r-- | app/Models/EntryDAO.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index af229df54..a234dce91 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -981,6 +981,30 @@ SQL; $sub_search .= 'AND ' . static::sqlRegex($alias . 'title', $title, $values) . ' '; } } + if ($filter->getIntext() !== null) { + if (static::isCompressed()) { // MySQL-only + foreach ($filter->getIntext() as $content) { + $sub_search .= "AND UNCOMPRESS({$alias}content_bin) LIKE ? "; + $values[] = "%{$content}%"; + } + } else { + foreach ($filter->getIntext() as $content) { + $sub_search .= 'AND ' . $alias . 'content LIKE ? '; + $values[] = "%{$content}%"; + } + } + } + if ($filter->getIntextRegex() !== null) { + if (static::isCompressed()) { // MySQL-only + foreach ($filter->getIntextRegex() as $content) { + $sub_search .= 'AND ' . static::sqlRegex("UNCOMPRESS({$alias}content_bin)", $content, $values) . ') '; + } + } else { + foreach ($filter->getIntextRegex() as $content) { + $sub_search .= 'AND ' . static::sqlRegex($alias . 'content', $content, $values) . ' '; + } + } + } if ($filter->getTags() !== null) { foreach ($filter->getTags() as $tag) { $sub_search .= 'AND ' . static::sqlConcat('TRIM(' . $alias . 'tags) ', " ' #'") . ' LIKE ? '; @@ -1026,6 +1050,30 @@ SQL; $sub_search .= 'AND NOT ' . static::sqlRegex($alias . 'title', $title, $values) . ' '; } } + if ($filter->getNotIntext() !== null) { + if (static::isCompressed()) { // MySQL-only + foreach ($filter->getNotIntext() as $content) { + $sub_search .= "AND UNCOMPRESS({$alias}content_bin) NOT LIKE ? "; + $values[] = "%{$content}%"; + } + } else { + foreach ($filter->getNotIntext() as $content) { + $sub_search .= 'AND ' . $alias . 'content NOT LIKE ? '; + $values[] = "%{$content}%"; + } + } + } + if ($filter->getNotIntextRegex() !== null) { + if (static::isCompressed()) { // MySQL-only + foreach ($filter->getNotIntextRegex() as $content) { + $sub_search .= 'AND NOT ' . static::sqlRegex("UNCOMPRESS({$alias}content_bin)", $content, $values) . ') '; + } + } else { + foreach ($filter->getNotIntextRegex() as $content) { + $sub_search .= 'AND NOT ' . static::sqlRegex($alias . 'content', $content, $values) . ' '; + } + } + } if ($filter->getNotTags() !== null) { foreach ($filter->getNotTags() as $tag) { $sub_search .= 'AND ' . static::sqlConcat('TRIM(' . $alias . 'tags) ', " ' #'") . ' NOT LIKE ? '; |
