Your IP : 3.147.58.83
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
class CNewsTools
{
function OnSearchGetURL($arFields)
{
global $DB, $BX_NEWS_DETAIL_URL, $BX_NEWS_SECTION_URL;
static $arIBlockCache = array();
if($arFields["MODULE_ID"] !== "iblock" || substr($arFields["URL"], 0, 1) !== "=")
return $arFields["URL"];
if(!CModule::IncludeModule('iblock'))
return '';
$IBLOCK_ID = 0;
if (isset($arFields["PARAM2"]))
$IBLOCK_ID = (int)$arFields["PARAM2"];
if ($IBLOCK_ID <= 0)
return '';
if(!isset($arIBlockCache[$IBLOCK_ID]))
{
$res = $DB->Query("
SELECT
DETAIL_PAGE_URL,
SECTION_PAGE_URL,
CODE as IBLOCK_CODE,
XML_ID as IBLOCK_EXTERNAL_ID,
IBLOCK_TYPE_ID
FROM
b_iblock
WHERE ID = ".$IBLOCK_ID."
");
$arIBlockCache[$IBLOCK_ID] = $res->Fetch();
}
if(!is_array($arIBlockCache[$IBLOCK_ID]))
return '';
$arr = array();
$arFields["URL"] = LTrim($arFields["URL"], " =");
parse_str($arFields["URL"], $arr);
$arr = $arIBlockCache[$IBLOCK_ID] + $arr;
$arr["LANG_DIR"] = $arFields["DIR"];
if(substr($arFields["ITEM_ID"], 0, 1) !== 'S')
return CIBlock::ReplaceDetailUrl($BX_NEWS_DETAIL_URL, $arr, true, "E");
else
return CIBlock::ReplaceDetailUrl($BX_NEWS_SECTION_URL, $arr, true, "S");
}
}