-
Notifications
You must be signed in to change notification settings - Fork 3
/
editor.php
421 lines (407 loc) · 15.6 KB
/
editor.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<?php
/*
#############################################################################################
Editor values for section "Contact Form" for Typesetter CMS developer plugin - 'Custom Sections'
By: webks: websolutions kept simple
Based on Custom Sections by: J. Krausz and a2exfr
Date: 2017-02-21
Version 0.5b
#############################################################################################
*/
defined('is_running') or die('Not an entry point...');
global $addonPathData, $addonPathCode, $config;
// Load common variables, functions and initialize translation:
require($addonPathCode.'/_types/contact_form/common.php');
$editor = array(
'custom_scripts' => false, // use a custom editor Javascript for this section type?
'custom_css' => false, // use a custom editor CSS for this section type?
'editor_components' => false, // only when using custom editor script(s), we use this to load components like text, colorpicker, clockpicker, datepicker
// the components value can be a string 'text', a csv 'text,colorpicker' or an array('text','colorpicker');
// when the universal editor is used, we do not need to set this value, because components will be auto loaded with the respective control_type
// js_on_content is a callback executed after content has been changed.
// javascript code to be executed when the currently edited section is updated. Use e.g. for re-initing something.
// 'js_on_content' => 'console.log("Section updated")',
// TODO: Attributes currently not working - add regex if fixed (https://github.com/juek/CustomSections/issues/19):
// : - HTML allowed in mail headers & footers
// : - Only letters and digits component texts (button, messages, ...)
'controls' => array(
'form_items'=>array(
'label' => '<i class="fa fa-file-text-o"></i> ' . $tString['formItemLabel'],
'control_type' => 'bunch_control',
'sub_controls'=>array(
// Single field settings
// Field required
'required' => array(
'label' => $tString['fieldRequiredLabel'],
'control_type' => 'checkbox',
'attributes' => array(),
'on' => array(),
),
// Field disabled
'disabled' => array(
'label' => $tString['fieldDisabledLabel'],
'control_type' => 'checkbox',
'attributes' => array(),
'on' => array(),
),
// Field types
'field_type' => array(
'label' => '<i class="fa fa-cube"></i> ' . $tString['fieldTypeLabel'],
'control_type' => 'radio_group',
'radio-buttons' => array(
// Define selectable input types:
'input_type_text' => 'Text',
'input_type_textarea' => 'Textarea',
'input_type_select' => 'Select',
'input_type_radio' => 'Radio',
'input_type_checkbox' => 'Checkbox',
'input_type_date' => 'Date',
'input_type_time' => 'Time',
'input_type_datetime' => 'Datetime',
'input_type_datetime_local' => 'Datetime (Local)',
'input_type_email' => 'E-Mail',
'input_type_phone' => 'Telephone Number',
'input_type_url' => 'URL',
'input_type_number' => 'Number',
),
'attributes' => array(
// TODO: Attributes not working on bunch_control sub items? ==> https://github.com/juek/CustomSections/issues/19
'id' => 'field-types',
'class' => 'contact-form-field-type',
),
'on' => array(
'change' => 'function(){
console.log($(this).attr("value"));
if($(this).attr("value") === "input_type_radio" || $(this).attr("value") === "input_type_select" || $(this).attr("value") === "input_type_checkbox"){
// Show options field on multi value fields
$(this).parents(".sub_controls_cont:first").find("textarea[id*=\"options\"]").parents(".editor-ctl-box:first").show();
// Hide placeholder field on none text fields
$(this).parents(".sub_controls_cont:first").find("input[id*=\"placeholder\"]").parents(".editor-ctl-box:first").hide();
}else{
// Hide options field on none multi value fields
$(this).parents(".sub_controls_cont:first").find("textarea[id*=\"options\"]").parents(".editor-ctl-box:first").hide();
// Show placeholder field on text fields
$(this).parents(".sub_controls_cont:first").find("input[id*=\"placeholder\"]").parents(".editor-ctl-box:first").show();
}
}',
),
),
// Field options (eg. Select options)
'options' => array(
'label' => '<i class="fa fa-cubes"></i> ' . $tString['fieldOptionsLabel'],
'control_type' => 'textarea',
'attributes' => array(
'id' => 'form-field-subvalues',
'class' => 'hidden', // hide initally (visibility depends on the field type) - TODO: Class not working?
'placeholder' => 'value|Label',
),
// 'on' => array(),
),
// value 'option / select values' --end
'label' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['fieldLabelLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
'placeholder' => 'Label',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
'input' => 'function(){
// Automaticly creates a machine readable name from the label value
function convertToSlug(text)
{
return text
.toLowerCase()
.replace(/[^\w ]+/g,"")
.replace(/ +/g,"_");
}
var currentLabel = convertToSlug($(this).val());
$(this).parents(".sub_controls_cont:first").find("input[id*=\"machine_name\"]:first").attr("value", currentLabel);
}',
),
),
'machine_name' => array(
'label' => '<i class="fa fa-terminal"></i> ' . $tString['fieldMachineNameLabel'],
'control_type' => 'text',
'attributes' => array(
'class' => 'machine-name',
'placeholder' => 'Machine Name',
'pattern' => '^[a-z0-9_]*$', // regex: start of string, lowercase letters, digits and underline
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'placeholder' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['fieldPlaceholderLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
'placeholder' => 'Placeholder',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'description_on_error' => array(
'label' => $tString['fieldDescOnErrorLabel'],
'control_type' => 'checkbox',
'attributes' => array(),
'on' => array(),
),
'description' => array(
'label' => '<i class="fa fa-align-left"></i> ' . $tString['fieldDescLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
// 'placeholder' => 'A short description',
),
'on' => array(),
),
'prefix' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['fieldPrefixLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
'placeholder' => 'Placeholder',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'suffix' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['fieldSuffixLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
'placeholder' => 'Placeholder',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
),
),
// Form settings
'success_message_text' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['successMessageTextLabel'],
'control_type' => 'ck_editor',
'attributes' => array(
// 'class' => '',
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'unexpected_error_text' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['unexpectedErrorTextLabel'],
'control_type' => 'ck_editor',
'attributes' => array(
// 'class' => '',
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'button_text' => array(
'label' => '<i class="fa fa-cc-stripe"></i> ' . $tString['submitButtonTextLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
'placeholder' => 'Click me!',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'button_send_text' => array(
'label' => '<i class="fa fa-cc-stripe"></i> ' . $tString['submitButtonSendTextLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
'placeholder' => 'Button text while sending',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'validation_inactive_icon' => array(
'label' => '<i class="fa fa-css3"></i> ' . $tString['validationInactiveIconLabel'],
'control_type' => 'iconpicker',
'attributes' => array(
// 'class' => '',
// 'placeholder' => 'Click me!',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'validation_passed_icon' => array(
'label' => '<i class="fa fa-css3"></i> ' . $tString['validationPassedIconLabel'],
'control_type' => 'iconpicker',
'attributes' => array(
// 'class' => '',
// 'placeholder' => '',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'html_mails' => array(
'label' => $tString['htmlMailsLabel'],
'control_type' => 'checkbox',
'attributes' => array(),
'on' => array(),
),
'from_address' => array(
'label' => '<i class="fa fa-envelope"></i> ' . $tString['mailFromAddressLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
// 'pattern' => '', // regex for validation
'placeholder' => $config['from_address'],
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'from_name' => array(
'label' => '<i class="fa fa-envelope"></i> ' . $tString['mailFromNameLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
// 'pattern' => '', // regex for validation
'placeholder' => $config['from_name'],
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'toemail' => array(
'label' => '<i class="fa fa-envelope"></i> ' . $tString['mailToEmailLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
// 'pattern' => '', // regex for validation
'placeholder' => $config['toemail'],
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'toname' => array(
'label' => '<i class="fa fa-envelope"></i> ' . $tString['mailToNameLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
// 'pattern' => '', // regex for validation
'placeholder' => $config['toname'],
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'admin_mail_subject' => array(
'label' => '<i class="fa fa-envelope"></i> ' . $tString['adminMailSubjectLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'admin_mail_header_text' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['adminMailHeaderTextLabel'],
'control_type' => 'ck_editor',
'attributes' => array(
// 'class' => '',
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'admin_mail_footer_text' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['adminMailFooterTextLabel'],
'control_type' => 'ck_editor',
'attributes' => array(
// 'class' => '',
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'send_copy_to_submitter' => array(
'label' => $tString['sendCopyToSubmitterLabel'],
'control_type' => 'checkbox',
'attributes' => array(),
'on' => array(
'change' => 'function(){
if($(this).prop("checked")){
$("#editor-ctl-mail_subject").parents(".editor-ctl-box:first").show();
$("#editor-ctl-mail_header_text").parents(".editor-ctl-box:first").show();
$("#editor-ctl-mail_footer_text").parents(".editor-ctl-box:first").show();
} else {
$("#editor-ctl-mail_subject").parents(".editor-ctl-box:first").hide();
$("#editor-ctl-mail_header_text").parents(".editor-ctl-box:first").hide();
$("#editor-ctl-mail_footer_text").parents(".editor-ctl-box:first").hide();
}
}',
),
),
'mail_subject' => array(
'label' => '<i class="fa fa-envelope"></i> ' . $tString['mailSubjectLabel'],
'control_type' => 'text',
'attributes' => array(
// 'class' => '',
// 'pattern' => '', // regex for validation
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'mail_header_text' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['mailHeaderTextLabel'],
'control_type' => 'ck_editor',
'attributes' => array(
// 'class' => '',
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
'mail_footer_text' => array(
'label' => '<i class="fa fa-font"></i> ' . $tString['mailFooterTextLabel'],
'control_type' => 'ck_editor',
'attributes' => array(
// 'class' => '',
),
'on' => array(
'focus' => 'function(){ $(this).select(); }',
),
),
// Form ID - we need this to get the section out of the page data file (inside the ContactformSectionSendHandler)
// Actually we just use the php timestamp of the time the form is created / last edited.
// So we are able to use multiple form sections on one page.
// Form settings
'form_id' => array(
'label' => '<strong>#</strong> ' . $tstring['formIdLabel'],
'control_type' => 'text',
'attributes' => array(
'readonly' => 'readonly',
'style' => 'opacity:0.7;'
)
),
'attributes' => array(),
),
);