← All changes
|
includes/Frontend/Form/View/Conversational/ConversationalTheme.php
+52
-17
2.10.0
→
V3.3.2
View file →
| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm\Frontend\Form\View\Conversational; |
| 4 | 4 | |
| 5 | -use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\AdvanceFileUpField; | |
| 6 | 5 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\CheckBoxField; |
| 7 | 6 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\CountryField; |
| 8 | 7 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\CurrencyField; |
| 9 | 8 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\DecisionBoxField; |
| @@ -8,20 +7,18 @@ | ||
| 8 | 7 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\CurrencyField; |
| 9 | 8 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\DecisionBoxField; |
| 10 | 9 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\DropdownField; |
| 11 | 10 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\FileUploadField; |
| 11 | +use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\GDPRAgreementField; | |
| 12 | +use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\HiddenField; | |
| 12 | 13 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\HtmlSelectField; |
| 13 | 14 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\ImageSelectField; |
| 14 | -use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\PayPalField; | |
| 15 | 15 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\PhoneNumberField; |
| 16 | 16 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\RadioBoxField; |
| 17 | 17 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\RatingField; |
| 18 | -use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\RazorPayField; | |
| 19 | 18 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\RecaptchaV2Field; |
| 20 | 19 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\RepeaterField; |
| 21 | 20 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\SectionField; |
| 22 | -use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\SignatureField; | |
| 23 | -use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\StripeField; | |
| 24 | 21 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\TextAreaField; |
| 25 | 22 | use BitCode\BitForm\Frontend\Form\View\Conversational\Fields\TextField; |
| 26 | 23 | |
| 27 | 24 | class ConversationalTheme |
| @@ -40,11 +37,16 @@ | ||
| 40 | 37 | { |
| 41 | 38 | $formID = $formViewInstance->getFormID(); |
| 42 | 39 | $this->_conversationalHelpers = new ConversationalHelpers($formID, $this->_conversationalSettings); |
| 43 | 40 | $stepSettings = $this->_conversationalHelpers->getMergedStepSettings($rowID); |
| 44 | - if(isset($stepSettings->enable) && !$stepSettings->enable) return ''; | |
| 41 | + if (isset($stepSettings->enable) && !$stepSettings->enable) { | |
| 42 | + return ''; | |
| 43 | + } | |
| 45 | 44 | |
| 46 | 45 | $field = $formViewInstance->fields($rowID); |
| 46 | + if (!is_object($field)) { | |
| 47 | + return ''; | |
| 48 | + } | |
| 47 | 49 | $field_name = $formViewInstance->getFieldName($rowID); |
| 48 | 50 | $form_atomic_Cls_map = $formViewInstance->getAtomicClaMap(); |
| 49 | 51 | $error = $formViewInstance->getError($rowID); |
| 50 | 52 | $value = $formViewInstance->getValue($field_name, $rowID); |
| @@ -54,14 +56,21 @@ | ||
| 54 | 56 | |
| 55 | 57 | $fieldHTML = $this->getField($field, $rowID, $field_name, $form_atomic_Cls_map, $error, $value, $formID); |
| 56 | 58 | $stepBtnHTML = $isNestedField ? '' : $this->_conversationalHelpers->getStepButtonsView($field, $stepSettings); |
| 57 | 59 | $minHeightCls = $isNestedField ? "bc{$formID}-min-height" : ''; |
| 58 | - $fieldContent = <<<FIELDCONTENT | |
| 59 | - <div class="btcd-fld-itm $rowID $minHeightCls $isHidden"> | |
| 60 | - $fieldHTML | |
| 61 | - $stepBtnHTML | |
| 60 | + $fieldContent = sprintf( | |
| 61 | + ' | |
| 62 | + <div class="btcd-fld-itm %1$s %2$s %3$s"> | |
| 63 | + %4$s | |
| 64 | + %5$s | |
| 62 | 65 | </div> |
| 63 | -FIELDCONTENT; | |
| 66 | + ', | |
| 67 | + $rowID, | |
| 68 | + $minHeightCls, | |
| 69 | + $isHidden, | |
| 70 | + $fieldHTML, | |
| 71 | + $stepBtnHTML | |
| 72 | + ); | |
| 64 | 73 | |
| 65 | 74 | $imageContent = $this->_conversationalHelpers->conversationalSettingsIcon($stepSettings, 'layoutImage', 'step-img', 'Field Image'); |
| 66 | 75 | $convStepLayout = empty($stepSettings->layout) ? 'normal-layout' : $stepSettings->layout; |
| 67 | 76 | $layoutClsNames = "bc{$formID}-{$rowID} $convStepLayout"; |
| @@ -70,9 +79,16 @@ | ||
| 70 | 79 | } |
| 71 | 80 | |
| 72 | 81 | public function getField($field, $rowID, $field_name, $form_atomic_Cls_map, $error, $value, $formID) |
| 73 | 82 | { |
| 74 | - switch($field->typ) { | |
| 83 | + if (!is_object($field)) { | |
| 84 | + return ''; | |
| 85 | + } | |
| 86 | + | |
| 87 | + // Pro-only fields ship in the Bit Form Pro plugin. In the free plugin, we avoid rendering Pro implementations. | |
| 88 | + $proMissingHtml = '<div class="bf-pro-field-missing"> <!-- Require Bit Form Pro --> </div>'; | |
| 89 | + | |
| 90 | + switch ($field->typ) { | |
| 75 | 91 | case 'text': |
| 76 | 92 | case 'username': |
| 77 | 93 | case 'number': |
| 78 | 94 | case 'password': |
| @@ -106,14 +122,27 @@ | ||
| 106 | 122 | // return $this->recaptcha($field, $rowID, $field_name, $formID, $error, $value); |
| 107 | 123 | case 'decision-box': |
| 108 | 124 | // return $this->decisionBox($field, $rowID, $field_name, $formID, $error, $value); |
| 109 | 125 | return DecisionBoxField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| 126 | + case 'gdpr': | |
| 127 | + return GDPRAgreementField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 128 | + case 'hidden': | |
| 129 | + return HiddenField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 110 | 130 | case 'paypal': |
| 111 | - return PayPalField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 131 | + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\PayPalField')) { | |
| 132 | + return \BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\PayPalField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 133 | + } | |
| 134 | + return $proMissingHtml; | |
| 112 | 135 | case 'stripe': |
| 113 | - return StripeField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 136 | + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\StripeField')) { | |
| 137 | + return \BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\StripeField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 138 | + } | |
| 139 | + return $proMissingHtml; | |
| 114 | 140 | case 'razorpay': |
| 115 | - return RazorPayField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 141 | + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\RazorPayField')) { | |
| 142 | + return \BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\RazorPayField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 143 | + } | |
| 144 | + return $proMissingHtml; | |
| 116 | 145 | case 'country': |
| 117 | 146 | return CountryField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| 118 | 147 | case 'currency': |
| 119 | 148 | return CurrencyField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| @@ -119,15 +148,21 @@ | ||
| 119 | 148 | return CurrencyField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| 120 | 149 | case 'phone-number': |
| 121 | 150 | return PhoneNumberField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| 122 | 151 | case 'advanced-file-up': |
| 123 | - return AdvanceFileUpField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 152 | + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\AdvanceFileUpField')) { | |
| 153 | + return \BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\AdvanceFileUpField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 154 | + } | |
| 155 | + return $proMissingHtml; | |
| 124 | 156 | case 'section': |
| 125 | 157 | return SectionField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $this->_formViewerInstance, $this->_nestedLayout, $error, $value); |
| 126 | 158 | case 'repeater': |
| 127 | 159 | return RepeaterField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $this->_formViewerInstance, $this->_nestedLayout, $error, $value); |
| 128 | 160 | case 'signature': |
| 129 | - return SignatureField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 161 | + if (class_exists('\BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\SignatureField')) { | |
| 162 | + return \BitCode\BitFormPro\Frontend\Form\View\Conversational\Fields\SignatureField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); | |
| 163 | + } | |
| 164 | + return $proMissingHtml; | |
| 130 | 165 | case 'rating': |
| 131 | 166 | return RatingField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| 132 | 167 | case 'image-select': |
| 133 | 168 | return ImageSelectField::init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |