- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/templateref.php
- Класс: BitrixLandingTemplateRef
- Вызов: TemplateRef::set
static function set($id, $type, array $data = array())
{
$id = intval($id);
$res = TemplateRefTable::getList(array(
'select' => array(
'ID', 'AREA', 'LANDING_ID'
),
'filter' => array(
'ENTITY_ID' => $id,
'=ENTITY_TYPE' => $type
)
));
while (($row = $res->fetch()))
{
if (isset($data[$row['AREA']]) && $data[$row['AREA']] > 0)
{
if ($row['LANDING_ID'] != $data[$row['AREA']])
{
TemplateRefTable::update($row['ID'], array(
'LANDING_ID' => $data[$row['AREA']]
));
}
unset($data[$row['AREA']]);
}
else
{
TemplateRefTable::delete($row['ID']);
}
}
foreach ($data as $area => $lid)
{
if ($lid > 0)
{
TemplateRefTable::add(array(
'ENTITY_ID' => $id,
'ENTITY_TYPE' => $type,
'LANDING_ID' => $lid,
'AREA' => $area
));
}
}
}