Your IP : 18.188.230.221
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true)
die();
use Bitrix\Main\Context;
class ProjectTopSlider extends CBitrixComponent
{
protected $isAjax;
protected $request;
protected $sectionsVariants;
public function __construct(CBitrixComponent $component = null)
{
parent::__construct($component);
\Bitrix\Main\Loader::includeModule("rusklimat.b2c");
\Bitrix\Main\Loader::includeModule("iblock");
}
public function executeComponent()
{
try
{
$this->arResult = [];
$dbRes = CIBlockElement::GetList(
[],
[
"IBLOCK_ID" => \Rusklimat\B2c\Parts\Projects\Config::IBLOCK_ID,
"PROPERTY_IS_TOP" => 1
],
false,
false,
[
"ID",
"NAME",
// "PROPERTY_PHOTO",
"PROPERTY_ADDRESS",
"PROPERTY_IS_TOP",
"PROPERTY_SUMM_SQUARE",
"PROPERTY_OBJECT_TYPE",
]
);
\CBitrixComponent::includeComponentClass("ballu.b2c:project.base");
$arNoPhotos = ProjectBase::getNoPhotos();
$first = false;
while ($res = $dbRes->fetch())
{
if (!$first)
$first = $res["ID"];
$dbProps = $props = CIBlockElement::GetProperty(
\Rusklimat\B2c\Parts\Projects\Config::IBLOCK_ID,
$res["ID"],
[],
[
"ACTIVE" => "Y",
"CODE" => $this->getPropCodes()
]
);
$arProps = [];
while ($prop = $dbProps->fetch())
{
if ($prop["VALUE"])
$arProps[$prop["CODE"]][] = [
"DISPLAY_VALUE" => CFile::GetPath($prop["VALUE"]),
"VALUE" => $prop["VALUE"]
];
}
$tmpResult = [
"ID" => $res["ID"],
"NAME" => $res["NAME"],
"IS_TOP" => $res["PROPERTY_IS_TOP_VALUE"],
"SUMM_SQUARE" => $res["PROPERTY_SUMM_SQUARE_VALUE"],
"ADDRESS" => $res["PROPERTY_ADDRESS_VALUE"],
];
foreach($arProps as $propCode => $prop)
$tmpResult[$propCode] = $prop;
if (!isset($tmpResult["PHOTO"]) || empty($tmpResult["PHOTO"]))
{
$tmpResult["PHOTO"] = [
[
// "DISPLAY_VALUE" => "/local/templates/ballu/images/no-photo.png"
"DISPLAY_VALUE" => $arNoPhotos[ $res["PROPERTY_OBJECT_TYPE_VALUE"] ]
]
];
}
$this->arResult["ITEMS"][$res["ID"]] = $tmpResult;
}
// \Rusklimat\B2c\Parts\Debug\Debugger::getInstance()->pub($this->arResult);
}
catch (Exception $e)
{
$errorStr = $e->getMessage();// . "\n" . $e->getTraceAsString();
$this->arResult["ERROR"] = $errorStr;
}
if ($this->arParams["AJAX_CALL"])
return $this->arResult;
else
$this->IncludeComponentTemplate();
return $first;
}
protected function getPropCodes()
{
return "PHOTO";
}
}