<?php
/**
 * OpenMage
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available at https://opensource.org/license/afl-3-0-php
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://www.openmage.org)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php switch ($element->getType()){
    case 'fieldset': ?>

    <h3><?php echo $element->getLegend() ?></h3>
    <fieldset>
        <legend><?php echo $element->getLegend() ?></legend>
        <?php foreach ($element->getElements() as $_element): ?>
            <?php echo $formBlock->drawElement($_element) ?>
        <?php endforeach ?>
    </fieldset>
      <?php break;
    case 'column': ?>
      <?php break;
    case 'hidden': ?>
    <input type="<?php echo $element->getType() ?>" name="<?php echo $element->getName() ?>" id="<?php echo $element->getHtmlId() ?>" value="<?php echo $element->getValue() ?>">
      <?php break;
    case 'select': ?>
    <span class="form_row">
        <?php if($element->getLabel()): ?><label for="<?php echo $element->getHtmlId() ?>"><?php echo $element->getLabel() ?>:</label><?php endif ?>
        <select name="<?php echo $element->getName() ?>" id="<?php echo $element->getHtmlId() ?>" class="select<?php echo $element->getClass() ?>" title="<?php echo $element->getTitle() ?>">
        <?php foreach ($element->getValues() as $_value): ?>
            <option <?php echo $_value->serialize() ?><?php if($_value->getValue() == $element->getValue()): ?> selected="selected"<?php endif ?>><?php echo $_value->getLabel() ?></option>
        <?php endforeach ?>
        </select>
    </span>
      <?php break;
    case 'text':
    case 'button':
    case 'password': ?>
    <span class="form_row">
        <?php if($element->getLabel()): ?><label for="<?php echo $element->getHtmlId() ?>"><?php echo $element->getLabel() ?>:</label><?php endif ?>
        <input type="<?php echo $element->getType() ?>" name="<?php echo $element->getName() ?>" id="<?php echo $element->getHtmlId() ?>" value="<?php echo $element->getValue() ?>" class="input-text <?php echo $element->getClass() ?>" title="<?php echo $element->getTitle() ?>" <?php echo ( $element->getOnClick() ? 'onClick="'.$element->getOnClick().'"' : '' ) ?>/>
    </span>
      <?php break;
    case 'radio': ?>
    <span class="form_row">
        <?php if($element->getLabel()): ?><label for="<?php echo $element->getHtmlId() ?>"><?php echo $element->getLabel() ?>:</label><?php endif ?>
        <input type="<?php echo $element->getType() ?>" name="<?php echo $element->getName() ?>" id="<?php echo $element->getHtmlId() ?>" value="<?php echo $element->getValue() ?>" class="input-text <?php echo $element->getClass() ?>" title="<?php echo $element->getTitle() ?>"/>
    </span>
      <?php break;
    case 'hidden': ?>
        <input type="<?php echo $element->getType() ?>" name="<?php echo $element->getName() ?>" id="<?php echo $element->getHtmlId() ?>" value="<?php echo $element->getValue() ?>">
      <?php break;
    case 'radios': ?>
    <span class="form_row">
        <label for="<?php echo $element->getHtmlId() ?>"><?php echo $element->getLabel() ?>:</label>
    <?php foreach($element->getRadios() as $_radio): ?>
    <input type="radio" name="<?php echo $_radio->getName() ?>" id="<?php echo $_radio->getHtmlId() ?>" value="<?php echo $_radio->getValue() ?>" class="input-radio <?php echo $_radio->getClass() ?>" title="<?php echo $_radio->getTitle() ?>" <?php echo ( $_radio->getValue() == $element->getChecked() ) ? 'checked="true"' : '' ?> >&nbsp;<?php echo $_radio->getLabel() ?>
    <?php endforeach ?>
    </span>
      <?php break;
    case 'wysiwyg': ?>
    <span class="form_row">
      <label for="<?php echo $element->getHtmlId() ?>"><?php echo $element->getLabel() ?>:</label>
        <script type="text/javascript" src="<?php echo Mage::getBaseUrl('js') ?>lib/tinymce/tinymce.min.js"></script>
        <script type="text/javascript">
        //<![CDATA[
        tinyMCE.init({
            license_key: "gpl",
            mode : "exact",
            theme : "advanced",
            elements : "<?php echo $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="<?php echo $element->getName() ?>" title="<?php echo $element->getTitle() ?>" id="<?php echo $element->getHtmlId() ?>" class="textarea <?php echo $element->getClass() ?>" cols="80" rows="20"><?php echo $element->getValue(); ?></textarea>
    </span>
      <?php break;
        case 'textarea': ?>
            <span class="form_row">
                    <label for="<?php echo $element->getHtmlId() ?>"><?php echo $element->getLabel() ?>:</label>
                    <textarea name="<?php echo $element->getName() ?>" title="<?php echo $element->getTitle() ?>" id="<?php echo $element->getHtmlId() ?>" class="textarea <?php echo $element->getClass() ?>" cols="15" rows="2"><?php echo $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">
    <?php echo $element->getScript() ?>
</script>
<?php endif ?>
