1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
element.php
См. документацию.
1
<?php
7
namespace
Bitrix\Iblock\Template\Entity;
8
9
class
Element
extends
Base
10
{
11
protected
$property
=
null
;
12
protected
$iblock
=
null
;
13
protected
$parent
=
null
;
14
protected
$sections
=
null
;
15
protected
$catalog
=
null
;
19
public
function
__construct
($id)
20
{
21
parent::__construct($id);
22
$this->fieldMap =
array
(
23
"name"
=>
"NAME"
,
24
"previewtext"
=>
"PREVIEW_TEXT"
,
25
"detailtext"
=>
"DETAIL_TEXT"
,
26
"code"
=>
"CODE"
,
27
//not accessible from template engine
28
"ID"
=>
"ID"
,
29
"IBLOCK_ID"
=>
"IBLOCK_ID"
,
30
"IBLOCK_SECTION_ID"
=>
"IBLOCK_SECTION_ID"
,
31
);
32
}
33
41
public
function
resolve
(
$entity
)
42
{
43
if
(
$entity
===
"property"
)
44
{
45
if
(!$this->property && $this->
loadFromDatabase
())
46
{
47
if
($this->fields[
"IBLOCK_ID"
] > 0)
48
{
49
$this->
property
= ElementProperty::getInstance($this->
id
);
50
$this->
property
->setIblockId($this->fields[
"IBLOCK_ID"
]);
51
}
52
}
53
54
if
($this->property)
55
return
$this->property
;
56
}
57
elseif
(
$entity
===
"iblock"
)
58
{
59
if
(!$this->iblock && $this->
loadFromDatabase
())
60
{
61
if
($this->fields[
"IBLOCK_ID"
] > 0)
62
$this->iblock =
Iblock::getInstance
($this->fields[
"IBLOCK_ID"
]);
63
}
64
65
if
($this->iblock)
66
return
$this->iblock
;
67
}
68
elseif
(
$entity
===
"parent"
)
69
{
70
if
(!$this->parent && $this->
loadFromDatabase
())
71
{
72
if
($this->fields[
"IBLOCK_SECTION_ID"
] > 0)
73
$this->parent = Section::getInstance($this->fields[
"IBLOCK_SECTION_ID"
]);
74
}
75
76
if
($this->parent)
77
return
$this->parent
;
78
}
79
elseif
(
$entity
===
"sections"
)
80
{
81
if
(!$this->sections && $this->
loadFromDatabase
())
82
{
83
if
($this->fields[
"IBLOCK_SECTION_ID"
] > 0)
84
$this->sections = SectionPath::getInstance($this->fields[
"IBLOCK_SECTION_ID"
]);
85
}
86
87
if
($this->sections)
88
return
$this->sections
;
89
}
90
elseif
(
$entity
===
"catalog"
)
91
{
92
if
(!$this->catalog && $this->
loadFromDatabase
())
93
{
94
if
(\
Bitrix
\
Main
\
Loader::includeModule
(
'catalog'
))
95
$this->catalog = ElementCatalog::getInstance($this->
id
);
96
}
97
98
if
($this->catalog)
99
return
$this->catalog
;
100
}
101
return
parent::resolve(
$entity
);
102
}
103
111
public
function
setFields
(
array
$fields
)
112
{
113
parent::setFields(
$fields
);
114
if
(
115
is_array($this->fields)
116
&& $this->fields[
"IBLOCK_ID"
] > 0
117
)
118
{
119
if
(
120
isset(
$fields
[
"PROPERTY_VALUES"
])
121
&& is_array(
$fields
[
"PROPERTY_VALUES"
])
122
)
123
{
124
$this->
property
=
new
ElementProperty
($this->
id
);
125
$this->
property
->setIblockId($this->fields[
"IBLOCK_ID"
]);
126
$this->
property
->setFields($fields[
"PROPERTY_VALUES"
]);
127
}
128
129
$this->iblock =
new
Iblock
(
$fields
[
"IBLOCK_ID"
]);
130
131
if
(
132
isset(
$fields
[
"IBLOCK_SECTION_ID"
])
133
&&
$fields
[
"IBLOCK_SECTION_ID"
] > 0
134
)
135
{
136
$this->parent =
new
Section
(
$fields
[
"IBLOCK_SECTION_ID"
]);
137
$this->sections =
new
SectionPath
(
$fields
[
"IBLOCK_SECTION_ID"
]);
138
}
139
elseif
(
140
isset(
$fields
[
"IBLOCK_SECTION"
])
141
&& is_array(
$fields
[
"IBLOCK_SECTION"
])
142
)
143
{
144
$section = -1;
145
foreach
(
$fields
[
"IBLOCK_SECTION"
] as $sectionId)
146
{
147
if
($sectionId > 0)
148
{
149
if
($section < 0 || $section > $sectionId)
150
$section = $sectionId;
151
}
152
}
153
154
if
($section > 0)
155
{
156
$this->parent =
new
Section
($section);
157
$this->sections =
new
SectionPath
($section);
158
}
159
}
160
161
if
(\
Bitrix
\
Main
\
Loader::includeModule
(
'catalog'
))
162
$this->catalog =
new
ElementCatalog
($this->
id
);
163
}
164
}
165
172
protected
function
loadFromDatabase
()
173
{
174
static
$cache =
array
();
175
if
($this->
id
> 0)
176
{
177
if
(!isset($cache[$this->
id
]))
178
{
179
//Element fields
180
$elementList =
\Bitrix\Iblock\ElementTable::getList
(
array
(
181
"select"
=> array_values($this->fieldMap),
182
"filter"
=>
array
(
"=ID"
=> $this->
id
),
183
));
184
$cache[$this->id] = $elementList->fetch();
185
}
186
$this->fields = $cache[$this->id];
187
}
188
return
is_array($this->fields);
189
}
190
}
Bitrix\Iblock\Template\Entity\ElementCatalog
Определения
elementcatalog.php:12
Bitrix\Iblock\Template\Entity\Element
Определения
element.php:10
Bitrix\Iblock\Template\Entity\Element\$iblock
$iblock
Определения
element.php:12
Bitrix\Iblock\Template\Entity\Element\__construct
__construct($id)
Определения
element.php:19
Bitrix\Iblock\Template\Entity\Element\loadFromDatabase
loadFromDatabase()
Определения
element.php:172
Bitrix\Iblock\Template\Entity\Element\resolve
resolve($entity)
Определения
element.php:41
Bitrix\Iblock\Template\Entity\Element\$parent
$parent
Определения
element.php:13
Bitrix\Iblock\Template\Entity\Element\$catalog
$catalog
Определения
element.php:15
Bitrix\Iblock\Template\Entity\Element\$property
$property
Определения
element.php:11
Bitrix\Iblock\Template\Entity\Element\$sections
$sections
Определения
element.php:14
Bitrix\Iblock\Template\Entity\Element\setFields
setFields(array $fields)
Определения
element.php:111
Bitrix\Iblock\Template\Entity\ElementProperty
Определения
elementproperty.php:10
Bitrix\Iblock\Template\Entity\Section
Определения
section.php:10
Bitrix\Iblock\Template\Entity\SectionPath
Определения
sectionpath.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
element.php
Создано системой
1.14.0