From 712c063cdac0301467f1995d94c9b3e2a2fc54e6 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 17 Sep 2014 20:40:11 +0200 Subject: [PATCH] Search: * show terms in quicksearch-box, when performing searches * use trim() after urldecode() to catch urlencoded whitespaces * check for empty search terms (wich occur with multiple adjacent whitespaces) --- pages/search.php | 9 +++++---- template/bricks/header.tpl.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pages/search.php b/pages/search.php index 89ba315d..2f95eaaa 100644 --- a/pages/search.php +++ b/pages/search.php @@ -56,7 +56,7 @@ class SearchPage extends GenericPage public function __construct($pageCall, $pageParam) { - $this->search = urlDecode(trim($pageParam)); + $this->search = trim(urlDecode($pageParam)); $this->query = strtr($this->search, '?*', '_%'); // restricted access @@ -117,10 +117,11 @@ class SearchPage extends GenericPage if (!$this->query) return; - $parts = explode(' ', $this->query); - foreach ($parts as $p) + foreach (explode(' ', $this->query) as $p) { - if ($p[0] == '-') + if (!$p) // multiple spaces + continue; + else if ($p[0] == '-') { if (strlen($p) < 4) $this->invalid[] = substr($p, 1); diff --git a/template/bricks/header.tpl.php b/template/bricks/header.tpl.php index 3a9b45a9..64c2a12d 100644 --- a/template/bricks/header.tpl.php +++ b/template/bricks/header.tpl.php @@ -18,7 +18,7 @@
- +