]> git.mxchange.org Git - friendica.git/blobdiff - mod/search.php
Update use statement lists with new Friendica\Database\dba class
[friendica.git] / mod / search.php
index 6580246e4a4122faba4f94aeb0a216dddffca44b..b425464dcc40bb2f31e2c1e9d14fb35fd2683606 100644 (file)
@@ -2,6 +2,7 @@
 /**
  * @file mod/search.php
  */
+
 use Friendica\App;
 use Friendica\Content\Feature;
 use Friendica\Content\Nav;
@@ -9,6 +10,7 @@ use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
+use Friendica\Database\dba;
 use Friendica\Database\DBM;
 use Friendica\Model\Item;
 
@@ -21,7 +23,7 @@ function search_saved_searches() {
        $o = '';
        $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
 
-       if (! Feature::isEnabled(local_user(),'savedsearch'))
+       if (!Feature::isEnabled(local_user(),'savedsearch'))
                return $o;
 
        $r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
@@ -74,6 +76,11 @@ function search_init(App $a) {
                        dba::delete('search', ['uid' => local_user(), 'term' => $search]);
                }
 
+               /// @todo Check if there is a case at all that "aside" is prefilled here
+               if (!isset($a->page['aside'])) {
+                       $a->page['aside'] = '';
+               }
+
                $a->page['aside'] .= search_saved_searches();
 
        } else {
@@ -184,7 +191,7 @@ function search_content(App $a) {
                                break;
                }
 
-       if (! $search)
+       if (!$search)
                return $o;
 
        if (Config::get('system','only_tag_search'))
@@ -211,8 +218,13 @@ function search_content(App $a) {
                }
                dba::close($terms);
 
-               $items = Item::selectForUser(local_user(), [], ['id' => array_reverse($itemids)]);
-               $r = dba::inArray($items);
+               if (!empty($itemids)) {
+                       $params = ['order' => ['id' => true]];
+                       $items = Item::selectForUser(local_user(), [], ['id' => $itemids], $params);
+                       $r = Item::inArray($items);
+               } else {
+                       $r = [];
+               }
        } else {
                logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
 
@@ -222,7 +234,7 @@ function search_content(App $a) {
                $params = ['order' => ['id' => true],
                        'limit' => [$a->pager['start'], $a->pager['itemspage']]];
                $items = Item::selectForUser(local_user(), [], $condition, $params);
-               $r = dba::inArray($items);
+               $r = Item::inArray($items);
        }
 
        if (!DBM::is_result($r)) {
@@ -250,4 +262,3 @@ function search_content(App $a) {
 
        return $o;
 }
-