if (is_array($arResult["DETAIL_PICTURE"])) { $arResult["PICTURE"] = $arResult["DETAIL_PICTURE"]; } elseif (is_array($arResult["PREVIEW_PICTURE"])) { $arResult["PICTURE"] = $arResult["PREVIEW_PICTURE"]; } $arSectionFilter = array("IBLOCK_ID" => $arResult["IBLOCK_ID"], "ACTIVE" => "Y"); if ($arParams["SECTION_ID"]) { $arSectionFilter["ID"] = $arParams["SECTION_ID"]; } elseif ($arParams["SECTION_CODE"]) { $arSectionFilter["CODE"] = $arParams["SECTION_CODE"]; } $rsSection = CIBlockSection::GetList(array(), $arSectionFilter); $rsSection->SetUrlTemplates("", $arParams["SECTION_URL"]); if ($arResult["SECTION"] = $rsSection->GetNext()) { $arResult["SECTION"]["PATH"] = array(); $rsPath = GetIBlockSectionPath($arResult["SECTION"]["IBLOCK_ID"], $arResult["SECTION"]["ID"]); $rsPath->SetUrlTemplates("", $arParams["SECTION_URL"]); while ($arPath = $rsPath->GetNext()) { $arResult["SECTION"]["PATH"][] = $arPath; } } } } // get the values for the Next and Previous links if (isset($arResult["ID"])) { //SELECT $arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PAGE_URL", "LIST_PAGE_URL", "NAME", "PREVIEW_PICTURE"); //WHERE $arFilter = array("IBLOCK_ID" => $arResult["IBLOCK_ID"], "SECTION_ID" => $arResult["SECTION"]["ID"], "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"); //ORDER BY $arSort = array($arParams["ELEMENT_SORT_FIELD"] => $arParams["ELEMENT_SORT_ORDER"], "ID" => "ASC");
function GetSection($id, &$arSection, $params = array()) { static $arResult = array(); $params = is_array($params) ? $params : array($params); $id = intval($id); if ($id <= 0) { return 200; } $arCache = array("id" => serialize(array("iblock_id" => $this->IBlockID, "section_id" => $id, "gallery_id" => $this->Gallery && $this->Gallery['ID'] ? $this->Gallery['ID'] : "0", "site" => SITE_ID)), "path" => $this->arCache["path"], "time" => $this->arCache["time"]); if (($tzOffset = CTimeZone::GetOffset()) != 0) { $arCache["id"] .= "_" . $tzOffset; } if (empty($arResult[$arCache["id"]])) { $cache = new CPHPCache(); if ($arCache["time"] > 0 && $cache->InitCache($arCache["time"], $arCache["id"], $arCache["path"])) { $arResult[$arCache["id"]] = $cache->GetVars(); } else { CModule::IncludeModule("iblock"); $arFilter = array("IBLOCK_ACTIVE" => "Y", "IBLOCK_ID" => $this->IBlockID, "ID" => $id); $db_res = CIBlockSection::GetList(array(), $arFilter, false); if (!($db_res && ($arSection = $db_res->GetNext()))) { if ($this->arError["show_error"] == "Y") { ShowError(GetMessage("P_SECTION_NOT_FOUND")); } if ($this->arError["set_404"] == "Y") { @define("ERROR_404", "Y"); CHTTP::SetStatus("404 Not Found"); } return 404; } elseif ($arSection["ACTIVE"] != "Y" && $this->User["Permission"] < "U") { if ($this->arError["show_error"] == "Y") { ShowError(GetMessage("P_ALBUM_IS_BLOCKED")); } return 405; } elseif ($this->Gallery && ($arSection["LEFT_MARGIN"] < $this->Gallery["LEFT_MARGIN"] || $this->Gallery["RIGHT_MARGIN"] < $arSection["RIGHT_MARGIN"])) { return 301; } else { $arSection["SECTIONS_CNT"] = 0; if ($arSection["RIGHT_MARGIN"] - $arSection["LEFT_MARGIN"] > 1) { $arSection["SECTIONS_CNT"] = intVal(CIBlockSection::GetCount(array("SECTION_ID" => $arSection["ID"]))); } $arSection["SECTION_ELEMENTS_CNT"] = $arSection["SECTION_ELEMENTS_CNT_ALL"] = $arSection["ELEMENTS_CNT"] = 0; $arSection["ELEMENTS_CNT_ALL"] = intVal(CIBlockSection::GetSectionElementsCount($arSection["ID"], array("CNT_ALL" => "Y"))); // if section not empty if ($arSection["ELEMENTS_CNT_ALL"] > 0) { if ($arSection["SECTIONS_CNT"] > 0) { $arSection["SECTION_ELEMENTS_CNT_ALL"] = intval(CIBlockElement::GetList(array(), array("SECTION_ID" => $arSection["ID"]), array(), false, array("ID"))); } else { $arSection["SECTION_ELEMENTS_CNT_ALL"] = $arSection["ELEMENTS_CNT_ALL"]; } if ($this->User["Permission"] < "U") { $arSection["ELEMENTS_CNT"] = intVal(CIBlockSection::GetSectionElementsCount($arSection["ID"], array("CNT_ACTIVE" => "Y"))); } else { $arSection["ELEMENTS_CNT"] = $arSection["ELEMENTS_CNT_ALL"]; } // if not exists active elements if ($arSection["ELEMENTS_CNT"] <= 0) { $arSection["SECTION_ELEMENTS_CNT"] = 0; } elseif ($arSection["ELEMENTS_CNT_ALL"] == $arSection["ELEMENTS_CNT"]) { $arSection["SECTION_ELEMENTS_CNT"] = $arSection["SECTION_ELEMENTS_CNT_ALL"]; } elseif ($arSection["SECTIONS_CNT"] <= 0) { $arSection["SECTION_ELEMENTS_CNT"] = $arSection["ELEMENTS_CNT"]; } else { $arSection["SECTION_ELEMENTS_CNT"] = intval(CIBlockElement::GetList(array(), array("SECTION_ID" => $arSection["ID"], "ACTIVE" => "Y"), array(), false, array("ID"))); } } $arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $this->IBlockID . "_SECTION", $arSection["ID"], LANGUAGE_ID); $arSection["USER_FIELDS"] = $arUserFields; $arSection["DATE"] = $arSection["~DATE"] = $arUserFields["UF_DATE"]; $arSection["~PASSWORD"] = $arUserFields["UF_PASSWORD"]; if (is_array($arSection["~PASSWORD"])) { $arSection["PASSWORD"] = $arSection["~PASSWORD"]["VALUE"]; } $arSection["PICTURE"] = CFile::GetFileArray($arSection["PICTURE"]); $arSection["DETAIL_PICTURE"] = CFile::GetFileArray($arSection["DETAIL_PICTURE"]); $arSection["PATH"] = array(); $db_res = GetIBlockSectionPath($this->IBlockID, $arSection["ID"]); while ($res = $db_res->GetNext()) { $arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $this->IBlockID . "_SECTION", $res["ID"], LANGUAGE_ID); $res["~PASSWORD"] = $arUserFields["UF_PASSWORD"]; if (is_array($res["~PASSWORD"])) { $res["PASSWORD"] = $res["~PASSWORD"]["VALUE"]; } $arSection["PATH"][$res["ID"]] = $res; } $arResult[$arCache["id"]] = $arSection; if ($arCache["time"] > 0) { $cache->StartDataCache($arCache["time"], $arCache["id"], $arCache["path"]); $cache->EndDataCache($arSection); } } } } $arSection = $arResult[$arCache["id"]]; return 200; }
} // add chain items if iblock (task, calendar event, library document) $element_type = false; if ($arElement) { if ($arElement["IBLOCK_ID"] == $arParams["TASKS_USER_IBLOCK_ID"]) { $element_type = "tasks"; } elseif ($arElement["IBLOCK_ID"] == $arParams["CALENDAR_USER_IBLOCK_ID"]) { $element_type = "calendar"; } elseif ($arElement["IBLOCK_ID"] == $arParams["FILES_USER_IBLOCK_ID"]) { $element_type = "files"; } elseif ($arElement["IBLOCK_ID"] == $arParams["PHOTO_USER_IBLOCK_ID"]) { $element_type = "photo"; } $arElement["SECTION_PATH"] = array(); if ($arElement["IBLOCK_SECTION_ID"] > 0) { $rsPath = GetIBlockSectionPath($arElement["IBLOCK_ID"], $arElement["IBLOCK_SECTION_ID"]); while ($arPath = $rsPath->GetNext()) { $arElement["SECTION_PATH"][] = $arPath; } } $strUrl = ""; $arChainBody[] = '<a href="' . CComponentEngine::MakePathFromTemplate($arParams["~PATH_TO_USER_" . toUpper($element_type)], array("user_id" => $arParams["SOCNET_USER_ID"], "path" => "")) . '">' . $arFeaturesTitles[$element_type] . '</a>'; $k = 0; foreach ($arElement["SECTION_PATH"] as $arPath) { if ($k > 0) { $strUrl .= $arPath["NAME"] . "/"; $arPath["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~PATH_TO_USER_" . toUpper($element_type) . "_SECTION"], array("user_id" => $arParams["SOCNET_USER_ID"], "path" => rtrim($strUrl, "/"), "section_id" => $arPath["ID"], "user_alias" => "user_" . $arParams["SOCNET_USER_ID"])); if ($element_type != "calendar") { $arChainBody[] = '<a href="' . $arPath["URL"] . '">' . htmlspecialcharsex($arPath["NAME"]) . '</a>'; } else { $arChainBody[] = htmlspecialcharsex($arPath["NAME"]);
$ar_file = CFile::GetFileArray($ar_elems["DETAIL_PICTURE"]); if (!$ar_file) { $ar_file = CFile::GetFileArray($ar_elems["PREVIEW_PICTURE"]); } if ($ar_file) { if (substr($ar_file["SRC"], 0, 1) == "/") { $strImage = "http://" . COption::GetOptionString("main", "server_name", $SERVER_NAME) . $ar_file["SRC"]; } else { $strImage = $ar_file["SRC"]; } } else { $strImage = ""; } if (!is_set($arSectionPaths, IntVal($ar_elems["IBLOCK_SECTION_ID"]))) { $strCategory = $ar_iblock["NAME"]; $sections_path = GetIBlockSectionPath($IBLOCK_ID, $ar_elems["IBLOCK_SECTION_ID"]); while ($arSection = $sections_path->GetNext()) { if (strlen($strCategory) > 0) { $strCategory .= ">"; } $strCategory .= $arSection["NAME"]; } $arSectionPaths[IntVal($ar_elems["IBLOCK_SECTION_ID"])] = PrepareString($strCategory); } $minPrice = 0; for ($i = 0, $intPCount = count($arPTypes); $i < $intPCount; $i++) { if (strlen($ar_elems["CATALOG_CURRENCY_" . $arPTypes[$i]]) <= 0) { continue; } $tmpPrice = Round(CCurrencyRates::ConvertCurrency($ar_elems["CATALOG_PRICE_" . $arPTypes[$i]], $ar_elems["CATALOG_CURRENCY_" . $arPTypes[$i]], "USD"), 2); if ($minPrice <= 0 || $minPrice > $tmpPrice) {
else { $arItem["PRICE_MATRIX"] = false; $arItem["PRICES"] = CIBlockPriceTools::GetItemPrices($arParams["IBLOCK_ID"], $arResult["PRICES"], $arItem, $arParams['PRICE_VAT_INCLUDE'], $arConvertParams); } $arItem["CAN_BUY"] = CIBlockPriceTools::CanBuy($arParams["IBLOCK_ID"], $arResult["PRICES"], $arItem); $arItem["BUY_URL"] = htmlspecialcharsbx($APPLICATION->GetCurPageParam($arParams["ACTION_VARIABLE"]."=BUY&".$arParams["PRODUCT_ID_VARIABLE"]."=".$arItem["ID"], array($arParams["PRODUCT_ID_VARIABLE"], $arParams["ACTION_VARIABLE"]))); $arItem["ADD_URL"] = htmlspecialcharsbx($APPLICATION->GetCurPageParam($arParams["ACTION_VARIABLE"]."=ADD2BASKET&".$arParams["PRODUCT_ID_VARIABLE"]."=".$arItem["ID"], array($arParams["PRODUCT_ID_VARIABLE"], $arParams["ACTION_VARIABLE"]))); $arItem["COMPARE_URL"] = htmlspecialcharsbx($APPLICATION->GetCurPageParam("action=ADD_TO_COMPARE_LIST&id=".$arItem["ID"], array("action", "id"))); $arItem["SUBSCRIBE_URL"] = htmlspecialcharsbx($APPLICATION->GetCurPageParam($arParams["ACTION_VARIABLE"]."=SUBSCRIBE_PRODUCT&id=".$arItem["ID"], array($arParams["PRODUCT_ID_VARIABLE"], $arParams["ACTION_VARIABLE"]))); $arItem["SECTION"]["PATH"] = array(); if($arParams["BY_LINK"]==="Y") { $rsPath = GetIBlockSectionPath($arItem["IBLOCK_ID"], $arItem["IBLOCK_SECTION_ID"]); $rsPath->SetUrlTemplates("", $arParams["SECTION_URL"]); while($arPath = $rsPath->GetNext()) { $arItem["SECTION"]["PATH"][]=$arPath; } } if ('Y' == $arParams['CONVERT_CURRENCY']) { if ($arParams["USE_PRICE_COUNT"]) { if (is_array($arItem["PRICE_MATRIX"]) && !empty($arItem["PRICE_MATRIX"])) { if (isset($arItem["PRICE_MATRIX"]['CURRENCY_LIST']) && is_array($arItem["PRICE_MATRIX"]['CURRENCY_LIST'])) $arCurrencyList = array_merge($arCurrencyList, $arItem["PRICE_MATRIX"]['CURRENCY_LIST']);
$csvFile->SaveFile($_SERVER["DOCUMENT_ROOT"].$SETUP_FILE_NAME, $arNeedFields); } $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N'), false, false, $selectArray); while ($res1 = $res->Fetch()) { $arResSections = array(); if ($bNeedGroups) { $indreseg = 0; $reseg = CIBlockElement::GetElementGroups($res1["ID"], false, array('ID', 'ADDITIONAL_PROPERTY_ID')); while ($reseg1 = $reseg->Fetch()) { if (0 < intval($reseg1['ADDITIONAL_PROPERTY_ID'])) continue; $sections_path = GetIBlockSectionPath($IBLOCK_ID, $reseg1["ID"]); while ($arSection = $sections_path->Fetch()) { $arResSectionTmp = array(); foreach ($arAvailGroupFields_names as $key => $value) { $arResSectionTmp[$key] = $arSection[$value["field"]]; } $arResSections[$indreseg][] = $arResSectionTmp; } $indreseg++; } if (empty($arResSections)) $arResSections[0] = array(); } else
public function getPath() { $retval = array(); $className = get_class($this); $res = \GetIBlockSectionPath($this->iblock_id, $this->id); while ($row = $res->Fetch()) { $retval[] = new $className($row); } return $retval; }
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (is_array($arResult['VALUE']) && count($arResult['VALUE']) > 0) { if (!CModule::IncludeModule("iblock")) { return; } if (array_key_exists("inChain", $arParams) && $arParams["inChain"] == "Y") { $bMultiHead = false; $rsSections = CIBlockSection::GetList(array($by => $order), array("IBLOCK_ID" => $arParams["arUserField"]["SETTINGS"]["IBLOCK_ID"], "GLOBAL_ACTIVE" => "Y", "DEPTH_LEVEL" => 1), false, array("ID")); if ($rsSections->Fetch() && $rsSections->Fetch()) { $bMultiHead = true; } foreach ($arResult['VALUE'] as $sectionID) { $iDepth = 1; $rsPath = GetIBlockSectionPath($arParams["arUserField"]["SETTINGS"]["IBLOCK_ID"], $sectionID); while ($arPath = $rsPath->GetNext()) { if ($bMultiHead || $iDepth > 1) { $arResult["CHAIN"][$sectionID][] = $arPath; } $iDepth++; } } } $arValue = array(); $dbRes = CIBlockSection::GetList(array('left_margin' => 'asc'), array('ID' => $arResult['VALUE']), false); while ($arRes = $dbRes->Fetch()) { $arValue[$arRes['ID']] = $arRes['NAME']; } $arResult['VALUE'] = $arValue; }
if ($bGetProperty) { $arSelect[] = "PROPERTY_*"; } //WHERE $arFilter = array("IBLOCK_ID" => $arResult["ID"], "IBLOCK_LID" => SITE_ID, "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"); if ($arParams["CHECK_DATES"]) { $arFilter["ACTIVE_DATE"] = "Y"; } $arParams["PARENT_SECTION"] = CIBlockFindTools::GetSectionID($arParams["PARENT_SECTION"], $arParams["PARENT_SECTION_CODE"], array("GLOBAL_ACTIVE" => "Y", "IBLOCK_ID" => $arResult["ID"])); if ($arParams["PARENT_SECTION"] > 0) { $arFilter["SECTION_ID"] = $arParams["PARENT_SECTION"]; if ($arParams["INCLUDE_SUBSECTIONS"]) { $arFilter["INCLUDE_SUBSECTIONS"] = "Y"; } $arResult["SECTION"] = array("PATH" => array()); $rsPath = GetIBlockSectionPath($arResult["ID"], $arParams["PARENT_SECTION"]); $rsPath->SetUrlTemplates("", $arParams["SECTION_URL"], $arParams["IBLOCK_URL"]); while ($arPath = $rsPath->GetNext()) { $arResult["SECTION"]["PATH"][] = $arPath; } } else { $arResult["SECTION"] = false; } //ORDER BY $arSort = array($arParams["SORT_BY1"] => $arParams["SORT_ORDER1"], $arParams["SORT_BY2"] => $arParams["SORT_ORDER2"]); if (!array_key_exists("ID", $arSort)) { $arSort["ID"] = "DESC"; } $obParser = new CTextParser(); $arResult["ITEMS"] = array(); $arResult["ELEMENTS"] = array();
CModule::IncludeModule("iblock"); IncludeModuleLangFile(__FILE__); $POST_RIGHT = $APPLICATION->GetGroupRight("main"); if ($POST_RIGHT == "D") { $APPLICATION->AuthForm("Доступ запрещен"); } $BID = 8; $limit = 1; if ($_REQUEST['work_start'] && check_bitrix_sessid()) { $rsEl = CIBlockElement::GetList(array("ID" => "ASC"), array("IBLOCK_ID" => $BID, ">ID" => $_REQUEST["lastid"]), false, array("nTopCount" => $limit)); while ($arFields = $rsEl->Fetch()) { if ($arFields["IBLOCK_ID"] == 8) { $prop_id = 121; //121 = PROP["GOOGLE_MERCHANT"] if (isset($arFields["IBLOCK_SECTION_ID"])) { $rsPath = GetIBlockSectionPath($arFields["IBLOCK_ID"], $arFields["IBLOCK_SECTION_ID"]); while ($arPath = $rsPath->GetNext()) { $arrPath[] = array("ID" => $arPath["ID"], "NAME" => $arPath["NAME"]); } $res = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], array(), array("ID" => $prop_id)); $update = 0; $arRes = array(); while ($arRes = $res->GetNext()) { if ($arRes["VALUE"] != $arrPath[0]["NAME"]) { $update = 1; } } if ($update > 0) { $arUpdateProps[$prop_id] = 2985; if (count($arUpdateProps) > 0) { CIBlockElement::SetPropertyValuesEx($arFields["ID"], $arFields["IBLOCK_ID"], $arUpdateProps);
$arValues = ""; } } else { $arValues = ""; } } else { $arValues = $arProperty["~VALUE"]; } $arPropsValues[$arProperty["ID"]] = $arValues; } $arResSections = array(); if ($bNeedGroups) { $rsSections = CIBlockElement::GetElementGroups($arElement["ID"], true); while ($arSection = $rsSections->Fetch()) { $arPath = array(); $rsPath = GetIBlockSectionPath($IBLOCK_ID, $arSection["ID"]); while ($arPathSection = $rsPath->Fetch()) { $arPath[] = $arPathSection["NAME"]; } $arResSections[] = $arPath; } if (count($arResSections) <= 0) { $arResSections[] = array(); } } else { $arResSections[] = array(); } $arResFields = array(); foreach ($arResSections as $arPath) { $arTuple = array(); foreach ($arNeedFields as $field_name) {
$arResult["LINKED_ELEMENTS"] = array(); if (strlen($arParams["LINK_PROPERTY_SID"]) > 0 && strlen($arParams["LINK_IBLOCK_TYPE"]) > 0 && $arParams["LINK_IBLOCK_ID"] > 0) { $rsLinkElements = CIBlockElement::GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => $arParams["LINK_IBLOCK_ID"], "IBLOCK_ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y", "IBLOCK_TYPE" => $arParams["LINK_IBLOCK_TYPE"], "PROPERTY_" . $arParams["LINK_PROPERTY_SID"] => $arResult["ID"]), false, false, array("ID", "IBLOCK_ID", "NAME", "DETAIL_PAGE_URL", "IBLOCK_NAME")); while ($ar = $rsLinkElements->GetNext()) { $arResult["LINKED_ELEMENTS"][] = $ar; } } if (!$arSection && $arResult["IBLOCK_SECTION_ID"] > 0) { $arSectionFilter = array("ID" => $arResult["IBLOCK_SECTION_ID"], "IBLOCK_ID" => $arResult["IBLOCK_ID"], "ACTIVE" => "Y"); $rsSection = CIBlockSection::GetList(array(), $arSectionFilter); $rsSection->SetUrlTemplates("", $arParams["SECTION_URL"]); $arSection = $rsSection->GetNext(); } if ($arSection) { $arSection["PATH"] = array(); $rsPath = GetIBlockSectionPath($arResult["IBLOCK_ID"], $arSection["ID"]); $rsPath->SetUrlTemplates("", $arParams["SECTION_URL"]); while ($arPath = $rsPath->GetNext()) { $arSection["PATH"][] = $arPath; } $arResult["SECTION"] = $arSection; } if ($arParams["USE_PRICE_COUNT"]) { if (CModule::IncludeModule("catalog")) { $arResult["PRICE_MATRIX"] = CatalogGetPriceTableEx($arResult["ID"], 0, $arPriceTypeID, 'Y', $arConvertParams); foreach ($arResult["PRICE_MATRIX"]["COLS"] as $keyColumn => $arColumn) { $arResult["PRICE_MATRIX"]["COLS"][$keyColumn]["NAME_LANG"] = htmlspecialcharsbx($arColumn["NAME_LANG"]); } } else { $arResult["PRICE_MATRIX"] = false; }