From ffd1061850d73182d40126658a0e9dd7f28f646e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 15 May 2022 21:53:13 +0200 Subject: User query automatic reconstruct of URL (#4360) * User query automatic reconstruct of URL (Invisible through the Web UI, only when working with configuration files manually) Avoid the requirement of storing user queries with duplicated information (parsed parameters AND the resulting URL): Before: ``` [ 'name' => 'Hello', 'search' => 'Hello OR World', 'state' => '3', 'url' => './?search=Hello+OR+World&state=3', ] ``` After: ``` [ 'name' => 'Hello', 'search' => 'Hello OR World', 'state' => '3', ] ``` * Fix test --- app/Models/UserQuery.php | 11 ++++++++--- app/layout/header.phtml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php index 7f8aa07ef..236813942 100644 --- a/app/Models/UserQuery.php +++ b/app/Models/UserQuery.php @@ -39,6 +39,14 @@ class FreshRSS_UserQuery { if (isset($query['order'])) { $this->order = $query['order']; } + if (empty($query['url'])) { + if (!empty($query)) { + unset($query['name']); + $this->url = Minz_Url::display(array('params' => $query)); + } + } else { + $this->url = $query['url']; + } if (!isset($query['search'])) { $query['search'] = ''; } @@ -47,9 +55,6 @@ class FreshRSS_UserQuery { if (isset($query['state'])) { $this->state = $query['state']; } - if (isset($query['url'])) { - $this->url = $query['url']; - } } /** diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 6040df2d3..b5a9b662c 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -40,7 +40,7 @@