protected function getFilter() { $arFilter = array("IBLOCK_ID" => $this->getIblockId(), 'SECTION_ID' => $this->getSectionId() > 0 ? $this->getSectionId() : 0, 'ACTIVE' => empty($_REQUEST['filter_active']) ? 'Y' : $_REQUEST['filter_active'], "WF_PARENT_ELEMENT_ID" => false, "SHOW_NEW" => "Y"); if ($arProps = $this->getProps()) { $filtered = null; foreach ($arProps as $arProp) { $value = $_REQUEST['filter_el_property_' . $arProp["ID"]]; if (array_key_exists("AddFilterFields", $arProp["PROPERTY_USER_TYPE"])) { call_user_func_array($arProp["PROPERTY_USER_TYPE"]["AddFilterFields"], array($arProp, array("VALUE" => "filter_el_property_" . $arProp["ID"]), &$arFilter, &$filtered)); } elseif (is_array($value) || strlen($value)) { if ($value === "NOT_REF") { $value = false; } $arFilter["?PROPERTY_" . $arProp["ID"]] = $value; } } } $arSubQuery = array(); if ($arSKUProps = $this->getSkuProps()) { $arCatalog = $this->getOffersCatalog(); $arSubQuery = array("IBLOCK_ID" => $arCatalog['IBLOCK_ID']); $filtered = null; for ($i = 0, $intPropCount = count($arSKUProps); $i < $intPropCount; $i++) { if ('Y' == $arSKUProps[$i]["FILTRABLE"] && 'F' != $arSKUProps[$i]["PROPERTY_TYPE"] && $arCatalog['SKU_PROPERTY_ID'] != $arSKUProps[$i]["ID"]) { if (array_key_exists("AddFilterFields", $arSKUProps[$i]["PROPERTY_USER_TYPE"])) { call_user_func_array($arSKUProps[$i]["PROPERTY_USER_TYPE"]["AddFilterFields"], array($arSKUProps[$i], array("VALUE" => "filter_sub_el_property_" . $arSKUProps[$i]["ID"]), &$arSubQuery, &$filtered)); } else { $value = $_REQUEST['filter_sub_el_property_' . $arSKUProps[$i]["ID"]]; if (is_array($value) || strlen($value)) { if ($value === "NOT_REF") { $value = false; } $arSubQuery["?PROPERTY_" . $arSKUProps[$i]["ID"]] = $value; } } } } } if (!empty($_REQUEST["filter_timestamp_from"])) { $arFilter["DATE_MODIFY_FROM"] = $_REQUEST["filter_timestamp_from"]; } if (!empty($_REQUEST["filter_timestamp_to"])) { $arFilter["DATE_MODIFY_TO"] = $_REQUEST["filter_timestamp_to"]; } if (!empty($_REQUEST["filter_code"])) { $arFilter["CODE"] = $_REQUEST["filter_code"]; } $arSearchedIds = $arSearchedSectionIds = null; if (!empty($_REQUEST['QUERY'])) { $arFilter['QUERY'] = $_REQUEST['QUERY']; $arSearchedIds = $arSearchedSectionIds = array(0); if (preg_match('#^[0-9\\s]+$#', $_REQUEST['QUERY'])) { $barcode = preg_replace('#[^0-9]#', '', $_REQUEST['QUERY']); if (strlen($barcode) > 0) { $rsBarCode = \CCatalogStoreBarCode::getList(array(), array("BARCODE" => $barcode), false, false, array('PRODUCT_ID')); while ($res = $rsBarCode->Fetch()) { $res2 = \CCatalogSKU::GetProductInfo($res["PRODUCT_ID"]); $arSearchedIds[] = $res2 ? $res2['ID'] : $res['PRODUCT_ID']; } } } elseif ($this->isAdvancedSearchAvailable()) { $arFilter['PARAM2'] = $this->getIblockId(); if (!empty($arFilter['SECTION_ID'])) { $arFilter['PARAMS'] = array('iblock_section' => $arFilter['SECTION_ID']); } $obSearch = new \CSearch(); $obSearch->Search($arFilter); $cnt = 0; $activeSectionId = $this->getSectionId(); while ($ar = $obSearch->Fetch()) { if (strpos($ar['ITEM_ID'], 'S') === 0) { $sectionId = preg_replace('#[^0-9]+#', '', $ar['ITEM_ID']); if ($sectionId != $activeSectionId) { $arSearchedSectionIds[] = $sectionId; } } else { $arSearchedIds[] = $ar['ITEM_ID']; } if (++$cnt >= 100) { break; } } } else { $arSearchedIds = $arSearchedSectionIds = null; $arFilter['NAME'] = $_REQUEST['QUERY']; } } if (sizeof($arSubQuery) > 1) { $arFilteredIds = array(0); $db = \CIBlockElement::GetList(array(), $arSubQuery, false, false, array('PROPERTY_' . $arCatalog['SKU_PROPERTY_ID'])); while ($res = $db->Fetch()) { $arFilteredIds[] = $res['PROPERTY_' . $arCatalog['SKU_PROPERTY_ID'] . '_VALUE']; } $arFilter['ID'] = is_array($arSearchedIds) ? array_intersect($arFilteredIds, $arSearchedIds) : $arFilteredIds; } elseif ($arSearchedIds) { $arFilter['ID'] = $arSearchedIds; } if ($arSearchedSectionIds) { $arFilter['S_ID'] = $arSearchedSectionIds; } unset($arFilter['PARAM1'], $arFilter['PARAM2'], $arFilter['PARAMS']); if ($this->isFiltering() || !empty($_REQUEST['QUERY'])) { $arFilter['INCLUDE_SUBSECTIONS'] = 'Y'; if (isset($arFilter['SECTION_ID']) && $arFilter['SECTION_ID'] == 0) { unset($arFilter["SECTION_ID"]); } } return $arFilter; }
$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"]); $arResult["order"]["topic"] = htmlspecialcharsbx($arResult["order"]["~topic"]);
/* TODO: now, no course_id in PARAM1, it must be added firstly to search index, and after - uncomment it. if ($arParams["COURSE_ID"]) { $arFilter["PARAM1"] = "C".$arParams["COURSE_ID"]; } */ if ($arResult["~how"] == "d") { $aSort = array("DATE_CHANGE" => "DESC", "CUSTOM_RANK" => "DESC", "RANK" => "DESC"); } else { $aSort = array("CUSTOM_RANK" => "DESC", "RANK" => "DESC", "DATE_CHANGE" => "DESC"); } $arResult["SEARCH_RESULT"] = array(); if (strlen($arResult["~q"]) > 0 || strlen($arResult["~tags"]) > 0) { $obSearch = new CSearch(); $obSearch->Search($arFilter, $aSort); $arResult["SEARCH_RESULT"] = array(); if ($obSearch->errorno == 0) { $obSearch->NavStart($arParams["PAGE_RESULT_COUNT"]); $arResult["NAV_STRING"] = $obSearch->GetPageNavString(GetMessage("LEARNING_RESULT_PAGES"), $arParams["NAV_TEMPLATE"]); while ($arSearch = $obSearch->GetNext()) { $arResult["SEARCH_RESULT"][] = $arSearch; } if (count($arResult["SEARCH_RESULT"]) > 0) { if (strlen($arResult["~tags"]) > 0) { $arResult["ORDER_LINK"] = $APPLICATION->GetCurPageParam("tags=" . urlencode($arResult["tags"]) . "&where=" . urlencode($arResult["where"]), array("tags", "where", "how")); } else { $arResult["ORDER_LINK"] = $APPLICATION->GetCurPageParam("q=" . urlencode($arResult["q"]) . "&where=" . urlencode($arResult["where"]), array("q", "where", "how")); } if ($arResult["~how"] != "d") { $arResult["ORDER_LINK"] .= "&how=d";
$arUserGroupFilter["USER_ID"] = $arResult["User"]["ID"]; $arUserGroupFilter["<=ROLE"] = SONET_ROLES_USER; } if (CModule::IncludeModule("extranet") && !CExtranet::IsExtranetSite() && $arResult["filter_extranet"] == "Y") { $arUserGroupFilter["GROUP_SITE_ID"] = CExtranet::GetExtranetSiteID(); $arUserGroupFilter["<=ROLE"] = SONET_ROLES_USER; } if (!$arResult["CurrentUserPerms"]["IsCurrentUser"] && !CSocNetUser::IsCurrentUserModuleAdmin()) { $arGroupFilter["VISIBLE"] = "Y"; } } if ($arParams["USE_KEYWORDS"] == "Y" && strlen($arResult["~tags"]) > 0 && CModule::IncludeModule("search")) { $arFilter = array("SITE_ID" => SITE_ID, "QUERY" => "", array("=MODULE_ID" => "socialnetwork", "ITEM_ID" => "G%"), "CHECK_DATES" => "Y", "TAGS" => $arResult["~tags"]); $aSort = array("DATE_CHANGE" => "DESC", "CUSTOM_RANK" => "DESC", "RANK" => "DESC"); $obSearch = new CSearch(); $obSearch->Search($arFilter); if ($obSearch->errorno == 0) { while ($arSearch = $obSearch->Fetch()) { if (intval($arSearch["PARAM2"]) > 0) { $arGroupFilter["ID"][] = $arSearch["PARAM2"]; } } } } if (array_key_exists("ID", $arGroupFilter) && is_array($arGroupFilter["ID"])) { $arGroupFilter["ID"] = array_unique($arGroupFilter["ID"]); } if (!$bNoMyGroups) { if ($arUserGroupFilter && !empty($arUserGroupFilter)) { $dbUserGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), $arUserGroupFilter, false, false, array("GROUP_ID")); if ($dbUserGroups) {
<div class="c-separator-line"></div><?php //sim items $templateData['simId'] = array(); $templateData['simCount'] = 2; if (empty($arResult['PROPERTIES']['TAGS']['VALUE'])) { if (\Bitrix\Main\Loader::includeModule('iblock')) { $arFilter = array('!ID' => $arResult['ID'], 'IBLOCK_ID' => $arParams['IBLOCK_ID'], 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'SECTION_GLOBAL_ACTIVE' => 'Y', 'SECTION_ID' => $arResult['IBLOCK_SECTION_ID']); $db = CIBlockElement::GetList(array('ACTIVE_FROM' => 'DESC', 'ID' => 'DESC'), $arFilter, false, array('nTopCount' => $templateData['simCount']), array('ID', 'IBLOCK_ID')); while ($row = $db->Fetch()) { $templateData['simId'][] = $row['ID']; } } } elseif (\Bitrix\Main\Loader::includeModule('search')) { $q = ''; foreach ($arResult['PROPERTIES']['TAGS']['VALUE'] as $val) { if (!empty($q)) { $q .= ' | '; } $q .= 'tag_search_' . $val; } $obSearch = new CSearch(); $obSearch->Search(array('QUERY' => $q, 'SITE_ID' => SITE_ID, 'MODULE_ID' => 'iblock', 'PARAM2' => $arResult['IBLOCK_ID'], '!ITEM_ID' => $arResult['ID']), array('RANK' => 'DESC')); if ($obSearch->errorno == 0) { while ($row = $obSearch->GetNext()) { $templateData['simId'][] = $row['ITEM_ID']; if (count($templateData['simId']) >= $templateData['simCount']) { break; } } } }
function PROPFIND(&$options, &$files, $arParams = array()) { global $by, $order, $USER; $io = self::GetIo(); if (!function_exists("__sort_array_folder_and_file")) { function __sort_array_folder_and_file($res1, $res2) { global $by, $order; InitSorting(); if (empty($by)) { $by = "NAME"; $order = "ASC"; } $by = strtoupper($by); $order = strtoupper($order); if ($res1["~TYPE"] == "FOLDER" && $res2["~TYPE"] == "FILE") { return -1; } elseif ($res1["~TYPE"] == "FILE" && $res2["~TYPE"] == "FOLDER") { return 1; } else { $by = is_set($res1, $by) ? $by : "NAME"; $ord = $order; if ($by == "TIMESTAMP_X") { $ord = $order == "ASC" ? "DESC" : "ASC"; } if ($ord == "ASC") { return $res1[$by] < $res2[$by] ? -1 : 1; } else { return $res1[$by] < $res2[$by] ? 1 : -1; } } } } $this->IsDir($options); $files['files'] = array(); $arResult = array("NAV_RESULT" => false, "RESULT" => array()); if (empty($options["FILTER"])) { if ($this->arParams["not_found"] === true) { return false; } elseif ($this->arParams["is_dir"] != true) { //$files["files"]["E".$res["ID"]] = $this->_get_fileinfo($this->arParams["item_id"]); $files["files"]["E"] = $this->_get_fileinfo($this->arParams["item_id"]); } else { $files["files"]["section"] = $this->_get_fileinfo($this->arParams["item_id"]); if (!empty($this->arParams["item_id"]) && $this->arParams["item_id"] != "/") { $arResult["SECTION"] = array("ID" => $this->arParams["item_id"], "NAME" => $this->arParams["item_id"]); } //$path = $this->_slashify($io->CombinePath($this->real_path_full, $this->arParams["item_id"])); $path = CWebDavBase::CleanRelativePathString($this->arParams["item_id"], $this->real_path_full); if ($path === false) { return false; } $path = $this->_slashify($path); if (!empty($options["depth"])) { $dir = $io->GetDirectory($path); if ($dir->IsExists()) { $this->arParams["item_id"] = $this->_slashify(str_replace("//", "/", $this->arParams["item_id"])); $tzOffset = CTimeZone::GetOffset(); $arChildren = $dir->GetChildren(); foreach ($arChildren as $node) { $filename = $node->GetName(); $filePath = $io->CombinePath($this->arParams["item_id"], $filename); $res = array("~TYPE" => "FOLDER", "TYPE" => "S", "ID" => $filePath, "NAME" => $filename, "TIMESTAMP_X" => $node->GetModificationTime() + $tzOffset, "PERMISSION" => $this->permission, "PATH" => $filePath, "REAL_PATH" => $path . $filename, "FILE_SIZE" => 0); if ($this->MetaNames($res)) { if (!$node->IsDirectory()) { $ext = strtolower(strrchr($filename, '.')); if (in_array($ext, $this->arFileForbiddenExtentions["READ"])) { continue; } $res["~TYPE"] = "FILE"; $res["TYPE"] = "E"; $res["LOCK_STATUS"] = "green"; $res["EXTENTION"] = $ext; $res["FILE_SIZE"] = $node->GetFileSize(); $res["FILE_ARRAY"] = array("TIMESTAMP_X" => $res["TIMESTAMP_X"], "MODULE_ID" => "webdav", "HEIGHT" => 0, "WIDTH" => 0, "FILE_SIZE" => $res["FILE_SIZE"], "CONTENT_TYPE" => $node->IsReadable() ? $this->_mimetype($path . $filename) : 'application/x-non-readable', "SUBDIR" => $io->CombinePath("/", $this->real_path, $this->arParams["item_id"]), "FILE_NAME" => $filename, "ORIGINAL_NAME" => $filename, "DESCRIPTION" => ""); } $res["PROPS"] = $this->_get_props($filePath); $res["LOCK_STATUS"] = 'green'; if (is_array($res['PROPS']['LOCK'])) { $userLogin = $GLOBALS['USER']->GetLogin(); $now = time(); foreach ($res['PROPS']['LOCK'] as $arLock) { if ($arLock['exclusivelock'] == 1 && $arLock['expires'] >= $now && $arLock['created'] <= $now) { $res['LOCK_STATUS'] = $userLogin == $arLock['owner'] ? 'yellow' : 'red'; $rsUser = CUser::GetByLogin($arLock['owner']); $arUser = $rsUser->GetNext(); $res['LOCKED_USER_NAME'] = '(' . $arUser['LOGIN'] . ')'; if (strlen($arUser['NAME']) > 0 && strlen($arUser['LAST_NAME']) > 0) { $res['LOCKED_USER_NAME'] .= ' ' . $arUser['NAME'] . ' ' . $arUser['LAST_NAME']; } break; } } } $res['SHOW'] = $this->_getShowParams($res); $arResult["RESULT"][($res["TYPE"] == "FOLDER" ? "S" : "E") . $filename] = $res; $files['files'][] = $this->_get_fileinfo($this->arParams["item_id"] . $filename); } } } } } } else { $arSearchResults = array(); if (IsModuleInstalled('search') && CModule::IncludeModule('search')) { $arSearchParams = array("MODULE_ID" => "main", "URL" => $this->base_url . '%'); if (isset($options["FILTER"]["content"]) && strlen($options["FILTER"]["content"]) > 0) { $arSearchParams += array("QUERY" => $options["FILTER"]["content"]); } $obSearch = new CSearch(); $obSearch->Search($arSearchParams); if ($obSearch->errorno != 0) { $arResult["ERROR_MESSAGE"] = $obSearch->error; } else { while ($arSearchResultItem = $obSearch->GetNext()) { $arSearchResults[] = $arSearchResultItem['ITEM_ID']; } } $tzOffset = CTimeZone::GetOffset(); foreach ($arSearchResults as $sSearchItem) { $file = array_pop(explode("|", $sSearchItem)); $filename = GetFileName($file); $sFullFileName = $io->CombinePath($_SERVER['DOCUMENT_ROOT'], $file); if (strpos($sFullFileName, $this->real_path_full) === 0) { $filePath = CWebDavBase::ConvertPathToRelative($sFullFileName, $this->real_path_full); } $filePath = CWebDavBase::CleanRelativePathString($filePath, $this->real_path_full); if ($filePath === false) { return false; } /*$sFullFileName = $io->CombinePath($_SERVER['DOCUMENT_ROOT'], $file); $filename = array_pop(explode("/", $file)); $path = implode("/", array_slice(explode("/", $sFullFileName), 0 , -1)) . "/"; $filePath = $io->CombinePath($path, $filename);*/ $oFile = $io->GetFile($filePath); $res = array("ID" => $file, "NAME" => $filename, "TIMESTAMP_X" => $oFile->GetModificationTime() + $tzOffset, "PERMISSION" => $this->permission, "PATH" => substr($file, strlen($this->real_path)), "REAL_PATH" => $filePath, "FILE_SIZE" => 0); $res['SHOW'] = $this->_getShowParams($res); if ($this->MetaNames($res)) { $res["PROPS"] = $this->_get_props(substr($file, strlen($this->real_path))); if (!isset($res["PROPS"]["UNDELETEBX:"])) { if ($oFile->IsExists()) { $ext = strtolower(strrchr($filename, '.')); if (in_array($ext, $this->arFileForbiddenExtentions["READ"])) { continue; } $fileSize = $oFile->GetFileSize(); $res["~TYPE"] = "FILE"; $res["TYPE"] = "E"; $res["LOCK_STATUS"] = "green"; $res["EXTENTION"] = $ext; $res["FILE_SIZE"] = $fileSize; $res["FILE_ARRAY"] = array("TIMESTAMP_X" => $res["TIMESTAMP_X"], "MODULE_ID" => "webdav", "HEIGHT" => 0, "WIDTH" => 0, "FILE_SIZE" => $fileSize, "CONTENT_TYPE" => $oFile->IsReadable() ? $this->_mimetype($filePath) : 'application/x-non-readable', "SUBDIR" => implode("/", array_slice(explode("/", $file), 0, -1)), "FILE_NAME" => $filename, "ORIGINAL_NAME" => $filename, "DESCRIPTION" => ""); } $arResult["RESULT"][($res["TYPE"] == "FOLDER" ? "S" : "E") . $filename] = $res; } } } } } if ($arParams["return"] == "nav_result" || $arParams["return"] == "array") { uasort($arResult["RESULT"], "__sort_array_folder_and_file"); $arResult["NAV_RESULT"] = new CDBResult(); $arResult["NAV_RESULT"]->InitFromArray($arResult["RESULT"]); $arResult["NAV_RESULT"] = new CDBResultWebDAVFiles($arResult["NAV_RESULT"]); return $arResult; } return true; }
} $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) {
function PROPFIND(&$options, &$files, $arParams = array()) { global $DB; if (empty($files)) { $files = array(); } $files["files"] = array(); $arParams = is_array($arParams) ? $arParams : array(); if ($this->e_rights) { $options['check_permissions'] = false; } $this->IsDir($options); $arParamsIsDir = $this->arParams; $arResult = array("NAV_RESULT" => false, "RESULT" => array()); if ($arParamsIsDir["not_found"] === true) { $msg = $arParamsIsDir['parent_id'] === false ? GetMessage("WD_FOLDER_NOT_FOUND") : GetMessage("WD_FILE_NOT_FOUND"); return $this->ThrowError("404 Not Found", "DESTINATION_FILE_OR_FOLDER_IS_NOT_FOUND", $msg, __LINE__); } elseif ($arParamsIsDir["is_dir"] != true) { $db_res = $this->_get_mixed_list(intVal($arParamsIsDir["parent_id"]), $arParams, intVal($arParamsIsDir["item_id"])); if ($db_res && ($res = $db_res->Fetch())) { if ($this->MetaNames($res)) { $files["files"]["F" . $res["ID"]] = $this->_get_file_info_arr($res, $arParams); if ($arParams["return"] == "array") { $files["files"]["F" . $res["ID"]] = $res; } $arResult["RESULT"]["E" . $res["ID"]] = $res; // dummy } } } else { if (!empty($arParamsIsDir['dir_array'][self::UF_LINK_SECTION_ID])) { $linkWebdav = new self($arParamsIsDir['dir_array'][self::UF_LINK_IBLOCK_ID], $this->base_url . $this->_path, array_merge($this->_originalParams, array('ROOT_SECTION_ID' => $arParamsIsDir['dir_array'][self::UF_LINK_SECTION_ID], 'symlinkMode' => true, 'symlinkSectionData' => $arParamsIsDir['dir_array'], 'symlinkRealRootSectionData' => $this->arRootSection))); $options = array('path' => '/', 'depth' => 1, 'check_permissions' => false); $params = array_merge($arParams, array('PARENT_ID' => $arParamsIsDir['dir_array'][self::UF_LINK_SECTION_ID])); $linkWebdav->_path = $this->_path; return $linkWebdav->PROPFIND($options, $files, $params); } //simple detect symlink list($contextType, $contextEntityId) = $this->getContextData(); if ($arParamsIsDir['dir_array']) { $sectionData = $this->getSectionDataForLinkAnalyze($arParamsIsDir['dir_array']['ID'], array('IBLOCK_ID' => $arParamsIsDir['dir_array']['IBLOCK_ID'], 'ID' => $arParamsIsDir['dir_array']['ID'])); if (!$this->_symlinkMode && CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData)) { $symlinkSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData); } } if (!empty($symlinkSectionData)) { $linkWebdav = new self($symlinkSectionData[self::UF_LINK_IBLOCK_ID], $this->base_url . $this->_path, array_merge($this->_originalParams, array('ROOT_SECTION_ID' => $symlinkSectionData[self::UF_LINK_SECTION_ID], 'symlinkMode' => true, 'symlinkSectionData' => $symlinkSectionData, 'symlinkRealRootSectionData' => $this->arRootSection))); $options = array('path' => '/', 'depth' => 1, 'check_permissions' => false); $params = array_merge($arParams, array('PARENT_ID' => $arParamsIsDir['dir_array']['ID'])); $linkWebdav->_path = $this->_path; return $linkWebdav->PROPFIND($options, $files, $params); } if ($arParamsIsDir["item_id"] <= 0 || $this->arRootSection["ID"] == $arParamsIsDir["item_id"]) { $files["files"]["iblock"] = $this->get_iblock_info($arr); if ($this->_symlinkMode) { $files["files"]["iblock"]['path'] = $this->_path; if (SITE_CHARSET != "UTF-8") { $files["files"]["iblock"]['path'] = $GLOBALS["APPLICATION"]->ConvertCharset($this->_path, SITE_CHARSET, "UTF-8"); } } $arResult["IBLOCK"] = $arr; } else { $arResult["SECTION"] = $this->arParams["dir_array"]; if ($this->MetaNames($arResult["SECTION"])) { $files["files"]["section"] = $this->_get_section_info_arr($arResult["SECTION"]); } else { unset($arResult["SECTION"]); } } if (!empty($options["depth"])) { if (intVal($arParamsIsDir["item_id"]) <= 0) { $arParamsIsDir["item_id"] = $this->arRootSection ? $this->arRootSection["ID"] : $arParamsIsDir["item_id"]; } // content search $arSearchResults = array(); if (isset($arParams["FILTER"]["content"]) && strlen($arParams["FILTER"]["content"]) > 0 && IsModuleInstalled('search') && CModule::IncludeModule('search')) { $obSearch = new CSearch(); if (preg_match("/\\.[a-zA-Z]{3,4}\$/", $arParams["FILTER"]["content"])) { $arParams["FILTER"]["content"] = '"' . $arParams["FILTER"]["content"] . '"'; } $arSearchParams = array("QUERY" => $arParams["FILTER"]["content"]); if (!$this->arRootSection) { $arSearchParams += array("MODULE_ID" => "iblock", "PARAM_2" => $this->IBLOCK_ID); } else { if (isset($this->attributes['user_id'])) { $arSearchParams += array("PARAMS" => array("socnet_user" => $this->attributes['user_id'])); } elseif (isset($this->attributes['group_id'])) { $arSearchParams += array("PARAMS" => array("socnet_group" => $this->attributes['group_id'])); } } $obSearch->Search($arSearchParams); if ($obSearch->errorno != 0) { $arResult["ERROR_MESSAGE"] = $obSearch->error; } else { while ($arSearchResultItem = $obSearch->GetNext()) { $arSearchResults[$arSearchResultItem['ITEM_ID']] = true; } } } $arSearchOptParams = array_flip(array("SHOW_NEW", "SHOW_HISTORY", "FILE_SIZE_multiply")); $arParams["function"] = "propfind"; $parentID = isset($arParams["FILTER"]) ? sizeof(array_diff_key($arParams["FILTER"], $arSearchOptParams)) == 0 ? $arParamsIsDir["item_id"] : null : $arParamsIsDir["item_id"]; if (isset($arParams["PARENT_ID"]) && intval($arParams["PARENT_ID"]) > 0) { $parentID = $arParams["PARENT_ID"]; } if (!empty($arParams["FILTER"])) { $arParams["FILTER"]["SHOW_NEW"] = "Y"; } if ($this->meta_state == "TRASH" && $this->workflow == "bizproc") { $arParams["FILTER"]["SHOW_HISTORY"] = "Y"; } if (isset($arParams["FILTER"]["doctype"])) { $arFileTypes = @unserialize(COption::GetOptionString("webdav", "file_types")); if ($arFileTypes !== false) { foreach ($arFileTypes as $arFileType) { if ($arParams["FILTER"]["doctype"] == $arFileType["ID"]) { $arParams["FILTER"]["extension"] = str_replace(".", "", $arFileType["EXTENSIONS"]); } } } unset($arParams["FILTER"]["doctype"]); } if (isset($arParams["FILTER"]["extension"])) { $arFltExtensions = array_map('strtoupper', explode(" ", $arParams["FILTER"]["extension"])); } //$arResult["NAV_RESULT"] = $db_res; if (isset($arParams["FILTER"]["content"]) && sizeof(array_diff_key($arParams["FILTER"], $arSearchOptParams)) === 1) { // there is only content search unset($arParams["FILTER"]["content"]); unset($arParams["FILTER"]["FILE_SIZE_multiply"]); foreach ($arSearchResults as $itemID => $nopValue) { $arParams["FILTER"]["ID"] = $itemID; $db_res = $this->_get_mixed_list(null, $arParams); if ($db_res && ($res = $db_res->Fetch())) { if ($this->MetaNames($res)) { if ($res["TYPE"] == "S") { if (!$this->MetaSectionHide($res)) { $files["files"]["S" . $res["ID"]] = $this->_get_section_info_arr($res); $arResult["RESULT"]["S" . $res["ID"]] = $res; } } else { $files["files"]["F" . $res["ID"]] = $this->_get_file_info_arr($res, $arParams); $arResult["RESULT"]["E" . $res["ID"]] = $res; } } } } } else { // there are some other fields to search $db_res = $this->_get_mixed_list($parentID, $arParams); if ($db_res && ($res = $db_res->Fetch())) { do { if (!empty($arSearchResults) && !isset($arSearchResults[$res["ID"]])) { continue; } $this->_parse_webdav_info($res); if ($this->meta_state != 'TRASH' && isset($res['PROPS']['BX:']['UNDELETE'])) { continue; } if ($this->MetaNames($res)) { if ($res["TYPE"] == "S") { if (!$this->MetaSectionHide($res)) { if (empty($arParams["FILTER"]) || $this->meta_state == "TRASH" || !empty($arParams['FILTER']['SHOW_SECTIONS'])) { $files["files"]["S" . $res["ID"]] = $this->_get_section_info_arr($res); $arResult["RESULT"]["S" . $res["ID"]] = $res; } } } else { if (isset($arFltExtensions)) { $ext = GetFileExtension($res["NAME"]); if (!in_array(strtoupper($ext), $arFltExtensions)) { continue; } } $files["files"]["F" . $res["ID"]] = $this->_get_file_info_arr($res, $arParams); $arResult["RESULT"]["E" . $res["ID"]] = $res; } } } while ($res = $db_res->Fetch()); } } } } if ($this->e_rights && sizeof($arResult['RESULT']) <= 0 && !$this->GetPermission('SECTION', $arParamsIsDir['item_id'], 'section_read')) { $options['check_permissions'] = true; $arParamsIsDir = $this->GetObject($options); if ($arParamsIsDir["not_found"] === true) { return $this->ThrowError("404 Not Found", "DESTINATION_FILE_OR_FOLDER_IS_NOT_FOUND", GetMessage("WD_FOLDER_NOT_FOUND"), __LINE__); } } if ($arParams["return"] == "array") { return $arResult; } elseif ($arParams["return"] == "nav_result") { $arResult["NAV_RESULT"] = new CDBResult(); $arResult["NAV_RESULT"]->InitFromArray($arResult["RESULT"]); return $arResult; } return true; }
if ($arParams["CHECK_DATES"]) { $arFilter["CHECK_DATES"] = "Y"; } $arFilter = array_merge($arFILTERCustom, $arFilter); $obSearch = new CSearch(); $obSearch->Search($arFilter, array("CNT" => "DESC"), $exFILTER, true); $arResult["ERROR_CODE"] = $obSearch->errorno; $arResult["ERROR_TEXT"] = $obSearch->error; $arResult["DATE"] = array(); $arResult["SEARCH"] = array(); if ($obSearch->errorno == 0) { $res = $obSearch->GetNext(); if (!$res && $arParams["RESTART"] == "Y" && $obSearch->Query->bStemming) { $exFILTER["STEMMING"] = false; $obSearch = new CSearch(); $obSearch->Search($arFilter, array("CNT" => "DESC"), $exFILTER, true); $arResult["ERROR_CODE"] = $obSearch->errorno; $arResult["ERROR_TEXT"] = $obSearch->error; if ($obSearch->errorno == 0) { $res = $obSearch->GetNext(); } } if ($res) { $arResult["CNT_MIN"] = $res["CNT"]; $arResult["CNT_MAX"] = $res["CNT"]; $res["TIME"] = MakeTimeStamp($res["FULL_DATE_CHANGE"]); $arResult["TIME_MIN"] = $res["TIME"]; $arResult["TIME_MAX"] = $res["TIME"]; $arTags = array(); if ($arParams["TAGS_INHERIT"] != "N" && strlen($arParams["TAGS"]) > 0) { $tmp = explode(",", $arParams["~TAGS"]);
/** * $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; } $ar["TAGS"][] = array("URL" => $APPLICATION->GetCurPageParam("tags=" . urlencode($tags), array("tags")), "TAG_NAME" => htmlspecialcharsex($name)); } } $arResult["SEARCH"][] = $ar; $ar = $obSearch->GetNext(); } return $arResult; } }
</font></td></tr> </table> </td></tr></table> </form> <br> <?php if (strlen($q) > 0) { ?> <table width="99%" align="center" border="0" cellspacing="0" cellpadding="0"><tr><td><?php $FORUM_ID = IntVal($_REQUEST["FORUM_ID"]); if ($FORUM_ID <= 0) { $FORUM_ID = false; } $obSearch = new CSearch(); $obSearch->Search(array("MODULE_ID" => "forum", "PARAM1" => $FORUM_ID, "SITE_ID" => SITE_ID, "QUERY" => $q)); if ($obSearch->errorno != 0) { ?> <font class="text"><?php echo GetMessage("FS_PHRASE_ERROR"); ?> </font> <?php echo ShowError($obSearch->error); ?> <font class="text"><?php echo GetMessage("FS_PHRASE_ERROR_CORRECT"); ?> </font><br><br> <font class="text">