]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Merge pull request #2453 from rabuzarus/1404_reworked_autocomplete
[friendica.git] / include / api.php
index 55e39e3583e3db9d2e005126046603f74bdda16c..305a86ca13e7148de24210c2515ea675a1ffd9f0 100644 (file)
                if ($max_id > 0)
                        $sql_extra = ' AND `item`.`id` <= '.intval($max_id);
 
+               // Not sure why this query was so complicated. We should keep it here for a while,
+               // just to make sure that we really don't need it.
+               //      FROM `item` INNER JOIN (SELECT `uri`,`parent` FROM `item` WHERE `id` = %d) AS `temp1`
+               //      ON (`item`.`thr-parent` = `temp1`.`uri` AND `item`.`parent` = `temp1`.`parent`)
+
                $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
                        `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
                        `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
                        `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
-                       FROM `item` INNER JOIN (SELECT `uri`,`parent` FROM `item` WHERE `id` = %d) AS `temp1`
-                       ON (`item`.`thr-parent` = `temp1`.`uri` AND `item`.`parent` = `temp1`.`parent`), `contact`
-                       WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
-                       AND `item`.`uid` = %d AND `item`.`verb` = '%s' AND `contact`.`id` = `item`.`contact-id`
-                       AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+                       FROM `item`
+                       INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+                       WHERE `item`.`parent` = %d AND `item`.`visible`
+                       AND NOT `item`.`moderated` AND NOT `item`.`deleted`
+                       AND `item`.`uid` = %d AND `item`.`verb` = '%s'
+                       AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
                        AND `item`.`id`>%d $sql_extra
                        ORDER BY `item`.`id` DESC LIMIT %d ,%d",
                        intval($id), intval(api_user()),
                return api_apply_template("timeline", $type, $data);
        }
        api_register_func('api/conversation/show','api_conversation_show', true);
+       api_register_func('api/statusnet/conversation','api_conversation_show', true);
 
 
        /**
                        `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
                        `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
                        `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
-                       FROM `item`, `contact`
+                       FROM `item`  FORCE INDEX (`uid_id`), `contact`
                        WHERE `item`.`uid` = %d AND `verb` = '%s'
                        AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s'))
-                       AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
+                       AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted`
                        AND `contact`.`id` = `item`.`contact-id`
-                       AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
-                       AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention` AND !`ignored`)
+                       AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+                       AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `uid` = %d AND `mention` AND !`ignored`)
                        $sql_extra
                        AND `item`.`id`>%d
                        ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
 
                $statushtml = trim(bbcode($body, false, false));
 
+               $search = array("<br>", "<blockquote>", "</blockquote>",
+                               "<h1>", "</h1>", "<h2>", "</h2>",
+                               "<h3>", "</h3>", "<h4>", "</h4>",
+                               "<h5>", "</h5>", "<h6>", "</h6>");
+               $replace = array("<br>\n", "\n<blockquote>", "</blockquote>\n",
+                               "\n<h1>", "</h1>\n", "\n<h2>", "</h2>\n",
+                               "\n<h3>", "</h3>\n", "\n<h4>", "</h4>\n",
+                               "\n<h5>", "</h5>\n", "\n<h6>", "</h6>\n");
+               $statushtml = str_replace($search, $replace, $statushtml);
+
                if ($item['title'] != "")
                        $statushtml = "<h4>".bbcode($item['title'])."</h4>\n".$statushtml;