From 49a92c2437d3be9fba8c6af2d3f328ae525d81c6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 28 Oct 2025 19:07:14 +0100 Subject: Mark as read 1 or 7 days based on publication date (#8163) Allow the UI for marking as read articles older than 1 or 7 days to also work when sorting by publication date (in which case, the publication date is used). image --- app/Controllers/entryController.php | 9 ++++++++- app/Models/BooleanSearch.php | 5 +++++ app/Models/Search.php | 3 +++ app/layout/nav_menu.phtml | 14 +++++++++++--- 4 files changed, 27 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index 1d4792267..6bcf7f49e 100644 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -40,7 +40,8 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController { * - id (default: false) * - get (default: false) /(c_\d+|f_\d+|s|a)/ * - nextGet (default: $get) - * - idMax (default: 0) + * - idMax (default: '0') + * - maxPubDate (default: 0) * - is_read (default: true) */ public function readAction(): void { @@ -52,6 +53,12 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController { } $is_read = Minz_Request::paramTernary('is_read') ?? true; FreshRSS_Context::$search = new FreshRSS_BooleanSearch(Minz_Request::paramString('search')); + $maxPubDate = Minz_Request::paramInt('maxPubDate'); + if ($maxPubDate > 0) { + $search = new FreshRSS_Search(''); + $search->setMaxPubdate($maxPubDate); + FreshRSS_Context::$search->prepend($search); + } FreshRSS_Context::$state = Minz_Request::paramInt('state'); if (FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_FAVORITE)) { diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php index 7b3cc0e12..720cbf78e 100644 --- a/app/Models/BooleanSearch.php +++ b/app/Models/BooleanSearch.php @@ -421,6 +421,11 @@ class FreshRSS_BooleanSearch implements \Stringable { return $this->operator; } + /** @param FreshRSS_BooleanSearch|FreshRSS_Search $search */ + public function prepend(FreshRSS_BooleanSearch|FreshRSS_Search $search): void { + array_unshift($this->searches, $search); + } + /** @param FreshRSS_BooleanSearch|FreshRSS_Search $search */ public function add(FreshRSS_BooleanSearch|FreshRSS_Search $search): void { $this->searches[] = $search; diff --git a/app/Models/Search.php b/app/Models/Search.php index a14f1bf1a..265f6a45d 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -274,6 +274,9 @@ class FreshRSS_Search implements \Stringable { public function getNotMaxPubdate(): ?int { return $this->not_max_pubdate ?: null; } + public function setMaxPubdate(int $value): void { + $this->max_pubdate = $value; + } public function getMinUserdate(): ?int { return $this->min_userdate ?: null; diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index bf6d331ee..4529d0df3 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -152,12 +152,20 @@ type="submit"> -- cgit v1.2.3