]> git.mxchange.org Git - friendica.git/blobdiff - mod/search.php
Merge pull request #37 from fabrixxm/master
[friendica.git] / mod / search.php
index 034794e179db10d2137967a270fdf3778647ad28..e2c365fd3ace99bbff38ebb5475db0411e70e265 100644 (file)
@@ -15,7 +15,7 @@ function search_saved_searches() {
                foreach($r as $rr) {
                        $o .= '<li class="saved-search-li clear"><a href="search/?f=&remove=1&search=' . $rr['term'] . '" class="icon drophide savedsearchdrop" title="' . t('Remove term') . '" onclick="return confirmDelete();" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a> <a href="search/?f=&search=' . $rr['term'] . '" class="savedsearchterm" >' . $rr['term'] . '</a></li>' . "\r\n";
                }
-               $o .= '</ul></div>' . "\r\n";
+               $o .= '</ul><div class="clear"></div></div>' . "\r\n";
        }               
 
        return $o;
@@ -50,6 +50,9 @@ function search_init(&$a) {
                $a->page['aside'] .= search_saved_searches();
 
        }
+       else
+               unset($_SESSION['theme']);
+
 
 
 }
@@ -75,12 +78,9 @@ function search_content(&$a) {
        require_once('include/security.php');
        require_once('include/conversation.php');
 
-       if(x($_SESSION,'theme'))
-               unset($_SESSION['theme']);
-
        $o = '<div id="live-search"></div>' . "\r\n";
 
-       $o .= '<h3>' . t('Search') . '</h3>';
+       $o .= '<h3>' . t('Search This Site') . '</h3>';
 
        if(x($a->data,'search'))
                $search = notags(trim($a->data['search']));
@@ -96,12 +96,15 @@ function search_content(&$a) {
        // Only public wall posts can be shown
        // OR your own posts if you are a logged in member
 
-       $s_bool  = "AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )";
-       $s_regx  = "AND `item`.`body` REGEXP '%s' ";
 
-       if(mb_strlen($search) >= 3)
-               $search_alg = $s_bool;
-       else
+//     $s_bool  = sprintf("AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )", dbesc($search));
+       $s_regx  = sprintf("AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )", 
+               dbesc($search), dbesc('\\]' . $search . '\\['));
+
+//     if(mb_strlen($search) >= 3)
+//             $search_alg = $s_bool;
+//     else
+
                $search_alg = $s_regx;
 
        $r = q("SELECT COUNT(*) AS `total`
@@ -111,8 +114,7 @@ function search_content(&$a) {
                        OR `item`.`uid` = %d )
                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                $search_alg ",
-               intval(local_user()),
-               dbesc($search)
+               intval(local_user())
        );
 
        if(count($r))
@@ -137,7 +139,6 @@ function search_content(&$a) {
                $search_alg
                ORDER BY `received` DESC LIMIT %d , %d ",
                intval(local_user()),
-               dbesc($search),
                intval($a->pager['start']),
                intval($a->pager['itemspage'])