<?php
function render_field($field)
{
    echo '<tr>';
        echo '<td>'.$field['name'].'</td>';
        echo '<td>';

            if($field['type'] == "TEXT")
            {
                echo '<input type="text" name="fields['.$field['id'].']" value="'.$field['value'].'" size="100"/>';
            }
            elseif($field['type'] == "WYSIWYG")
            {
                echo '<textarea cols="100" rows="10" class="wysiwyg" name="fields['.$field['id'].']">'.$field['value'].'</textarea>';
            }
            else
            {
                echo '<textarea cols="100" rows="10" name="fields['.$field['id'].']">'.$field['value'].'</textarea>';
            }

        echo '</td>';
    echo '</tr>';
}
//------------------------------------------------------------------------------
?>

<h1><?= ucfirst($this->localization['ustawienia']).' > '.$this->localization['edycja'].' > '.$category['name'];?></h1>
<form method="post" action="" name="edit_form">
    <table>
        <?php
            foreach($settings as $k=>$v)
            {
                render_field($v);
            }
        ?>
    </table>
    <br /><br />
    <a href="javascript:document.edit_form.submit();"   class="form_button" ><?= ucfirst($this->localization['zatwierdz']);?></a>
    &nbsp;&nbsp;&nbsp;<a href="/settings/index"  class="form_button"><?= ucfirst($this->localization['anuluj']);?></a>
</form>

<script type="text/javascript">
        $(document).ready(function(){
            
            $('textarea.wysiwyg').each(function(){
                var _name = $(this).attr('name');

                var oFCKeditor      = new FCKeditor(_name) ;
                oFCKeditor.Height   = '300' ;
                oFCKeditor.Width    = '600' ;
                oFCKeditor.BasePath = "/files/fckeditor/" ;
                oFCKeditor.ReplaceTextarea() ;
            })
        });
</script>