Exemplo n.º 1
0
	public function buildExcerpts($str)
	{
		$sql = "CALL SNIPPETS(
			'".$this->sphinx->Escape2($str)."'
			,'".$this->sphinx->Escape($this->sphinx->indexName)."'
			,'".$this->sphinx->Escape($this->sphinx->query.$this->sphinx->tags)."'
			,500 as limit
		)";
		$result = mysql_query($sql, $this->sphinx->db);

		if ($result)
		{
			$res = mysql_fetch_array($result, MYSQL_ASSOC);
			if ($res)
			{
				return $res["snippet"];
			}
			else
			{
				return "";
			}
		}
		else
		{
			throw new \Bitrix\Main\Db\SqlQueryException('Sphinx select error', mysql_error($this->sphinx->db), $sql);
		}
	}
Exemplo n.º 2
0
IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/options.php");
IncludeModuleLangFile(__FILE__);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/search/prolog.php";
/** @global CMain $APPLICATION */
global $APPLICATION;
/** @var CAdminMessage $message */
$bVarsFromForm = false;
$aTabs = array(array("DIV" => "index", "TAB" => GetMessage("SEARCH_OPTIONS_TAB_INDEX"), "ICON" => "search_settings", "TITLE" => GetMessage("SEARCH_OPTIONS_TAB_TITLE_INDEX_2"), "OPTIONS" => array("max_file_size" => array(GetMessage("SEARCH_OPTIONS_REINDEX_MAX_SIZE"), array("text", 6)), "include_mask" => array(GetMessage("SEARCH_OPTIONS_MASK_INC"), array("text", 60)), "exclude_mask" => array(GetMessage("SEARCH_OPTIONS_MASK_EXC"), array("textarea", 5)), "page_tag_property" => array(GetMessage("SEARCH_OPTIONS_PAGE_PROPERTY"), array("text", "tags")))), array("DIV" => "stemming", "TAB" => GetMessage("SEARCH_OPTIONS_TAB_STEMMING"), "ICON" => "search_settings", "TITLE" => GetMessage("SEARCH_OPTIONS_TAB_TITLE_STEMMING"), "OPTIONS" => array("use_stemming" => array(GetMessage("SEARCH_OPTIONS_USE_STEMMING"), array("checkbox", "N")), "agent_stemming" => array(GetMessage("SEARCH_OPTIONS_AGENT_STEMMING"), array("checkbox", "N")), "agent_duration" => array(GetMessage("SEARCH_OPTIONS_AGENT_DURATION"), array("text", 6)), "full_text_engine" => array(GetMessage("SEARCH_OPTIONS_FULL_TEXT_ENGINE"), array("select", array("bitrix" => GetMessage("SEARCH_OPTIONS_FULL_TEXT_ENGINE_BITRIX"), "sphinx" => GetMessage("SEARCH_OPTIONS_FULL_TEXT_ENGINE_SPHINX")))), "letters" => array(GetMessage("SEARCH_OPTIONS_LETTERS"), array("text", 45), "bitrix"), "sphinx_connection" => array(GetMessage("SEARCH_OPTIONS_SPHINX_CONNECTION"), array("text", 45), "sphinx"), "sphinx_index_name" => array(GetMessage("SEARCH_OPTIONS_SPHINX_INDEX_NAME"), array("text", 45), "sphinx"), "sphinx_note" => array("", array("note", "\n<pre>\n#sphinx.conf\nindex bitrix\n{\n\t#main settings\n\t\ttype = rt\n\t\tpath = /var/lib/sphinxsearch/data/bitrix\n\t\tdocinfo = inline\n\t#choose appropriate type of morphology to use\n\t\t#morphology = lemmatize_ru_all, lemmatize_en_all, lemmatize_de_all, stem_enru\n\t\tmorphology = stem_enru, soundex\n\t#these settings are used by bitrix:search.title component\n\t\tdict = keywords\n\t\tprefix_fields = title\n\t\tinfix_fields=\n\t\tmin_prefix_len = 2\n\t\tenable_star = 1\n\t#all fields must be defined exactly as followed\n\t\trt_field = title\n\t\trt_field = body\n\t\trt_attr_uint = module_id\n\t\trt_attr_string = module\n\t\trt_attr_uint = item_id\n\t\trt_attr_string = item\n\t\trt_attr_uint = param1_id\n\t\trt_attr_string = param1\n\t\trt_attr_uint = param2_id\n\t\trt_attr_string = param2\n\t\trt_attr_timestamp = date_change\n\t\trt_attr_timestamp = date_to\n\t\trt_attr_timestamp = date_from\n\t\trt_attr_uint = custom_rank\n\t\trt_attr_multi = tags\n\t\trt_attr_multi = right\n\t\trt_attr_multi = site\n\t\trt_attr_multi = param\n\t#depends on settings of your site\n\t\t# uncomment for single byte character set\n\t\tcharset_type = sbcs\n\t\t# uncomment for UTF character set\n\t\t#charset_type = utf-8\n}\n</pre>\n\t\t\t"), "sphinx"))), array("DIV" => "search", "TAB" => GetMessage("SEARCH_OPTIONS_TAB_SEARCH"), "ICON" => "search_settings", "TITLE" => GetMessage("SEARCH_OPTIONS_TAB_TITLE_SEARCH"), "OPTIONS" => array("max_result_size" => array(GetMessage("SEARCH_OPTIONS_MAX_RESULT_SIZE"), array("text", 6)), "use_tf_cache" => array(GetMessage("SEARCH_OPTIONS_USE_TF_CACHE"), array("checkbox", "N")), "use_word_distance" => array(GetMessage("SEARCH_OPTIONS_USE_WORD_DISTANCE"), array("checkbox", "N"), "disabled" => BX_SEARCH_VERSION > 1 ? "" : GetMessage("SEARCH_OPTIONS_REINSTALL_MODULE")), "use_social_rating" => array(GetMessage("SEARCH_OPTIONS_USE_SOCIAL_RATING"), array("checkbox", "N"), "disabled" => BX_SEARCH_VERSION > 1 ? "" : GetMessage("SEARCH_OPTIONS_REINSTALL_MODULE")), "suggest_save_days" => array(GetMessage("SEARCH_OPTIONS_SUGGEST_SAVE_DAYS"), array("text", 6)))), array("DIV" => "statistic", "TAB" => GetMessage("SEARCH_OPTIONS_TAB_STATISTIC"), "ICON" => "search_settings", "TITLE" => GetMessage("SEARCH_OPTIONS_TAB_TITLE_STATISTIC"), "OPTIONS" => array("stat_phrase" => array(GetMessage("SEARCH_OPTIONS_STAT_PHRASE"), array("checkbox", "Y")), "stat_phrase_save_days" => array(GetMessage("SEARCH_OPTIONS_STAT_PHRASE_SAVE_DAYS"), array("text", 6)))));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
if ($REQUEST_METHOD == "POST" && strlen($Update . $Apply . $RestoreDefaults) > 0 && check_bitrix_sessid()) {
    if (strlen($RestoreDefaults) > 0) {
        COption::RemoveOption("search");
    } else {
        if ($_POST["full_text_engine"] === "sphinx") {
            $search = new CSearchSphinx();
            if (!$search->connect($_POST["sphinx_connection"], $_POST["sphinx_index_name"], true)) {
                $e = $APPLICATION->GetException();
                if (is_object($e)) {
                    $message = new CAdminMessage(GetMessage("SEARCH_OPTIONS_SPHINX_ERROR"), $e);
                }
                $bVarsFromForm = true;
            }
        }
        if (!$bVarsFromForm) {
            $old_use_tf_cache = COption::GetOptionString("search", "use_tf_cache");
            $old_max_result_size = COption::GetOptionInt("search", "max_result_size");
            $old_full_text_engine = COption::GetOptionString("search", "full_text_engine");
            foreach ($aTabs as $i => $aTab) {
                foreach ($aTab["OPTIONS"] as $name => $arOption) {
                    $disabled = array_key_exists("disabled", $arOption) ? $arOption["disabled"] : "";