diff options
author | Vasudev Kamath <kamathvasudev@gmail.com> | 2012-06-04 12:04:17 +0530 |
---|---|---|
committer | Vasudev Kamath <kamathvasudev@gmail.com> | 2012-06-04 12:04:17 +0530 |
commit | 12474e3c2eb21e4b5f9f6cd4b9d223f1f39bfe89 (patch) | |
tree | 49e5e7dd30e1b1263fa5a9c9921b4a59758d94bd /mod/search.php | |
parent | 3a45d4f9e0af301b8fdd4d509fc7ffe7514fb519 (diff) | |
parent | ca105f1c669950768a1f4cd6b93f471cabbc5114 (diff) | |
download | volse-hubzilla-12474e3c2eb21e4b5f9f6cd4b9d223f1f39bfe89.tar.gz volse-hubzilla-12474e3c2eb21e4b5f9f6cd4b9d223f1f39bfe89.tar.bz2 volse-hubzilla-12474e3c2eb21e4b5f9f6cd4b9d223f1f39bfe89.zip |
Merge branch 'master' of git://github.com/friendica/friendica
Diffstat (limited to 'mod/search.php')
-rw-r--r-- | mod/search.php | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/mod/search.php b/mod/search.php index d467764b0..320ffddce 100644 --- a/mod/search.php +++ b/mod/search.php @@ -71,7 +71,7 @@ function search_content(&$a) { notice( t('Public access denied.') . EOL); return; } - + nav_set_selected('search'); require_once("include/bbcode.php"); @@ -80,7 +80,7 @@ function search_content(&$a) { $o = '<div id="live-search"></div>' . "\r\n"; - $o .= '<h3>' . t('Search This Site') . '</h3>'; + $o .= '<h3>' . t('Search') . '</h3>'; if(x($a->data,'search')) $search = notags(trim($a->data['search'])); @@ -96,13 +96,29 @@ function search_content(&$a) { $o .= search($search,'search-box','/search',((local_user()) ? true : 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(! $search) return $o; - if($tag) - $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); - else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + if (get_config('system','use_fulltext_engine')) { + if($tag) + $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search))); + else + $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(protect_sprintf($search))); + } else { + if($tag) + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . protect_sprintf(preg_quote($search)) . '\\[')); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); + } @@ -130,7 +146,7 @@ function search_content(&$a) { } $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname` |