From 74bf3a4dc8cbcc46d9502ecc06246a5feb7d5971 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Oct 2019 08:39:41 -0400 Subject: [PATCH] Replace path parameter with query string parameter in Module\Search\Saved --- src/Module/Search/Saved.php | 4 ++-- static/routes.config.php | 4 ++-- view/templates/searchbox.tpl | 2 +- view/templates/widget/saved_searches.tpl | 2 +- view/theme/frio/css/style.css | 2 +- view/theme/frio/js/theme.js | 2 +- view/theme/frio/templates/searchbox.tpl | 15 ++++++--------- .../frio/templates/widget/saved_searches.tpl | 2 +- .../quattro/templates/widget/saved_searches.tpl | 2 +- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index 9a02c8a4e4..9d8d84b55a 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -16,11 +16,11 @@ class Saved extends BaseModule $args = self::getClass(Arguments::class); $action = $args->get(2, 'none'); - $search = Strings::escapeTags(trim(rawurldecode($args->get(3, '')))); + $search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? ''))); $return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search); - if (local_user()) { + if (local_user() && $search) { switch ($action) { case 'add': $fields = ['uid' => local_user(), 'term' => $search]; diff --git a/static/routes.config.php b/static/routes.config.php index 841fd68f99..c52b5d8026 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -191,8 +191,8 @@ return [ '/search' => [ '[/]' => [Module\Search\Index::class, [R::GET]], '/acl' => [Module\Search\Acl::class, [R::GET, R::POST]], - '/saved/add/{term}' => [Module\Search\Saved::class, [R::GET]], - '/saved/remove/{term}' => [Module\Search\Saved::class, [R::GET]], + '/saved/add' => [Module\Search\Saved::class, [R::GET]], + '/saved/remove' => [Module\Search\Saved::class, [R::GET]], ], '/settings' => [ diff --git a/view/templates/searchbox.tpl b/view/templates/searchbox.tpl index d566befba0..8317c59b1d 100644 --- a/view/templates/searchbox.tpl +++ b/view/templates/searchbox.tpl @@ -11,7 +11,7 @@ {{/if}} {{if $s}} - {{$save_label}} + {{$save_label}} {{/if}} {{/strip}} diff --git a/view/templates/widget/saved_searches.tpl b/view/templates/widget/saved_searches.tpl index 858e921f78..4e3a80b765 100644 --- a/view/templates/widget/saved_searches.tpl +++ b/view/templates/widget/saved_searches.tpl @@ -6,7 +6,7 @@