From 64288a62f816ed76114b456e07d3e515daddee85 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 11 Nov 2012 21:05:13 -0500 Subject: [PATCH] Adding a search notice stream object --- actions/apisearchjson.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/actions/apisearchjson.php b/actions/apisearchjson.php index 79b2666554..7ee353440f 100644 --- a/actions/apisearchjson.php +++ b/actions/apisearchjson.php @@ -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 -- 2.39.2