]> git.mxchange.org Git - friendica.git/blobdiff - mod/search.php
backward compatibility
[friendica.git] / mod / search.php
index c0e6809ec019772c4b73d5b3ce76d6459c72f4e8..a6a4b613fcb5b87a3cff55dce47f24e2f5ddc516 100644 (file)
@@ -1,13 +1,25 @@
 <?php
 
 
+function search_post(&$a) {
+       if(x($_POST,'search'))
+               $a->data['search'] = $_POST['search'];
+}
+
+
 function search_content(&$a) {
 
+       if(x($_SESSION,'theme'))
+               unset($_SESSION['theme']);
+
        $o = '<div id="live-search"></div>' . "\r\n";
 
        $o .= '<h3>' . t('Search') . '</h3>';
 
-       $search = ((x($_GET,'search')) ? $_GET['search'] : '');
+       if(x($a->data,'search'))
+               $search = notags(trim($a->data['search']));
+       else
+               $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
 
        $o .= search($search);
 
@@ -27,10 +39,11 @@ function search_content(&$a) {
        $r = q("SELECT COUNT(*) AS `total`
                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
-               AND `wall` = 1
+               AND ( `wall` = 1 OR `contact`.`uid` = %d )
                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
                $sql_extra ",
+               intval(local_user()),
                dbesc($search)
        );
 
@@ -50,11 +63,12 @@ function search_content(&$a) {
                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` 
                WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
-               AND `wall` = 1
+               AND ( `wall` = 1 OR `contact`.`uid` = %d )
                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
                $sql_extra
                ORDER BY `parent` DESC ",
+               intval(local_user()),
                dbesc($search)
        );
 
@@ -67,6 +81,7 @@ function search_content(&$a) {
 
                foreach($r as $item) {
 
+                       $total       = 0;
                        $comment     = '';
                        $owner_url   = '';
                        $owner_photo = '';
@@ -77,6 +92,8 @@ function search_content(&$a) {
                                && ($item['id'] != $item['parent']))
                                continue;
 
+                       $total ++;
+
                        $profile_name   = ((strlen($item['author-name']))   ? $item['author-name']   : $item['name']);
                        $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
                        $profile_link   = ((strlen($item['author-link']))   ? $item['author-link']   : $item['url']);
@@ -105,7 +122,7 @@ function search_content(&$a) {
                                '$body' => bbcode($item['body']),
                                '$ago' => relative_date($item['created']),
                                '$location' => $location,
-                               '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
+                               '$indent' => '',
                                '$owner_url' => $owner_url,
                                '$owner_photo' => $owner_photo,
                                '$owner_name' => $owner_name,
@@ -115,6 +132,16 @@ function search_content(&$a) {
 
                }
        }
+
+
+       if(! $r[0]['total']) {
+               notice('No results.');
+               return $o;
+       }
+
+
+       $o .= paginate($a);
+
        return $o;
 }