aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/BooleanSearch.php28
-rw-r--r--app/Models/View.php4
2 files changed, 23 insertions, 9 deletions
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php
index 1832bd419..7b3cc0e12 100644
--- a/app/Models/BooleanSearch.php
+++ b/app/Models/BooleanSearch.php
@@ -102,7 +102,7 @@ class FreshRSS_BooleanSearch implements \Stringable {
private function parseUserQueryIds(string $input, bool $allowUserQueries = true): string {
$all_matches = [];
- if (preg_match_all('/\bS:(?P<search>\d+)/', $input, $matchesFound)) {
+ if (preg_match_all('/\bS:(?P<search>[0-9,]+)/', $input, $matchesFound)) {
$all_matches[] = $matchesFound;
}
@@ -119,16 +119,26 @@ class FreshRSS_BooleanSearch implements \Stringable {
continue;
}
for ($i = count($matches['search']) - 1; $i >= 0; $i--) {
- // Index starting from 1
- $id = (int)(trim($matches['search'][$i])) - 1;
- if (!empty($queries[$id])) {
- $fromS[] = $matches[0][$i];
- if ($allowUserQueries) {
- $toS[] = '(' . self::escapeLiteralParentheses($queries[$id]) . ')';
- } else {
- $toS[] = '';
+ $ids = explode(',', $matches['search'][$i]);
+ $ids = array_map('intval', $ids);
+
+ $matchedQueries = [];
+ foreach ($ids as $id) {
+ if (!empty($queries[$id])) {
+ $matchedQueries[] = $queries[$id];
}
}
+ if (empty($matchedQueries)) {
+ continue;
+ }
+
+ $fromS[] = $matches[0][$i];
+ if ($allowUserQueries) {
+ $escapedQueries = array_map(fn(string $query): string => self::escapeLiteralParentheses($query), $matchedQueries);
+ $toS[] = '(' . implode(') OR (', $escapedQueries) . ')';
+ } else {
+ $toS[] = '';
+ }
}
}
diff --git a/app/Models/View.php b/app/Models/View.php
index 104afb3c0..cf5c30e15 100644
--- a/app/Models/View.php
+++ b/app/Models/View.php
@@ -30,6 +30,10 @@ class FreshRSS_View extends Minz_View {
public array $tagsForEntries;
public bool $excludeMutedFeeds;
+ // Search
+ /** @var array<int,FreshRSS_Tag> where the key is the label ID */
+ public array $labels;
+
// Subscriptions
public bool $displaySlider = false;
public bool $load_ok;