<?php
/**
 * Landofcoder
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Landofcoder.com license that is
 * available through the world-wide-web at this URL:
 * https://landofcoder.com/terms
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category   Landofcoder
 * @package    Lof_Formbuilder
 * @copyright  Copyright (c) 2021 Landofcoder (https://www.landofcoder.com/)
 * @license    https://landofcoder.com/terms
 */

$helper         = $this->helper("Lof\Formbuilder\Helper\Fields");
$helper_data = $this->helper("Lof\Formbuilder\Helper\Data");
$form           = $block->getForm();
$field          = $this->getData('field_data');

$field_type     = $field['field_type'];
$label          = $block->filterMessage($field['label']);
$options        = $field['field_options'];
$required       = $field['required'];
$cid              = $helper_data->getFieldId($field);
$inlineCss      = isset($field['inline_css'])?$field['inline_css']:'';
$cssClass   = isset($field['css_class']) ? ($block->escapeHtmlAttr($field['css_class']).' ') : '';
$field_name     = $helper->getFieldPrefix() . $cid . $form->getId();
$field_id          = $field_name.uniqid();
$frame_work_css = '';
if (isset($field['frame_work_css'])) {
    $frame_work_css      = $field['frame_work_css'];
}
$available_fields = $helper->getAvailableFields();
$html             = '';
$field_validate   = isset($available_fields[$field_type])?$available_fields[$field_type]:'';
$validates        = $field_validate;
$field_help       = isset($options['description'])?$block->filterMessage($options['description']):'';
if ($field_validate && is_array($field_validate)) {
    $validates = implode(" ", $field_validate);
}
$validates .= " ".$cssClass;
$image_type = isset($field['image_type'])?$field['image_type']:'png,jpg,gif,jpeg,zip,doc,pdf';
$image_maximum_size = isset($field['image_maximum_size'])?$field['image_maximum_size']:10;

$color_label       = isset($options['color_label'])?'color:'.$options['color_label'].';':'';
$color_text       = isset($options['color_text'])?'color:'.$options['color_text'].';':'';
$color_description= isset($options['color_description'])?'color:'.$options['color_description'].';':'';
$background_color = isset($options['background_color'])?'background-color:'.$options['background_color'].';':'';

$font_size           = isset($options['font_size'])?'font-size:'.(int)$options['font_size'].'px;':'';
$font_style       = isset($options['font_style'])?'font-style:'.$options['font_style'].';':'';
$font_weight      = isset($options['font_weight'])?'font-weight:'.$options['font_weight'].';':'';

if ($frame_work_css =='foundation') : ?>
<div class="docs-code-live">
    <label for="<?= $field_id; ?>" style="<?= $font_size.$font_style.$font_weight.$color_label; ?>" class="button <?= (1==$required)?'required':''; ?>"><?= $label; ?><?= (1==$required)?'<em>*</em>':'';?></label>
    <input name="<?= $field_name; ?>" id="<?= $field_id; ?>" style="<?= $color_text.$background_color; ?>" title="<?= $label; ?>" class="show-for-sr input-text<?= (1==$required)?' required-entry':''; ?> <?= $validates; ?>" type="file" />
        <?php if ($field_help) : ?>
            <span class="help-block" style="<?= $color_description; ?>" ><?= $field_help; ?></span>
        <?php endif; ?>
</div>
<?php
else :
    ?>

<div class="subtemplate-wrapper" style="<?= $inlineCss ?>">
    <label for="<?= $field_id; ?>" style="<?= $font_size.$font_style.$font_weight.$color_label; ?>" class="<?= (1==$required)?'required':''; ?>"><?= $label; ?><?= (1==$required)?'<em>*</em>':'';?></label>
    <div class="input-box">
        <input name="<?= $field_name; ?>" id="<?= $field_id; ?>" style="<?= $color_text.$background_color; ?>" title="<?= $label; ?>" class="input-text<?= (1==$required)?' required-entry':''; ?> <?= $validates; ?>" type="file" />
        <?php if ($field_help) : ?>
            <span class="help-block" style="<?= $color_description; ?>" ><?= $field_help; ?></span>
        <?php endif; ?>
    </div>
</div>
<?php endif; ?>
