Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
viewed.php
1<?php
3
7
14class Viewed
15{
24 public static function getParentSection($sectionId, $depth)
25 {
26 $sectionId = (int)$sectionId;
27 $depth = (int)$depth;
28 if ($sectionId <= 0 || $depth <= 0)
29 return null;
30 $section = Iblock\SectionTable::getList(array(
31 'select' => array('ID', 'IBLOCK_ID', 'LEFT_MARGIN', 'RIGHT_MARGIN', 'DEPTH_LEVEL'),
32 'filter' => array('=ID' => $sectionId)
33 ))->fetch();
34 if (empty($section))
35 return null;
36 $section['DEPTH_LEVEL'] = (int)$section['DEPTH_LEVEL'];
37 if ($section['DEPTH_LEVEL'] < $depth)
38 return null;
39 if ($section['DEPTH_LEVEL'] == $depth)
40 return (int)$section['ID'];
41
42 $parentSection = Iblock\SectionTable::getList(array(
43 'select' => array('ID'),
44 'filter' => array(
45 '=IBLOCK_ID' => $section['IBLOCK_ID'],
46 '<=LEFT_MARGIN' => $section['LEFT_MARGIN'],
47 '>=RIGHT_MARGIN' => $section['RIGHT_MARGIN'],
48 '=DEPTH_LEVEL' => $depth
49 )
50 ))->fetch();
51 if (!empty($parentSection))
52 return (int)$parentSection['ID'];
53
54 return null;
55 }
56}
static getParentSection($sectionId, $depth)
Definition viewed.php:24