]> git.mxchange.org Git - friendica.git/blobdiff - mod/search.php
The autofollow option is moved from the addons to the core.
[friendica.git] / mod / search.php
index ee9e48bc62f0df5b7e9de5bcac55bd996e4bc4fa..339efc92db5750a075851e428424615aea91686e 100644 (file)
@@ -7,7 +7,7 @@ function search_saved_searches() {
        if(! feature_enabled(local_user(),'savedsearch'))
                return $o;
 
-       $r = q("select `id`,`term` from `search` WHERE `uid` = %d",
+       $r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
                intval(local_user())
        );
 
@@ -15,11 +15,11 @@ function search_saved_searches() {
                $saved = array();
                foreach($r as $rr) {
                        $saved[] = array(
-                               'id'            => $rr['id'],
-                               'term'                  => $rr['term'],
-                               'encodedterm'   => urlencode($rr['term']),
-                               'delete'                => t('Remove term'),
-                               'selected'              => ($search==$rr['term']),
+                               'id'            => $rr['id'],
+                               'term'          => $rr['term'],
+                               'encodedterm'   => urlencode($rr['term']),
+                               'delete'        => t('Remove term'),
+                               'selected'      => ($search==$rr['term']),
                        );
                }
 
@@ -27,10 +27,10 @@ function search_saved_searches() {
                $tpl = get_markup_template("saved_searches_aside.tpl");
 
                $o .= replace_macros($tpl, array(
-                       '$title'         => t('Saved Searches'),
-                       '$add'           => '',
-                       '$searchbox' => '',
-                       '$saved'         => $saved,
+                       '$title'        => t('Saved Searches'),
+                       '$add'          => '',
+                       '$searchbox'    => '',
+                       '$saved'        => $saved,
                ));
        }
 
@@ -45,12 +45,12 @@ function search_init(&$a) {
 
        if(local_user()) {
                if(x($_GET,'save') && $search) {
-                       $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1",
+                       $r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
                                intval(local_user()),
                                dbesc($search)
                        );
                        if(! count($r)) {
-                               q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ",
+                               q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')",
                                        intval(local_user()),
                                        dbesc($search)
                                );
@@ -133,9 +133,9 @@ function search_content(&$a) {
        // No items will be shown if the member has a blocked profile wall.
 
        if($tag) {
-               logger("Start tag search for '".$search."'");
+               logger("Start tag search for '".$search."'", LOGGER_DEBUG);
 
-               $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
+               $r = q("SELECT STRAIGHT_JOIN `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
                                `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`
@@ -143,12 +143,12 @@ function search_content(&$a) {
                                INNER JOIN `item` ON `item`.`id`=`term`.`oid`
                                INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
                        WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
-                               AND `term`.`uid` IN (%d,0) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s' AND `term`.`guid` != ''
-                       GROUP BY `term`.`guid` ORDER BY term.created DESC LIMIT %d , %d ",
+                               AND (`term`.`uid` = 0 OR (`term`.`uid` = %d AND NOT `term`.`global`)) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s'
+                       ORDER BY term.created DESC LIMIT %d , %d ",
                                intval(local_user()), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)),
                                intval($a->pager['start']), intval($a->pager['itemspage']));
        } else {
-               logger("Start fulltext search for '".$search."'");
+               logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
 
                if (get_config('system','use_fulltext_engine')) {
                        $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
@@ -156,7 +156,7 @@ function search_content(&$a) {
                        $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
                }
 
-               $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
+               $r = q("SELECT STRAIGHT_JOIN `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
                                `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`
@@ -177,20 +177,20 @@ function search_content(&$a) {
 
 
        if($tag)
-               $o .= '<h2>Items tagged with: ' . $search . '</h2>';
+               $title = sprintf( t('Items tagged with: %s'), $search);
        else
-               $o .= '<h2>Search results for: ' . $search . '</h2>';
+               $title = sprintf( t('Search results for: %s'), $search);
 
-       logger("Start Conversation");
+       $o .= replace_macros(get_markup_template("section_title.tpl"),array(
+               '$title' => $title
+       ));
+
+       logger("Start Conversation for '".$search."'", LOGGER_DEBUG);
        $o .= conversation($a,$r,'search',false);
 
-       logger("Start Pager");
-       if(!get_config('system', 'old_pager')) {
-               $o .= alt_pager($a,count($r));
-       } else {
-               $o .= paginate($a);
-       }
-       logger("Done");
+       $o .= alt_pager($a,count($r));
+
+       logger("Done '".$search."'", LOGGER_DEBUG);
 
        return $o;
 }