'forminator', 'title' => 'Forminator' ); function __construct() { parent::__construct(); } /** * Get info about extension * * @param string $key - Key to get assigned extension info value * * @return array|string - Extension Key and Title or Assigned extension info value */ public function info($key = false) { if ($key && isset($this->info[$key])) { return $this->info[$key]; } else { return array( $this->info['key'] => $this->info['title'] ); } } public function active() { if (!function_exists('is_plugin_active')) { include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); } if (is_plugin_active('forminator/forminator.php')) { return true; } return false; } /** * Set option * * @param string $key - Key of option * @param string $value - Value of option * * @return bool - Status of setting option */ public function set($key, $value) { if (!isset($this->options)) { $this->options = new stdClass(); } $this->options->$key = $value; return true; } /** * Get option by key * * @param string $key - Key to get assigned option value * * @return mixed */ public function get($key) { if (isset($this->options->$key)) { $value = $this->options->$key; return $value; } else { return false; } } /** * Get items to work with * * @return array() - List of available items */ public function items() { $content = array(); if (class_exists("Forminator_API")) { $forms = Forminator_API::get_forms(); foreach ($forms as $key => $value) { $content[] = $this->item($value->id); } } return $content; } /** * Get entries for export * * @param int $item - Form ID * @param string $name - Entries names * * @return array() - Entries list */ public function datasets($item = false, $name = false) { $datasets = array(); if (class_exists("Forminator_API") && $item) { $entries = Forminator_API::get_entries($item); foreach ($entries as $key => $dataset) { $this->set('item', $item); $this->set('dataset', $dataset->entry_id); $dataset_title = $this->render($name); if (!$dataset_title) { $dataset_title = $dataset->entry_id; } $datasets[] = array( 'key' => $dataset->entry_id, 'value' => $dataset_title ); } } return $datasets; } /** * Get dataset * * @param int $dataset - Dataset ID * * @return object - Dataset */ public function dataset($dataset = false) { $dataset = (int) $dataset; if (!$dataset) { return false; } $data = new stdClass(); $data->url = false; return $data; } /** * Get item * * @param string $item - Item ID * * @return object - Item */ public function item($item = false) { $form = new stdClass(); if (!$item && $this->get('item')) { $item = $this->get('item'); } $forminator_form = false; if (class_exists("Forminator_API")) { $forminator_form = Forminator_API::get_form($item); } if (!is_wp_error($forminator_form)) { $form->id = (string) $item; $form->url = $this->helper->get_url(array('page' => 'forminator-cform-wizard', 'id' => $forminator_form->id)); $form->name = $forminator_form->name; } else { $form->id = ''; $form->url = 'javascript:void(0);'; $form->name = ''; } return $form; } /** * Render value according to content * * @param string $value - Content * @param string $type - Type of rendering value * @param string $field - Field * * @return string - Fully rendered value */ public function render($value, $type = false, $field = array()) { $value = $this->render_shortcodes($value, $type, $field); $value = $this->strip_shortcodes($value); if ($type === 'value' && isset($field['type']) && $field['type'] === 'e2pdf-checkbox' && isset($field['properties']['option'])) { $option = $this->render($field['properties']['option']); $options = explode(', ', $value); $option_options = explode(', ', $option); if (is_array($options) && is_array($option_options) && !array_diff($option_options, $options)) { return $option; } else { return ""; } } if ($type === 'value') { $value = $this->convert_shortcodes($value, true); } return $value; } /** * Render shortcodes which available in this extension * * @param string $type - Type of rendering value * @param string $value - Content * * @return string - Value with rendered shortcodes */ public function render_shortcodes($value, $type = false, $field = array()) { $dataset = $this->get('dataset'); $item = $this->get('item'); if ($this->verify() && function_exists("forminator_replace_form_data") && class_exists("Forminator_API")) { $form = Forminator_API::get_form($item); $entry = Forminator_API::get_entry($item, $dataset); $data = array(); foreach ($entry->meta_data as $key => $meta) { if (is_array($meta['value'])) { if (array_unique(array_map("is_int", array_keys($meta['value']))) === array(true)) { $data[$key] = $meta['value']; } else { if (isset($meta['value']['file']['file_url'])) { $data[$key] = $meta['value']['file']['file_url']; } else { foreach ($meta['value'] as $sub_key => $sub_meta) { $data[$key . "-" . $sub_key] = $sub_meta; } } } } else { $data[$key] = $meta['value']; } } if (false !== strpos($value, '[')) { $shortcode_tags = array( 'e2pdf-format-number', 'e2pdf-format-date', 'e2pdf-format-output', ); preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches); $tagnames = array_intersect($shortcode_tags, $matches[1]); if (!empty($tagnames)) { $pattern = get_shortcode_regex($tagnames); preg_match_all("/$pattern/", $value, $shortcodes); foreach ($shortcodes[0] as $key => $shortcode_value) { $shortcode = array(); $shortcode[1] = $shortcodes[1][$key]; $shortcode[2] = $shortcodes[2][$key]; $shortcode[3] = $shortcodes[3][$key]; $shortcode[4] = $shortcodes[4][$key]; $shortcode[5] = $shortcodes[5][$key]; $shortcode[6] = $shortcodes[6][$key]; if (isset($shortcode['5'])) { if (isset($field['type']) && ($field['type'] === 'e2pdf-image' || $field['type'] === 'e2pdf-signature')) { $sub_value = $this->render($shortcode['5'], $type); } else { $sub_value = $this->render($shortcode['5'], $type, $field); } $value = str_replace($shortcode_value, "[" . $shortcode['2'] . $shortcode['3'] . "]" . $sub_value . "[/" . $shortcode['2'] . "]", $value); } } } } $value = do_shortcode($value); $value = forminator_replace_form_data($value, $data, $form, $entry); $value = forminator_replace_variables($value, $item); if (isset($field['type']) && ($field['type'] === 'e2pdf-image' || $field['type'] === 'e2pdf-signature')) { $esig = isset($field['properties']['esig']) && $field['properties']['esig'] ? true : false; if ($esig) { //process e-signature $value = ""; } else { if (!$this->helper->load('image')->get_image($value)) { $value = $this->strip_shortcodes($value); if ( $value && trim($value) != "" && extension_loaded('gd') && function_exists('imagettftext') ) { if (isset($field['properties']['text_color']) && $field['properties']['text_color']) { $penColour = $this->helper->load('convert')->to_hex_color($field['properties']['text_color']); } else { $penColour = array(0x14, 0x53, 0x94); } $default_options = array( 'imageSize' => array(isset($field['width']) ? $field['width'] : '400', isset($field['height']) ? $field['height'] : '150'), 'bgColour' => 'transparent', 'penColour' => $penColour ); $options = array(); $options = array_merge($default_options, $options); $model_e2pdf_font = new Model_E2pdf_Font(); $font = false; if (isset($field['properties']['text_font']) && $field['properties']['text_font']) { $font = $model_e2pdf_font->get_font_path($field['properties']['text_font']); } if (!$font) { $font = $model_e2pdf_font->get_font_path('Noto Sans'); } $size = 150; if (isset($field['properties']['text_font_size']) && $field['properties']['text_font_size']) { $size = $field['properties']['text_font_size']; } $model_e2pdf_signature = new Model_E2pdf_Signature(); $value = $model_e2pdf_signature->ttf_signature($value, $size, $font, $options); } else { $value = ""; } } } } else { $value = $this->convert_shortcodes($value); } } return $value; } /** * Strip unused shortcodes * * @param string $value - Content * * @return string - Value with removed unused shortcodes */ public function strip_shortcodes($value) { $value = preg_replace('~(?:\[/?)[^/\]]+/?\]~s', "", $value); $value = preg_replace('~(?:{/?)[^/}]+/?}~s', "", $value); return $value; } public function convert_shortcodes($value, $to = false) { if ($value) { if ($to) { $value = str_replace("[", "[", $value); //$value = str_replace("%", "%", $value); } else { $value = str_replace("[", "[", $value); //$value = str_replace("%", "%", $value); } } return $value; } public function verify() { $item = $this->get('item'); $dataset = $this->get('dataset'); if ($item && $dataset && class_exists("Forminator_API")) { $entry = Forminator_API::get_entry($item, $dataset); if ($entry) { return true; } } return false; } public function visual_mapper() { $item = $this->get('item'); if ($item && function_exists("forminator_form_preview") && class_exists("Forminator_API")) { ob_start(); forminator_form_preview($item, true, array()); $source = ob_get_clean(); $form = Forminator_API::get_form($item); if (is_wp_error($form)) { return __('Form could not be found', 'e2pdf'); } libxml_use_internal_errors(true); $dom = new DOMDocument(); if (function_exists('mb_convert_encoding')) { $html = $dom->loadHTML(mb_convert_encoding($source, 'HTML-ENTITIES', 'UTF-8')); } else { $html = $dom->loadHTML('' . $source); } libxml_clear_errors(); if (!$html) { return __('Form could not be parsed due incorrect HTML', 'e2pdf'); } else { $xpath = new DomXPath($dom); $remove_by_class = array( 'forminator-pagination-submit' ); foreach ($remove_by_class as $key => $class) { $elements = $xpath->query("//*[contains(@class, '{$class}')]"); foreach ($elements as $element) { $element->parentNode->removeChild($element); } } $inputs = $xpath->query("//*[contains(@class, 'forminator-input')]"); foreach ($inputs as $element) { if (!$element->attributes->getNamedItem("type")->nodeValue) { $element->setAttribute("type", "text"); } } //remove pagination $pagination = $xpath->query("//*[contains(@class, 'forminator-pagination')]"); foreach ($pagination as $element) { if ($element->attributes->getNamedItem("style")) { $element->attributes->getNamedItem("style")->nodeValue = ""; } } //remove buttons $remove_rows = $xpath->query("//*[contains(@class, 'forminator-row')][.//button[contains(@class, 'forminator-button') and not(contains(@class, 'forminator-upload-button'))]]"); foreach ($remove_rows as $element) { $element->parentNode->removeChild($element); } //replace name on fileuploads $fileuploads = $xpath->query("//*[contains(@class, 'forminator-upload')]"); foreach ($fileuploads as $element) { $file = $xpath->query(".//input[contains(@class, 'forminator-input-file')]", $element)->item(0); $button = $xpath->query(".//button[contains(@class, 'forminator-upload-button')]", $element)->item(0); if ($file && $button) { if ($button->attributes->getNamedItem("type")) { $button->attributes->getNamedItem("type")->nodeValue = "upload"; } $button->setAttribute("name", "{" . $file->attributes->getNamedItem("name")->nodeValue . "}"); } } //replace names on inputs $inputs = $xpath->query("//input"); foreach ($inputs as $element) { $type = $element->attributes->getNamedItem("type")->nodeValue; if ($type == 'checkbox') { if ($element->attributes->getNamedItem("name")) { $element->attributes->getNamedItem("name")->nodeValue = str_replace("[]", "", $element->attributes->getNamedItem("name")->nodeValue); } } if ($element->attributes->getNamedItem("name")) { $element->attributes->getNamedItem("name")->nodeValue = "{" . $element->attributes->getNamedItem("name")->nodeValue . "}"; } if ($element->attributes->getNamedItem("class")) { if (strpos($element->attributes->getNamedItem("class")->nodeValue, 'forminator-checkbox--input') !== false) { $element->attributes->getNamedItem("class")->nodeValue = $element->attributes->getNamedItem("class")->nodeValue . " forminator-checkbox--design"; } if (strpos($element->attributes->getNamedItem("class")->nodeValue, 'forminator-radio--input') !== false) { $element->attributes->getNamedItem("class")->nodeValue = $element->attributes->getNamedItem("class")->nodeValue . " forminator-radio--design"; } } } //replace names on textareas $textareas = $xpath->query("//textarea"); foreach ($textareas as $element) { if ($element->attributes->getNamedItem("name")) { $element->attributes->getNamedItem("name")->nodeValue = "{" . $element->attributes->getNamedItem("name")->nodeValue . "}"; } } //replace names on selects $selects = $xpath->query("//select"); foreach ($selects as $element) { if ($element->attributes->getNamedItem("name")) { $element->attributes->getNamedItem("name")->nodeValue = "{" . $element->attributes->getNamedItem("name")->nodeValue . "}"; } } //multiselects $multiselect = $xpath->query("//ul[contains(@class, 'forminator-multiselect')]"); foreach ($multiselect as $element) { $name = ''; $options = array(); $inputs = $xpath->query(".//*[contains(@class, 'forminator-multiselect--item')]", $element); foreach ($inputs as $sub_element) { $input = $xpath->query(".//input", $sub_element)->item(0); $label = $xpath->query(".//label", $sub_element)->item(0); if ($input && $label) { $options[] = array( 'value' => $input->attributes->getNamedItem("value")->nodeValue, 'label' => $label->childNodes->item(0)->nodeValue ); $name = $input->attributes->getNamedItem("name")->nodeValue; } $sub_element->parentNode->removeChild($sub_element); } $li = $dom->createElement('li'); $field_atts = array( 'class' => 'forminator-multiselect--item', ); foreach ($field_atts as $key => $value) { $attr = $dom->createAttribute($key); $attr->value = $value; $li->appendChild($attr); } $element->appendChild($li); $field = $dom->createElement('select'); $field_atts = array( 'multiple' => 'multiple', 'name' => $name, ); foreach ($field_atts as $key => $value) { $attr = $dom->createAttribute($key); $attr->value = $value; $field->appendChild($attr); } $li->appendChild($field); foreach ($options as $option) { $option_field = $dom->createElement('option'); $field_atts = array( 'value' => $option['value'], ); foreach ($field_atts as $key => $value) { $attr = $dom->createAttribute($key); $attr->value = $value; $option_field->appendChild($attr); } $label = $dom->createTextNode($option['label']); $option_field->appendChild($label); $field->appendChild($option_field); } } return $dom->saveHTML(); } } return false; } /** * Auto Generate of Template for this extension * * @return array - List of elements */ public function auto() { $item = $this->get('item'); $response = array(); $elements = array(); $fields = array(); $form = false; if (class_exists("Forminator_API")) { $forminator_form = Forminator_API::get_form($item); if (!is_wp_error($forminator_form)) { $form = $forminator_form; $fields = $form->fields; } } if ($form && $fields) { foreach ($fields as $field_obj) { $field = $field_obj->raw; $float = true; $width = 100 / (12 / $field['cols']); switch ($field['type']) { case 'name': case 'email': case 'phone': case 'url': case 'upload': case 'number': case 'date': //multiple name field if ($field['type'] == 'name' && isset($field['multiple_name']) && $field['multiple_name']) { if (!$field['prefix'] && !$field['fname']) { if ($field['mname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['lname'] ? $width / 2 . '%' : $width . '%', 'height' => 'auto', 'value' => $field['mname_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-middle-name" . "}", ) )); } if ($field['lname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['mname'] ? $width / 2 . '%' : $width . '%', 'height' => 'auto', 'value' => $field['lname_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-last-name" . "}", ) )); } } else { if ($field['prefix']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['fname'] ? $width / 2 . '%' : $width . '%', 'height' => 'auto', 'value' => $field['prefix_label'], ) )); $options_tmp = array(); if (function_exists('forminator_get_name_prefixes')) { $options = forminator_get_name_prefixes(); foreach ($options as $key => $option) { $options_tmp[] = $key; } } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'options' => implode("\n", $options_tmp), 'value' => "{" . $field['element_id'] . "-prefix" . "}", ) )); if ($field['mname'] && $field['fname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'width' => $field['lname'] ? '100%' : '200%', 'right' => $field['lname'] ? '0' : '-40', 'height' => 'auto', 'value' => $field['mname_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => $field['lname'] ? '100%' : '200%', 'height' => 'auto', 'right' => $field['lname'] ? '0' : '-40', 'value' => "{" . $field['element_id'] . "-middle-name" . "}", ) )); } elseif ($field['lname'] && !$field['mname'] && $field['fname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'width' => $field['mname'] ? '100%' : '200%', 'height' => 'auto', 'right' => $field['mname'] ? '0' : '-40', 'value' => $field['lname_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => $field['mname'] ? '100%' : '200%', 'height' => 'auto', 'right' => $field['mname'] ? '0' : '-40', 'value' => "{" . $field['element_id'] . "-last-name" . "}", ) )); } } if ($field['fname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['prefix'] ? ($width / 2) . '%' : $width . '%', 'height' => 'auto', 'value' => $field['fname_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-first-name" . "}", ) )); if ($field['lname'] && $field['mname'] && $field['prefix']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'width' => $field['mname'] ? '100%' : '200%', 'height' => 'auto', 'right' => $field['mname'] ? '0' : '-40', 'value' => $field['lname_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => $field['mname'] ? '100%' : '200%', 'height' => 'auto', 'right' => $field['mname'] ? '0' : '-40', 'value' => "{" . $field['element_id'] . "-last-name" . "}", ) )); } } if (!$field['prefix'] || !$field['fname']) { if ($field['mname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'right' => $field['lname'] ? '20' : '0', 'width' => $field['lname'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['mname_label'], ) )); } if ($field['lname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'float' => $field['mname'] ? true : false, 'properties' => array( 'top' => '20', 'left' => $field['mname'] ? '20' : '0', 'width' => $field['mname'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['lname_label'], ) )); } if ($field['mname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'right' => $field['lname'] ? '20' : '0', 'width' => $field['lname'] ? '50%' : '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-middle-name" . "}", ) )); } if ($field['lname']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'float' => $field['mname'] ? true : false, 'properties' => array( 'top' => '5', 'left' => $field['mname'] ? '20' : '0', 'width' => $field['mname'] ? '50%' : '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-last-name" . "}", ) )); } } } } elseif ($field['type'] == 'date' && $field['field_type'] == 'select') { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => $float, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $width . "%", 'height' => 'auto', 'value' => $field['field_label'], ) )); $days = array(); $months = array(); $years = array(); if (class_exists('Forminator_Date')) { $forminator_date = new Forminator_Date(); $options = $forminator_date->get_day(); foreach ($options as $option) { $days[] = $option['value']; } $options = $forminator_date->get_months(); foreach ($options as $option) { $months[] = $option['value']; } $options = $forminator_date->get_years($field['min_year'], $field['max_year']); foreach ($options as $option) { $years[] = $option['value']; } } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'width' => '30%', 'height' => 'auto', 'options' => implode("\n", $days), 'value' => "{" . $field['element_id'] . "-month" . "}", ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'float' => true, 'properties' => array( 'top' => '5', 'left' => '5%', 'right' => '5%', 'width' => '40%', 'height' => 'auto', 'options' => implode("\n", $months), 'value' => "{" . $field['element_id'] . "-day" . "}", ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'float' => true, 'properties' => array( 'top' => '5', 'width' => '30%', 'height' => 'auto', 'options' => implode("\n", $years), 'value' => "{" . $field['element_id'] . "-year" . "}", ) )); } elseif ($field['type'] == 'date' && $field['field_type'] == 'input') { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => $float, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $width . "%", 'height' => 'auto', 'value' => $field['field_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '30%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-month" . "}", ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'float' => true, 'properties' => array( 'top' => '5', 'left' => '5%', 'right' => '5%', 'width' => '40%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-day" . "}", ) )); $elements[] = $this->auto_field($field, array( 'float' => true, 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '30%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-year" . "}", ) )); } else { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => $float, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $width . "%", 'height' => 'auto', 'value' => $field['field_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "}", ) )); } break; case 'address': if (!$field['street_address'] && !$field['address_line']) { if (!$field['address_city'] && !$field['address_state']) { if ($field['address_zip']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['address_country'] ? $width / 2 . '%' : $width . '%', 'height' => 'auto', 'value' => $field['address_zip_label'] ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-zip" . "}", ) )); } if ($field['address_country']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['address_zip'] ? $width / 2 . '%' : $width . '%', 'height' => 'auto', 'value' => $field['address_country_label'], ) )); $options_tmp = array(); if (function_exists('forminator_to_field_array') && function_exists('forminator_get_countries_list')) { $options = forminator_to_field_array(forminator_get_countries_list(), true); foreach ($options as $option) { $options_tmp[] = $option['value']; } //can be value or label } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'options' => implode("\n", $options_tmp), 'value' => "{" . $field['element_id'] . "-country" . "}", ) )); } } else { if ($field['address_city']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['address_state'] ? $width / 2 . '%' : $width . '%', 'height' => 'auto', 'value' => $field['address_city_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-city" . "}", ) )); if ($field['address_zip'] && $field['address_state']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'right' => $field['address_country'] ? '0' : '-40', 'width' => $field['address_country'] ? '100%' : '200%', 'height' => 'auto', 'value' => $field['address_zip_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'right' => $field['address_country'] ? '0' : '-40', 'width' => $field['address_country'] ? '100%' : '200%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-zip" . "}", ) )); } elseif ($field['address_country'] && !$field['address_zip'] && $field['address_state']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'right' => $field['address_zip'] ? '0' : '-40', 'width' => $field['address_zip'] ? '100%' : '200%', 'height' => 'auto', 'value' => $field['address_country_label'], ) )); $options_tmp = array(); if (function_exists('forminator_to_field_array') && function_exists('forminator_get_countries_list')) { $options = forminator_to_field_array(forminator_get_countries_list(), true); foreach ($options as $option) { $options_tmp[] = $option['value']; } //can be value or label } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'right' => $field['address_zip'] ? '0' : '-40', 'width' => $field['address_zip'] ? '100%' : '200%', 'height' => 'auto', 'options' => implode("\n", $options_tmp), 'value' => "{" . $field['element_id'] . "-country" . "}", ) )); } } if ($field['address_state']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $field['address_city'] ? ($width / 2) . '%' : $width . '%', 'height' => 'auto', 'value' => $field['address_state_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-state" . "}", ) )); if ($field['address_country'] && $field['address_zip'] && $field['address_city']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'right' => $field['address_zip'] ? '0' : '-40', 'width' => $field['address_zip'] ? '100%' : '200%', 'height' => 'auto', 'value' => $field['address_country_label'], ) )); $options_tmp = array(); if (function_exists('forminator_to_field_array') && function_exists('forminator_get_countries_list')) { $options = forminator_to_field_array(forminator_get_countries_list(), true); foreach ($options as $option) { $options_tmp[] = $option['value']; } //can be value or label } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'right' => $field['address_zip'] ? '0' : '-40', 'width' => $field['address_zip'] ? '100%' : '200%', 'height' => 'auto', 'options' => implode("\n", $options_tmp), 'value' => "{" . $field['element_id'] . "-country" . "}", ) )); } } if (!$field['address_city'] || !$field['address_state']) { if ($field['address_zip']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'right' => $field['address_country'] ? '20' : '0', 'width' => $field['address_country'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['address_zip_label'], ) )); } if ($field['address_country']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'float' => $field['address_zip'] ? true : false, 'properties' => array( 'top' => '20', 'left' => $field['address_zip'] ? '20' : '0', 'width' => $field['address_zip'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['address_country_label'], ) )); } if ($field['address_zip']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'right' => $field['address_country'] ? '20' : '0', 'width' => $field['address_country'] ? '50%' : '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-zip" . "}", ) )); } if ($field['address_country']) { $options_tmp = array(); if (function_exists('forminator_to_field_array') && function_exists('forminator_get_countries_list')) { $options = forminator_to_field_array(forminator_get_countries_list(), true); foreach ($options as $option) { $options_tmp[] = $option['value']; } //can be value or label } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'float' => $field['address_zip'] ? true : false, 'properties' => array( 'top' => '5', 'left' => $field['address_zip'] ? '20' : '0', 'width' => $field['address_zip'] ? '50%' : '100%', 'height' => 'auto', 'options' => implode("\n", $options_tmp), 'value' => "{" . $field['element_id'] . "-country" . "}", ) )); } } } } else { if ($field['street_address']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $width . '%', 'height' => 'auto', 'value' => $field['street_address_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-street_address" . "}", ) )); } if ($field['address_line']) { if ($field['address_line_label']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => $field['street_address'] ? false : true, 'float' => $field['street_address'] ? false : true, 'properties' => array( 'top' => '20', 'left' => $field['street_address'] ? '0' : '20', 'right' => $field['street_address'] ? '0' : '20', 'width' => $field['street_address'] ? '100%' : $width . '%', 'height' => 'auto', 'value' => $field['address_line_label'], ) )); } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => $field['address_line_label'] ? '0' : '20', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-address_line" . "}", ) )); } if ($field['address_city']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'right' => $field['address_state'] ? '20' : '0', 'width' => $field['address_state'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['address_city_label'], ) )); } if ($field['address_state']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'float' => $field['address_city'] ? true : false, 'properties' => array( 'top' => $field['address_city'] ? '0' : '20', 'left' => $field['address_city'] ? '20' : '0', 'width' => $field['address_city'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['address_state_label'], ) )); } if ($field['address_city']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'right' => $field['address_state'] ? '20' : '0', 'width' => $field['address_state'] ? '50%' : '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-city" . "}", ) )); } if ($field['address_state']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'float' => $field['address_city'] ? true : false, 'properties' => array( 'top' => '5', 'left' => $field['address_city'] ? '20' : '0', 'width' => $field['address_city'] ? '50%' : '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-state" . "}", ) )); } if ($field['address_zip']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '20', 'right' => $field['address_country'] ? '20' : '0', 'width' => $field['address_country'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['address_zip_label'], ) )); } if ($field['address_country']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'float' => $field['address_zip'] ? true : false, 'properties' => array( 'top' => '20', 'left' => $field['address_zip'] ? '20' : '0', 'width' => $field['address_zip'] ? '50%' : '100%', 'height' => 'auto', 'value' => $field['address_country_label'], ) )); } if ($field['address_zip']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'right' => $field['address_country'] ? '20' : '0', 'width' => $field['address_country'] ? '50%' : '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-zip" . "}", ) )); } if ($field['address_country']) { $options_tmp = array(); if (function_exists('forminator_to_field_array') && function_exists('forminator_get_countries_list')) { $options = forminator_to_field_array(forminator_get_countries_list(), true); foreach ($options as $option) { $options_tmp[] = $option['value']; } //can be value or label } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'float' => $field['address_zip'] ? true : false, 'properties' => array( 'top' => '5', 'left' => $field['address_zip'] ? '20' : '0', 'width' => $field['address_zip'] ? '50%' : '100%', 'height' => 'auto', 'options' => implode("\n", $options_tmp), 'value' => "{" . $field['element_id'] . "-country" . "}", ) )); } } break; case 'time': $hours = array(); $minutes = array(); if (class_exists('Forminator_Time')) { $forminator_time = new Forminator_Time(); $options = $forminator_time->get_hours($field['time_type']); foreach ($options as $option) { $hours[] = $option['value']; } $options = $forminator_time->get_minutes(); foreach ($options as $option) { $minutes[] = $option['value']; } } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => ($field['time_type'] == 'twelve' ? $width / 3 : $width / 2) . '%', 'height' => 'auto', 'value' => $field['hh_label'], ) )); if ($field['field_type'] == 'select') { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'options' => implode("\n", $hours), 'value' => "{" . $field['element_id'] . "-hours" . "}", ) )); } else { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-hours" . "}", ) )); } $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => ($field['time_type'] == 'twelve' ? $width / 3 : $width / 2) . '%', 'height' => 'auto', 'value' => $field['mm_label'], ) )); if ($field['field_type'] == 'select') { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'options' => implode("\n", $minutes), 'value' => "{" . $field['element_id'] . "-minutes" . "}", ) )); } else { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-input', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => "{" . $field['element_id'] . "-minutes" . "}", ) )); } if ($field['time_type'] == 'twelve') { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'float' => $float, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => ($width / 3) . '%', 'height' => 'auto', 'value' => '', ) )); $ampm = array( 'am', 'pm' ); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-select', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'options' => implode("\n", $ampm), 'value' => "{" . $field['element_id'] . "-ampm" . "}", ) )); } break; case 'html': { if ($field['field_label']) { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $width . '%', 'height' => 'auto', 'value' => $field['field_label'], ) )); $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'properties' => array( 'top' => '5', 'width' => '100%', 'height' => 'auto', 'value' => $field['variations'], ) )); } else { $elements[] = $this->auto_field($field, array( 'type' => 'e2pdf-html', 'block' => true, 'properties' => array( 'top' => '20', 'left' => '20', 'right' => '20', 'width' => $width . '%', 'height' => 'auto', 'value' => $field['variations'], ) )); } break; } case 'section': { $section = ''; if ($field['section_title']) { $section .= "