mirror of
https://github.com/friendica/friendica
synced 2024-11-10 13:42:53 +00:00
Merge pull request #1848 from annando/1508-search-options
Visible search options
This commit is contained in:
commit
ccc5533069
6 changed files with 63 additions and 18 deletions
|
@ -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'))) {
|
||||
|
|
|
@ -986,16 +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'),
|
||||
));
|
||||
|
||||
$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"));
|
||||
|
||||
return replace_macros(get_markup_template('searchbox.tpl'), $values);
|
||||
}}
|
||||
|
||||
if(! function_exists('valid_email')) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?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() {
|
||||
|
||||
|
@ -92,9 +96,6 @@ function search_content(&$a) {
|
|||
|
||||
nav_set_selected('search');
|
||||
|
||||
require_once("include/bbcode.php");
|
||||
require_once('include/security.php');
|
||||
require_once('include/conversation.php');
|
||||
|
||||
$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) {
|
||||
$tag = true;
|
||||
$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;
|
||||
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
<form action="{{$action_url}}" method="get" >
|
||||
{{strip}}
|
||||
<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}}" />
|
||||
{{if $savedsearch}}
|
||||
<input type="submit" name="save" id="search-save" value="{{$save_label}}" />
|
||||
|
|
|
@ -72,6 +72,12 @@
|
|||
<li role="search" id="search-box">
|
||||
<form method="get" action="{{$nav.search.0}}">
|
||||
<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>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in a new issue