本文整理汇总了PHP中Profile::getSearchEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::getSearchEngine方法的具体用法?PHP Profile::getSearchEngine怎么用?PHP Profile::getSearchEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::getSearchEngine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showResults
function showResults($q, $page)
{
$profile = new Profile();
$search_engine = $profile->getSearchEngine('profile');
$search_engine->set_sort_mode('chron');
// Ask for an extra to see if there's more.
$search_engine->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
if (false === $search_engine->query($q)) {
$cnt = 0;
} else {
$cnt = $profile->find();
}
if ($cnt > 0) {
$terms = preg_split('/[\\s,]+/', $q);
$results = new PeopleSearchResults($profile, $terms, $this);
$results->show();
$profile->free();
$this->pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'peoplesearch', array('q' => $q));
} else {
// TRANS: Message on the "People search" page where a query has no results.
$this->element('p', 'error', _('No results.'));
$this->searchSuggestions($q);
$profile->free();
}
}
示例2: showResults
/**
* Search for users matching the query and spit the results out
* as a quick-n-dirty JSON document
*
* @return void
*/
function showResults()
{
$people = array();
$profile = new Profile();
$search_engine = $profile->getSearchEngine('profile');
$search_engine->set_sort_mode('nickname_desc');
$search_engine->limit(0, 10);
$search_engine->query(strtolower($this->query . '*'));
$cnt = $profile->find();
if ($cnt > 0) {
$sql = 'SELECT profile.* FROM profile, user WHERE profile.id = user.id ' . ' AND LEFT(LOWER(profile.nickname), ' . strlen($this->query) . ') = \'%s\' ' . ' LIMIT 0, 10';
$profile->query(sprintf($sql, $this->query));
}
while ($profile->fetch()) {
$people[] = $profile->nickname;
}
header('Content-Type: application/json; charset=utf-8');
print json_encode($people);
}
示例3: showResults
function showResults($q, $page)
{
$profile = new Profile();
// lcase it for comparison
// $q = strtolower($q);
$search_engine = $profile->getSearchEngine('identica_people');
$search_engine->set_sort_mode('chron');
// Ask for an extra to see if there's more.
$search_engine->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
if (false === $search_engine->query($q)) {
$cnt = 0;
} else {
$cnt = $profile->find();
}
if ($cnt > 0) {
$terms = preg_split('/[\\s,]+/', $q);
$results = new PeopleSearchResults($profile, $terms, $this);
$results->show();
} else {
$this->element('p', 'error', _('No results'));
}
$profile->free();
$this->pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'peoplesearch', array('q' => $q));
}
示例4: getUsers
function getUsers()
{
$profile = new Profile();
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
if (isset($this->q)) {
// User is searching via query
$search_engine = $profile->getSearchEngine('profile');
$mode = 'reverse_chron';
if ($this->sort == 'nickname') {
if ($this->reverse) {
$mode = 'nickname_desc';
} else {
$mode = 'nickname_asc';
}
} else {
if ($this->reverse) {
$mode = 'chron';
}
}
$search_engine->set_sort_mode($mode);
$search_engine->limit($offset, $limit);
$search_engine->query($this->q);
$profile->find();
} else {
// User is browsing via AlphaNav
$sort = $this->getSortKey();
$sql = 'SELECT profile.* FROM profile, user WHERE profile.id = user.id';
switch ($this->filter) {
case 'all':
// NOOP
break;
case '0-9':
$sql .= ' AND LEFT(profile.nickname, 1) BETWEEN \'0\' AND \'9\'';
break;
default:
$sql .= sprintf(' AND LEFT(LOWER(profile.nickname), 1) = \'%s\'', $this->filter);
}
$sql .= sprintf(' ORDER BY profile.%s %s, profile.nickname ASC LIMIT %d, %d', $sort, $this->reverse ? 'DESC' : 'ASC', $offset, $limit);
$profile->query($sql);
}
return $profile;
}
示例5: getResults
function getResults()
{
$profiles = array();
$q = $this->arg('q');
$q = strtolower($q);
if (strlen($q) < 3) {
// TRANS: Error message in case a search is shorter than three characters.
$this->msg = _('The search string must be at least 3 characters long.');
}
$page = $this->arg('page');
$page = (int) (empty($page) ? 1 : $page);
$profile = new Profile();
$search_engine = $profile->getSearchEngine('profile');
if (Event::handle('StartProfileCompletionSearch', array($this, &$profile, $search_engine))) {
$search_engine->set_sort_mode('chron');
$search_engine->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
if (false === $search_engine->query($q)) {
$cnt = 0;
} else {
$cnt = $profile->find();
}
// @todo FIXME: Call-time pass-by-reference has been deprecated.
Event::handle('EndProfileCompletionSearch', $this, &$profile, $search_engine);
}
while ($profile->fetch()) {
$profiles[] = clone $profile;
}
return $this->filter($profiles);
}
示例6: getUsers
function getUsers()
{
$profile = new Profile();
// Comment this out or disable to get global profile searches
$profile->joinAdd(array('id', 'user:id'));
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
if (!empty($this->q)) {
// User is searching via query
$search_engine = $profile->getSearchEngine('profile');
$mode = 'reverse_chron';
if ($this->sort == 'nickname') {
if ($this->reverse) {
$mode = 'nickname_desc';
} else {
$mode = 'nickname_asc';
}
} else {
if ($this->reverse) {
$mode = 'chron';
}
}
$search_engine->set_sort_mode($mode);
$search_engine->limit($offset, $limit);
$search_engine->query($this->q);
$profile->find();
} else {
// User is browsing via AlphaNav
switch ($this->filter) {
case 'all':
// NOOP
break;
case '0-9':
$profile->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s', $profile->escapedTableName(), 'nickname', $profile->_quote("0"), $profile->_quote("9")));
break;
default:
$profile->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s', $profile->escapedTableName(), 'nickname', $profile->_quote($this->filter)));
}
$order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC', $profile->escapedTableName(), $this->getSortKey('nickname'), $this->reverse ? 'DESC' : 'ASC', 'nickname');
$profile->orderBy($order);
$profile->limit($offset, $limit);
$profile->find();
}
return $profile;
}