From c6b5b74a3fbcca16cc05abbfc719529279fb6ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de> Date: Tue, 27 Mar 2018 13:17:57 +0200 Subject: [PATCH] fix(search): detect irregular fragment query If the entered query does not cleanly fall into the area of the given options, show the current behavior as "custom". --- inc/Ui/Search.php | 7 ++++++- inc/lang/en/lang.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/inc/Ui/Search.php b/inc/Ui/Search.php index 5ac9a6ef1..8bb1913e3 100644 --- a/inc/Ui/Search.php +++ b/inc/Ui/Search.php @@ -235,12 +235,17 @@ class Search extends Ui ]; // detect current - $activeOption = 'exact'; + $activeOption = 'custom'; foreach ($options as $key => $option) { if ($this->parsedQuery['and'] === $option['and']) { $activeOption = $key; } } + if ($activeOption === 'custom') { + $options = array_merge(['custom' => [ + 'label' => $lang['search_custom_match'], + ]], $options); + } $searchForm->addTagOpen('div')->addClass('search-tool js-search-tool'); // render current diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 4f388c17a..c2c4eb8e5 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -75,6 +75,7 @@ $lang['search_exact_match'] = 'Exact match'; $lang['search_starts_with'] = 'Starts with'; $lang['search_ends_with'] = 'Ends with'; $lang['search_contains'] = 'Contains'; +$lang['search_custom_match'] = 'Custom'; $lang['search_any_ns'] = 'Any namespace'; $lang['search_any_time'] = 'Any time'; $lang['search_past_7_days'] = 'Past week'; -- GitLab