PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.13
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.13
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 / InputWrapper.php

InputWrapper.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.21.13, at includes/Frontend/Form/View/InputWrapper.php

232 lines 7.6 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;
4
5 use BitCode\BitForm\Core\Util\FrontendHelpers;
6
7 class InputWrapper
8 {
9 private $_fieldData;
10 private $_fieldKey;
11 private $_fieldName;
12 private $_formID;
13 private $_error;
14 private $_value;
15 private $_fieldHelpers;
16
17 public function __construct($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
18 {
19 $this->_fieldData = $field;
20 $this->_fieldKey = $rowID;
21 $this->_fieldName = $field_name;
22 $this->_formID = $formID;
23 $this->_error = $error;
24 $this->_value = $value;
25 $this->_fieldHelpers = new FieldHelpers($field, $rowID, $form_atomic_Cls_map);
26 }
27
28 public function wrapper($field, $noLabel = false, $noErrMsg = false)
29 {
30 $labelWrapper = !$noLabel ? $this->labelWrapper() : '';
31 $helperText = $this->helperText();
32 $error = !$noErrMsg ? $this->errorMessages() : '';
33
34 return sprintf(
35 '<div %1$s class="%2$s %3$s">
36 %4$s
37 <div %5$s class="%6$s %7$s">
38 %8$s
39 %9$s
40 %10$s
41 </div>
42 </div>',
43 $this->_fieldHelpers->getCustomAttributes('fld-wrp'),
44 $this->_fieldHelpers->getAtomicCls('fld-wrp'),
45 $this->_fieldHelpers->getCustomClasses('fld-wrp'),
46 $labelWrapper,
47 $this->_fieldHelpers->getCustomAttributes('inp-wrp'),
48 $this->_fieldHelpers->getAtomicCls('inp-wrp'),
49 $this->_fieldHelpers->getCustomClasses('inp-wrp'),
50 $field,
51 $helperText,
52 $error
53 );
54 }
55
56 private function labelWrapper()
57 {
58 $_label = '';
59 $_lblPreIcn = $this->_fieldHelpers->icon('lblPreIcn', 'lbl-pre-i');
60 $_lblSufIcn = $this->_fieldHelpers->icon('lblSufIcn', 'lbl-suf-i');
61 $_reqPre = '';
62 $_reqPost = '';
63 $_lbl = '';
64 $_subtitle = '';
65 $_subtitleText = '';
66 $_subtitlePreIcn = $this->_fieldHelpers->icon('subTlePreIcn', 'sub-titl-pre-i');
67 $_subtitlePostIcn = $this->_fieldHelpers->icon('subTleSufIcn', 'sub-titl-suf-i');
68 if (property_exists($this->_fieldData, 'lbl')) {
69 $replaceToBackSlash = $this->_fieldHelpers->replaceToBackSlash($this->_fieldData->lbl);
70 $_lbl = wp_kses_post($this->_fieldHelpers->renderHTMR($replaceToBackSlash));
71 }
72
73 if (property_exists($this->_fieldData, 'subtitle')) {
74 $replaceToBackSlash = $this->_fieldHelpers->replaceToBackSlash($this->_fieldData->subtitle);
75 $_subtitleText = wp_kses_post($this->_fieldHelpers->renderHTMR($replaceToBackSlash));
76 }
77
78 // for pre required icon
79 if (
80 $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->req')
81 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqShow', true)
82 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqPos', 'before')
83 ) {
84 $_reqPre = sprintf(
85 '<span %1$s class="%2$s %3$s">*</span>',
86 $this->_fieldHelpers->getCustomAttributes('req-smbl'),
87 $this->_fieldHelpers->getAtomicCls('req-smbl'),
88 $this->_fieldHelpers->getCustomClasses('req-smbl')
89 );
90 }
91 // for post required icon
92 if (
93 $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->req')
94 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqShow', true)
95 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqPos', 'before', 1)
96 ) {
97 $_reqPost = sprintf(
98 '<span %1$s class="%2$s %3$s">*</span>',
99 $this->_fieldHelpers->getCustomAttributes('req-smbl'),
100 $this->_fieldHelpers->getAtomicCls('req-smbl'),
101 $this->_fieldHelpers->getCustomClasses('req-smbl')
102 );
103 }
104
105 // for Label
106 if (
107 property_exists($this->_fieldData, 'lbl')
108 // && isset($this->_fieldData->valid->hideLbl)
109 // && $this->_fieldData->valid->hideLbl !== true
110 ) {
111 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
112 $contentCount = count($bfFrontendFormIds);
113 $_label = sprintf(
114 '<label %1$s class="%2$s %3$s" for="%4$s-%5$d">%6$s%7$s%8$s%9$s%10$s</label>',
115 $this->_fieldHelpers->getCustomAttributes('lbl'),
116 $this->_fieldHelpers->getAtomicCls('lbl'),
117 $this->_fieldHelpers->getCustomClasses('lbl'),
118 $this->_fieldKey,
119 $contentCount,
120 $_reqPre,
121 $_lblPreIcn,
122 $_lbl,
123 $_lblSufIcn,
124 $_reqPost
125 );
126 }
127
128 // for subtitle
129 if (property_exists($this->_fieldData, 'subtitle') && $this->_fieldData->subtitleHide) {
130 $_subtitle = sprintf(
131 '<div %1$s class="%2$s %3$s">%4$s%5$s%6$s</div>',
132 $this->_fieldHelpers->getCustomAttributes('sub-titl'),
133 $this->_fieldHelpers->getAtomicCls('sub-titl'),
134 $this->_fieldHelpers->getCustomClasses('sub-titl'),
135 $_subtitlePreIcn,
136 $_subtitleText,
137 $_subtitlePostIcn
138 );
139 }
140
141 return sprintf(
142 '<div %1$s class="%2$s %3$s">%4$s%5$s</div>',
143 $this->_fieldHelpers->getCustomAttributes('lbl-wrp'),
144 $this->_fieldHelpers->getAtomicCls('lbl-wrp'),
145 $this->_fieldHelpers->getCustomClasses('lbl-wrp'),
146 $_label,
147 $_subtitle
148 );
149 }
150
151 private function helperText()
152 {
153 $_helperTxtPreIcn = $this->_fieldHelpers->icon('hlpPreIcn', 'hlp-txt-pre-i');
154 $_helperTxtSufIcn = $this->_fieldHelpers->icon('hlpSufIcn', 'hlp-txt-suf-i');
155 $_helperTxt = '';
156
157 if (isset($this->_fieldData->helperTxt)) {
158 $_helperTxt = wp_kses_post($this->_fieldHelpers->renderHTMR($this->_fieldData->helperTxt));
159 }
160
161 if (property_exists($this->_fieldData, 'helperTxt') && $this->_fieldData->helperTxt) {
162 $_helperTxt = sprintf(
163 '<div %1$s class="%2$s %3$s">%4$s%5$s%6$s</div>',
164 $this->_fieldHelpers->getCustomAttributes('hlp-txt'),
165 $this->_fieldHelpers->getAtomicCls('hlp-txt'),
166 $this->_fieldHelpers->getCustomClasses('hlp-txt'),
167 $_helperTxtPreIcn,
168 $_helperTxt,
169 $_helperTxtSufIcn
170 );
171 }
172
173 // for helper text
174 return $_helperTxt;
175 }
176
177 public function errorMessages()
178 {
179 $_errorPreIcn = $this->_fieldHelpers->icon('errPreIcn', 'err-txt-pre-i');
180 $_errorSufIcn = $this->_fieldHelpers->icon('errSufIcn', 'err-txt-suf-i');
181 $_error = '';
182 $_style = 'opacity: 0 !important; height: 0px !important;';
183
184 if ($this->_error) {
185 $_error = wp_kses_post($this->_error);
186 $_style = 'margin-top: 5px !important; height: 9px !important;';
187 }
188
189 $errMsgStart = '';
190 $errMsgEnd = '';
191 $msgStyle = "style='display: none !important;'";
192 $errMsgAtomicCls = $this->_fieldHelpers->getAtomicCls('err-msg');
193 $errMsgCustomCls = $this->_fieldHelpers->getCustomClasses('err-msg');
194 $errMsgCustomAttr = $this->_fieldHelpers->getCustomAttributes('err-msg');
195 if (!(empty($_errorPreIcn) && empty($_errorSufIcn))) {
196 $errMsgStart = "<div {$errMsgCustomAttr} class='{$errMsgAtomicCls} {$errMsgCustomCls}' {$msgStyle}>";
197 $errMsgEnd = '</div>';
198 $msgStyle = '';
199 $errMsgAtomicCls = '';
200 $errMsgCustomCls = '';
201 $errMsgCustomAttr = '';
202 }
203
204 return sprintf(
205 '<div class="%1$s" style="%2$s">
206 <div class="%3$s">
207 %4$s
208 %5$s
209 <div %6$s %7$s class="%8$s %9$s %10$s %11$s" %12$s>%13$s</div>
210 %14$s
211 %15$s
212 </div>
213 </div>',
214 $this->_fieldHelpers->getAtomicCls('err-wrp'),
215 $_style,
216 $this->_fieldHelpers->getAtomicCls('err-inner'),
217 $errMsgStart,
218 $_errorPreIcn,
219 $this->_fieldHelpers->getCustomAttributes('err-txt'),
220 $errMsgCustomAttr,
221 $errMsgAtomicCls,
222 $errMsgCustomCls,
223 $this->_fieldHelpers->getAtomicCls('err-txt'),
224 $this->_fieldHelpers->getCustomClasses('err-txt'),
225 $msgStyle,
226 $_error,
227 $_errorSufIcn,
228 $errMsgEnd
229 );
230 }
231 }
232