From 3ff196f00dbad7e1efe6bb32cefbd7ece24127d4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 24 Aug 2015 11:55:29 +0200 Subject: [PATCH 1/2] 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 3d27be13b..e1661644d 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 4747a376f..f3e44b3eb 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 e70dfe968..3cee6c133 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 a01984d24..d5e0dfb20 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 c3b875294..b9a01752c 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 8a40d6dd7..5483113f3 100644 --- a/view/theme/vier/templates/nav.tpl +++ b/view/theme/vier/templates/nav.tpl @@ -72,6 +72,12 @@
{{/if}} From 3bca2db11bf45fb132cc06185d57792b2bf44930 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 24 Aug 2015 12:12:14 +0200 Subject: [PATCH 2/2] Don't show search options in side bar. --- include/text.php | 27 ++++++++++++++++----------- mod/search.php | 2 +- view/templates/searchbox.tpl | 4 +++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/include/text.php b/include/text.php index f3e44b3eb..9a65224af 100644 --- a/include/text.php +++ b/include/text.php @@ -986,21 +986,26 @@ if(! function_exists('search')) { * @param string $url search url * @param boolean $savedsearch show save search button */ -function search($s,$id='search-box',$url='/search',$save = false) { +function search($s,$id='search-box',$url='/search',$save = false, $aside = true) { $a = get_app(); - return replace_macros(get_markup_template('searchbox.tpl'), array( - '$s' => $s, - '$id' => $id, - '$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url, - '$search_label' => t('Search'), - '$save_label' => t('Save'), - '$savedsearch' => feature_enabled(local_user(),'savedsearch'), - '$searchoption' => array( + + $values = array( + '$s' => $s, + '$id' => $id, + '$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url, + '$search_label' => t('Search'), + '$save_label' => t('Save'), + '$savedsearch' => feature_enabled(local_user(),'savedsearch'), + ); + + if (!$aside) + $values['$searchoption'] = array( t("Full Text"), t("Tags"), t("Contacts"), - t("Forums")) - )); + t("Forums")); + + return replace_macros(get_markup_template('searchbox.tpl'), $values); }} if(! function_exists('valid_email')) { diff --git a/mod/search.php b/mod/search.php index d5e0dfb20..d9a2852dd 100644 --- a/mod/search.php +++ b/mod/search.php @@ -111,7 +111,7 @@ function search_content(&$a) { } - $o .= search($search,'search-box','/search',((local_user()) ? true : false)); + $o .= search($search,'search-box','/search',((local_user()) ? true : false), false); if(strpos($search,'#') === 0) { $tag = true; diff --git a/view/templates/searchbox.tpl b/view/templates/searchbox.tpl index b9a01752c..9c1be50cf 100644 --- a/view/templates/searchbox.tpl +++ b/view/templates/searchbox.tpl @@ -2,12 +2,14 @@
{{strip}} - + {{/if}} {{if $savedsearch}}