]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Adding a search notice stream object
authorEvan Prodromou <evan@status.net>
Mon, 12 Nov 2012 02:05:13 +0000 (21:05 -0500)
committerEvan Prodromou <evan@status.net>
Mon, 12 Nov 2012 02:05:13 +0000 (21:05 -0500)
actions/apisearchjson.php

index 79b26665541bb2b09364019c34acca81839ecbc3..7ee353440f849423e6482701912a62589bded025 100644 (file)
@@ -89,6 +89,12 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction
         $this->since_id = $this->trimmed('since_id');
         $this->geocode  = $this->trimmed('geocode');
 
+        if (!empty($this->auth_user)) {
+            $this->auth_profile = $this->auth_user->getProfile();
+        } else {
+            $this->auth_profile = null;
+        }
+
         return true;
     }
 
@@ -112,21 +118,13 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction
      */
     function showResults()
     {
-        // TODO: Support search operators like from: and to:, boolean, etc.
+        $q = strtolower($this->query);
 
-        $notice = new Notice();
+        // TODO: Support search operators like from: and to:, boolean, etc.
 
-        // lcase it for comparison
-        $q = strtolower($this->query);
+        $stream = new SearchNoticeStream($q, $this->auth_profile);
 
-        $search_engine = $notice->getSearchEngine('notice');
-        $search_engine->set_sort_mode('chron');
-        $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true);
-        if (false === $search_engine->query($q)) {
-            $cnt = 0;
-        } else {
-            $cnt = $notice->find();
-        }
+        $notice = $stream->getNotices(($this->page - 1) * $this->rpp, $this->rpp + 1);
 
         // TODO: max_id, lang, geocode