本文整理匯總了PHP中CSearch::SetOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP CSearch::SetOptions方法的具體用法?PHP CSearch::SetOptions怎麽用?PHP CSearch::SetOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CSearch
的用法示例。
在下文中一共展示了CSearch::SetOptions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: elseif
} elseif ($_REQUEST["order"] == "topic") {
$arResult["order"]["active"] = "topic";
$aSort = array("PARAM2" => "DESC", "DATE_CHANGE" => "ASC");
}
$arFilter1 = array("MODULE_ID" => "forum", "SITE_ID" => SITE_ID, "QUERY" => $q, "TAGS" => $_REQUEST["tags"] ? $_REQUEST["tags"] : "");
if (intVal($_REQUEST["DATE_CHANGE"]) > 0) {
$arFilter1["DATE_CHANGE"] = Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANGUAGE_ID)), time() - intVal($_REQUEST["DATE_CHANGE"]) * 24 * 3600 + CTimeZone::GetOffset());
}
$arFilter2 = array();
if (!empty($arParams["FID_RANGE"]) || !empty($arParams["FID"])) {
$arFilter2["PARAM1"] = empty($arParams["FID_RANGE"]) ? array() : array_keys($arResult["FORUMS"]);
$arFilter2["PARAM1"] = empty($arParams["FID"]) ? $arFilter2["PARAM1"] : $arParams["FID"];
}
$obSearch = new CSearch();
//When restart option is set we will ignore error on query with only stop words
$obSearch->SetOptions(array("ERROR_ON_EMPTY_STEM" => $arParams["RESTART"] != "Y", "NO_WORD_LOGIC" => $arParams["NO_WORD_LOGIC"] == "Y"));
$obSearch->Search($arFilter1, $aSort, array($arFilter2));
if ($obSearch->errorno != 0) {
$arResult["ERROR_MESSAGE"] = $obSearch->error;
} else {
$obSearch->NavStart($arParams["TOPICS_PER_PAGE"], false);
$obSearch->nPageWindow = $arParams["PAGE_NAVIGATION_WINDOW"];
$arResult["NAV_RESULT"] = $obSearch;
$arResult["NAV_STRING"] = $obSearch->GetPageNavStringEx($navComponentObject, GetMessage("FL_TOPIC_LIST"), $arParams["PAGE_NAVIGATION_TEMPLATE"]);
$arResult["EMPTY"] = "Y";
$topics = array();
if ($res = $obSearch->GetNext()) {
$arResult["order"]["~relevance"] = $APPLICATION->GetCurPageParam("q=" . urlencode($q) . (!empty($arParams["FID"]) ? "&FORUM_ID=" . $arParams["FID"] : ""), array("FORUM_ID", "q", "order", "s", BX_AJAX_PARAM_ID));
$arResult["order"]["~topic"] = $APPLICATION->GetCurPageParam("q=" . urlencode($q) . (!empty($arParams["FID"]) ? "&FORUM_ID=" . $arParams["FID"] : "") . "&order=topic", array("FORUM_ID", "q", "order", "s", BX_AJAX_PARAM_ID));
$arResult["order"]["~date"] = $APPLICATION->GetCurPageParam("q=" . urlencode($q) . (!empty($arParams["FID"]) ? "&FORUM_ID=" . $arParams["FID"] : "") . "&order=date", array("FORUM_ID", "q", "order", "s", BX_AJAX_PARAM_ID));
$arResult["order"]["relevance"] = htmlspecialcharsbx($arResult["order"]["~relevance"]);
示例2: getSearchedElement
/**
* $arParams,
* $request
*/
function getSearchedElement($arParams, $request)
{
if (!CModule::IncludeModule("search")) {
return false;
}
$arParams["SHOW_WHEN"] = $arParams["SHOW_WHEN"] == "Y";
if (!is_array($arParams["arrWHERE"])) {
$arParams["arrWHERE"] = array();
}
$arParams["PAGE_RESULT_COUNT"] = 50;
if ($arParams["DEFAULT_SORT"] !== "date") {
$arParams["DEFAULT_SORT"] = "rank";
}
if (strlen($arParams["FILTER_NAME"]) <= 0 || !preg_match("/^[A-Za-z_][A-Za-z01-9_]*\$/", $arParams["FILTER_NAME"])) {
$arFILTERCustom = array();
} else {
$arFILTERCustom = $GLOBALS[$arParams["FILTER_NAME"]];
if (!is_array($arFILTERCustom)) {
$arFILTERCustom = array();
}
}
$exFILTER = CSearchParameters::ConvertParamsToFilter($arParams, "arrFILTER");
//options
if (isset($_REQUEST["q"])) {
$q = trim($_REQUEST["q"]);
} else {
$q = false;
}
if ($q !== false) {
if ($arParams["USE_LANGUAGE_GUESS"] == "N" || isset($_REQUEST["spell"])) {
$arResult["REQUEST"]["~QUERY"] = $q;
$arResult["REQUEST"]["QUERY"] = htmlspecialcharsex($q);
} else {
$arLang = CSearchLanguage::GuessLanguage($q);
if (is_array($arLang) && $arLang["from"] != $arLang["to"]) {
$arResult["REQUEST"]["~ORIGINAL_QUERY"] = $q;
$arResult["REQUEST"]["ORIGINAL_QUERY"] = htmlspecialcharsex($q);
$arResult["REQUEST"]["~QUERY"] = CSearchLanguage::ConvertKeyboardLayout($arResult["REQUEST"]["~ORIGINAL_QUERY"], $arLang["from"], $arLang["to"]);
$arResult["REQUEST"]["QUERY"] = htmlspecialcharsex($arResult["REQUEST"]["~QUERY"]);
} else {
$arResult["REQUEST"]["~QUERY"] = $q;
$arResult["REQUEST"]["QUERY"] = htmlspecialcharsex($q);
}
}
}
$arResult["URL"] = $APPLICATION->GetCurPage() . "?q=" . urlencode($q) . (isset($_REQUEST["spell"]) ? "&spell=1" : "") . ($tags !== false ? "&tags=" . urlencode($tags) : "");
if (isset($arResult["REQUEST"]["~ORIGINAL_QUERY"])) {
$arResult["ORIGINAL_QUERY_URL"] = $APPLICATION->GetCurPage() . "?q=" . urlencode($arResult["REQUEST"]["~ORIGINAL_QUERY"]) . "&spell=1" . "&where=" . urlencode($arResult["REQUEST"]["WHERE"]) . ($arResult["REQUEST"]["HOW"] == "d" ? "&how=d" : "") . ($arResult["REQUEST"]["FROM"] ? '&from=' . urlencode($arResult["REQUEST"]["~FROM"]) : "") . ($arResult["REQUEST"]["TO"] ? '&to=' . urlencode($arResult["REQUEST"]["~TO"]) : "") . ($tags !== false ? "&tags=" . urlencode($tags) : "");
}
$templatePage = "";
$arReturn = false;
$arFilter = array("SITE_ID" => SITE_ID, "QUERY" => $arResult["REQUEST"]["~QUERY"], "TAGS" => $arResult["REQUEST"]["~TAGS"]);
$arFilter = array_merge($arFILTERCustom, $arFilter);
if ($from) {
$arFilter[">=DATE_CHANGE"] = $from;
}
if ($to) {
$arFilter["<=DATE_CHANGE"] = $to;
}
$obSearch = new CSearch();
//When restart option is set we will ignore error on query with only stop words
$obSearch->SetOptions(array("ERROR_ON_EMPTY_STEM" => $arParams["RESTART"] != "Y", "NO_WORD_LOGIC" => $arParams["NO_WORD_LOGIC"] == "Y"));
$obSearch->Search($arFilter, $aSort, $exFILTER);
$arResult["ERROR_CODE"] = $obSearch->errorno;
$arResult["ERROR_TEXT"] = $obSearch->error;
$arResult["SEARCH"] = array();
if ($obSearch->errorno == 0) {
$obSearch->NavStart($arParams["PAGE_RESULT_COUNT"], false);
$ar = $obSearch->GetNext();
//Search restart
if (!$ar && $arParams["RESTART"] == "Y" && $obSearch->Query->bStemming) {
$exFILTER["STEMMING"] = false;
$obSearch = new CSearch();
$obSearch->Search($arFilter, $aSort, $exFILTER);
$arResult["ERROR_CODE"] = $obSearch->errorno;
$arResult["ERROR_TEXT"] = $obSearch->error;
if ($obSearch->errorno == 0) {
$obSearch->NavStart($arParams["PAGE_RESULT_COUNT"], false);
$ar = $obSearch->GetNext();
}
}
$arReturn = array();
while ($ar) {
$arReturn[$ar["ID"]] = $ar["ITEM_ID"];
$ar["CHAIN_PATH"] = $APPLICATION->GetNavChain($ar["URL"], 0, $folderPath . "/chain_template.php", true, false);
$ar["URL"] = htmlspecialcharsbx($ar["URL"]);
$ar["TAGS"] = array();
if (!empty($ar["~TAGS_FORMATED"])) {
foreach ($ar["~TAGS_FORMATED"] as $name => $tag) {
if ($arParams["TAGS_INHERIT"] == "Y") {
$arTags = $arResult["REQUEST"]["~TAGS_ARRAY"];
$arTags[$tag] = $tag;
$tags = implode(",", $arTags);
} else {
$tags = $tag;
}
//.........這裏部分代碼省略.........