1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
section.php
См. документацию.
1
<?php
7
namespace
Bitrix\Iblock\Template\Entity;
8
9
class
Section
extends
Base
10
{
11
protected
$property
=
null
;
12
protected
$iblock
=
null
;
13
protected
$parent
=
null
;
14
protected
$sections
=
null
;
15
protected
$catalog
=
null
;
16
20
public
function
__construct
($id)
21
{
22
parent::__construct($id);
23
$this->fieldMap =
array
(
24
"name"
=>
"NAME"
,
25
"previewtext"
=>
"DESCRIPTION"
,
26
"detailtext"
=>
"DESCRIPTION"
,
27
"code"
=>
"CODE"
,
28
//not accessible from template engine
29
"ID"
=>
"ID"
,
30
"IBLOCK_ID"
=>
"IBLOCK_ID"
,
31
"IBLOCK_SECTION_ID"
=>
"IBLOCK_SECTION_ID"
,
32
);
33
}
34
42
public
function
resolve
(
$entity
)
43
{
44
if
(
$entity
===
"property"
)
45
{
46
if
(!$this->property && $this->
loadFromDatabase
())
47
{
48
if
($this->fields[
"IBLOCK_ID"
] > 0)
49
{
50
$this->
property
= SectionProperty::getInstance($this->
id
);
51
$this->
property
->setIblockId($this->fields[
"IBLOCK_ID"
]);
52
}
53
}
54
55
if
($this->property)
56
return
$this->property
;
57
}
58
elseif
(
$entity
===
"iblock"
)
59
{
60
if
(!$this->iblock && $this->
loadFromDatabase
())
61
{
62
if
($this->fields[
"IBLOCK_ID"
] > 0)
63
$this->iblock =
Iblock::getInstance
($this->fields[
"IBLOCK_ID"
]);
64
}
65
66
if
($this->iblock)
67
return
$this->iblock
;
68
}
69
elseif
(
$entity
===
"parent"
)
70
{
71
if
(!$this->parent && $this->
loadFromDatabase
())
72
{
73
if
($this->fields[
"IBLOCK_SECTION_ID"
] > 0)
74
$this->parent = Section::getInstance($this->fields[
"IBLOCK_SECTION_ID"
]);
75
else
76
return
$this->
resolve
(
"iblock"
);
77
}
78
79
if
($this->parent)
80
return
$this->parent
;
81
}
82
elseif
(
$entity
===
"sections"
)
83
{
84
if
(!$this->sections && $this->
loadFromDatabase
())
85
{
86
if
($this->fields[
"IBLOCK_SECTION_ID"
] > 0)
87
$this->sections = SectionPath::getInstance($this->fields[
"IBLOCK_SECTION_ID"
]);
88
}
89
90
if
($this->sections)
91
return
$this->sections
;
92
}
93
elseif
(
$entity
===
"catalog"
)
94
{
95
if
(!$this->catalog && $this->
loadFromDatabase
())
96
{
97
if
(\
Bitrix
\
Main
\
Loader::includeModule
(
'catalog'
))
98
$this->catalog = ElementCatalog::getInstance(0);
99
}
100
101
if
($this->catalog)
102
return
$this->catalog
;
103
}
104
return
parent::resolve(
$entity
);
105
}
106
114
public
function
setFields
(
array
$fields
)
115
{
116
parent::setFields(
$fields
);
117
if
(
118
is_array($this->fields)
119
&& $this->fields[
"IBLOCK_ID"
] > 0
120
)
121
{
122
$properties =
array
();
123
foreach
($this->fields as $id => $value)
124
{
125
if
(mb_substr($id, 0, 3) ===
"UF_"
)
126
$properties[$id] = $value;
127
}
128
$this->
property
=
new
SectionProperty
($this->
id
);
129
$this->
property
->setIblockId($this->fields[
"IBLOCK_ID"
]);
130
$this->
property
->setFields($properties);
131
132
$this->iblock =
new
Iblock
(
$fields
[
"IBLOCK_ID"
]);
133
134
if
(
135
isset(
$fields
[
"IBLOCK_SECTION_ID"
])
136
&&
$fields
[
"IBLOCK_SECTION_ID"
] > 0
137
)
138
{
139
$this->parent =
new
Section
(
$fields
[
"IBLOCK_SECTION_ID"
]);
140
$this->sections =
new
SectionPath
(
$fields
[
"IBLOCK_SECTION_ID"
]);
141
}
142
143
if
(\
Bitrix
\
Main
\
Loader::includeModule
(
'catalog'
))
144
$this->catalog =
new
ElementCatalog
($this->
id
);
145
}
146
}
147
154
protected
function
loadFromDatabase
()
155
{
156
if
(!isset($this->fields))
157
{
158
$sectionList =
\Bitrix\Iblock\SectionTable::getList
(
array
(
159
"select"
=> array_values($this->fieldMap),
160
"filter"
=>
array
(
"=ID"
=> $this->
id
),
161
));
162
$this->fields = $sectionList->fetch();
163
}
164
return
is_array($this->fields);
165
}
166
}
Bitrix\Iblock\Template\Entity\ElementCatalog
Определения
elementcatalog.php:12
Bitrix\Iblock\Template\Entity\Section
Определения
section.php:10
Bitrix\Iblock\Template\Entity\Section\$iblock
$iblock
Определения
section.php:12
Bitrix\Iblock\Template\Entity\Section\__construct
__construct($id)
Определения
section.php:20
Bitrix\Iblock\Template\Entity\Section\loadFromDatabase
loadFromDatabase()
Определения
section.php:154
Bitrix\Iblock\Template\Entity\Section\resolve
resolve($entity)
Определения
section.php:42
Bitrix\Iblock\Template\Entity\Section\$parent
$parent
Определения
section.php:13
Bitrix\Iblock\Template\Entity\Section\$catalog
$catalog
Определения
section.php:15
Bitrix\Iblock\Template\Entity\Section\$property
$property
Определения
section.php:11
Bitrix\Iblock\Template\Entity\Section\$sections
$sections
Определения
section.php:14
Bitrix\Iblock\Template\Entity\Section\setFields
setFields(array $fields)
Определения
section.php:114
Bitrix\Iblock\Template\Entity\SectionPath
Определения
sectionpath.php:10
Bitrix\Iblock\Template\Entity\SectionProperty
Определения
sectionproperty.php:10
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Определения
loader.php:67
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
Bitrix\Iblock
Bitrix\Main
Bitrix\Sale\Services\Base
Определения
concreteproductrestriction.php:3
Bitrix
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
iblock
lib
template
entity
section.php
Создано системой
1.14.0