Exemplo n.º 1
0
		{
			if(is_array($arParams["CATEGORY_".$i]))
				$category_title = implode(", ", $arParams["CATEGORY_".$i]);
			else
				$category_title = trim($arParams["CATEGORY_".$i]);
		}
		if(empty($category_title))
			continue;

		$arResult["CATEGORIES"][$i] = array(
			"TITLE" => htmlspecialcharsbx($category_title),
			"ITEMS" => array()
		);

		$exFILTER = array(
			0 => CSearchParameters::ConvertParamsToFilter($arParams, "CATEGORY_".$i),
		);
		$exFILTER[0]["LOGIC"] = "OR";

		if($arParams["CHECK_DATES"] === "Y")
			$exFILTER["CHECK_DATES"] = "Y";

		$arOthersFilter[] = $exFILTER;

		$j = 0;
		$obTitle = new CSearchTitle;
		$obTitle->setMinWordLength($_REQUEST["l"]);
		if($obTitle->Search(
			$arResult["alt_query"]? $arResult["alt_query"]: $arResult["query"]
			,$arParams["TOP_COUNT"]
			,$exFILTER
Exemplo n.º 2
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("search")) {
    ShowError(GetMessage("BSF_C_MODULE_NOT_INSTALLED"));
    return;
}
$exFILTER = CSearchParameters::ConvertParamsToFilter($arParams, "arrFILTER");
foreach ($exFILTER as $i => $subFilter) {
    if (is_array($subFilter) && array_key_exists("PARAMS", $subFilter) && is_array($subFilter["PARAMS"]) && array_key_exists("socnet_group", $subFilter["PARAMS"])) {
        $exFILTER["SOCIAL_NETWORK_GROUP"] = $subFilter["PARAMS"]["socnet_group"];
    }
}
$exFILTER["SITE_ID"] = !empty($arParams["SITE_ID"]) ? $arParams["SITE_ID"] : SITE_ID;
$arResult["exFILTER"] = $exFILTER;
if (empty($arParams["NAME"])) {
    $arParams["NAME"] = "TAGS";
    $arParams["~NAME"] = "TAGS";
}
$arResult["ID"] = GenerateUniqId($arParams["NAME"]);
$arResult["NAME"] = $arParams["NAME"];
$arResult["~NAME"] = $arParams["~NAME"];
$arResult["VALUE"] = $arParams["VALUE"];
$arResult["~VALUE"] = $arParams["~VALUE"];
$this->IncludeComponentTemplate();
Exemplo n.º 3
0
         continue;
     }
 }
 $category_title = trim($arParams["CATEGORY_" . $i . "_TITLE"]);
 if (empty($category_title)) {
     if (is_array($arParams["CATEGORY_" . $i])) {
         $category_title = implode(", ", $arParams["CATEGORY_" . $i]);
     } else {
         $category_title = trim($arParams["CATEGORY_" . $i]);
     }
 }
 if (empty($category_title)) {
     continue;
 }
 $arResult["CATEGORIES"][$i] = array("TITLE" => htmlspecialcharsbx($category_title), "ITEMS" => array());
 $exFILTER = array(0 => CSearchParameters::ConvertParamsToFilter($arParams, "CATEGORY_" . $i));
 $exFILTER[0]["LOGIC"] = "OR";
 if ($arParams["CHECK_DATES"] === "Y") {
     $exFILTER["CHECK_DATES"] = "Y";
 }
 $arOthersFilter[] = $exFILTER;
 $j = 0;
 $obTitle = new CSearchTitle();
 if ($obTitle->Search($arResult["alt_query"] ? $arResult["alt_query"] : $arResult["query"], $arParams["TOP_COUNT"], $exFILTER, false, $arParams["ORDER"])) {
     while ($ar = $obTitle->Fetch()) {
         $j++;
         if ($j > $arParams["TOP_COUNT"]) {
             $params = array("q" => $arResult["alt_query"] ? $arResult["alt_query"] : $arResult["query"]);
             $url = CHTTP::urlAddParams(str_replace("#SITE_DIR#", SITE_DIR, $arParams["PAGE_2"]), $params, array("encode" => true)) . CSearchTitle::MakeFilterUrl("f", $exFILTER);
             $arResult["CATEGORIES"][$i]["ITEMS"][] = array("NAME" => GetMessage("MORE_CATEGORY"), "URL" => htmlspecialcharsex($url), "MORE" => "Y");
             break;
Exemplo n.º 4
0
		<td><?php 
    echo GetMessage("SEARCH_REINDEX_MODULE");
    ?>
</td>
		<td>
		<select name="MODULE_ID" id="MODULE_ID">
		<option value="NOT_REF"><?php 
    echo GetMessage("SEARCH_REINDEX_ALL");
    ?>
</option>
		<option value="main"><?php 
    echo GetMessage("SEARCH_REINDEX_MAIN");
    ?>
</option>
		<?php 
    foreach (CSearchParameters::GetModulesList() as $module_id => $module_name) {
        ?>
			<option value="<?php 
        echo $module_id;
        ?>
"><?php 
        echo htmlspecialcharsbx($module_name);
        ?>
</option>
		<?php 
    }
    ?>
		</select>
		</td>
	</tr>
	<tr>
Exemplo n.º 5
0
 public static function ModulesSelectBox($sFieldName, $sValue, $sDefaultValue = "", $sFuncName = "", $field = "class=\"typeselect\"")
 {
     $s = '<select name="' . $sFieldName . '" id="' . $sFieldName . '" ' . $field;
     if (strlen($sFuncName) > 0) {
         $s .= ' OnChange="' . $sFuncName . '"';
     }
     $s .= '>' . "\n";
     $s1 = '<option value="main"' . ($sValue == "main" ? ' selected' : '') . '>' . GetMessage("customrank_files") . '</option>' . "\n";
     foreach (CSearchParameters::GetModulesList() as $module_id => $module_name) {
         $s1 .= '<option value="' . $module_id . '"' . ($sValue == $module_id ? ' selected' : '') . '>' . htmlspecialcharsex($module_name) . '</option>' . "\n";
     }
     if (strlen($sDefaultValue) > 0) {
         $s .= "<option value='NOT_REF'>" . htmlspecialcharsex($sDefaultValue) . "</option>";
     }
     return $s . $s1 . '</select>';
 }
Exemplo n.º 6
0
 function AddFilterParams(&$arComponentParameters, $arCurrentValues, $name, $parent, $MULTIPLE = "Y")
 {
     $arComponentParameters["PARAMETERS"][$name] = array("PARENT" => $parent, "NAME" => GetMessage("SEARCH_CP_WHERE_FILTER"), "TYPE" => "LIST", "MULTIPLE" => $MULTIPLE, "VALUES" => CSearchParameters::GetFilterDropDown(true), "DEFAULT" => "all", "REFRESH" => "Y");
     if (!is_array($arCurrentValues[$name]) && strlen($arCurrentValues[$name]) > 0) {
         $arCurrentValues[$name] = array($arCurrentValues[$name]);
     }
     if (is_array($arCurrentValues[$name])) {
         foreach ($arCurrentValues[$name] as $strFILTER) {
             if ($strFILTER == "main") {
                 $arComponentParameters["PARAMETERS"][$name . "_" . $strFILTER] = array("PARENT" => $parent, "NAME" => GetMessage("SEARCH_CP_URL"), "TYPE" => "STRING", "MULTIPLE" => $MULTIPLE, "ADDITIONAL_VALUES" => "Y", "DEFAULT" => "");
             } elseif ($strFILTER == "forum") {
                 $arrFILTER = array();
                 if (CModule::IncludeModule("forum")) {
                     $arrFILTER["all"] = GetMessage("SEARCH_CP_ALL");
                     $rsForum = CForumNew::GetList();
                     while ($arForum = $rsForum->Fetch()) {
                         $arrFILTER[$arForum["ID"]] = $arForum["NAME"];
                     }
                 }
                 $arComponentParameters["PARAMETERS"][$name . "_" . $strFILTER] = array("PARENT" => $parent, "NAME" => GetMessage("SEARCH_CP_FORUM"), "TYPE" => "LIST", "MULTIPLE" => $MULTIPLE, "VALUES" => $arrFILTER, "ADDITIONAL_VALUES" => "N", "DEFAULT" => "all");
             } elseif (strpos($strFILTER, "iblock_") === 0) {
                 $arrFILTER = array();
                 if (CModule::IncludeModule("iblock")) {
                     $arrFILTER["all"] = GetMessage("SEARCH_CP_ALL");
                     $rsIBlock = CIBlock::GetList(array("SORT" => "ASC"), array("TYPE" => substr($strFILTER, 7)));
                     while ($arIBlock = $rsIBlock->Fetch()) {
                         $arrFILTER[$arIBlock["ID"]] = $arIBlock["NAME"];
                     }
                 }
                 $arComponentParameters["PARAMETERS"][$name . "_" . $strFILTER] = array("PARENT" => $parent, "NAME" => GetMessage("SEARCH_CP_IBLOCK_TYPE", array("#TYPE_ID#" => $strFILTER)), "TYPE" => "LIST", "MULTIPLE" => $MULTIPLE, "VALUES" => $arrFILTER, "ADDITIONAL_VALUES" => "N", "DEFAULT" => "all");
             } elseif ($strFILTER == "blog") {
                 $arrFILTER = array();
                 if (CModule::IncludeModule("blog")) {
                     $arrFILTER["all"] = GetMessage("SEARCH_CP_ALL");
                     $rsBlog = CBlog::GetList();
                     while ($arBlog = $rsBlog->Fetch()) {
                         $arrFILTER[$arBlog["ID"]] = $arBlog["NAME"];
                     }
                 }
                 $arComponentParameters["PARAMETERS"][$name . "_" . $strFILTER] = array("PARENT" => $parent, "NAME" => GetMessage("SEARCH_CP_BLOG"), "TYPE" => "LIST", "MULTIPLE" => $MULTIPLE, "VALUES" => $arrFILTER, "ADDITIONAL_VALUES" => "N", "DEFAULT" => "all");
             } elseif ($strFILTER == "socialnetwork") {
                 $arrFILTER = array();
                 if (CModule::IncludeModule("socialnetwork")) {
                     $arrFILTER["all"] = GetMessage("SEARCH_CP_ALL");
                     $rsGroup = CSocNetGroup::GetList(array("ID" => "DESC"), array(), false, false, array("ID", "NAME"));
                     while ($arGroup = $rsGroup->Fetch()) {
                         $arrFILTER[$arGroup["ID"]] = $arGroup["NAME"];
                     }
                 }
                 $arComponentParameters["PARAMETERS"][$name . "_" . $strFILTER] = array("PARENT" => $parent, "NAME" => GetMessage("SEARCH_CP_SOCIALNETWORK_GROUPS"), "TYPE" => "LIST", "MULTIPLE" => $MULTIPLE, "VALUES" => $arrFILTER, "ADDITIONAL_VALUES" => "N", "DEFAULT" => "all");
             } elseif ($strFILTER == "socialnetwork_user") {
                 $arComponentParameters["PARAMETERS"][$name . "_" . $strFILTER] = array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("SEARCH_CP_SOCIALNETWORK_USER"), "TYPE" => "STRING", "DEFAULT" => "");
             }
         }
     }
 }
Exemplo n.º 7
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("search")) {
    return;
}
$arComponentParameters = array("PARAMETERS" => array("NAME" => array("PARENT" => "BASE", "NAME" => GetMessage("SEARCH_NAME"), "TYPE" => "STRING", "DEFAULT" => "TAG"), "VALUE" => array("PARENT" => "BASE", "NAME" => GetMessage("SEARCH_VALUE"), "TYPE" => "STRING", "DEFAULT" => ""), "SITE_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("SEARCH_SITE_ID"), "TYPE" => "STRING", "DEFAULT" => SITE_ID)));
CSearchParameters::AddFilterParams($arComponentParameters, $arCurrentValues, "arrFILTER", "DATA_SOURCE", "N");
Exemplo n.º 8
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("search")) {
    return;
}
$arComponentParameters = array("GROUPS" => array(), "PARAMETERS" => array("PAGE" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("CP_BST_FORM_PAGE"), "TYPE" => "STRING", "DEFAULT" => "#SITE_DIR#search/index.php"), "NUM_CATEGORIES" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BST_NUM_CATEGORIES"), "TYPE" => "STRING", "DEFAULT" => "1", "REFRESH" => "Y"), "TOP_COUNT" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BST_TOP_COUNT"), "TYPE" => "STRING", "DEFAULT" => "5", "REFRESH" => "Y"), "ORDER" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BST_ORDER"), "TYPE" => "LIST", "DEFAULT" => "date", "VALUES" => array("date" => GetMessage("CP_BST_ORDER_BY_DATE"), "rank" => GetMessage("CP_BST_ORDER_BY_RANK"))), "USE_LANGUAGE_GUESS" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BST_USE_LANGUAGE_GUESS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "CHECK_DATES" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BST_CHECK_DATES"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "SHOW_OTHERS" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BST_SHOW_OTHERS"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", "REFRESH" => "Y")));
if ($arCurrentValues["SHOW_OTHERS"] === "Y") {
    $arComponentParameters["GROUPS"]["OTHERS_CATEGORY"] = array("NAME" => GetMessage("CP_BST_OTHERS_CATEGORY"));
    $arComponentParameters["PARAMETERS"]["CATEGORY_OTHERS_TITLE"] = array("PARENT" => "OTHERS_CATEGORY", "NAME" => GetMessage("CP_BST_CATEGORY_TITLE"), "TYPE" => "STRING");
}
$NUM_CATEGORIES = intval($arCurrentValues["NUM_CATEGORIES"]);
if ($NUM_CATEGORIES <= 0) {
    $NUM_CATEGORIES = 1;
}
for ($i = 0; $i < $NUM_CATEGORIES; $i++) {
    $arComponentParameters["GROUPS"]["CATEGORY_" . $i] = array("NAME" => GetMessage("CP_BST_NUM_CATEGORY", array("#NUM#" => $i + 1)));
    $arComponentParameters["PARAMETERS"]["CATEGORY_" . $i . "_TITLE"] = array("PARENT" => "CATEGORY_" . $i, "NAME" => GetMessage("CP_BST_CATEGORY_TITLE"), "TYPE" => "STRING");
    CSearchParameters::AddFilterParams($arComponentParameters, $arCurrentValues, "CATEGORY_" . $i, "CATEGORY_" . $i);
}
/**
 * $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"]) ? "&amp;spell=1" : "") . ($tags !== false ? "&amp;tags=" . urlencode($tags) : "");
    if (isset($arResult["REQUEST"]["~ORIGINAL_QUERY"])) {
        $arResult["ORIGINAL_QUERY_URL"] = $APPLICATION->GetCurPage() . "?q=" . urlencode($arResult["REQUEST"]["~ORIGINAL_QUERY"]) . "&amp;spell=1" . "&amp;where=" . urlencode($arResult["REQUEST"]["WHERE"]) . ($arResult["REQUEST"]["HOW"] == "d" ? "&amp;how=d" : "") . ($arResult["REQUEST"]["FROM"] ? '&amp;from=' . urlencode($arResult["REQUEST"]["~FROM"]) : "") . ($arResult["REQUEST"]["TO"] ? '&amp;to=' . urlencode($arResult["REQUEST"]["~TO"]) : "") . ($tags !== false ? "&amp;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;
                    }
                    $ar["TAGS"][] = array("URL" => $APPLICATION->GetCurPageParam("tags=" . urlencode($tags), array("tags")), "TAG_NAME" => htmlspecialcharsex($name));
                }
            }
            $arResult["SEARCH"][] = $ar;
            $ar = $obSearch->GetNext();
        }
        return $arResult;
    }
}