/
form_ctypes_prop.php
executable file
·129 lines (124 loc) · 5.13 KB
/
form_ctypes_prop.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
class formAdminCtypesProp extends cmsForm {
public function init($do, $ctype) {
$model = cmsCore::getModel('backend_content');
$table_name = $model->table_prefix . $ctype['name'] . '_props';
return [
'basic' => [
'type' => 'fieldset',
'childs' => [
new fieldString('title', [
'title' => LANG_CP_PROP_TITLE,
'can_multilanguage' => true,
'multilanguage_params' => [
'is_table_field' => true,
'table' => $table_name
],
'rules' => [
['required'],
['max_length', 100]
]
]),
new fieldCheckbox('is_in_filter', [
'title' => LANG_CP_FIELD_IN_FILTER,
])
]
],
'group' => [
'type' => 'fieldset',
'title' => LANG_CP_FIELD_FIELDSET,
'childs' => [
new fieldList('fieldset', [
'title' => LANG_CP_FIELD_FIELDSET_SELECT,
'generator' => function ($prop) use ($model, $ctype) {
$fieldsets = $model->getContentPropsFieldsets($ctype['name']);
$items = [''];
if (is_array($fieldsets)) {
foreach ($fieldsets as $fieldset) {
$items[$fieldset] = $fieldset;
}
}
return $items;
}
]),
new fieldString('new_fieldset', [
'title' => LANG_CP_FIELD_FIELDSET_ADD,
'rules' => [
['max_length', 32]
]
])
]
],
'type' => [
'type' => 'fieldset',
'title' => LANG_CP_FIELD_TYPE,
'childs' => [
new fieldList('type', [
'default' => 'list',
'items' => [
'list' => LANG_PARSER_LIST,
'list_multiple' => LANG_PARSER_LIST_MULTIPLE,
'string' => LANG_PARSER_STRING,
'color' => LANG_PARSER_COLOR,
'number' => LANG_PARSER_NUMBER,
'checkbox' => LANG_PARSER_CHECKBOX
]
]),
new fieldCheckbox('options:is_required', [
'title' => LANG_VALIDATE_REQUIRED
])
]
],
'number' => [
'type' => 'fieldset',
'title' => LANG_PARSER_NUMBER,
'childs' => [
new fieldString('options:units', [
'title' => LANG_CP_PROP_UNITS,
'can_multilanguage' => true
]),
new fieldCheckbox('options:is_filter_range', [
'title' => LANG_PARSER_NUMBER_FILTER_RANGE
])
]
],
'values' => [
'type' => 'fieldset',
'title' => LANG_CP_PROP_VALUES,
'childs' => [
new fieldText('values', [
'can_multilanguage' => true,
'multilanguage_params' => [
'is_table_field' => true,
'table' => $table_name
],
'size' => 8,
'is_strip_tags' => true,
'hint' => LANG_CP_PROP_VALUES_HINT
]),
new fieldCheckbox('options:is_filter_multi', [
'title' => LANG_PARSER_LIST_FILTER_MULTI
])
]
],
'cats' => [
'type' => 'fieldset',
'title' => LANG_CP_PROP_CATS,
'childs' => [
new fieldList('cats', [
'is_multiple' => true,
'multiple_select_deselect' => true,
'is_tree' => true,
'generator' => function ($prop) use ($model, $ctype) {
$tree = $model->limit(0)->getCategoriesTree($ctype['name'], false);
foreach ($tree as $c) {
$items[$c['id']] = str_repeat('- ', $c['ns_level']) . ' ' . $c['title'];
}
return $items;
}
])
]
]
];
}
}