Advertisement
SpeakeazyYT

Untitled

Aug 6th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.67 KB | None | 0 0
  1. <?
  2. if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
  3.  
  4. /*************************************************************************
  5. Processing of received parameters
  6.  *************************************************************************/
  7. if(!isset($arParams["CACHE_TIME"]))
  8.     $arParams["CACHE_TIME"] = 36000000;
  9.  
  10. //$arParams["IBLOCK_TYPE"] = trim($arParams["IBLOCK_TYPE"]);
  11. $arParams["IBLOCK_ID"] = intval($arParams["IBLOCK_ID"]);
  12.  
  13. $arParams["SECTION_URL"]=trim($arParams["SECTION_URL"]);
  14.  
  15. $arResult["SECTIONS"]=array();
  16.  
  17. /*************************************************************************
  18. Work with cache
  19.  *************************************************************************/
  20. if($this->StartResultCache(false, ($arParams["CACHE_GROUPS"]==="N"? false: $USER->GetGroups())))
  21. {
  22.     if(!CModule::IncludeModule("iblock"))
  23.     {
  24.         $this->AbortResultCache();
  25.         return;
  26.     }
  27.     $arFilter = array(
  28.         "ACTIVE" => "Y",
  29.         "GLOBAL_ACTIVE" => "Y",
  30.         "IBLOCK_ID" => $arParams["IBLOCK_ID"],
  31.         "CNT_ACTIVE" => "Y",
  32.     );
  33.  
  34.     $arSelect = array();
  35.  
  36.     if(!empty($arSelect))
  37.     {
  38.         $arSelect[] = "ID";
  39.         $arSelect[] = "NAME";
  40.         $arSelect[] = "LEFT_MARGIN";
  41.         $arSelect[] = "RIGHT_MARGIN";
  42.         $arSelect[] = "DEPTH_LEVEL";
  43.         $arSelect[] = "IBLOCK_ID";
  44.         $arSelect[] = "IBLOCK_SECTION_ID";
  45.         $arSelect[] = "LIST_PAGE_URL";
  46.         $arSelect[] = "SECTION_PAGE_URL";
  47.     }
  48.  
  49.     $arFilter["<="."DEPTH_LEVEL"] = 1;
  50.  
  51.     //ORDER BY
  52.     $arSort = array(
  53.         "left_margin"=>"asc",
  54.     );
  55.     //EXECUTE
  56.     $rsSections = CIBlockSection::GetList($arSort, $arFilter, false, $arSelect);
  57.     $rsSections->SetUrlTemplates("", $arParams["SECTION_URL"]);
  58.     while($arSection = $rsSections->GetNext())
  59.     {
  60.         if(isset($arSection["PICTURE"]))
  61.         {
  62.             $picture = CFile::GetFileArray($arSection["PICTURE"]);
  63.  
  64.             $arFileTmp = CFile::ResizeImageGet(
  65.                 $picture,
  66.                 array("width" => 130, "height" => 130),
  67.                 BX_RESIZE_IMAGE_PROPORTIONAL,
  68.                 true, $arFilter
  69.             );
  70.             $arSection["PICTURE"] = $arFileTmp["src"];
  71.         }
  72.         else
  73.             $arSection["PICTURE"] = "/bitrix/components/bitrix/eshopapp.sections/images/no_image.png";
  74.         $arResult["SECTIONS"][]=$arSection;
  75.     }
  76.  
  77.     //$arResult["SECTIONS_COUNT"] = count($arResult["SECTIONS"]);
  78.  
  79.     $this->SetResultCacheKeys(array(
  80.         "SECTIONS_COUNT",
  81.         "SECTION",
  82.     ));
  83.  
  84.     //$this->IncludeComponentTemplate();
  85. }
  86.  
  87. $data = array();
  88. foreach($arResult["SECTIONS"] as $arSection)
  89. {
  90.     $data["data"][] = array(
  91.         "ID" => $arSection["ID"],
  92.         "NAME" => $arSection["~NAME"],
  93.         "URL" => $arSection["SECTION_PAGE_URL"],
  94.         "IMAGE" => $arSection["PICTURE"]
  95.     );
  96. }
  97. if (SITE_CHARSET != "utf-8")
  98.     $data = $APPLICATION->ConvertCharsetArray($data, SITE_CHARSET, "utf-8");
  99. echo json_encode($data);
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement