本文整理汇总了PHP中search::getElements方法的典型用法代码示例。如果您正苦于以下问题:PHP search::getElements方法的具体用法?PHP search::getElements怎么用?PHP search::getElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search
的用法示例。
在下文中一共展示了search::getElements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: intval
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;
}
$search->search($search_string, $page, isset($_SESSION['search_advanced']) ? $_SESSION['search_advanced'] : "");
break;
default:
break;
}
$elements = $search->getElements();
// Заполняем сессию количеством найденных документов.
foreach ($elements as $key => $elm) {
$_SESSION['search_elms'][$key] = $elm->isActive() ? $elm->total : $_SESSION['search_elms'][$key];
$_SESSION['search_limit'][$key] = $elm->isActive() ? $elm->getProperty('limit') : $_SESSION['search_limit'][$key];
}
$element = $elements[$type];
if (isset($_SESSION['search_elms'][$type]) && isset($_POST['search_string']) && !isset($_GET['only_tab'])) {
if ($_SESSION['search_elms'][$type] == 0) {
foreach ($_SESSION['search_elms'] as $name => $count) {
if ($count > 0) {
header("Location: /search/?type={$name}&{$query_string_menu}&only_tab=1");
exit;
}
}
}
示例3: getUsersList
//.........这里部分代码省略.........
$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));
$search->addElement('users_simple', true);
$search->search($s, 0, $filter, $limit == 'ALL' ? 1000 : $limit);
$res = $search->getElements();
$rows = $res['users_simple']->getRecords();
$more[$i] = $res['users_simple']->total - count($rows);
}
// готовим вывод
foreach ($rows as $k => $v) {
if ($v['uid'] == null) {
$v['uid'] = $v['id'];
}
$v['uname'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', $v['uname']);
$v['usurname'] = iconv('WINDOWS-1251', 'UTF-8//IGNORE', $v['usurname']);
if ($v['photo']) {
$v['path'] = 'users/' . substr($v['login'], 0, 2) . '/' . $v['login'] . '/foto';
$v['photo'] = get_unanimated_gif($v['login'], $v['photo']);
} else {
$v['photo'] = '/images/temp/small-pic.gif';
}
$v['isContacts'] = (int) (!(bool) $i);
$result[] = $v;
}
}
//return $result;
// выводим
$data = array('list' => $result, 'counters' => array('moreContacts' => $more[0], 'moreUsers' => $more[1]), 'dav' => WDCPREFIX);
return json_encode($data);
}
示例4: 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;
//.........这里部分代码省略.........