PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.9
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.9
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.9, at includes/Frontend/Form/View/Theme/DefaultTheme.php

303 lines 12.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;
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 if (isset($field->ph)) {
105 $ph = htmlentities($field->ph, ENT_QUOTES);
106 }
107 $ph = isset($field->ph) ? "placeholder='$ph'" : "";
108 $val = isset($value) ? $value : "";
109 $required = isset($field->valid->req) ? "required" : "";
110
111 return <<<TEXTAREA
112 <div>
113 <textarea id="$rowID" class="fld fld-$formID no-drg" type="$field->typ" $name $ph $required $isDisabled $readonly>$val</textArea>
114 </div>
115 TEXTAREA;
116 }
117
118 protected function dropDown($field, $rowID, $field_name, $formID, $error = null, $value = null)
119 {
120 $defaultValue = $value == null ? [] : array_map('esc_html', $value);
121 $isDisabled = empty($field->valid->disabled) ? (empty($field->valid->readonly) ? null : 'msl-disabled') : 'msl-disabled';
122 $mul = isset($field->mul);
123 $ph = isset($field->ph) ? "data-placeholder='$field->ph'" : "data-placeholder='Select...'";
124 $val = "";
125 if (isset($field->val)) {
126 $dval = is_string($field->val) ? $field->val : implode(",", $field->val);
127 $val = "value='$dval'";
128 }
129 $options = "";
130 foreach ($field->opt as $selectOption) {
131 $label = esc_html($selectOption->label);
132 $value = esc_html($selectOption->value);
133 // preg_match('/asd 1/', $input_line, $output_array);
134 $selected = in_array($value, $defaultValue) ? "msl-option-selected" : "";
135 $options .= "<option title='$label' class='msl-option vis-n $selected' value='$value'>$label</option>";
136 }
137
138 $defaultValuePlacehold = "<div data-msl='true' $ph class='msl-input' contenteditable='true'></div>";
139 if ($defaultValue !== null && sizeof($defaultValue) === 1 && !$mul) {
140 $defaultValuePlacehold = "<span class='msl-single-value' data-msl='true'>$defaultValue[0]</span>";
141 }
142 return <<<DROPDOWN
143 <div class="msl-wrp msl-vars no-drg $isDisabled fld fld-$formID dpd" style="width: 100%;">
144 <input name="$field_name" type="hidden" value="$val">
145 <div data-msl="true" class="msl">
146 <div data-msl="true" class="msl-input-wrp" tabindex="0">
147 $defaultValuePlacehold
148 </div>
149 <div class="msl-actions msl-flx">
150 <div role="button" aria-label="toggle-menu" class="msl-btn msl-arrow-btn msl-flx"></div>
151 </div>
152 </div>
153 <div class="msl-options">
154 $options
155 </div>
156 </div>
157 DROPDOWN;
158 }
159
160 protected function recaptcha($field, $rowID, $field_name, $formID, $error = null, $value = null)
161 {
162 return <<<RECAPTCHA
163 <div class="btcd-flx j-c-c" style="min-height='inherit'"></div>
164 RECAPTCHA;
165 }
166
167 protected function paypal($field, $rowID, $field_name, $formID, $error = null, $value = null)
168 {
169 return <<<PAYPAL
170 <div style="width: auto; min-width: 150px; max-width: 750px; margin-left: auto; margin-right: auto;"></div>
171 PAYPAL;
172 }
173
174 protected function razorPay($field, $rowID, $field_name, $formID, $error = null, $value = null)
175 {
176 $center = $field->align === 'center' ? 'j-c-c' : '';
177 $right = $field->align === 'right' ? 'j-c-e' : '';
178 $btnSiz = $field->btnSiz === 'md' ? 'btcd-btn-md' : '';
179 $fulW = $field->fulW ? 'ful-w' : '';
180 $btnTxt = isset($field->btnTxt) ? esc_html($field->btnTxt) : '';
181
182 return <<<RAZORPAY
183 <div class="btcd-frm-sub $center $right">
184 <button class="btcd-sub-btn btcd-sub $btnSiz $fulW" type="button" name="$field_name">
185 $btnTxt
186 </button>
187 </div>
188 RAZORPAY;
189 }
190
191 protected function checkBox($field, $rowID, $field_name, $formID, $error = null, $value = null)
192 {
193 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
194 $readonly = empty($field->valid->readonly) ? null : 'readonly';
195 $round = isset($field->round) ? "btcd-round" : "";
196 $options = "";
197
198 foreach ($field->opt as $checkBoxOption) {
199 $name = isset($field_name) ? "name='" . esc_attr($field_name) . "[]" . "'" : "";
200 $required = isset($checkBoxOption->req) ? "required" : "";
201 $checked = isset($checkBoxOption->check) ? "checked" : "";
202 $checkBoxOptionValue = isset($checkBoxOption->val) ? esc_html($checkBoxOption->val) : esc_html($checkBoxOption->lbl);
203 $value = $value === null ? '' : $value;
204 if ((!is_array($value) && strpos($value, $checkBoxOptionValue) !== false) || (isset($value) && \is_array($value) && $checkBoxOptionValue === $value[array_search($checkBoxOptionValue, $value)])) {
205 $checked = "checked";
206 }
207 $options .= <<<OPTION
208 <label class="btcd-ck-wrp btcd-ck-wrp-$formID">
209 <span>$checkBoxOption->lbl</span>
210 <input type="checkbox" $checked $required $name value="$checkBoxOptionValue" $isDisabled $readonly/>
211 <span class="btcd-mrk ck"></span>
212 </label>
213 OPTION;
214 }
215
216 return <<<CHECKBOX
217 <div class="no-drg fld btcd-ck-con $round">
218 $options
219 </div>
220 CHECKBOX;
221 }
222
223 protected function radioBox($field, $rowID, $field_name, $formID, $error = null, $value = null)
224 {
225 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
226 $readonly = empty($field->valid->readonly) ? null : 'readonly';
227 $round = isset($field->round) ? "btcd-round" : "";
228 $options = "";
229
230 foreach ($field->opt as $checkBoxOption) {
231 $name = isset($field_name) ? "name='" . esc_attr($field_name) . "'" : "";
232 $required = isset($checkBoxOption->req) ? "required" : "";
233 $optionValue = esc_html($checkBoxOption->lbl);
234 $checked = "";
235 if (isset($checkBoxOption->check) || $checkBoxOption->lbl === $value) {
236 $checked = "checked";
237 }
238 $options .= <<<OPTION
239 <label class="btcd-ck-wrp btcd-ck-wrp-$formID">
240 <span>$checkBoxOption->lbl</span>
241 <input type="radio" $checked $required $name value="$optionValue" $isDisabled $readonly/>
242 <span class="btcd-mrk rdo"></span>
243 </label>
244 OPTION;
245 }
246
247 return <<<RADIOBOX
248 <div class="no-drg fld btcd-ck-con $round">
249 $options
250 </div>
251 RADIOBOX;
252 }
253
254 protected function decisionBox($field, $rowID, $field_name, $formID, $error = null, $value = null)
255 {
256 $isRequired = !empty($field->valid->req) ? 'required' : '';
257 $isChecked = !empty($field->valid->checked) ? 'checked' : '';
258 $isDisabled = empty($field->valid->disabled) ? null : 'disabled';
259 $readonly = empty($field->valid->readonly) ? null : 'readonly';
260 $value = $isChecked ? $field->msg->checked : $field->msg->unchecked;
261 $round = isset($field->round) ? "btcd-round" : "";
262 $size = $isRequired ? '1px' : '';
263
264 $lbl = !empty($field->lbl) ? wp_kses_post($field->lbl) : (isset($field->info) ? wp_kses_post($field->info->lbl) : '');
265
266 return <<<DECISIONBOX
267 <div class="no-drg fld fld-{$formID} btcd-ck-con $round">
268 <input
269 size="height: {$size}, width: {$size}"
270 type="checkbox"
271 $isDisabled
272 $readonly
273 $isRequired
274 $isChecked
275 value="{$value}"
276 />
277 <label class="btcd-ck-wrp btcd-ck-wrp-{$formID}">
278 <span class="decision-content">
279 {$lbl}
280 </span>
281 <input type="hidden" value="{$value}" name="{$field_name}" />
282 <span class="btcd-mrk ck"></span>
283 </label>
284 </div>
285 DECISIONBOX;
286 }
287
288 protected function html($field, $rowID, $field_name, $formID, $error = null, $value = null)
289 {
290 $isHidden = !empty($field->valid->hide) && $field->valid->hide ? 'vis-n' : null;
291
292 $content = !empty($field->content) ? wp_kses_post($field->content) : '';
293
294 return <<<HTML
295 <div class="btcd-fld-itm $rowID $isHidden">
296 <div class="fld-wrp fld-wrp-$formID drag" btcd-fld="decision-box">
297 $content
298 </div>
299 </div>
300 HTML;
301 }
302 }
303