PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.0
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / includes / Frontend / Form / View / Theme / Fields / FileUploadField.php

FileUploadField.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.0, at includes/Frontend/Form/View/Theme/Fields/FileUploadField.php

110 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Frontend\Form\View\Theme\Fields;
4
5 class FileUploadField {
6 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) {
7 $inputWrapper = new InputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
8 $input = self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
9 return $inputWrapper->wrapper($input);
10 }
11
12 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) {
13 $fh = new FieldHelpers($field, $rowID, $form_atomic_Cls_map);
14 $prefixIcn = $fh->icon('prefixIcn', 'pre-i');
15 $suffixIcn = $fh->icon('suffixIcn', 'suf-i');
16 $name = $fh->name();
17 $req = $fh->required();
18 $readonlyCls = isset($field->readonly) ? 'readonly' : '';
19 $disabledCls = isset($field->disabled) ? 'disabled' : '';
20 $btnTxt = isset($field->btnTxt) ? $field->btnTxt : '';
21 $showSelectStatus = '';
22 $maxSizeSection = '';
23 $maxSize = isset($field->config->maxSize) ? $field->config->maxSize : '';
24 $sizeUnit = isset($field->config->sizeUnit) ? $field->config->sizeUnit : '';
25
26 if ($fh->property_exists_nested($field, 'config->showSelectStatus', true)) {
27 $showSelectStatus = <<<SHOWSELSTATUS
28 <div
29 class="{$fh->getAtomicCls('file-select-status')} {$fh->getCustomClasses('file-select-status')}"
30 {$fh->getCustomAttributes('file-select-status')}
31 >
32 No Choosen File
33 </div>
34 SHOWSELSTATUS;
35 }
36
37 if (
38 $fh->property_exists_nested($field, 'config->allowMaxSize', true)
39 && $fh->property_exists_nested($field, 'config->showMaxSize', true)
40 && $fh->property_exists_nested($field, 'config->maxSize')
41 && 0 !== $field->config->maxSize
42 ) {
43 $maxSizeLbl = $fh->property_exists_nested($field, 'config->maxSizeLabel', '', 1) ? $field->config->maxSizeLabel : "(Max {$maxSize} ${sizeUnit})";
44 $maxSizeSection = <<<MAXSIZE
45 <small
46 class="{$fh->getAtomicCls('max-size-lbl')} {$fh->getCustomClasses('max-size-lbl')}"
47 {$fh->getCustomAttributes('max-size-lbl')}
48 >
49 $maxSizeLbl
50 </small>
51 MAXSIZE;
52 }
53
54 return <<<FILEUPLOADFIELD
55 <div
56 class="{$fh->getAtomicCls('file-up-container')} {$fh->getCustomClasses('file-up-container')}"
57 {$fh->getCustomAttributes('file-up-container')}
58 >
59 <div
60 class="{$fh->getAtomicCls('file-up-wrpr')} {$fh->getCustomClasses('file-up-wrpr')} {$readonlyCls} {$disabledCls}"
61 {$fh->getCustomAttributes('file-up-wrpr')}
62 >
63 <div
64 class="{$fh->getAtomicCls('file-input-wrpr')} {$fh->getCustomClasses('file-input-wrpr')}"
65 {$fh->getCustomAttributes('file-input-wrpr')}
66 >
67 <div
68 class="{$fh->getAtomicCls('btn-wrpr')} {$fh->getCustomClasses('btn-wrpr')}"
69 {$fh->getCustomAttributes('btn-wrpr')}
70 >
71 <button
72 type="button"
73 class="{$fh->getAtomicCls('inp-btn')} {$fh->getCustomClasses('inp-btn')}"
74 {$fh->getCustomAttributes('inp-btn')}
75 >
76 {$prefixIcn}
77 <span
78 class="{$fh->getAtomicCls('btn-txt')} {$fh->getCustomClasses('btn-txt')}"
79 {$fh->getCustomAttributes('btn-txt')}
80 >
81 {$btnTxt}
82 </span>
83 {$suffixIcn}
84 </button>
85 {$showSelectStatus}
86 {$maxSizeSection}
87 <input
88 type="file"
89 class="{$fh->getAtomicCls('file-upload-input')} {$fh->getCustomClasses('file-upload-input')}"
90 {$fh->getCustomAttributes('file-upload-input')}
91 id="{$rowID}"
92 {$name}
93 {$req}
94 {$fh->disabled()}
95 {$fh->readonly()}
96 aria-disabled="true"
97 tabindex="-1"
98 />
99 </div>
100 <div
101 class="err-wrp {$fh->getCustomClasses('err-wrp')}"
102 {$fh->getCustomAttributes('err-wrp')}
103 ></div>
104 </div>
105 </div>
106 </div>
107 FILEUPLOADFIELD;
108 }
109 }
110