-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessDataTablesConfig.php
More file actions
160 lines (142 loc) · 5.31 KB
/
Copy pathProcessDataTablesConfig.php
File metadata and controls
160 lines (142 loc) · 5.31 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
/**
* ProcessDataTablesConfig
*
* Simple config module for ProcessDataTables global settings.
*
* @author frameless Media
* @version 0.6.2
* @license MIT
*/
class ProcessDataTablesConfig extends ModuleConfig {
public static function getModuleInfo() {
return [
'title' => 'ProcessDataTables Config',
'version' => '0.6.2',
'summary' => 'Global configuration for ProcessDataTables module.',
'autoload' => false,
'singular' => true,
];
}
/**
* Single‐source defaults for module config.
*
* @return array<string,mixed>
*/
public static function getDefaultConfig(): array {
return [
'checkboxYesLabel' => 'Yes',
'checkboxNoLabel' => 'No',
'dateFormat' => 'd.m.Y H:i',
'currencyFormat' => 'de_AT:EUR',
'numberDecimals' => 2,
'imageThumbnailMaxWidth' => 100,
'optionLabelMap' => '',
'pageRefSeparator' => ', ',
'textMaxLength' => 80,
'textareaStripTags' => true,
'textareaMaxLength' => 120,
'rowsPerPage' => 50,
];
}
public function getInputfields() {
$defaults = self::getDefaultConfig();
$inputfields = new InputfieldWrapper();
// Checkbox labels
$f = $this->modules->get('InputfieldText');
$f->name = 'checkboxYesLabel';
$f->label = __('Label for "Yes" checkbox output');
$f->description = __('Displayed for "Yes" values in checkbox fields.');
$f->value = $this->checkboxYesLabel ?? $defaults['checkboxYesLabel'];
$f->columnWidth = 33;
$inputfields->add($f);
$f = $this->modules->get('InputfieldText');
$f->name = 'checkboxNoLabel';
$f->label = __('Label for "No" checkbox output');
$f->description = __('Displayed for "No" values in checkbox fields.');
$f->columnWidth = 33;
$f->value = $this->checkboxNoLabel ?? $defaults['checkboxNoLabel'];
$inputfields->add($f);
// Date format
$f = $this->modules->get('InputfieldText');
$f->name = 'dateFormat';
$f->label = __('Date Format');
$f->description = __('PHP date format string, e.g. "d.m.Y H:i".');
$f->columnWidth = 33;
$f->value = $this->dateFormat ?? $defaults['dateFormat'];
$inputfields->add($f);
// Currency format
$f = $this->modules->get('InputfieldText');
$f->name = 'currencyFormat';
$f->label = __('Currency Format');
$f->description = __('e.g. de_AT:EUR or en_US:USD');
$f->columnWidth = 33;
$f->value = $this->currencyFormat ?? $defaults['currencyFormat'];
$inputfields->add($f);
// Decimal places for numbers
$f = $this->modules->get('InputfieldInteger');
$f->name = 'numberDecimals';
$f->label = __('Number of decimals for numbers');
$f->description = __('How many decimal places should numbers display?');
$f->columnWidth = 33;
$f->value = $this->numberDecimals ?? $defaults['numberDecimals'];
$inputfields->add($f);
// Maximum image thumbnail width
$f = $this->modules->get('InputfieldInteger');
$f->name = 'imageThumbnailMaxWidth';
$f->label = __('Maximum image thumbnail width (px)');
$f->description = __('Default: 100px');
$f->columnWidth = 33;
$f->value = $this->imageThumbnailMaxWidth ?? $defaults['imageThumbnailMaxWidth'];
$inputfields->add($f);
// Option label map
$f = $this->modules->get('InputfieldTextarea');
$f->name = 'optionLabelMap';
$f->label = __('Options Label Mapping');
$f->description = __('Optional: Map option values to labels (one per line: value=Label)');
$f->columnWidth = 33;
$f->value = $this->optionLabelMap ?? $defaults['optionLabelMap'];
$inputfields->add($f);
// Page reference separator
$f = $this->modules->get('InputfieldText');
$f->name = 'pageRefSeparator';
$f->label = __('Page reference separator');
$f->description = __('Separator for multiple referenced pages (e.g. comma, semicolon, etc.)');
$f->columnWidth = 33;
$f->value = $this->pageRefSeparator ?? $defaults['pageRefSeparator'];
$inputfields->add($f);
// Text field max length
$f = $this->modules->get('InputfieldInteger');
$f->name = 'textMaxLength';
$f->label = __('Max length for text output');
$f->description = __('Maximum character length for simple text fields');
$f->columnWidth = 33;
$f->value = (int) ($this->numberDecimals ?? $defaults['numberDecimals']);
$inputfields->add($f);
// Textarea: strip HTML tags
$f = $this->modules->get('InputfieldCheckbox');
$f->name = 'textareaStripTags';
$f->label = __('Strip HTML tags from textarea?');
$f->description = __('If enabled, HTML tags will be removed from textarea output.');
$f->columnWidth = 33;
$f->checked = (bool) ($this->textareaStripTags ?? $defaults['textareaStripTags']);
$inputfields->add($f);
// Textarea max length
$f = $this->modules->get('InputfieldInteger');
$f->name = 'textareaMaxLength';
$f->label = __('Max length for textarea output');
$f->description = __('Maximum character length for textarea fields');
$f->columnWidth = 33;
$f->value = $this->textareaMaxLength ?? $defaults['textareaMaxLength'];
$inputfields->add($f);
// Rows per page
$f = $this->modules->get('InputfieldInteger');
$f->name = 'rowsPerPage';
$f->label = __('Rows per page');
$f->description = __('Number of rows to display per page in the DataTable.');
$f->columnWidth = 33;
$f->value = $this->rowsPerPage ?? self::getDefaultConfig()['rowsPerPage'];
$inputfields->add($f);
return $inputfields;
}
}