本文整理汇总了PHP中search::search方法的典型用法代码示例。如果您正苦于以下问题:PHP search::search方法的具体用法?PHP search::search怎么用?PHP search::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search
的用法示例。
在下文中一共展示了search::search方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_display_context
static function get_display_context($item, $title, $query_terms, $q)
{
$position = search::get_position($item, $query_terms);
if ($position > 1) {
list($count, $result_data) = search::search($query_terms, 3, $position - 2);
list($previous_item, $ignore, $next_item) = $result_data;
} else {
$previous_item = null;
list($count, $result_data) = search::search($query_terms, 1, $position);
list($next_item) = $result_data;
}
$search_url = url::abs_site("search?q=" . urlencode($q) . "&show={$item->id}");
$root = item::root();
return array("position" => $position, "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => $count, "breadcrumbs" => array(Breadcrumb::instance($root->title, "/", $root->id)->set_first(), Breadcrumb::instance(t("Search: %q", array("q" => $q)), $search_url), Breadcrumb::instance($item->title, $item->url())->set_last()));
}
示例2: index
public function index()
{
$page_size = module::get_var("gallery", "page_size", 9);
$q = Input::instance()->get("q");
$page = Input::instance()->get("page", 1);
$offset = ($page - 1) * $page_size;
// Make sure that the page references a valid offset
if ($page < 1) {
$page = 1;
}
list($count, $result) = search::search($q, $page_size, $offset);
$max_pages = max(ceil($count / $page_size), 1);
$template = new Theme_View("page.html", "collection", "search");
$template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, "children_count" => $count));
$template->content = new View("search.html");
$template->content->items = $result;
$template->content->q = $q;
print $template;
}
示例3: index
public function index()
{
$page_size = module::get_var("gallery", "page_size", 9);
$q = $this->input->get("q");
$page = $this->input->get("page", 1);
$offset = ($page - 1) * $page_size;
// Make sure that the page references a valid offset
if ($page < 1) {
$page = 1;
}
list($count, $result) = search::search($q, $page_size, $offset);
$template = new Theme_View("page.html", "search");
$template->set_global("page_size", $page_size);
$template->set_global("children_count", $count);
$template->content = new View("search.html");
$template->content->items = $result;
$template->content->q = $q;
print $template;
}
示例4: searchProject
function searchProject($string, $categories, $page = 1, $type_loading = 1)
{
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/search/search.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
$objResponse = new xajaxResponse();
if (!$string) {
$string = '';
}
$limit_project = 10;
if ($type_loading == 0) {
$filter['active'] = 't';
$filter['my_specs'] = 'f';
if ($categories[0] != '-1') {
$filter['categories'][0] = array($categories[0] => '0');
if ($categories[1] != '-1') {
unset($filter['categories'][0]);
$filter['categories'][1] = array($categories[1] => '1');
}
}
$project = new new_projects();
$project->page_size = $limit_project;
$projects = $project->getProjects($total, -1, $page, false, $filter, true, false, null, true);
} else {
$_SESSION['search_tab_active'] = 'projects';
$search = new search(false);
$search->setUserLimit($limit_project);
$search->addElement('projects', true, $limit_project);
$filter['active'] = 't';
$filter['my_specs'] = 'f';
if ($categories[0] != '-1') {
$filter['categories'][0] = array($categories[0] => '0');
if ($categories[1] != '-1') {
unset($filter['categories'][0]);
$filter['categories'][1] = array($categories[1] => '1');
}
} else {
$filter['categories'] = null;
}
$filter['is_closed_contest'] = true;
$search->search($string, $page, $filter);
$element = $search->getElements();
$total = $element['projects']->total;
$projects = $element['projects']->results;
}
$max_page = ceil($total / $limit_project);
$next_page = $page + 1;
if ($projects) {
if ($page > 1) {
$dont_show_hint = true;
}
ob_start();
include $_SERVER['DOCUMENT_ROOT'] . '/wizard/registration/steps/tpl.step.search.project.php';
$html = ob_get_clean();
$objResponse->script("\$('project_search_hint').show()");
} else {
$html = 'Совпадений не найдено';
$objResponse->script("\$('project_search_hint').hide()");
}
if ($next_page > $max_page) {
$objResponse->script("\$('load_project').getElement('.b-button').addClass('b-button_disabled')");
} else {
$objResponse->script("\$('load_project').getElement('.b-button').removeClass('b-button_disabled')");
$objResponse->assign('page-search', 'value', $next_page);
}
if ($page > 1) {
$objResponse->assign('project_loader_content', 'innerHTML', $html);
$objResponse->script("var html = new Element('span', {html:\$('project_loader_content').get('html')});\n \$('project_content').adopt(html);");
$objResponse->assign('project_loader_content', 'innerHTML', '');
} else {
$objResponse->assign('project_content', 'innerHTML', $html);
}
return $objResponse;
}
示例5: dirname
<?php
//Check if search data was submitted
if (isset($_GET['s'])) {
// Include the search class
require_once dirname(__FILE__) . '/class-search.php';
// Instantiate a new instance of the search class
$search = new search();
// Store search term into a variable
$search_term = htmlspecialchars($_GET['s'], ENT_QUOTES);
// Send the search term to our search class and store the result
$search_results = $search->search($search_term);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Search</title>
</head>
<body>
<h1>Search</h1>
<div class="search-form">
<form action="" method="get">
<div class="form-field">
<label for="search-field">Search</label>
<input type="search" name="s" placeholder="Enter your search term..." results="5" value="<?php
echo $search_term;
?>
">
示例6: getUsersList
/**
* Получение списка пользователей.
*
* @todo кеш и js
*
* @param string $s - поисковая строка
* @param string $limit - сколько записей запрашивать
* @param int $userType - фильтр результатов поиска: 0 - искать и фриленсеров и работодателей,
* 1 - искать только фриленсеров,
* 2 - искать только работодателей,
* @param int $scope - определяет, где искать: 0 - в СБР/контактах и общем списке пользователей,
* 1 - в СБР/контактах,
* 2 - в общем списке пользователей
*
* @return string - список пользователей в формате JSON
*/
public function getUsersList($s, $limit = 'ALL', $userType = 0, $scope = 0)
{
session_start();
$uid = get_uid(false);
$result = array();
$contacts = array();
$more = array();
// подготовка строки для поиска в shpinx
if ($s != '') {
$s = iconv('UTF-8', 'WINDOWS-1251//IGNORE', $s);
$s = substr(trim($s), 0, 60);
$r = preg_split("/\\s+/", $s);
$s = '';
// если введено два слова, то пологаем что это имя и фамилия и обрабатываем вариант такого поиска особо
// если одно из слов состоит только из /^[-_a-z0-9]+$/i также полагаем что это может быть часть логина
if (count($r) == 2) {
$s = "(@uname {$r[0]} & (@usurname *{$r[1]}* | @usurname {$r[1]})) | (@usurname {$r[0]} & (@uname *{$r[1]}* | @uname {$r[1]}))";
if (preg_match('/^[-_a-z0-9]+$/i', $r[0])) {
$s .= " | (@login *{$r[0]}* & (@uname *{$r[1]}* | @usurname *{$r[1]}*)) | @login *{$r[0]}*";
}
if (preg_match('/^[-_a-z0-9]+$/i', $r[1])) {
$s .= " | (@login *{$r[1]}* & (@uname {$r[0]} | @usurname {$r[0]})) | @login *{$r[1]}*";
}
// во всех остальных случаях полагаем что все слова кроме последнего введены полностью и просто ищем совпадения
} else {
for ($i = 0; $i < count($r) - 1; ++$i) {
$s .= "{$r[$i]} | ";
}
$s .= "*{$r[$i]}* | {$r[$i]}";
}
}
// если нужны контакты в сбр и личке, то получаем их id
if ($scope == 0 || $scope == 1) {
// контакты в сбр
$memBuff = new memBuff();
$contacts = $memBuff->get("bComboUsers{$uid}");
if ($contacts === false) {
if (is_emp()) {
$sbr = new sbr_emp($uid);
} else {
$sbr = new sbr_frl($uid);
}
$contacts = $sbr->getPartersId();
// контакты в личке
$mess = new messages();
$rows = $mess->GetContacts($uid);
for ($i = 0; $i < count($rows); ++$i) {
if (!in_array($rows[$i]['uid'], $contacts)) {
$contacts[] = $rows[$i]['uid'];
}
}
$memBuff->set("bComboUsers{$uid}", $contacts, 600);
}
}
// $i = 0-контакты, 1-остальные пользователи
for ($i = 0; $i <= 1; ++$i) {
if (!$i && !$contacts) {
continue;
}
$rows = array();
// если поиск не требуется
if ($s == '') {
if (!$i) {
if ($userType) {
$table = $userType == 2 ? 'employer' : 'freelancer';
} else {
$table = 'users';
}
$rows = users::GetUsersInfoByIds($limit == 'ALL' ? $contacts : array_slice($contacts, 0, $limit), $table);
}
// если требуется
} else {
$filter = array();
if ($contacts) {
if (!$i) {
$filter['uids'] = $contacts;
} else {
$filter['nouids'] = $contacts;
}
}
if ($userType) {
$filter['utype'] = $userType - 1;
}
$search = new search(get_uid(false));
//.........这里部分代码省略.........
示例7: defined
<?php
defined("SYSPATH") or die("No direct script access.");
// @todo Set hover on AlbumGrid list items
?>
<?php
list($children_count_true, $children_all) = search::search($q, 1000, 0);
$theme->pagination = new Pagination();
$theme->pagination->initialize(array("query_string" => "page", "total_items" => $children_count_true, "items_per_page" => $page_size, "style" => "classic"));
$children_offset = ($theme->pagination->current_page - 1) * $page_size;
?>
<div id="g-search-results">
<h2><?php
echo t("Results for <b>%term</b>", array("term" => $q));
?>
</h2>
<?php
if (count($items)) {
?>
<ul id="g-album-grid" class="ui-helper-clearfix">
<?php
for ($i = 0; $i < $children_offset; $i++) {
?>
<?php
$child = $children_all[$i];
?>
<?php
echo three_nids::fancylink($child, "header");
示例8: intval
$action = 'search';
}
if (!$page) {
$page = 1;
$bPageDefault = true;
}
if ($_POST['action']) {
$action = $_POST['action'];
}
if (isset($_SESSION['search_advanced'][$type]) && $action == 'view') {
$action = 'view_advanced';
}
$is_search = $search_string != '' || $_SESSION['search_advanced'][$type];
switch ($action) {
case "search_advanced":
$search->search($search_string, $page, $_SESSION['search_advanced'][$type]);
break;
case 'search':
$search->search($search_string, $page);
break;
case 'view_advanced':
$search->search($search_string, $page, $_SESSION['search_advanced'][$type]);
break;
case 'view':
$nCount = $_SESSION['search_elms'][$type];
$nPerPage = $_SESSION['search_limit'][$type];
$nPerPage = intval($nPerPage) ? $nPerPage : 5;
$nPages = ceil($nCount / $nPerPage);
if (($nCount == 0 || $nCount - 1 < ($page - 1) * $nPerPage) && !$bPageDefault || $nPages == 1 && !$bPageDefault) {
include ABS_PATH . '/404.php';
exit;
示例9: CalculateFromSearch
/**
* Подсчет получателей если пришли в рассылку из поиска исполнителей
* Метод может использоваться в двух случаях:
* 1. Для подсчета количества пользователей и стомости рассылки исходя из заданного фильтра.
* 2. Расчитать (без дополнительно расчета каталога и городов) количество пользователей и стоимость + сохранить список пользователей в mass_sending_users
* @param integer $uid uid пользователя совершаемого рассылку
* @param array $param массив с данными фильтра фрилансеров
* @param commit integer если не 0, то сохранит всех найденых пользователей для рассылки $commit иначе просто расчет
* @return array результат расчета в виде
* array('count', 'cost', 'pro'=>array('count', 'cost'), locations=>array(array('city', 'country', 'count', 'cost')), professions=>array(array('group', 'profession', 'count', 'cost')))
*
*/
public function CalculateFromSearch($uid, array $param, $commit = 0)
{
global $DB;
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/search/search.php";
if ($param['exp'][0] > $param['exp'][1] && $param['exp'][1] != 0) {
$a = $param['exp'][0];
$param['exp'][0] = $param['exp'][1];
$param['exp'][1] = $a;
}
if ($param['age'][0] > $param['age'][1] && $param['age'][1] != 0) {
$a = $param['age'][0];
$param['age'][0] = $param['age'][1];
$param['age'][1] = $a;
}
if (is_array($param['from_cost'])) {
foreach ($param['from_cost'] as $key => $val) {
if ($val > $param['to_cost'][$key] && $param['to_cost'][$key] != 0) {
$a = $param['from_cost'][$key];
$param['from_cost'][$key] = $param['to_cost'][$key];
$param['to_cost'][$key] = $a;
}
}
}
if ($param['action'] == "search_advanced" || $param['advanced_search']) {
$filter = array("active" => "t", "categories" => $param['pf_categofy'], "prof" => $param['pf_categofy'], "kwords" => $param['kword'], "cost_type" => is_array($param['cost_type']) ? array_map("intval", $param['cost_type']) : $param['cost_type'], "from_cost" => is_array($param['from_cost']) ? array_map("intval", $param['from_cost']) : $param['from_cost'], "to_cost" => is_array($param['to_cost']) ? array_map("intval", $param['to_cost']) : $param['to_cost'], "curr_type" => is_array($param['curr_type']) ? array_map("intval", $param['curr_type']) : $param['curr_type'], "exp" => is_array($param['exp']) ? array_map("intval", $param['exp']) : $param['exp'], "exp_from" => (int) $param['exp'][0], "exp_to" => (int) $param['exp'][1], "login" => htmlspecialchars($param['login']), "age" => is_array($param['age']) ? array_map("intval", $param['age']) : $param['age'], "age_from" => (int) $param['age'][0], "age_to" => (int) $param['age'][1], "country" => (int) $param['pf_country'], "city" => (int) $param['pf_city'], "in_office" => $param['in_office'], "in_fav" => $param['in_fav'], "only_free" => $param['only_free'], "is_pro" => $param['is_pro'], "sbr_is_positive" => $param['sbr_is_positive'], "is_preview" => $param['is_preview'], "sbr_not_negative" => $param['sbr_not_negative'], "opi_is_positive" => $param['opi_is_positive'], "opi_not_negative" => $param['opi_not_negative'], "success_sbr" => $param['success_sbr']);
}
if (!$filter) {
$filter = array();
}
if ($filter['cost_type']) {
foreach ($filter['cost_type'] as $key => $value) {
$cFilter[] = array("cost_type" => $filter['curr_type'][$key], "cost_from" => $filter['from_cost'][$key], "cost_to" => $filter['to_cost'][$key], "type_date" => $value);
}
$filter['cost'] = $cFilter;
}
$searchString = __paramValue('htmltext', $param['search_string']);
if ($filter["prof"][1] && is_array($filter["prof"][1])) {
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
$raw_professions = professions::GetProfessionsTitles(array_keys($filter["prof"][1]));
$a_professions = array();
foreach ($raw_professions as $profession_item) {
$a_professions[$profession_item["name"]] = '(@name_prof "' . $profession_item["name"] . '" | @additional_specs "' . $profession_item["name"] . '")';
}
$searchString .= join(" ", $a_professions);
}
$cost = $this->GetTariff($this->tariff_id);
$search = new search($uid);
// сохраняем всех будущих получателей в базу
if ($commit) {
$searchCount = __paramValue('int', $param['search_count']);
$searchCount = $searchCount ? $searchCount : 1;
$search->addElement('users', true, $searchCount);
$search->search($searchString, 1, $filter);
$elements = $search->getElements();
$massSendingUsers = array();
foreach ($elements['users']->results as $key => $user) {
$massSendingUsers[] = array('mid' => $commit, 'uid' => $user['id']);
}
$DB->insert('mass_sending_users', $massSendingUsers);
}
$search->addElement('users', true, 1);
if ($filter['is_pro']) {
// если нужны только ПРО
$search->search($searchString, 1, $filter);
$elements = $search->getElements();
$searchCountPro = (int) $elements['users']->total;
$searchCostPro = $searchCountPro * $cost['pro'];
$calc = array('count' => $searchCountPro, 'cost' => $searchCostPro, 'pro' => array('count' => $searchCountPro, 'cost' => $searchCostPro));
} else {
// все пользователи
$search->search($searchString, 1, $filter);
$elementsTotal = $search->getElements();
$searchCountTotal = (int) $elementsTotal['users']->total;
// только ПРО
$filter['is_pro'] = true;
$search->search($searchString, 1, $filter);
$elementsPro = $search->getElements();
// количество ПРО пользователей
$searchCountPro = (int) $elementsPro['users']->total;
// количество неПРО
$searchCount = $searchCountTotal - $searchCountPro;
// стоимость рассылки
$searchCostPro = $searchCountPro * $cost['pro'];
$searchCost = $searchCount * $cost['no_pro'];
$searchCostTotal = $searchCostPro + $searchCost;
$calc = array('count' => $searchCountTotal, 'cost' => $searchCostTotal, 'pro' => array('count' => $searchCountPro, 'cost' => $searchCostPro));
}
return $calc;
//.........这里部分代码省略.........