Merge pull request #1848 from annando/1508-search-options

Visible search options
This commit is contained in:
Tobias Diekershoff 2015-08-24 12:35:04 +02:00
commit ccc5533069
6 changed files with 63 additions and 18 deletions

View file

@ -26,7 +26,7 @@ function nav(&$a) {
$tpl = get_markup_template('nav.tpl'); $tpl = get_markup_template('nav.tpl');
$a->page['nav'] .= replace_macros($tpl, array( $a->page['nav'] .= replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => $a->get_baseurl(),
'$langselector' => lang_selector(), '$langselector' => lang_selector(),
'$sitelocation' => $nav_info['sitelocation'], '$sitelocation' => $nav_info['sitelocation'],
'$nav' => $nav_info['nav'], '$nav' => $nav_info['nav'],
@ -118,6 +118,12 @@ function nav_info(&$a) {
$nav['search'] = array('search', t('Search'), "", t('Search site content')); $nav['search'] = array('search', t('Search'), "", t('Search site content'));
$nav['searchoption'] = array(
t("Full Text"),
t("Tags"),
t("Contacts"),
t("Forums"));
$gdirpath = 'directory'; $gdirpath = 'directory';
if(strlen(get_config('system','singleuser'))) { if(strlen(get_config('system','singleuser'))) {

View file

@ -986,16 +986,26 @@ if(! function_exists('search')) {
* @param string $url search url * @param string $url search url
* @param boolean $savedsearch show save search button * @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(); $a = get_app();
return replace_macros(get_markup_template('searchbox.tpl'), array(
'$s' => $s, $values = array(
'$id' => $id, '$s' => $s,
'$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url, '$id' => $id,
'$search_label' => t('Search'), '$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url,
'$save_label' => t('Save'), '$search_label' => t('Search'),
'$savedsearch' => feature_enabled(local_user(),'savedsearch'), '$save_label' => t('Save'),
)); '$savedsearch' => feature_enabled(local_user(),'savedsearch'),
);
if (!$aside)
$values['$searchoption'] = array(
t("Full Text"),
t("Tags"),
t("Contacts"),
t("Forums"));
return replace_macros(get_markup_template('searchbox.tpl'), $values);
}} }}
if(! function_exists('valid_email')) { if(! function_exists('valid_email')) {

View file

@ -14,13 +14,13 @@ function dirfind_init(&$a) {
function dirfind_content(&$a) { function dirfind_content(&$a, $prefix = "") {
$community = false; $community = false;
$local = get_config('system','poco_local_search'); $local = get_config('system','poco_local_search');
$search = notags(trim($_REQUEST['search'])); $search = $prefix.notags(trim($_REQUEST['search']));
if(strpos($search,'@') === 0) if(strpos($search,'@') === 0)
$search = substr($search,1); $search = substr($search,1);

View file

@ -1,4 +1,8 @@
<?php <?php
require_once("include/bbcode.php");
require_once('include/security.php');
require_once('include/conversation.php');
require_once('mod/dirfind.php');
function search_saved_searches() { function search_saved_searches() {
@ -92,9 +96,6 @@ function search_content(&$a) {
nav_set_selected('search'); nav_set_selected('search');
require_once("include/bbcode.php");
require_once('include/security.php');
require_once('include/conversation.php');
$o = '<h3>' . t('Search') . '</h3>'; $o = '<h3>' . t('Search') . '</h3>';
@ -110,21 +111,34 @@ 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) { if(strpos($search,'#') === 0) {
$tag = true; $tag = true;
$search = substr($search,1); $search = substr($search,1);
} }
if(strpos($search,'@') === 0) { if(strpos($search,'@') === 0) {
require_once('mod/dirfind.php');
return dirfind_content($a); return dirfind_content($a);
} }
if(strpos($search,'!') === 0) { if(strpos($search,'!') === 0) {
require_once('mod/dirfind.php');
return dirfind_content($a); 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) if(! $search)
return $o; return $o;

View file

@ -2,6 +2,15 @@
<form action="{{$action_url}}" method="get" > <form action="{{$action_url}}" method="get" >
{{strip}} {{strip}}
<input type="text" name="search" id="search-text" placeholder="{{$search_label}}" value="{{$s}}" /> <input type="text" name="search" id="search-text" placeholder="{{$search_label}}" value="{{$s}}" />
{{if $searchoption}}
<select name="search-option" id="search-options">
<option value="fulltext">{{$searchoption.0}}</option>
<option value="tags">{{$searchoption.1}}</option>
<option value="contacts">{{$searchoption.2}}</option>
<option value="forums">{{$searchoption.3}}</option>
</select>
{{/if}}
<input type="submit" name="submit" id="search-submit" value="{{$search_label}}" /> <input type="submit" name="submit" id="search-submit" value="{{$search_label}}" />
{{if $savedsearch}} {{if $savedsearch}}
<input type="submit" name="save" id="search-save" value="{{$save_label}}" /> <input type="submit" name="save" id="search-save" value="{{$save_label}}" />

View file

@ -72,6 +72,12 @@
<li role="search" id="search-box"> <li role="search" id="search-box">
<form method="get" action="{{$nav.search.0}}"> <form method="get" action="{{$nav.search.0}}">
<input accesskey="s" id="search-text" class="nav-menu-search" type="text" value="" name="search"> <input accesskey="s" id="search-text" class="nav-menu-search" type="text" value="" name="search">
<select name="search-option">
<option value="fulltext">{{$nav.searchoption.0}}</option>
<option value="tags">{{$nav.searchoption.1}}</option>
<option value="contacts">{{$nav.searchoption.2}}</option>
<option value="forums">{{$nav.searchoption.3}}</option>
</select>
</form> </form>
</li> </li>
{{/if}} {{/if}}