function getNoticeIds($offset, $limit, $since_id, $max_id) { $notice = new Notice(); $search_engine = $notice->getSearchEngine('notice'); $search_engine->set_sort_mode('chron'); $search_engine->limit($offset, $limit); $ids = array(); // wtf? $search_engine->query($this->q); if ($notice->find()) { while ($notice->fetch()) { $ids[] = $notice->id; } } return $ids; }
function getNotices($limit = 0) { $q = $this->trimmed('q'); $notices = array(); $notice = new Notice(); $search_engine = $notice->getSearchEngine('identica_notices'); $search_engine->set_sort_mode('chron'); if (!$limit) { $limit = 20; } $search_engine->limit(0, $limit, true); $search_engine->query($q); $notice->find(); while ($notice->fetch()) { $notices[] = clone $notice; } return $notices; }
protected function getNotices() { $q = $this->trimmed('q'); $notices = array(); $notice = new Notice(); $search_engine = $notice->getSearchEngine('notice'); $search_engine->set_sort_mode('chron'); $search_engine->limit(0, $this->limit, true); if (false === $search_engine->query($q)) { $cnt = 0; } else { $cnt = $notice->find(); } if ($cnt > 0) { while ($notice->fetch()) { $notices[] = clone $notice; } } return $notices; }
/** * Get the notices to output as results. This also sets some class * attrs so we can use them to calculate pagination, and output * since_id and max_id. * * @return array an array of Notice objects sorted in reverse chron */ function getNotices() { // TODO: Support search operators like from: and to:, boolean, etc. $notices = array(); $notice = new Notice(); // lcase it for comparison $q = strtolower($this->query); $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)) { $this->cnt = 0; } else { $this->cnt = $notice->find(); } $cnt = 0; $this->max_id = 0; if ($this->cnt > 0) { while ($notice->fetch()) { ++$cnt; if (!$this->max_id) { $this->max_id = $notice->id; } if ($this->since_id && $notice->id <= $this->since_id) { break; } if ($cnt > $this->rpp) { break; } $notices[] = clone $notice; } } return $notices; }
/** * Show results * * @param string $q search query * @param integer $page page number * * @return void */ function showResults($q, $page) { $notice = new Notice(); $search_engine = $notice->getSearchEngine('notice'); $search_engine->set_sort_mode('chron'); // Ask for an extra to see if there's more. $search_engine->limit(($page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if (false === $search_engine->query($q)) { $cnt = 0; } else { $cnt = $notice->find(); } if ($cnt === 0) { $this->element('p', 'error', _('No results.')); $this->searchSuggestions($q); if (common_logged_in()) { $message = sprintf(_('Be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q)); } else { $message = sprintf(_('Why not [register an account](%%%%action.register%%%%) and be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q)); } $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); return; } $terms = preg_split('/[\\s,]+/', $q); $nl = new SearchNoticeList($notice, $this, $terms); $cnt = $nl->show(); $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE, $page, 'noticesearch', array('q' => $q)); }
/** * Show search results * * @return void */ function showResults() { // TODO: Support search operators like from: and to:, boolean, etc. $notice = new Notice(); // lcase it for comparison $q = strtolower($this->query); $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(); } // TODO: since_id, lang, geocode $results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page); $this->initDocument('json'); $results->show(); $this->endDocument('json'); }
/** * Show search results * * @return void */ function showResults() { // TODO: Support search operators like from: and to:, boolean, etc. $notice = new Notice(); $this->notices = array(); $search_engine = $notice->getSearchEngine('notice'); $search_engine->set_sort_mode('chron'); $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1); if ($search_engine->query($this->query)) { $cnt = $notice->find(); $this->notices = $notice->fetchAll(); } $this->showJsonTimeline($this->notices); }
/** * Show results * * @param string $q search query * @param integer $page page number * * @return void */ function showResults($q, $page) { $notice = new Notice(); $search_engine = $notice->getSearchEngine('identica_notices'); $search_engine->set_sort_mode('chron'); // Ask for an extra to see if there's more. $search_engine->limit(($page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if (false === $search_engine->query($q)) { $cnt = 0; } else { $cnt = $notice->find(); } if ($cnt === 0) { $this->element('p', 'error', _('No results')); return; } $terms = preg_split('/[\\s,]+/', $q); $nl = new SearchNoticeList($notice, $this, $terms); $cnt = $nl->show(); $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'noticesearch', array('q' => $q)); }