Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
elementprovider.php
1
<?php
2
3
namespace
Bitrix\Iblock\Grid\Column
;
4
5
use
Bitrix\Main\Grid
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Iblock
;
8
use
Bitrix\Main\Grid\Column\Editable\Config
;
9
10
class
ElementProvider
extends
BaseElementProvider
11
{
12
public
function
prepareColumns
(): array
13
{
14
$result = [];
15
16
if
(!$this->
isSkuSelectorEnabled
())
17
{
18
$result[
'NAME'
] = [
19
'type'
=> Grid\Column\Type::TEXT,
20
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_NAME'
),
21
'necessary'
=>
true
,
22
'editable'
=>
true
,
23
'multiple'
=>
false
,
24
'sort'
=>
'NAME'
,
25
];
26
$result[
'PREVIEW_PICTURE'
] = [
27
'type'
=> Grid\Column\Type::FILE,
28
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_PREVIEW_PICTURE'
),
29
'sort'
=>
'HAS_PREVIEW_PICTURE'
,
30
'necessary'
=>
false
,
31
'editable'
=>
true
,
32
'multiple'
=>
false
,
33
'prevent_default'
=>
true
,
// TODO: what is this
34
];
35
$result[
'DETAIL_PICTURE'
] = [
36
'type'
=> Grid\Column\Type::FILE,
37
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_DETAIL_PICTURE'
),
38
'sort'
=>
'HAS_DETAIL_PICTURE'
,
39
'necessary'
=>
false
,
40
'editable'
=>
true
,
41
'multiple'
=>
false
,
42
'prevent_default'
=>
true
,
// TODO: what is this
43
];
44
}
45
46
$result = array_merge(
47
$this->
getCommonColumns
(),
48
$this->
getElementFieldsColumns
(),
49
$this->getSpecificElementColumns(),
50
$result,
51
$this->
getSectionFields
(),
52
);
53
54
return
$this->
createColumns
($result);
55
}
56
57
protected
function
getCommonColumns
(): array
58
{
59
$result = [];
60
61
$result[
'ACTIVE'
] = [
62
'type'
=> Grid\Column\Type::CHECKBOX,
63
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_ACTIVE'
),
64
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_ACTIVE'
),
65
'necessary'
=>
true
,
66
'editable'
=>
true
,
67
'multiple'
=>
false
,
68
'sort'
=>
'ACTIVE'
,
69
'align'
=>
'center'
,
70
];
71
$result[
'SORT'
] = [
72
'type'
=> Grid\Column\Type::INT,
73
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_SORT'
),
74
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_SORT'
),
75
'necessary'
=>
false
,
76
'editable'
=>
true
,
77
'multiple'
=>
false
,
78
'sort'
=>
'SORT'
,
79
'align'
=>
'right'
,
80
];
81
$result[
'CODE'
] = [
82
'type'
=> Grid\Column\Type::TEXT,
83
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_CODE'
),
84
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_CODE'
),
85
'necessary'
=>
false
,
86
'editable'
=>
true
,
87
'multiple'
=>
false
,
88
'sort'
=>
'CODE'
,
89
];
90
$result[
'XML_ID'
] = [
91
'type'
=> Grid\Column\Type::TEXT,
92
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_XML_ID_MSGVER_1'
),
93
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_XML_ID'
),
94
'necessary'
=>
false
,
95
'editable'
=>
true
,
96
'multiple'
=>
false
,
97
'sort'
=>
'XML_ID'
,
98
];
99
$result[
'TIMESTAMP_X'
] = [
100
'type'
=> Grid\Column\Type::DATE,
101
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TIMESTAMP_X'
),
102
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_TIMESTAMP_X'
),
103
'necessary'
=>
false
,
104
'editable'
=>
false
,
105
'multiple'
=>
false
,
106
'sort'
=>
'TIMESTAMP_X'
,
107
];
108
$result[
'MODIFIED_BY'
] = [
109
'type'
=> Grid\Column\Type::CUSTOM,
110
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_MODIFIED_BY'
),
111
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_MODIFIED_BY'
),
112
'necessary'
=>
false
,
113
'editable'
=>
false
,
114
'multiple'
=>
false
,
115
'sort'
=>
'MODIFIED_BY'
,
116
'safeMode'
=>
true
,
117
];
118
$result[
'DATE_CREATE'
] = [
119
'type'
=> Grid\Column\Type::DATE,
120
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_DATE_CREATE'
),
121
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_DATE_CREATE'
),
122
'necessary'
=>
false
,
123
'editable'
=>
false
,
124
'multiple'
=>
false
,
125
'sort'
=>
'DATE_CREATE'
,
// TODO: check - created
126
];
127
$result[
'CREATED_BY'
] = [
128
'type'
=> Grid\Column\Type::CUSTOM,
129
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_CREATED_BY'
),
130
'title'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TITLE_CREATED_BY'
),
131
'necessary'
=>
false
,
132
'editable'
=>
false
,
133
'multiple'
=>
false
,
134
'sort'
=>
'CREATED_BY'
,
135
'safeMode'
=>
true
,
136
];
137
$select = [
138
'ID'
,
139
];
140
if
($this->
isSkuSelectorEnabled
())
141
{
142
$select[] =
'NAME'
;
143
}
144
$result[
'ID'
] = [
145
'type'
=> Grid\Column\Type::CUSTOM,
146
'name'
=>
'ID'
,
147
'necessary'
=>
true
,
148
'editable'
=>
false
,
149
'multiple'
=>
false
,
150
'select'
=> $select,
151
'sort'
=>
'ID'
,
152
];
153
unset($select);
154
155
return
$result;
156
}
157
158
protected
function
getElementFieldsColumns
(): array
159
{
160
$result = [];
161
$result[
'ACTIVE_FROM'
] = [
162
'type'
=> Grid\Column\Type::DATE,
163
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_ACTIVE_FROM'
),
164
'necessary'
=>
false
,
165
'editable'
=>
true
,
166
'multiple'
=>
false
,
167
'sort'
=>
'ACTIVE_FROM'
,
168
];
169
$result[
'ACTIVE_TO'
] = [
170
'type'
=> Grid\Column\Type::DATE,
171
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_ACTIVE_TO'
),
172
'necessary'
=>
false
,
173
'editable'
=>
true
,
174
'multiple'
=>
false
,
175
'sort'
=>
'ACTIVE_TO'
,
176
];
177
$result[
'SHOW_COUNTER'
] = [
178
'type'
=> Grid\Column\Type::INT,
179
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_SHOW_COUNTER'
),
180
'necessary'
=>
false
,
181
'editable'
=>
false
,
182
'multiple'
=>
false
,
183
'sort'
=>
'SHOW_COUNTER'
,
184
'align'
=>
'right'
,
185
];
186
$result[
'SHOW_COUNTER_START'
] = [
187
'type'
=> Grid\Column\Type::DATE,
188
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_SHOW_COUNTER_START'
),
189
'necessary'
=>
false
,
190
'editable'
=>
false
,
191
'multiple'
=>
false
,
192
'sort'
=>
'SHOW_COUNTER_START'
,
193
];
194
195
$result[
'PREVIEW_TEXT'
] = [
196
'type'
=> Grid\Column\Type::TEXT,
197
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_PREVIEW_TEXT'
),
198
'necessary'
=>
false
,
199
'editable'
=>
true
,
200
'multiple'
=>
false
,
201
'select'
=> [
202
'PREVIEW_TEXT'
,
203
'PREVIEW_TEXT_TYPE'
,
204
],
205
'editable'
=>
new
Config
(
'PREVIEW_TEXT'
,
Grid
\Editor\Types::TEXTAREA),
206
];
207
208
$result[
'DETAIL_TEXT'
] = [
209
'type'
=> Grid\Column\Type::TEXT,
210
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_DETAIL_TEXT'
),
211
'necessary'
=>
false
,
212
'editable'
=>
true
,
213
'multiple'
=>
false
,
214
'select'
=> [
215
'DETAIL_TEXT'
,
216
'DETAIL_TEXT_TYPE'
,
217
],
218
'editable'
=>
new
Config
(
'DETAIL_TEXT'
,
Grid
\Editor\Types::TEXTAREA),
219
];
220
221
$result[
'TAGS'
] = [
222
'type'
=> Grid\Column\Type::INPUT,
223
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_TAGS'
),
224
'necessary'
=>
false
,
225
'editable'
=>
true
,
226
'multiple'
=>
false
,
227
'sort'
=>
'TAGS'
,
228
];
229
230
return
$result;
231
}
232
233
private
function
getSpecificElementColumns(): array
234
{
235
$result = [];
236
237
if
($this->
isAllowedIblockSections
())
238
{
239
$result[
'SECTIONS'
] = [
240
'type'
=> Grid\Column\Type::CUSTOM,
241
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_SECTIONS'
),
242
'necessary'
=>
false
,
243
'editable'
=>
false
,
244
'multiple'
=>
false
,
245
'safeMode'
=>
true
,
246
];
247
}
248
249
return
$result;
250
}
251
252
protected
function
getSectionFields
(): array
253
{
254
if
(!$this->
isIblockCombinedMode
())
255
{
256
return
[];
257
}
258
259
$result = [];
260
$result[
'ELEMENT_CNT'
] = [
261
'type'
=> Grid\Column\Type::CUSTOM,
262
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_ELEMENT_CNT'
),
263
'necessary'
=>
false
,
264
'editable'
=>
false
,
265
'multiple'
=>
false
,
266
'sort'
=>
'ELEMENT_CNT'
,
267
'align'
=>
'right'
,
268
];
269
if
($this->
getIblockId
() !==
null
)
270
{
271
$result[
'SECTION_CNT'
] = [
272
'type'
=> Grid\Column\Type::CUSTOM,
273
'name'
=>
Loc::getMessage
(
'IBLOCK_ELEMENT_COLUMN_PROVIDER_FIELD_SECTION_CNT'
),
274
'necessary'
=>
false
,
275
'editable'
=>
false
,
276
'multiple'
=>
false
,
277
'align'
=>
'right'
,
278
];
279
}
280
281
return
$result;
282
}
283
284
protected
function
isAllowedIblockSections
(): bool
285
{
286
$settings = $this->
getSettings
();
287
288
return
$settings->isAllowedIblockSections();
289
}
290
291
protected
function
getIblockListMode
(): string
292
{
293
$settings = $this->
getSettings
();
294
295
return
$settings->getListMode();
296
}
297
298
protected
function
isIblockSeparateMode
(): bool
299
{
300
return
$this->
getIblockListMode
() === Iblock\IblockTable::LIST_MODE_SEPARATE;
301
}
302
303
protected
function
isIblockCombinedMode
(): bool
304
{
305
return
$this->
getIblockListMode
() === Iblock\IblockTable::LIST_MODE_COMBINED;
306
}
307
}
Bitrix\Iblock\Grid\Column\BaseElementProvider
Definition
baseelementprovider.php:12
Bitrix\Iblock\Grid\Column\BaseElementProvider\getIblockId
getIblockId()
Definition
baseelementprovider.php:18
Bitrix\Iblock\Grid\Column\BaseElementProvider\isSkuSelectorEnabled
isSkuSelectorEnabled()
Definition
baseelementprovider.php:23
Bitrix\Iblock\Grid\Column\ElementProvider
Definition
elementprovider.php:11
Bitrix\Iblock\Grid\Column\ElementProvider\isIblockSeparateMode
isIblockSeparateMode()
Definition
elementprovider.php:298
Bitrix\Iblock\Grid\Column\ElementProvider\getSectionFields
getSectionFields()
Definition
elementprovider.php:252
Bitrix\Iblock\Grid\Column\ElementProvider\getIblockListMode
getIblockListMode()
Definition
elementprovider.php:291
Bitrix\Iblock\Grid\Column\ElementProvider\prepareColumns
prepareColumns()
Definition
elementprovider.php:12
Bitrix\Iblock\Grid\Column\ElementProvider\getCommonColumns
getCommonColumns()
Definition
elementprovider.php:57
Bitrix\Iblock\Grid\Column\ElementProvider\isIblockCombinedMode
isIblockCombinedMode()
Definition
elementprovider.php:303
Bitrix\Iblock\Grid\Column\ElementProvider\getElementFieldsColumns
getElementFieldsColumns()
Definition
elementprovider.php:158
Bitrix\Iblock\Grid\Column\ElementProvider\isAllowedIblockSections
isAllowedIblockSections()
Definition
elementprovider.php:284
Bitrix\Main\Grid\Column\DataProvider\createColumns
createColumns(array $columns)
Definition
dataprovider.php:61
Bitrix\Main\Grid\Column\DataProvider\getSettings
getSettings()
Definition
dataprovider.php:31
Bitrix\Main\Grid\Column\Editable\Config
Definition
config.php:11
Bitrix\Main\Grid\Grid
Definition
grid.php:74
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Iblock\Grid\Column
Definition
baseelementprovider.php:3
Bitrix\Iblock
Bitrix\Main\Config
Definition
configuration.php:2
Bitrix\Main\Grid
modules
iblock
lib
grid
column
elementprovider.php
Создано системой
1.10.0