PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.1.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.1.1
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 3.1.1, at includes/Frontend/Form/View/Theme/Fields/FileUploadField.php

150 lines 4.5 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 use BitCode\BitForm\Core\Util\FrontendHelpers;
6
7 class FileUploadField
8 {
9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
10 {
11 $inputWrapper = new ClassicInputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
12 $input = self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
13 return $inputWrapper->wrapper($input);
14 }
15
16 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
17 {
18 $fh = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
19 $prefixIcn = $fh->icon('prefixIcn', 'pre-i');
20 $suffixIcn = $fh->icon('suffixIcn', 'suf-i');
21 $name = $fh->name();
22 $req = $fh->required();
23 $ariaDescribedBy = $fh->ariaDescribedBy();
24 $ariaRequired = $fh->ariaRequired();
25 $readonlyCls = isset($field->readonly) ? 'readonly' : '';
26 $disabledCls = isset($field->disabled) ? 'disabled' : '';
27 $btnTxt = isset($field->btnTxt) ? $field->btnTxt : '';
28 $showSelectStatus = '';
29 $maxSizeSection = '';
30 $multiple = '';
31 $maxSize = isset($field->config->maxSize) ? $field->config->maxSize : '';
32 $sizeUnit = isset($field->config->sizeUnit) ? $field->config->sizeUnit : '';
33 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
34 $contentCount = count($bfFrontendFormIds);
35
36 if ($fh->property_exists_nested($field, 'config->multiple', true)) {
37 $multiple = 'multiple';
38 }
39
40 if ($fh->property_exists_nested($field, 'config->showSelectStatus', true)) {
41 $showSelectStatus = sprintf(
42 '<div
43 %1$s
44 class="%2$s %3$s"
45 >
46 No Choosen File
47 </div>',
48 $fh->getCustomAttributes('file-select-status'),
49 $fh->getAtomicCls('file-select-status'),
50 $fh->getCustomClasses('file-select-status')
51 );
52 }
53
54 $maxSizeSection = apply_filters('bitform_file_max_size_section', '', $field, $fh);
55
56 return sprintf(
57 '<div
58 %1$s
59 class="%2$s %3$s"
60 >
61 <div
62 %4$s
63 class="%5$s %6$s %7$s %8$s"
64 >
65 <div
66 %9$s
67 class="%10$s %11$s"
68 >
69 <div
70 %12$s
71 class="%13$s %14$s"
72 >
73 <button
74 %15$s
75 type="button"
76 class="%16$s %17$s"
77 >
78 %18$s
79 <span
80 %19$s
81 class="%20$s %21$s"
82 >
83 %22$s
84 </span>
85 %23$s
86 </button>
87 %24$s
88 %25$s
89 <input
90 %26$s
91 type="file"
92 class="%27$s %28$s"
93 id="%29$s-%30$s"
94 %31$s
95 %32$s
96 %33$s
97 %34$s
98 %35$s
99 aria-disabled="true"
100 tabindex="-1"
101 />
102 </div>
103 <div
104 %36$s
105 class="err-wrp %37$s"
106 ></div>
107 </div>
108 </div>
109 </div>',
110 $fh->getCustomAttributes('file-up-container'),
111 $fh->getAtomicCls('file-up-container'),
112 $fh->getCustomClasses('file-up-container'),
113 $fh->getCustomAttributes('file-up-wrpr'),
114 $fh->getAtomicCls('file-up-wrpr'),
115 $fh->getCustomClasses('file-up-wrpr'),
116 $readonlyCls,
117 $disabledCls,
118 $fh->getCustomAttributes('file-input-wrpr'),
119 $fh->getAtomicCls('file-input-wrpr'),
120 $fh->getCustomClasses('file-input-wrpr'),
121 $fh->getCustomAttributes('btn-wrpr'),
122 $fh->getAtomicCls('btn-wrpr'),
123 $fh->getCustomClasses('btn-wrpr'),
124 $fh->getCustomAttributes('inp-btn'),
125 $fh->getAtomicCls('inp-btn'),
126 $fh->getCustomClasses('inp-btn'),
127 $prefixIcn,
128 $fh->getCustomAttributes('btn-txt'),
129 $fh->getAtomicCls('btn-txt'),
130 $fh->getCustomClasses('btn-txt'),
131 $fh->kses_post($btnTxt),
132 $suffixIcn,
133 $showSelectStatus,
134 $maxSizeSection,
135 $fh->getCustomAttributes('file-upload-input'),
136 $fh->getAtomicCls('file-upload-input'),
137 $fh->getCustomClasses('file-upload-input'),
138 $rowID,
139 $contentCount,
140 $name,
141 $req,
142 $fh->disabled(),
143 $fh->readonly(),
144 $multiple,
145 $fh->getCustomAttributes('err-wrp'),
146 $fh->getCustomClasses('err-wrp')
147 );
148 }
149 }
150