aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Tommaso Ferrari <raspaccio@gmail.com> 2025-10-22 12:28:33 -0700
committerGravatar GitHub <noreply@github.com> 2025-10-22 21:28:33 +0200
commit581b81006af157d0fa12b8d1e2604c637234f778 (patch)
treea75de00520a304e27296e4c6b5b6bf2116f1ae69 /app/Controllers
parent1282d3a2709064cb847b8757409a7153449faa9d (diff)
Add option to apply filter actions to existing articles (#7959)
* Add option to apply filter actions to existing articles * make fix-all * Fixes * Another approach with preview New approach: https://github.com/FreshRSS/FreshRSS/pull/7959/commits/20479475c90ac954b991b3703c3cc76c16aa2d5c <img width="666" height="202" alt="image" src="https://github.com/user-attachments/assets/bb68ede4-60c8-4e0c-9317-c5ed7a6ad7df" /> Additional improvements: * Also implemented at category level, and at global level * Also implemented for favourites at global level Shortcomings: * Does not always work reliably with advanced regex, since the DB's flavour is not necessarily the same than PHP's Related: https://github.com/FreshRSS/FreshRSS/pull/8141 * make fix-all --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/categoryController.php24
-rw-r--r--app/Controllers/configureController.php19
-rw-r--r--app/Controllers/subscriptionController.php24
3 files changed, 67 insertions, 0 deletions
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php
index 5ad83e977..2212a158b 100644
--- a/app/Controllers/categoryController.php
+++ b/app/Controllers/categoryController.php
@@ -171,6 +171,30 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {
}
}
+ public function viewFilterAction(): void {
+ $id = Minz_Request::paramInt('id');
+ if ($id === 0) {
+ Minz_Error::error(400);
+ return;
+ }
+ $filteractions = Minz_Request::paramTextToArray('filteractions_read');
+ $filteractions = array_map(fn(string $action): string => trim($action), $filteractions);
+ $filteractions = array_filter($filteractions, fn(string $action): bool => $action !== '');
+ $search = "c:$id (";
+ foreach ($filteractions as $action) {
+ $search .= "($action) OR ";
+ }
+ $search = preg_replace('/ OR $/', '', $search);
+ $search .= ')';
+ Minz_Request::forward([
+ 'c' => 'index',
+ 'a' => 'index',
+ 'params' => [
+ 'search' => $search,
+ ],
+ ], redirect: true);
+ }
+
/**
* This action deletes a category.
* Feeds in the given category are moved in the default category.
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 427fcb584..17c6c20bd 100644
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -180,6 +180,25 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
FreshRSS_View::prependTitle(_t('conf.reading.title') . ' ยท ');
}
+ public function viewFilterAction(): void {
+ $search = '';
+ $filters_name = Minz_Request::paramString('filters_name', plaintext: true);
+ $filteractions = Minz_Request::paramTextToArray($filters_name);
+ $filteractions = array_map(fn(string $action): string => trim($action), $filteractions);
+ $filteractions = array_filter($filteractions, fn(string $action): bool => $action !== '');
+ foreach ($filteractions as $action) {
+ $search .= "($action) OR ";
+ }
+ $search = preg_replace('/ OR $/', '', $search);
+ Minz_Request::forward([
+ 'c' => 'index',
+ 'a' => 'index',
+ 'params' => [
+ 'search' => $search,
+ ],
+ ], redirect: true);
+ }
+
/**
* This action handles the integration configuration page.
*
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index ccd421a41..244a16671 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -409,6 +409,30 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
}
}
+ public function viewFilterAction(): void {
+ $id = Minz_Request::paramInt('id');
+ if ($id === 0) {
+ Minz_Error::error(400);
+ return;
+ }
+ $filteractions = Minz_Request::paramTextToArray('filteractions_read');
+ $filteractions = array_map(fn(string $action): string => trim($action), $filteractions);
+ $filteractions = array_filter($filteractions, fn(string $action): bool => $action !== '');
+ $search = "f:$id (";
+ foreach ($filteractions as $action) {
+ $search .= "($action) OR ";
+ }
+ $search = preg_replace('/ OR $/', '', $search);
+ $search .= ')';
+ Minz_Request::forward([
+ 'c' => 'index',
+ 'a' => 'index',
+ 'params' => [
+ 'search' => $search,
+ ],
+ ], redirect: true);
+ }
+
/**
* This action displays the bookmarklet page.
*/