static function OnBeforeIndex($arFields) { $arFields['NAME'] = preg_replace('/^category:/i' . BX_UTF_PCRE_MODIFIER, GetMessage('CATEGORY_NAME') . ':', $arFields['NAME']); $CWikiParser = new CWikiParser(); $arFields['BODY'] = $CWikiParser->parseForSearch($arFields['BODY']); if (SITE_DIR != "/") { //http://www.jabber.bx/view.php?id=29053 if (preg_match("#^" . SITE_DIR . "#", $arFields['SITE_ID'][SITE_ID]) !== false) { $arFields['SITE_ID'][SITE_ID] = preg_replace("#^" . SITE_DIR . "#", "/", $arFields['SITE_ID'][SITE_ID]); } } return $arFields; }
function IndexIBlockElement($arFields, $entity_id, $entity_type, $feature, $operation, $path_template, $arFieldList) { $ID = intval($arFields["ID"]); $IBLOCK_ID = intval($arFields["IBLOCK_ID"]); $IBLOCK_SECTION_ID = is_array($arFields["IBLOCK_SECTION"]) ? $arFields["IBLOCK_SECTION"][0] : $arFields["IBLOCK_SECTION"]; $arItem = array(); if ($entity_type == "G") { $url = str_replace(array("#group_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#", "#name#"), array($entity_id, "group_" . $entity_id, $IBLOCK_SECTION_ID, $arFields["ID"], "view", $arFields["ID"], urlencode($arFields["NAME"])), $path_template); } else { $url = str_replace(array("#user_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#"), array($entity_id, "user_" . $entity_id, $IBLOCK_SECTION_ID, $arFields["ID"], "view", $arFields["ID"]), $path_template); } $body = ""; if ($feature == "wiki") { $CWikiParser = new CWikiParser(); } foreach ($arFieldList as $field) { if ($field == "PREVIEW_TEXT" || $field == "DETAIL_TEXT") { if (isset($CWikiParser)) { $arFields[$field] = HTMLToTxt($CWikiParser->parseForSearch($arFields[$field])); } elseif (isset($arFields[$field . "_TYPE"]) && $arFields[$field . "_TYPE"] === "html") { $arFields[$field] = HTMLToTxt($arFields[$field]); } } $body .= $arFields[$field] . "\n\r"; } if (isset($CWikiParser)) { $title = preg_replace('/^category:/i' . BX_UTF_PCRE_MODIFIER, GetMessage('CATEGORY_NAME') . ':', $arFields['NAME']); } else { $title = $arFields["NAME"]; } $arPermissions = $this->GetSearchGroups($entity_type, $entity_id, $feature, $operation); if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") == "E") { $obElementRights = new CIBlockElementRights($IBLOCK_ID, $arFields["ID"]); $arPermissions = $obElementRights->GetGroups(array("element_read")); } $arSearchIndexParams = $this->GetSearchParams($entity_type, $entity_id, $feature, $operation); CSearch::Index("socialnetwork", $ID, array("LAST_MODIFIED" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "TITLE" => $title, "BODY" => $body, "SITE_ID" => array(SITE_ID => $url), "PARAM1" => CIBlock::GetArrayByID($IBLOCK_ID, "IBLOCK_TYPE_ID"), "PARAM2" => $IBLOCK_ID, "PARAM3" => $feature, "TAGS" => $arFields["TAGS"], "PERMISSIONS" => $arPermissions, "PARAMS" => $arSearchIndexParams), true); if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_search_" . $entity_type . "_" . $entity_id); } }
function ReindexIBlock($iblock_id, $entity_type, $feature, $operation, $path_template, $arFieldList, $last_id) { global $DB; if (!CModule::IncludeModule("iblock")) { return false; } $arSections = array(); $rsElements = CIBlockElement::GetList(array("ID" => "asc"), array("IBLOCK_ID" => $iblock_id, ">ID" => intval($last_id), "CHECK_PERMISSIONS" => "N"), false, false, array_merge(array("ID", "IBLOCK_ID", "IBLOCK_TYPE_ID", "NAME", "TAGS", "TIMESTAMP_X", "IBLOCK_SECTION_ID"), $arFieldList)); while ($arFields = $rsElements->Fetch()) { if (!array_key_exists($arFields["IBLOCK_SECTION_ID"], $arSections)) { $rsPath = CIBlockSection::GetNavChain($arFields["IBLOCK_ID"], $arFields["IBLOCK_SECTION_ID"]); $arSection = $rsPath->Fetch(); if ($entity_type == "G") { $arSections[$arFields["IBLOCK_SECTION_ID"]] = intval($arSection["SOCNET_GROUP_ID"]); } else { $arSections[$arFields["IBLOCK_SECTION_ID"]] = intval($arSection["CREATED_BY"]); } } $entity_id = $arSections[$arFields["IBLOCK_SECTION_ID"]]; if ($entity_id) { $url = str_replace(array("#user_id#", "#group_id#", "#user_alias#", "#section_id#", "#element_id#", "#task_id#", "#name#"), array($entity_id, $entity_id, ($entity_type == "G" ? "group_" : "user_") . $entity_id, $arFields["IBLOCK_SECTION_ID"], $arFields["ID"], $arFields["ID"], urlencode($arFields["NAME"])), $path_template); $body = ""; if ($feature == "wiki") { $CWikiParser = new CWikiParser(); } foreach ($arFieldList as $field) { $text = ""; if ($field == "PREVIEW_TEXT" || $field == "DETAIL_TEXT") { if (isset($CWikiParser)) { $text = HTMLToTxt($CWikiParser->parseForSearch($arFields[$field])); } elseif (isset($arFields[$field . "_TYPE"]) && $arFields[$field . "_TYPE"] === "html") { $text = HTMLToTxt($arFields[$field]); } else { $text = $arFields[$field]; } } elseif ($field == $this->_file_property) { $arFile = CIBlockElement::__GetFileContent($arFields[$this->_file_property . "_VALUE"]); if (is_array($arFile)) { $text = $arFile["CONTENT"]; $arFields["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")]; } } elseif ($field == "PROPERTY_FORUM_TOPIC_ID") { $topic_id = intval($arFields["PROPERTY_FORUM_TOPIC_ID_VALUE"]); if ($topic_id) { $this->UpdateForumTopicIndex($topic_id, $entity_type, $entity_id, $feature, $operation, $this->Url($url, array("MID" => "#message_id#"), "message#message_id#")); } } $body .= $text . "\n\r"; } if (isset($CWikiParser)) { $title = preg_replace('/^category:/i' . BX_UTF_PCRE_MODIFIER, GetMessage('CATEGORY_NAME') . ':', $arFields['NAME']); } else { $title = $arFields["NAME"]; } $arPermissions = $this->GetSearchGroups($entity_type, $entity_id, $feature, $operation); if (CIBlock::GetArrayByID($arFields["IBLOCK_ID"], "RIGHTS_MODE") == "E") { $obElementRights = new CIBlockElementRights($arFields["IBLOCK_ID"], $arFields["ID"]); $arPermissions = $obElementRights->GetGroups(array("element_read")); } CSearch::Index("socialnetwork", $arFields["ID"], array("LAST_MODIFIED" => $arFields["TIMESTAMP_X"], "TITLE" => $title, "BODY" => $body, "SITE_ID" => array(SITE_ID => $url), "PARAM1" => $arFields["IBLOCK_TYPE_ID"], "PARAM2" => $arFields["IBLOCK_ID"], "PARAM3" => $entity_id, "TAGS" => $arFields["TAGS"], "PERMISSIONS" => $arPermissions, "PARAMS" => $this->GetSearchParams($entity_type, $entity_id, $feature, $operation), "REINDEX_FLAG" => true), true, $this->_sess_id); $this->_counter++; } if ($this->_end_time && $this->_end_time <= time()) { return $arFields["ID"]; } } return false; }