Adding a search notice stream object

This commit is contained in:
Evan Prodromou 2012-11-11 21:05:13 -05:00
parent 35499a9952
commit 64288a62f8

View File

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