PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.4
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 / DefaultTheme.php

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

299 lines 12.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;
4
5 final class DefaultTheme extends ThemeBase
6 {
7 protected function fileUp($field, $rowID, $field_name, $formID, $error = null, $value = null)
8 {
9 $name = esc_attr($field_name);
10 $name .= isset($field->mul) ? '[]' : null;
11 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
12 $upBtnTxt = isset($field->upBtnTxt) ? "<span>" . esc_html($field->upBtnTxt) . "</span>" : "";
13 $maxUpload = isset($field->mxUp) ? "Max " . esc_html($field->mxUp) . " MB" : "";
14 $req = isset($field->req) ? "required" : "";
15 $mul = isset($field->mul) ? "multiple" : "";
16 $extention = isset($field->exts) ? "accept='" . esc_attr($field->exts) . "'" : "";
17 // var_dump(function_exists('fastcgi_finish_request'));
18 return <<<FILEUPLOAD
19 <div class="btcd-f-input">
20 <div class="btcd-f-wrp">
21 <div class="btn-wrp">
22 <button class="btcd-inpBtn" type="button">
23 <svg viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" width="15" height="15"><path d="M13.5 7.5l-5.757 5.757a4.243 4.243 0 01-6-6l5.929-5.929a2.828 2.828 0 014 4l-5.758 5.758a1.414 1.414 0 01-2-2L9.5 3.5" stroke="currentColor" /></svg>
24 $upBtnTxt
25 </button>
26 </div>
27 <span class="btcd-f-title">No File Chosen</span>
28 <small class="f-max">$maxUpload</small>
29 <input id="$rowID" name="$name" $req $mul $extention $isDisabled type="file" />
30 </div>
31 </div>
32 FILEUPLOAD;
33 }
34
35 protected function submitBtns($field, $style, $field_id)
36 {
37 ob_start(); ?>
38 <div class="<?php echo $style; ?>">
39 <div>
40 <div class="btcd-frm-sub <?php $field->align === 'center' ? $this->setSingleValuedAttribute('j-c-c') : ''; ?><?php $field->align === 'right' ? $this->setSingleValuedAttribute('j-c-e') : ''; ?>">
41 <button class="btcd-sub-btn btcd-sub <?php $field->btnSiz === 'md' ? $this->setSingleValuedAttribute('btcd-btn-md') : ''; ?> <?php $field->fulW ? $this->setSingleValuedAttribute('ful-w') : ''; ?>" type="submit" <?php isset($field->name) ? $this->setAttribute('name', $field->name) : '' ?>><?php echo esc_html($field->subBtnTxt) ?></button>
42 <?php //{'rstBtnTxt' in attr && <button className={`btcd-sub-btn btcd-rst ${attr.btnSiz === 'md' && 'btcd-btn-md'} ${attr.fulW && 'ful-w'}`} type="button">{attr.rstBtnTxt}</button>}
43 ?>
44 <?php if (!empty($field->rstBtnTxt)) : ?>
45 <button class="btcd-sub-btn btcd-rst <?php $field->btnSiz === 'md' ? $this->setSingleValuedAttribute('btcd-btn-md') : ''; ?> <?php $field->fulW ? $this->setSingleValuedAttribute('ful-w') : ''; ?>" type="reset"><?php echo esc_html($field->rstBtnTxt) ?></button>
46 <?php endif ?>
47 </div>
48 </div>
49 </div>
50 <?php
51 return ob_get_clean();
52 }
53
54
55 protected function button($field, $style, $field_name, $formID, $error, $value)
56 {
57 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
58 $align = isset($field->align) ? ($field->align === 'center' ? 'j-c-c' : ($field->align === 'right' ? 'j-c-e' : '')) : '';
59 if ($field->btnTyp === 'reset') {
60 $btnCls = 'btcd-rst';
61 $name = '';
62 } else {
63 $btnCls = 'btcd-sub';
64 $name = " name='$field_name'";
65 }
66 $btnSizCls = $field->btnSiz === 'md' ? 'btcd-btn-md' : '';
67 $btnfulW = !empty($field->fulW) ? 'ful-w' : '';
68 $btnTyp = !empty($field->btnTyp) ? "type='$field->btnTyp'" : '';
69 return <<<BUTTON
70 <div class='btcd-frm-sub $align'>
71 <button
72 class='btcd-sub-btn $btnCls $btnSizCls $btnfulW'
73 $btnTyp
74 $name
75 $isDisabled
76 >
77 $field->txt
78 </button>
79 </div>
80 BUTTON;
81 }
82
83 protected function textField($field, $rowID, $field_name, $formID, $error = null, $value = null)
84 {
85 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
86 $readonly = empty($field->valid->readonly) ? null : 'readonly';
87 $name = isset($field_name) ? "name='" . esc_attr($field_name) . "'" : "";
88 $ph = isset($field->ph) ? "placeholder='" . esc_attr($field->ph) . "'" : "";
89 $mx = isset($field->mx) ? "max='" . esc_attr($field->mx) . "'" : "";
90 $mn = isset($field->mn) ? "min='" . esc_attr($field->mn) . "'" : "";
91 $val = isset($value) ? "value='" . esc_attr($value) . "'" : "";
92 $required = isset($field->valid->req) ? "required" : "";
93
94 return <<<TEXTFIELD
95 <input id="$rowID" class="fld fld-$formID no-drg" type="$field->typ" $name $ph $mx $mn $val $required $isDisabled $readonly/>
96 TEXTFIELD;
97 }
98
99 protected function textArea($field, $rowID, $field_name, $formID, $error = null, $value = null)
100 {
101 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
102 $readonly = empty($field->valid->readonly) ? null : 'readonly';
103 $name = isset($field_name) ? "name='" . esc_attr($field_name) . "'" : "";
104 $ph = isset($field->ph) ? "placeholder='$field->ph'" : "";
105 $val = isset($value) ? "value='$value'" : "";
106 $required = isset($field->valid->req) ? "required" : "";
107
108 return <<<TEXTAREA
109 <div>
110 <textarea id="$rowID" class="fld fld-$formID no-drg" type="$field->typ" $name $ph $required $isDisabled $readonly>$val</textArea>
111 </div>
112 TEXTAREA;
113 }
114
115 protected function dropDown($field, $rowID, $field_name, $formID, $error = null, $value = null)
116 {
117 $defaultValue = $value == null ? [] : array_map('esc_html', $value);
118 $isDisabled = empty($field->valid->disabled) ? (empty($field->valid->readonly) ? null : 'msl-disabled') : 'msl-disabled';
119 $mul = isset($field->mul);
120 $ph = isset($field->ph) ? "data-placeholder='$field->ph'" : "data-placeholder='Select...'";
121 $val = "";
122 if (isset($field->val)) {
123 $dval = is_string($field->val) ? $field->val : implode(",", $field->val);
124 $val = "value='$dval'";
125 }
126 $options = "";
127 foreach ($field->opt as $selectOption) {
128 $label = esc_html($selectOption->label);
129 $value = esc_html($selectOption->value);
130 // preg_match('/asd 1/', $input_line, $output_array);
131 $selected = in_array($value, $defaultValue) ? "msl-option-selected" : "";
132 $options .= "<option title='$label' class='msl-option vis-n $selected' value='$value'>$label</option>";
133 }
134
135 $defaultValuePlacehold = "<div data-msl='true' $ph class='msl-input' contenteditable='true'></div>";
136 if ($defaultValue !== null && sizeof($defaultValue) === 1 && !$mul) {
137 $defaultValuePlacehold = "<span class='msl-single-value' data-msl='true'>$defaultValue[0]</span>";
138 }
139 return <<<DROPDOWN
140 <div class="msl-wrp msl-vars no-drg $isDisabled fld fld-$formID dpd" style="width: 100%;">
141 <input name="$field_name" type="hidden" value="$val">
142 <div data-msl="true" class="msl">
143 <div data-msl="true" class="msl-input-wrp" tabindex="0">
144 $defaultValuePlacehold
145 </div>
146 <div class="msl-actions msl-flx">
147 <div role="button" aria-label="toggle-menu" class="msl-btn msl-arrow-btn msl-flx"></div>
148 </div>
149 </div>
150 <div class="msl-options">
151 $options
152 </div>
153 </div>
154 DROPDOWN;
155 }
156
157 protected function recaptcha($field, $rowID, $field_name, $formID, $error = null, $value = null)
158 {
159 return <<<RECAPTCHA
160 <div class="btcd-flx j-c-c" style="min-height='inherit'"></div>
161 RECAPTCHA;
162 }
163
164 protected function paypal($field, $rowID, $field_name, $formID, $error = null, $value = null)
165 {
166 return <<<PAYPAL
167 <div style="width: auto; min-width: 150px; max-width: 750px; margin-left: auto; margin-right: auto;"></div>
168 PAYPAL;
169 }
170
171 protected function razorPay($field, $rowID, $field_name, $formID, $error = null, $value = null)
172 {
173 $center = $field->align === 'center' ? 'j-c-c' : '';
174 $right = $field->align === 'right' ? 'j-c-e' : '';
175 $btnSiz = $field->btnSiz === 'md' ? 'btcd-btn-md' : '';
176 $fulW = $field->fulW ? 'ful-w' : '';
177 $btnTxt = isset($field->btnTxt) ? esc_html($field->btnTxt) : '';
178
179 return <<<RAZORPAY
180 <div class="btcd-frm-sub $center $right">
181 <button class="btcd-sub-btn btcd-sub $btnSiz $fulW" type="button" name="$field_name">
182 $btnTxt
183 </button>
184 </div>
185 RAZORPAY;
186 }
187
188 protected function checkBox($field, $rowID, $field_name, $formID, $error = null, $value = null)
189 {
190 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
191 $readonly = empty($field->valid->readonly) ? null : 'readonly';
192 $round = isset($field->round) ? "btcd-round" : "";
193 $options = "";
194
195 foreach ($field->opt as $checkBoxOption) {
196 $name = isset($field_name) ? "name='" . esc_attr($field_name) . "[]" . "'" : "";
197 $required = isset($checkBoxOption->req) ? "required" : "";
198 $checked = isset($checkBoxOption->check) ? "checked" : "";
199 $checkBoxOptionValue = isset($checkBoxOption->val) ? esc_html($checkBoxOption->val) : esc_html($checkBoxOption->lbl);
200 if ((!is_array($value) && strpos($value, $checkBoxOptionValue) !== false) || (isset($value) && \is_array($value) && $checkBoxOptionValue === $value[array_search($checkBoxOptionValue, $value)])) {
201 $checked = "checked";
202 }
203 $options .= <<<OPTION
204 <label class="btcd-ck-wrp btcd-ck-wrp-$formID">
205 <span>$checkBoxOption->lbl</span>
206 <input type="checkbox" $checked $required $name value="$checkBoxOptionValue" $isDisabled $readonly/>
207 <span class="btcd-mrk ck"></span>
208 </label>
209 OPTION;
210 }
211
212 return <<<CHECKBOX
213 <div class="no-drg fld btcd-ck-con $round">
214 $options
215 </div>
216 CHECKBOX;
217 }
218
219 protected function radioBox($field, $rowID, $field_name, $formID, $error = null, $value = null)
220 {
221 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
222 $readonly = empty($field->valid->readonly) ? null : 'readonly';
223 $round = isset($field->round) ? "btcd-round" : "";
224 $options = "";
225
226 foreach ($field->opt as $checkBoxOption) {
227 $name = isset($field_name) ? "name='" . esc_attr($field_name) . "'" : "";
228 $required = isset($checkBoxOption->req) ? "required" : "";
229 $optionValue = esc_html($checkBoxOption->lbl);
230 $checked = "";
231 if (isset($checkBoxOption->check) || $checkBoxOption->lbl === $value) {
232 $checked = "checked";
233 }
234 $options .= <<<OPTION
235 <label class="btcd-ck-wrp btcd-ck-wrp-$formID">
236 <span>$checkBoxOption->lbl</span>
237 <input type="radio" $checked $required $name value="$optionValue" $isDisabled $readonly/>
238 <span class="btcd-mrk rdo"></span>
239 </label>
240 OPTION;
241 }
242
243 return <<<RADIOBOX
244 <div class="no-drg fld btcd-ck-con $round">
245 $options
246 </div>
247 RADIOBOX;
248 }
249
250 protected function decisionBox($field, $rowID, $field_name, $formID, $error = null, $value = null)
251 {
252 $isRequired = !empty($field->valid->req) ? 'required' : '';
253 $isChecked = !empty($field->valid->checked) ? 'checked' : '';
254 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
255 $readonly = empty($field->valid->readonly) ? null : 'readonly';
256 $value = $isChecked ? $field->msg->checked : $field->msg->unchecked;
257 $round = isset($field->round) ? "btcd-round" : "";
258 $size = $isRequired ? '1px' : '';
259
260 $lbl = !empty($field->lbl) ? wp_kses_post($field->lbl) : (isset($field->info) ? wp_kses_post($field->info->lbl) : '');
261
262 return <<<DECISIONBOX
263 <div class="no-drg fld fld-{$formID} btcd-ck-con $round">
264 <input
265 size="height: {$size}, width: {$size}"
266 type="checkbox"
267 $isDisabled
268 $readonly
269 $isRequired
270 $isChecked
271 value="{$value}"
272 />
273 <label class="btcd-ck-wrp btcd-ck-wrp-{$formID}">
274 <span class="decision-content">
275 {$lbl}
276 </span>
277 <input type="hidden" value="{$value}" name="{$field_name}" />
278 <span class="btcd-mrk ck"></span>
279 </label>
280 </div>
281 DECISIONBOX;
282 }
283
284 protected function html($field, $rowID, $field_name, $formID, $error = null, $value = null)
285 {
286 $isHidden = !empty($field->valid->hide) && $field->valid->hide ? 'vis-n' : null;
287
288 $content = !empty($field->content) ? wp_kses_post($field->content) : '';
289
290 return <<<HTML
291 <div class="btcd-fld-itm $rowID $isHidden">
292 <div class="fld-wrp fld-wrp-$formID drag" btcd-fld="decision-box">
293 $content
294 </div>
295 </div>
296 HTML;
297 }
298 }
299