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

117 lines 4.3 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 $readonlyCls = isset($field->readonly) ? 'readonly' : '';
24 $disabledCls = isset($field->disabled) ? 'disabled' : '';
25 $btnTxt = isset($field->btnTxt) ? $field->btnTxt : '';
26 $showSelectStatus = '';
27 $maxSizeSection = '';
28 $maxSize = isset($field->config->maxSize) ? $field->config->maxSize : '';
29 $sizeUnit = isset($field->config->sizeUnit) ? $field->config->sizeUnit : '';
30 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
31 $contentCount = count($bfFrontendFormIds);
32
33 if ($fh->property_exists_nested($field, 'config->showSelectStatus', true)) {
34 $showSelectStatus = <<<SHOWSELSTATUS
35 <div
36 {$fh->getCustomAttributes('file-select-status')}
37 class="{$fh->getAtomicCls('file-select-status')} {$fh->getCustomClasses('file-select-status')}"
38 >
39 No Choosen File
40 </div>
41 SHOWSELSTATUS;
42 }
43
44 if (
45 $fh->property_exists_nested($field, 'config->allowMaxSize', true)
46 && $fh->property_exists_nested($field, 'config->showMaxSize', true)
47 && $fh->property_exists_nested($field, 'config->maxSize')
48 && 0 !== $field->config->maxSize
49 ) {
50 $maxSizeLbl = $fh->property_exists_nested($field, 'config->maxSizeLabel', '', 1) ? $field->config->maxSizeLabel : "(Max {$maxSize} ${sizeUnit})";
51 $maxSizeSection = <<<MAXSIZE
52 <small
53 {$fh->getCustomAttributes('max-size-lbl')}
54 class="{$fh->getAtomicCls('max-size-lbl')} {$fh->getCustomClasses('max-size-lbl')}"
55 >
56 {$fh->esc_html($maxSizeLbl)}
57 </small>
58 MAXSIZE;
59 }
60
61 return <<<FILEUPLOADFIELD
62 <div
63 {$fh->getCustomAttributes('file-up-container')}
64 class="{$fh->getAtomicCls('file-up-container')} {$fh->getCustomClasses('file-up-container')}"
65 >
66 <div
67 {$fh->getCustomAttributes('file-up-wrpr')}
68 class="{$fh->getAtomicCls('file-up-wrpr')} {$fh->getCustomClasses('file-up-wrpr')} {$readonlyCls} {$disabledCls}"
69 >
70 <div
71 {$fh->getCustomAttributes('file-input-wrpr')}
72 class="{$fh->getAtomicCls('file-input-wrpr')} {$fh->getCustomClasses('file-input-wrpr')}"
73 >
74 <div
75 {$fh->getCustomAttributes('btn-wrpr')}
76 class="{$fh->getAtomicCls('btn-wrpr')} {$fh->getCustomClasses('btn-wrpr')}"
77 >
78 <button
79 {$fh->getCustomAttributes('inp-btn')}
80 type="button"
81 class="{$fh->getAtomicCls('inp-btn')} {$fh->getCustomClasses('inp-btn')}"
82 >
83 {$prefixIcn}
84 <span
85 {$fh->getCustomAttributes('btn-txt')}
86 class="{$fh->getAtomicCls('btn-txt')} {$fh->getCustomClasses('btn-txt')}"
87 >
88 {$fh->kses_post($btnTxt)}
89 </span>
90 {$suffixIcn}
91 </button>
92 {$showSelectStatus}
93 {$maxSizeSection}
94 <input
95 {$fh->getCustomAttributes('file-upload-input')}
96 type="file"
97 class="{$fh->getAtomicCls('file-upload-input')} {$fh->getCustomClasses('file-upload-input')}"
98 id="{$rowID}-{$contentCount}"
99 {$name}
100 {$req}
101 {$fh->disabled()}
102 {$fh->readonly()}
103 aria-disabled="true"
104 tabindex="-1"
105 />
106 </div>
107 <div
108 {$fh->getCustomAttributes('err-wrp')}
109 class="err-wrp {$fh->getCustomClasses('err-wrp')}"
110 ></div>
111 </div>
112 </div>
113 </div>
114 FILEUPLOADFIELD;
115 }
116 }
117