_formId = $formId; $this->_conversationalSettings = $conversationalSettings; $this->_stepListObject = $this->_conversationalSettings->stepListObject; } public function getWelcomePageView() { $welcomePageSettings = $this->getMergedStepSettings("welcomePage"); $welcomeTitle = ''; $welcomePageMarkup = ''; $buttonMarkup = ''; if(!$welcomePageSettings->enable) return ''; if (!empty($welcomePageSettings->title)) { $welcomeTitle = <<

{$welcomePageSettings->title}

WELCOMETITLE; } $startBtnPreIcn = $this->conversationalSettingsIcon($welcomePageSettings, 'startBtnPreIcn', 'btn-pre-icon', 'Start Button Pre Icon'); $startBtnSufIcn = $this->conversationalSettingsIcon($welcomePageSettings, 'startBtnSufIcn', 'btn-suf-icon', 'Start Button Suf Icon'); $startBtnText = !empty($welcomePageSettings->btnTxt) ? $welcomePageSettings->btnTxt : 'Start'; $stepHints = !empty($welcomePageSettings->stepHints) ? $welcomePageSettings->stepHints : ''; $buttonMarkup = <<
{$stepHints}
BUTTONMARKUP; $welcomePageMarkup = << {$welcomeTitle} {$welcomePageSettings->content} {$buttonMarkup} WELCOMEPAGECONTENT; $imageContent = $this->conversationalSettingsIcon($welcomePageSettings, 'layoutImage', 'step-img', 'Background Image'); $welcomeLayout = $welcomePageSettings->layout; $welcomeLayoutClsNames = "bc{$this->_formId}-welcome $welcomeLayout"; return $this->getStepLayout($this->_formId, $imageContent, $welcomePageMarkup, $welcomeLayout, $welcomeLayoutClsNames); } public function getNavigationView() { $navigationSettings = $this->_conversationalSettings->navigationSettings; $formId = $this->_formId; $progressLabelMarkup = ''; $progressBarMarkup = ''; $progressMarkup = ''; $brandingMarkup = ''; $navBtnMarkup = ''; if ($navigationSettings->showProgressLabel) { $progressLabelMarkup = << {$navigationSettings->progressLabel} PERCENTAGEMARKUP; } if ($navigationSettings->showProgressBar) { $progressBarMarkup = <<
PROGRESSBARMARKUP; } if ($navigationSettings->showProgressBar || $navigationSettings->showProgressLabel) { $progressMarkup = <<
{$progressLabelMarkup} {$progressBarMarkup}
PROGRESSMARKUP; } if ($navigationSettings->showBranding) { $brandingMarkup = <<
Powered by Bit Form
BRANDINGMARKUP; } if ($navigationSettings->showNavigateBtn) { $navBtnMarkup = <<
NAVBTNMARKUP; } $navBtnContainer = ''; if ($navigationSettings->showNavigateBtn || $navigationSettings->showBranding) { $navBtnContainer = << {$brandingMarkup} {$navBtnMarkup} NAVBTNCNTNR; } if ($navigationSettings->show) { return <<
{$progressMarkup} {$navBtnContainer}
NAVVIEW; } return ''; } public function getStepButtonsView($fieldData, $stepSettings) { $formId = $this->_formId; $isFieldRequired = !empty($fieldData->valid->req) && $fieldData->valid->req; $btnTxt = $isFieldRequired ? $stepSettings->nextBtnTxt : $stepSettings->btnTxt; $btnPreIcn = $this->conversationalSettingsIcon($stepSettings, 'btnPreIcn', 'btn-pre-icon', 'Button Leading Icon'); $btnSufIcn = $this->conversationalSettingsIcon($stepSettings, 'btnSufIcn', 'btn-suf-icon', 'Button Trailing Icon'); $hiddenClass = $isFieldRequired ? 'bc-grid-hide' : ''; $stepHints = !empty($stepSettings->stepHints) ? $stepSettings->stepHints : ''; $btnWrapperMarkup = <<
{$stepHints}
BTNWRAPPERMARKUP; return $btnWrapperMarkup; } public static function getStepLayout($formID, $imageContent, $fieldContent, $layoutName, $layoutClassNames = '') { $imageContentWrapper = << {$imageContent} IMAGECONTENTWRAPPER; $imageContentWrapper = $layoutName === 'normal-layout' ? '' : $imageContentWrapper; return <<
{$imageContentWrapper}
{$fieldContent}
STEPLAYOUT; } public function conversationalSettingsIcon($data, $icnPropName, $element, $alt = 'Image') { if (Helpers::property_exists_nested($data, $icnPropName, '', 1)) { $url = esc_url($data->$icnPropName); return << ICON; } return ''; } public function filterConversationalAllowedFields($layout, $fields) { $ignoreFields = $this::getConversationalIgnoredFields(); $newLayouts = (object) ['lg' => []]; foreach ($layout->lg as $row) { if (!in_array($fields->{$row->i}->typ, $ignoreFields)) { $newLayouts->lg[] = $row; } } return $newLayouts; } public static function getConversationalIgnoredFields() { return [ 'button', 'divider', 'title', 'html', 'recaptcha', 'turnstile', 'image', 'stripe', 'paypal', 'razorpay', ]; } public function getMergedStepSettings($stepPropertyName){ $allStepsSettings = $this->_stepListObject->allSteps; $stepSettings = !empty($this->_stepListObject->{$stepPropertyName}) ? $this->_stepListObject->{$stepPropertyName} : (object) []; $mergedSettings = (object) array_merge((array) $allStepsSettings, (array) $stepSettings); return $mergedSettings; } }