]> git.mxchange.org Git - friendica.git/commitdiff
Saved searches now can search for tags as well
authorMichael Vogel <icarus@dabo.de>
Sat, 26 May 2012 09:51:48 +0000 (11:51 +0200)
committerMichael Vogel <icarus@dabo.de>
Sat, 26 May 2012 09:51:48 +0000 (11:51 +0200)
mod/network.php
mod/search.php

index f54d055d385343597631943bc78f0b2a2a3a4714..6b4fa9a5b3e899852fe3df0e1450d4dd4644f184 100644 (file)
@@ -402,10 +402,22 @@ function network_content(&$a, $update = 0) {
 
        if(x($_GET,'search')) {
                $search = escape_tags($_GET['search']);
-               $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
-                       dbesc(protect_sprintf('%' . $search . '%')),
-                       dbesc(protect_sprintf('%]' . $search . '[%'))
-               );
+               if (get_config('system','use_fulltext_engine')) {
+                       if(strpos($search,'#') === 0)
+                               $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
+                                       dbesc(protect_sprintf($search))
+                               );
+                       else
+                               $sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
+                                       dbesc(protect_sprintf($search)),
+                                       dbesc(protect_sprintf($search))
+                               );
+               } else {
+                       $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
+                                       dbesc(protect_sprintf('%' . $search . '%')),
+                                       dbesc(protect_sprintf('%]' . $search . '[%'))
+                       );
+               }
        }
        if(strlen($file)) {
                $sql_extra .= file_tag_file_query('item',unxmlify($file));
index ac51346963bbde408520a8b8168fb0206b04c2c1..d4cd9d96763c7d0838fa2fc72b3e0e00b345df6a 100644 (file)
@@ -71,7 +71,7 @@ function search_content(&$a) {
                notice( t('Public access denied.') . EOL);
                return;
        }
-       
+
        nav_set_selected('search');
 
        require_once("include/bbcode.php");
@@ -96,7 +96,6 @@ function search_content(&$a) {
 
        $o .= search($search,'search-box','/search',((local_user()) ? true : false));
 
-
        if(strpos($search,'#') === 0) {
                $tag = true;
                $search = substr($search,1);