<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2023 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php switch ($element->getType()){
    case 'fieldset': ?>

    <h3><?= $element->getLegend() ?></h3>
    <fieldset>
        <legend><?= $element->getLegend() ?></legend>
        <?php foreach ($element->getElements() as $_element): ?>
            <?= $formBlock->drawElement($_element) ?>
        <?php endforeach ?>
    </fieldset>
      <?php break;
    // no break
    case 'column': ?>
      <?php break;
    case 'hidden': ?>
    <input type="<?= $element->getType() ?>" name="<?= $element->getName() ?>" id="<?= $element->getHtmlId() ?>" value="<?= $element->getValue() ?>">
      <?php break;
    case 'select': ?>
    <span class="form_row">
        <?php if($element->getLabel()): ?><label for="<?= $element->getHtmlId() ?>"><?= $element->getLabel() ?>:</label><?php endif ?>
        <select name="<?= $element->getName() ?>" id="<?= $element->getHtmlId() ?>" class="select<?= $element->getClass() ?>" title="<?= $element->getTitle() ?>">
        <?php foreach ($element->getValues() as $_value): ?>
            <option <?= $_value->serialize() ?><?php if($_value->getValue() == $element->getValue()): ?> selected="selected"<?php endif ?>><?= $_value->getLabel() ?></option>
        <?php endforeach ?>
        </select>
    </span>
      <?php break;
    // no break
    case 'text':
    case 'button':
    case 'password': ?>
    <span class="form_row">
        <?php if($element->getLabel()): ?><label for="<?= $element->getHtmlId() ?>"><?= $element->getLabel() ?>:</label><?php endif ?>
        <input type="<?= $element->getType() ?>" name="<?= $element->getName() ?>" id="<?= $element->getHtmlId() ?>" value="<?= $element->getValue() ?>" class="input-text <?= $element->getClass() ?>" title="<?= $element->getTitle() ?>" <?= ( $element->getOnClick() ? 'onClick="'.$element->getOnClick().'"' : '' ) ?>/>
    </span>
      <?php break;
    // no break
    case 'radio': ?>
    <span class="form_row">
        <?php if($element->getLabel()): ?><label for="<?= $element->getHtmlId() ?>"><?= $element->getLabel() ?>:</label><?php endif ?>
        <input type="<?= $element->getType() ?>" name="<?= $element->getName() ?>" id="<?= $element->getHtmlId() ?>" value="<?= $element->getValue() ?>" class="input-text <?= $element->getClass() ?>" title="<?= $element->getTitle() ?>"/>
    </span>
      <?php break;
    // no break
    case 'hidden': ?>
        <input type="<?= $element->getType() ?>" name="<?= $element->getName() ?>" id="<?= $element->getHtmlId() ?>" value="<?= $element->getValue() ?>">
      <?php break;
    case 'radios': ?>
    <span class="form_row">
        <label for="<?= $element->getHtmlId() ?>"><?= $element->getLabel() ?>:</label>
    <?php foreach($element->getRadios() as $_radio): ?>
    <input type="radio" name="<?= $_radio->getName() ?>" id="<?= $_radio->getHtmlId() ?>" value="<?= $_radio->getValue() ?>" class="input-radio <?= $_radio->getClass() ?>" title="<?= $_radio->getTitle() ?>" <?= ( $_radio->getValue() == $element->getChecked() ) ? 'checked="true"' : '' ?> >&nbsp;<?= $_radio->getLabel() ?>
    <?php endforeach ?>
    </span>
      <?php break;
    // no break
    case 'wysiwyg': ?>
    <span class="form_row">
      <label for="<?= $element->getHtmlId() ?>"><?= $element->getLabel() ?>:</label>
        <script type="text/javascript" src="<?= Mage::getBaseUrl('js') ?>tinymce/tinymce.min.js"></script>
        <script type="text/javascript">
        //<![CDATA[
        tinyMCE.init({
            mode : "exact",
            theme : "advanced",
            elements : "<?= $element->getName() ?>",
            plugins : "inlinepopups,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
            theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,|,visualchars,nonbreaking",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_path_location : "bottom",
            extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
            theme_advanced_resize_horizontal : 'true',
            theme_advanced_resizing : 'true',
            apply_source_formatting : 'true',
            convert_urls : 'false',
            force_br_newlines : 'true',
            doctype : '<!DOCTYPE html>'

        });
        //]]>
        </script>
      <textarea name="<?= $element->getName() ?>" title="<?= $element->getTitle() ?>" id="<?= $element->getHtmlId() ?>" class="textarea <?= $element->getClass() ?>" cols="80" rows="20"><?= $element->getValue() ?></textarea>
    </span>
      <?php break;
        case 'textarea': ?>
            <span class="form_row">
                    <label for="<?= $element->getHtmlId() ?>"><?= $element->getLabel() ?>:</label>
                    <textarea name="<?= $element->getName() ?>" title="<?= $element->getTitle() ?>" id="<?= $element->getHtmlId() ?>" class="textarea <?= $element->getClass() ?>" cols="15" rows="2"><?= $element->getValue() ?></textarea>
            </span>
      <?php break;
    case 'editor': ?>
      <?php break;
    case 'file': ?>
      <?php break;
    case 'checkbox': ?>
      <?php break;
} ?>
<?php if($element->getScript()): ?>
<script type="text/javascript">
    <?= $element->getScript() ?>
</script>
<?php endif ?>
