本文整理汇总了PHP中Notice::getSearchEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::getSearchEngine方法的具体用法?PHP Notice::getSearchEngine怎么用?PHP Notice::getSearchEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::getSearchEngine方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNoticeIds
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;
}
示例2: getNotices
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;
}
示例3: getNotices
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;
}
示例4: getNotices
/**
* 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;
}
示例5: showResults
/**
* 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));
}
示例6: showResults
/**
* 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');
}
示例7: showResults
/**
* 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);
}
示例8: showResults
/**
* 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));
}