当前位置: 首页>>代码示例>>PHP>>正文


PHP Profile::getSearchEngine方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:25,代码来源:peoplesearch.php

示例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);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:25,代码来源:userautocomplete.php

示例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));
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:24,代码来源:peoplesearch.php

示例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;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:43,代码来源:userdirectory.php

示例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);
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:29,代码来源:profilecompletion.php

示例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;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:45,代码来源:userdirectory.php


注:本文中的Profile::getSearchEngine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。