_tokens = Helpers::csrfEecrypted(); $this->_fields = $form_contents->fields; $this->_layout = $form_contents->layout; $this->_buttons = isset($form_contents->buttons) ? $form_contents->buttons : ''; $this->_form = $formManager; $this->_error = $errorMessages; $this->form_contents = $form_contents; $this->_previousValue = $previousValue; $this->_formAtomicClsMap = $formAtomicClsMap; } public function getView($hasFile) { $name = str_replace(' ', '', $this->_theme); $file = false !== strpos($name, 'Theme') ? $name . '.php' : $name . 'Theme.php'; if (file_exists(__DIR__ . '/' . $file)) { $className = __NAMESPACE__ . '\\Theme\\' . $name . 'Theme'; $this->_themeDetails = new $className(); } else { $className = __NAMESPACE__ . '\\Theme\\' . 'DefaultTheme'; $this->_themeDetails = new $className(); } return $this->setView($hasFile); } public function honeypotField() { $time = time(); $honeypodFldName = Helpers::honeypotEncryptedToken("_bitforms_{$this->getFormID()}_{$time}_"); $honeypotInput = ''; if (Helpers::property_exists_nested($this->form_contents, 'additional->enabled->honeypot', true)) { $honeypotInput = << HTMLa; return $honeypotInput; } return $honeypotInput; } public function setTheme($theme = 'Default') { $this->_theme = $theme; } public function getError($field_name) { return isset($this->_error[$field_name]) ? $this->_error[$field_name] : null; } public function getFieldName($rowId) { $formIdentifier = $this->_form->getFormIdentifier(); $field_name = $rowId; if ('button' === $this->_fields->{$rowId}->typ && 'submit' === $this->_fields->{$rowId}->btnTyp) { $field_name = $formIdentifier; } $field_name .= isset($this->_fields->{$rowId}->lbl) ? preg_replace('/[\`\~\!\@\#\$\'\.\s\?\+\-\*\&\|\/\\\!]/', '_', $this->_fields->{$rowId}->lbl) : ''; return $field_name; } public function getAtomicClaMap() { return $this->_formAtomicClsMap; } public function getValue($field_name, $rowId) { $valueToEsc = isset($this->_previousValue[$field_name]) ? $this->_previousValue[$field_name] : (isset($this->_fields->{$rowId}->val) ? $this->_fields->{$rowId}->val : null); if (empty($valueToEsc)) { $value = null; } else { if ((isset($this->_fields->{$rowId}->mul) || 'check' === $this->_fields->{$rowId}->typ || 'select' === $this->_fields->{$rowId}->typ)) { if ('select' === $this->_fields->{$rowId}->typ && is_string($valueToEsc)) { $valueToEsc = explode(',', $valueToEsc); } if (is_array($valueToEsc)) { $value = array_map('esc_attr', $valueToEsc); } else { $value = esc_attr($valueToEsc); } } else { $value = !is_array($valueToEsc) ? esc_attr($valueToEsc) : esc_attr($valueToEsc[count($valueToEsc) - 1]); } } return $value; } public function getFormID() { return $this->_form->getFormID(); } public function fields($rowID) { return $this->_fields->{$rowID}; } private function setView($hasFile) { $file_upload_tag = null; $formID = $this->_form->getFormID(); if ($hasFile) { $file_upload_tag = 'enctype="multipart/form-data"'; wp_enqueue_script('bitforms-frontend-file'); } $formIdentifier = $this->_form->getFormIdentifier(); $fieldHtml = ''; foreach ($this->_layout->lg as $row) { $fieldHtml .= $this->_themeDetails->inputWrapper($this, $row->i); } $confMsg = $this->_form->getSuccessMessageMarkups(); if (!empty($this->_buttons)) { $this->_buttons->name = $formIdentifier; $buttonClass = "button-{$formIdentifier}"; $subBtn = $this->_themeDetails->getField($this->_buttons, $buttonClass, ''); } $formHTML = <<
{$this->honeypotField()} $fieldHtml
$confMsg HTMLa; return $formHTML; } }