本文整理汇总了PHP中search::addElement方法的典型用法代码示例。如果您正苦于以下问题:PHP search::addElement方法的具体用法?PHP search::addElement怎么用?PHP search::addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search
的用法示例。
在下文中一共展示了search::addElement方法的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: isset
}
$_SESSION['search_string'] = isset($_POST['search_string']) || $action == 'search' ? base64_encode(html_entity_decode(stripslashes(trim($pss)), ENT_QUOTES)) : $_SESSION['search_string'];
if (isset($_POST['search_elms']) && is_array($_POST['search_elms'])) {
$search_elms = array();
foreach ($_POST['search_elms'] as $search_elm => $total) {
if (in_array($search_elm, array('projects', 'users', 'works', 'messages', 'commune', 'notes'))) {
$search_elms[$search_elm] = abs(intval($total));
}
}
$_SESSION['search_elms'] = $search_elms;
}
$search_string = trim(base64_decode($_SESSION['search_string']) . ' ' . $_SESSION['string_professions']);
$search = new search($uid);
$search->setUserLimit($set_usr_limit);
foreach ($_SESSION['search_elms'] as $key => $total) {
$search->addElement($key, true, $set_usr_limit);
}
if ($type == 'all') {
$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];
示例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;
//.........这里部分代码省略.........