1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
options.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Grid;
4
5
use Bitrix\Main\Application;
6
12
class
Options
extends
\CGridOptions
13
{
15
protected
$id
;
16
17
24
public
function
__construct
($gridId,
array
$filterPresets
=
array
())
25
{
26
$this->
id
= $gridId;
27
parent::__construct($gridId,
$filterPresets
);
28
29
if
(!static::isAuthorized() &&
30
isset(
Application::getInstance
()->getSession()[
"main.ui.grid.options"
][$this->
id
]) &&
31
is_array(
Application::getInstance
()->getSession()[
"main.ui.grid.options"
][$this->
id
]) &&
32
!empty(
Application::getInstance
()->getSession()[
"main.ui.grid.options"
][$this->
id
]))
33
{
34
$this->all_options =
Application::getInstance
()->getSession()[
"main.ui.grid.options"
][
$this->id
];
35
}
36
}
37
38
43
public
function
getId
()
44
{
45
return
$this->id
;
46
}
47
48
53
protected
static
function
getUser
()
54
{
55
global
$USER
;
56
return
$USER
;
57
}
58
59
65
public
function
setColumnsSizes
($expand, $sizes)
66
{
67
$columns =
array
();
68
foreach
((
array
) $sizes as
$name
=>
$width
)
69
{
70
$name
= trim(
$name
);
71
$width
= is_scalar(
$width
) ? (int)
$width
: 0;
72
if
(
$name
!=
''
&&
$width
> 0)
73
$columns[
$name
] =
$width
;
74
}
75
76
$this->all_options[
'views'
][
$this->currentView
][
'columns_sizes'
] =
array
(
77
'expand'
=> is_scalar($expand) ? round((
float
) $expand, 8) : 1,
78
'columns'
=> $columns
79
);
80
}
81
82
87
public
function
setPageSize
($size)
88
{
89
$size = is_scalar($size) ? (int) $size : 20;
90
$size = $size >= 0 ? $size : 20;
91
92
$this->all_options[
'views'
][
$this->currentView
][
'page_size'
] = $size;
93
}
94
95
100
public
function
setCustomNames
($names)
101
{
102
$this->all_options[
"views"
][
"default"
][
"custom_names"
] = $names;
103
}
104
105
109
public
function
resetExpandedRows
()
110
{
111
$this->
setExpandedRows
();
112
}
113
114
119
public
function
setExpandedRows
($ids =
array
())
120
{
121
Application::getInstance
()->getSession()[
"main.ui.grid"
][$this->
getId
()][
"expanded_rows"
] = $ids;
122
}
123
124
129
public
function
getExpandedRows
()
130
{
131
return
Application::getInstance
()->getSession()[
"main.ui.grid"
][$this->
getId
()][
"expanded_rows"
] ??
null
;
132
}
133
134
139
public
function
setCollapsedGroups
($ids =
array
())
140
{
141
Application::getInstance
()->getSession()[
"main.ui.grid"
][$this->
getId
()][
"collapsed_groups"
] = is_array($ids) ? $ids :
array
();
142
}
143
144
149
public
function
getCollapsedGroups
()
150
{
151
return
Application::getInstance
()->getSession()[
"main.ui.grid"
][$this->
getId
()][
"collapsed_groups"
] ??
null
;
152
}
153
154
159
public
function
resetView
($viewId)
160
{
161
$gridId = $this->
getId
();
162
$this->all_options[
"views"
][$viewId] =
array
();
163
unset(
Application::getInstance
()->getSession()[
"main.interface.grid"
][$gridId]);
164
unset(
Application::getInstance
()->getSession()[
"main.ui.grid"
][$gridId]);
165
$this->
Save
();
166
parent::__construct($gridId);
167
}
168
169
174
public
function
deleteView
($viewId)
175
{
176
$gridId = $this->
getId
();
177
unset($this->all_options[
"views"
][$viewId]);
178
unset(
Application::getInstance
()->getSession()[
"main.interface.grid"
][$gridId]);
179
unset(
Application::getInstance
()->getSession()[
"main.ui.grid"
][$gridId]);
180
$this->
Save
();
181
parent::__construct($gridId);
182
}
183
184
188
public
function
getCurrentOptions
()
189
{
190
$options
= $this->getOptions();
191
$currentViewId =
$options
[
"current_view"
];
192
return
$options
[
"views"
][$currentViewId];
193
}
194
195
199
private
static
function
getDefaultGetSortingResult()
200
{
201
return
array
(
202
"sort"
=>
array
(),
203
"vars"
=>
array
(
204
"by"
=>
"by"
,
205
"order"
=>
"order"
206
)
207
);
208
}
209
210
216
public
function
getSorting
($default =
array
())
217
{
218
$result
= static::getDefaultGetSortingResult();
219
$result
[
"sort"
] = isset($default[
"sort"
]) && is_array($default[
"sort"
]) ? $default[
"sort"
] :
$result
[
"sort"
];
220
$result
[
"vars"
] = isset($default[
"vars"
]) && is_array($default[
"vars"
]) ? $default[
"vars"
] :
$result
[
"vars"
];
221
222
$options
= $this->
getCurrentOptions
();
223
224
if
(!empty(
$options
[
"last_sort_by"
]) && !empty(
$options
[
"last_sort_order"
]))
225
{
226
$result
[
"sort"
] =
array
(
$options
[
"last_sort_by"
] =>
$options
[
"last_sort_order"
]);
227
}
228
229
return
$result
;
230
}
231
232
237
protected
static
function
getUserId
()
238
{
239
return
(
int
)static::getUser()?->getID();
240
}
241
242
247
protected
static
function
isAuthorized
()
248
{
249
return
(
bool
)static::getUser()?->isAuthorized();
250
}
251
252
256
public
function
save
()
257
{
258
$gridId = $this->
getId
();
259
260
if
(static::isAuthorized())
261
{
262
\CUserOptions::setOption(
"main.interface.grid"
, $gridId, $this->all_options);
263
}
264
else
265
{
266
Application::getInstance
()->getSession()[
"main.ui.grid.options"
][$gridId] =
$this->all_options
;
267
}
268
}
269
270
276
public
function
getUsedColumns
($defaultColumns =
array
())
277
{
278
$currentOptions = $this->
getCurrentOptions
();
279
280
if
(isset($currentOptions[
"columns"
]) && is_string($currentOptions[
"columns"
]) && $currentOptions[
"columns"
] !==
""
)
281
{
282
return
explode(
","
, $currentOptions[
"columns"
]);
283
}
284
285
return
$defaultColumns;
286
}
287
288
293
public
function
setStickedColumns
($columns = [])
294
{
295
$this->all_options[
"views"
][
"default"
][
"sticked_columns"
] = is_array($columns) ? $columns : [];
296
}
297
302
public
function
getStickedColumns
()
303
{
304
$currentOptions = $this->
getCurrentOptions
();
305
306
if
(isset($currentOptions[
"sticked_columns"
]) && is_array($currentOptions[
"sticked_columns"
]))
307
{
308
return
$currentOptions[
"sticked_columns"
];
309
}
310
311
return
null
;
312
}
313
}
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\Grid\Options
Определения
options.php:13
Bitrix\Main\Grid\Options\setStickedColumns
setStickedColumns($columns=[])
Определения
options.php:293
Bitrix\Main\Grid\Options\setColumnsSizes
setColumnsSizes($expand, $sizes)
Определения
options.php:65
Bitrix\Main\Grid\Options\getId
getId()
Определения
options.php:43
Bitrix\Main\Grid\Options\getCollapsedGroups
getCollapsedGroups()
Определения
options.php:149
Bitrix\Main\Grid\Options\resetExpandedRows
resetExpandedRows()
Определения
options.php:109
Bitrix\Main\Grid\Options\getUserId
static getUserId()
Определения
options.php:237
Bitrix\Main\Grid\Options\getExpandedRows
getExpandedRows()
Определения
options.php:129
Bitrix\Main\Grid\Options\isAuthorized
static isAuthorized()
Определения
options.php:247
Bitrix\Main\Grid\Options\resetView
resetView($viewId)
Определения
options.php:159
Bitrix\Main\Grid\Options\deleteView
deleteView($viewId)
Определения
options.php:174
Bitrix\Main\Grid\Options\setPageSize
setPageSize($size)
Определения
options.php:87
Bitrix\Main\Grid\Options\getUsedColumns
getUsedColumns($defaultColumns=array())
Определения
options.php:276
Bitrix\Main\Grid\Options\setExpandedRows
setExpandedRows($ids=array())
Определения
options.php:119
Bitrix\Main\Grid\Options\getSorting
getSorting($default=array())
Определения
options.php:216
Bitrix\Main\Grid\Options\setCollapsedGroups
setCollapsedGroups($ids=array())
Определения
options.php:139
Bitrix\Main\Grid\Options\__construct
__construct($gridId, array $filterPresets=array())
Определения
options.php:24
Bitrix\Main\Grid\Options\getStickedColumns
getStickedColumns()
Определения
options.php:302
Bitrix\Main\Grid\Options\$id
$id
Определения
options.php:15
Bitrix\Main\Grid\Options\getUser
static getUser()
Определения
options.php:53
Bitrix\Main\Grid\Options\getCurrentOptions
getCurrentOptions()
Определения
options.php:188
Bitrix\Main\Grid\Options\setCustomNames
setCustomNames($names)
Определения
options.php:100
Bitrix\Main\Grid\Options\save
save()
Определения
options.php:256
CGridOptions
Определения
grids.php:8
CGridOptions\$options
$options
Определения
grids.php:11
CGridOptions\$all_options
$all_options
Определения
grids.php:10
CGridOptions\$filterPresets
$filterPresets
Определения
grids.php:13
CGridOptions\$currentView
$currentView
Определения
grids.php:14
CGridOptions\Save
Save()
Определения
grids.php:326
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$USER
global $USER
Определения
csv_new_run.php:40
$name
$name
Определения
menu_edit.php:35
$width
$width
Определения
html.php:68
bitrix
modules
main
lib
grid
options.php
Создано системой
1.14.0