PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.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 All 138 releases
← All changes | includes/Frontend/Form/View/Theme/ThemeBase.php +197 -30 1.33.3.1 View file →
@@ -1,17 +1,105 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Frontend\Form\View\Theme;
4 4
5 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\AddressField;
6 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\ButtonField;
7 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\CheckBoxField;
8 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\CountryField;
9 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\CurrencyField;
10 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\DecisionBoxField;
11 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\DividerField;
12 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\DropdownField;
13 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\FieldWithChild;
14 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\FileUploadField;
15 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\GDPRAgreementField;
16 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\HCaptchaField;
17 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\HiddenField;
18 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\HTMLField;
19 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\HtmlSelectField;
20 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\ImageField;
21 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\ImageSelectField;
22 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\PhoneNumberField;
23 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\RadioBoxField;
24 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\RatingField;
25 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\RecaptchaV2Field;
26 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\RepeaterField;
27 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\SectionField;
28 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\SliderField;
29 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\SpacerField;
30 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\TextAreaField;
31 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\TextField;
32 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\TitleField;
33 +use BitCode\BitForm\Frontend\Form\View\Theme\Fields\TurnstileField;
34 +
5 35 class ThemeBase
6 36 {
7 - public function getField($field, $rowID, $field_name, $error = null, $value = null, $formID = null)
37 + private $_nestedLayout;
38 + private $_formViewerInstance;
39 +
40 + public function inputWrapper($formViewInstance, $rowID)
8 41 {
42 + $field = $formViewInstance->fields($rowID);
43 + if (!is_object($field)) {
44 + return '';
45 + }
46 + $field_name = $formViewInstance->getFieldName($rowID);
47 + $form_atomic_Cls_map = $formViewInstance->getAtomicClaMap();
48 + $error = $formViewInstance->getError($rowID);
49 + $value = $formViewInstance->getValue($field_name, $rowID);
50 + $formID = $formViewInstance->getFormID();
51 + $this->_nestedLayout = $formViewInstance->getNestedLayout($rowID);
52 + $this->_formViewerInstance = $formViewInstance;
53 +
54 + // $isHidden = !empty($field->valid->hide) && $field->valid->hide ? 'vis-n' : null;
55 + $isHidden = !empty($field->valid->hide) && $field->valid->hide ? 'fld-hide' : null;
56 + // $isReqSym = empty($field->valid->req) ? null : ' <span class="fld-req-symbol">*</span>';
57 + // $noLabel = ['decision-box', 'html', 'button', 'paypal', 'razorpay', 'recaptcha'];
58 + // $fieldLbl = "";
59 +
60 + // if (!in_array($field->typ, $noLabel) && isset($field->lbl)) {
61 + // $replaceToBackslash = str_replace('$_bf_$', '\\', $field->lbl);
62 + // $fieldLbl = FieldValueHandler::replaceSmartTagWithValue($replaceToBackslash);
63 + // }
64 +
65 + // if (isset($field->ph)) {
66 + // $phReplaceToBackslash = str_replace('$_bf_$', '\\', $field->ph);
67 + // $field->ph = FieldValueHandler::replaceSmartTagWithValue($phReplaceToBackslash);
68 + // }
69 +
70 + // $lbl = (!in_array($field->typ, $noLabel) && !isset($field->valid->hideLbl) && isset($field->lbl)) ? "<label class='fld-lbl fld-lbl-$formID' for='$rowID'>" . esc_html($fieldLbl) . $isReqSym . "</label>" : "";
71 +
72 + // $err = (isset($error) && !empty($error)) ? $error : "";
73 + // $errStyle = !empty($err) ? "style='height: auto'" : "";
74 + $fieldHTML = $this->getField($field, $rowID, $field_name, $form_atomic_Cls_map, $error, $value, $formID);
75 + // $errHTML = '';
76 + // if ($err || isset($field->err)) {
77 + // $errHTML = <<<ERRORHTML
78 + // <div class="error-wrapper" $errStyle>
79 + // <div id="$rowID-error" class="error-txt">$err</div>
80 + // </div>
81 + // ERRORHTML;
82 + // }
83 +
84 + return sprintf('<div class="btcd-fld-itm %1$s %2$s">%3$s</div>', $rowID, $isHidden, $fieldHTML);
85 +
86 + // return $fieldHTML;
87 + }
88 +
89 + protected function getField($field, $rowID, $field_name, $form_atomic_Cls_map, $error = null, $value = null, $formID = null)
90 + {
91 + if (!is_object($field)) {
92 + return '';
93 + }
94 +
95 + // Pro-only fields ship in the Bit Form Pro plugin. In the free plugin, we avoid rendering Pro implementations.
96 + $proMissingHtml = '<div class="bf-pro-field-missing"> <!-- Require Bit Form Pro --> </div>';
97 +
9 98 switch ($field->typ) {
10 99 case 'text':
100 + case 'username':
11 101 case 'number':
12 - case 'password':
13 - case 'email':
14 102 case 'url':
15 103 case 'date':
16 104 case 'datetime-local':
17 105 case 'time':
@@ -17,46 +105,125 @@
17 105 case 'time':
18 106 case 'month':
19 107 case 'week':
20 108 case 'color':
21 - return $this->textField($field, $rowID, $field_name, $error, $value, $formID);
109 + return TextField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
110 + case 'password':
111 + case 'email':
112 + case 'name':
113 + return FieldWithChild::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
114 + case 'address':
115 + return AddressField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
22 116 case 'textarea':
23 - return $this->textArea($field, $rowID, $field_name, $error, $value, $formID);
117 + return TextAreaField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
118 + case 'range':
119 + return SliderField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
24 120 case 'check':
25 - return $this->checkBox($field, $rowID, $field_name, $error, $value, $formID);
121 + // return $this->checkBox($field, $rowID, $field_name, $formID, $error, $value);
122 + return CheckBoxField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
26 123 case 'radio':
27 - return $this->radioBox($field, $rowID, $field_name, $error, $value, $formID);
124 + // return $this->radioBox($field, $rowID, $field_name, $formID, $error, $value);
125 + return RadioBoxField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
126 + case 'html-select':
127 + return HtmlSelectField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
28 128 case 'select':
29 - return $this->dropDown($field, $rowID, $field_name, $error, $value, $formID);
129 + // return $this->dropDown($field, $rowID, $field_name, $formID, $error, $value);
130 + return DropdownField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
30 131 case 'file-up':
31 - return $this->fileUp($field, $rowID, $field_name, $error, $value, $formID);
132 + // return $this->fileUp($field, $rowID, $field_name, $formID, $error, $value);
133 + return FileUploadField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
32 134 case 'recaptcha':
33 - return $this->recaptcha($field, $rowID, $field_name, $error, $value, $formID);
135 + return RecaptchaV2Field::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
136 + case 'turnstile':
137 + return TurnstileField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
138 + case 'hcaptcha':
139 + return HCaptchaField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
34 140 case 'decision-box':
35 - return $this->decisionBox($field, $rowID, $field_name, $error, $value, $formID);
141 + // return $this->decisionBox($field, $rowID, $field_name, $formID, $error, $value);
142 + return DecisionBoxField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
143 + case 'gdpr':
144 + return GDPRAgreementField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
36 145 case 'html':
37 - return $this->html($field, $rowID, $field_name, $error, $value, $formID);
146 + // return $this->html($field, $rowID, $field_name, $formID, $error, $value);
147 + return HTMLField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
148 + case 'shortcode':
149 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\ShortcodeField')) {
150 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\ShortcodeField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
151 + }
152 + return $proMissingHtml;
153 + case 'hidden':
154 + return HiddenField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
38 155 case 'paypal':
39 - return $this->paypal($field, $rowID, $field_name, $error, $value, $formID);
156 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\PayPalField')) {
157 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\PayPalField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
158 + }
159 + return $proMissingHtml;
160 + case 'stripe':
161 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\StripeField')) {
162 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\StripeField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
163 + }
164 + return $proMissingHtml;
165 + case 'mollie':
166 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\MollieField')) {
167 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\MollieField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
168 + }
169 + return $proMissingHtml;
40 170 case 'razorpay':
41 - return $this->razorPay($field, $rowID, $field_name, $error, $value, $formID);
42 - case 'submit':
43 - return $this->submitBtns($field, $rowID, $field_name, $error, $value, $formID);
171 + // return $this->razorPay($field, $rowID, $field_name, $formID, $error, $value);
172 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\RazorPayField')) {
173 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\RazorPayField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
174 + }
175 + return $proMissingHtml;
176 + // case 'submit':
177 + // return $this->submitBtns($field, $rowID, $field_name, $formID, $error, $value);
178 + case 'button':
179 + // return $this->button($field, $rowID, $field_name, $formID, $error, $value);
180 + return ButtonField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
181 + case 'title':
182 + // return $this->button($field, $rowID, $field_name, $formID, $error, $value);
183 + return TitleField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
184 + case 'divider':
185 + // return $this->button($field, $rowID, $field_name, $formID, $error, $value);
186 + return DividerField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
187 + case 'spacer':
188 + return SpacerField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
189 + case 'country':
190 + return CountryField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
191 + case 'currency':
192 + return CurrencyField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
193 + case 'phone-number':
194 + return PhoneNumberField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
195 + case 'advanced-file-up':
196 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\AdvanceFileUpField')) {
197 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\AdvanceFileUpField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
198 + }
199 + return $proMissingHtml;
200 + case 'image':
201 + return ImageField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
202 + case 'section':
203 + return SectionField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $this->_formViewerInstance, $this->_nestedLayout, $error, $value);
204 + case 'repeater':
205 + return RepeaterField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $this->_formViewerInstance, $this->_nestedLayout, $error, $value);
206 + case 'signature':
207 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\SignatureField')) {
208 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\SignatureField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
209 + }
210 + return $proMissingHtml;
211 + case 'email-otp':
212 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\EmailOtpField')) {
213 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\EmailOtpField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
214 + }
215 + return $proMissingHtml;
216 + case 'rating':
217 + return RatingField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
218 + case 'image-select':
219 + return ImageSelectField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
220 + case 'advanced-datetime':
221 + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\AdvanceDateTimeField')) {
222 + return \BitCode\BitFormPro\Frontend\Form\View\Theme\Fields\AdvanceDateTimeField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
223 + }
224 + return $proMissingHtml;
44 225 default:
45 226 break;
46 227 }
47 - }
48 -
49 - protected function setTag($tag, $value, $attr = null)
50 - {
51 - echo "<$tag $attr>" . esc_html($value) . "</$tag>";
52 - }
53 -
54 - protected function setAttribute($attr, $value = null)
55 - {
56 - echo " $attr='" . esc_attr($value) . "' ";
57 - }
58 - protected function setSingleValuedAttribute($attr)
59 - {
60 - echo " $attr ";
61 228 }
62 229 }