From 3ff196f00dbad7e1efe6bb32cefbd7ece24127d4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 24 Aug 2015 11:55:29 +0200 Subject: [PATCH] Now you can set search options so that searching for contacts or forums isn't occult science anymore. --- include/nav.php | 8 +++++++- include/text.php | 5 +++++ mod/dirfind.php | 4 ++-- mod/search.php | 24 +++++++++++++++++++----- view/templates/searchbox.tpl | 7 +++++++ view/theme/vier/templates/nav.tpl | 6 ++++++ 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/include/nav.php b/include/nav.php index 3d27be13be..e1661644d1 100644 --- a/include/nav.php +++ b/include/nav.php @@ -26,7 +26,7 @@ function nav(&$a) { $tpl = get_markup_template('nav.tpl'); $a->page['nav'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => $a->get_baseurl(), '$langselector' => lang_selector(), '$sitelocation' => $nav_info['sitelocation'], '$nav' => $nav_info['nav'], @@ -118,6 +118,12 @@ function nav_info(&$a) { $nav['search'] = array('search', t('Search'), "", t('Search site content')); + $nav['searchoption'] = array( + t("Full Text"), + t("Tags"), + t("Contacts"), + t("Forums")); + $gdirpath = 'directory'; if(strlen(get_config('system','singleuser'))) { diff --git a/include/text.php b/include/text.php index 4747a376fe..f3e44b3ebc 100644 --- a/include/text.php +++ b/include/text.php @@ -995,6 +995,11 @@ function search($s,$id='search-box',$url='/search',$save = false) { '$search_label' => t('Search'), '$save_label' => t('Save'), '$savedsearch' => feature_enabled(local_user(),'savedsearch'), + '$searchoption' => array( + t("Full Text"), + t("Tags"), + t("Contacts"), + t("Forums")) )); }} diff --git a/mod/dirfind.php b/mod/dirfind.php index e70dfe9680..3cee6c1330 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -14,13 +14,13 @@ function dirfind_init(&$a) { -function dirfind_content(&$a) { +function dirfind_content(&$a, $prefix = "") { $community = false; $local = get_config('system','poco_local_search'); - $search = notags(trim($_REQUEST['search'])); + $search = $prefix.notags(trim($_REQUEST['search'])); if(strpos($search,'@') === 0) $search = substr($search,1); diff --git a/mod/search.php b/mod/search.php index a01984d244..d5e0dfb208 100644 --- a/mod/search.php +++ b/mod/search.php @@ -1,4 +1,8 @@ ' . t('Search') . ''; @@ -117,14 +118,27 @@ function search_content(&$a) { $search = substr($search,1); } if(strpos($search,'@') === 0) { - require_once('mod/dirfind.php'); return dirfind_content($a); } if(strpos($search,'!') === 0) { - require_once('mod/dirfind.php'); return dirfind_content($a); } + if(x($_GET,'search-option')) + switch($_GET['search-option']) { + case 'fulltext': + break; + case 'tags': + $tag = true; + break; + case 'contacts': + return dirfind_content($a, "@"); + break; + case 'forums': + return dirfind_content($a, "!"); + break; + } + if(! $search) return $o; diff --git a/view/templates/searchbox.tpl b/view/templates/searchbox.tpl index c3b8752942..b9a01752c0 100644 --- a/view/templates/searchbox.tpl +++ b/view/templates/searchbox.tpl @@ -2,6 +2,13 @@
{{strip}} + + {{if $savedsearch}} diff --git a/view/theme/vier/templates/nav.tpl b/view/theme/vier/templates/nav.tpl index 8a40d6dd77..5483113f33 100644 --- a/view/theme/vier/templates/nav.tpl +++ b/view/theme/vier/templates/nav.tpl @@ -72,6 +72,12 @@
{{/if}} -- 2.39.5