/
grid_controllers.php
executable file
·104 lines (96 loc) · 3.05 KB
/
grid_controllers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
function grid_controllers($controller) {
$denied = [
'admin', 'auth', 'images', 'content', 'moderation', 'users', 'typograph'
];
$options = [
'deny_mass_editing' => true,
'order_by' => false,
'order_to' => false,
'is_pagination' => false
];
$columns = [
'title' => [
'title' => LANG_TITLE,
'href' => href_to($controller->name, 'controllers', ['edit', '{name}']),
'filter' => 'like',
'href_handler' => function ($item) {
return $item['is_backend'];
}
],
'slug' => [
'title' => LANG_ADMIN_CONTROLLER_SLUG,
'class' => 'd-none d-lg-table-cell',
'editable' => [
'attributes' => ['placeholder' => '{name}'],
'rules' => [
['sysname']
]
],
'handler' => function ($v, $row) {
if (!$v) {
return $row['name'];
}
return $v;
}
],
'is_enabled' => [
'title' => LANG_IS_ENABLED,
'flag' => true,
'flag_toggle' => href_to($controller->name, 'controllers', ['toggle', '{id}']),
'href_handler' => function ($row) use ($denied) {
if (in_array($row['name'], $denied)) {
return false;
}
return true;
}
],
'version' => [
'title' => LANG_VERSION,
'class' => 'd-none d-lg-table-cell',
'width' => 70,
'filter' => 'like'
]
];
if (!cmsConfig::get('disable_copyright')) {
$columns['author'] = [
'title' => LANG_AUTHOR,
'class' => 'd-none d-lg-table-cell',
'width' => 200,
'href' => '{url}',
'filter' => 'like'
];
}
$actions = [
[
'title' => LANG_CP_PACKAGE_CONTENTS,
'class' => 'view ajax-modal',
'href' => href_to($controller->name, 'package_files_list', ['controllers', '{id}']),
'handler' => function ($row) {
return $row['files'];
}
],
[
'title' => LANG_CONFIG,
'class' => 'config',
'href' => href_to($controller->name, 'controllers', ['edit', '{name}']),
'handler' => function ($row) {
return $row['is_backend'];
}
],
[
'title' => LANG_DELETE,
'class' => 'delete',
'confirm' => LANG_CP_DELETE_COMPONENT_CONFIRM,
'href' => href_to($controller->name, 'controllers_delete', ['{name}']),
'handler' => function ($row) {
return $row['is_external'];
}
]
];
return [
'options' => $options,
'columns' => $columns,
'actions' => $actions
];
}