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

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