<?php $this->loadCss('/media/css/calendar.css'); ?>
<?php $this->loadJavascript('/media/js/jscalendar/calendar.js'); ?>
<?php $this->loadJavascript('/media/js/jscalendar/calendar-setup.js'); ?>
<?php $this->loadJavascript('/media/js/jscalendar/lang/calendar-pt.js'); ?>
<?php $this->loadCss('/media/css/dtree.css'); ?>
<?php $this->loadJavascript('/media/js/dtree.js'); ?>

<div id="accoes_bg">
    <div id="titulo_accao"><nobr><?php echo $action; ?> <?php echo translateAdmin('de');?> <?php echo $section_singular; ?></nobr></div>
</div>

<div id="conteudo">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <?php if (isset($tree)) : ?>
    <td valign="top" id="tr_tree">
        <div id="tree">
            <p><?php echo translateAdmin('P&aacute;ginas');?> | <a href="<?php echo $tree->openAllLink(); ?>"><?php echo translateAdmin('Expandir tudo');?></a> | <a href="<?php echo $tree->closeAllLink(); ?>"><?php echo translateAdmin('Fechar tudo');?></a></p>
            <?php echo $tree->render(); ?>
        </div>
    </td>
    <?php $align = "left"; ?>
    <?php else: ?>
    <?php $align = "center"; ?>
    <?php endif; ?>
    <td align="center" valign="top" id="manutencaodisplay">
        <?php echo $form->start(); ?>
        <div class="acessibilidade">
        	<span>
            <?/*
            <img src="/media/images/previsualizar.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Pr&eacute-Visualizar');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Pr&eacute;-Visualizar');?></a>&nbsp;
            <img src="/media/images/permissoes.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Permiss&otilde;es');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Permiss&otilde;es');?></a>&nbsp;
            */?>
            <?php if (isset($delete_link)) : ?>
            <input type="button" id="delete_link" name="delete_link" value="<?php echo translateAdmin('Remover');?>" class="form_delete" onClick="if (confirm('<?php echo translateAdmin('Tem a certeza que deseja remover o item seleccionado');?>?')) { location='<?php echo $this->link($delete_link); ?>'; } "/>
            <?php endif; ?>
            <?php echo $form->submit->input; ?>
            </span>
        </div>
        <div id="rte">
        <table border="0" cellpadding="2">
            <?php foreach ($form->getElementsNames() as $element): ?>
                <?php if ($form->{$element}->type != 'submit' && $form->{$element}->type != 'button'): ?>
                <tr>
                    <?php if ($form->{$element}->type == 'rte'): ?>
                    <td colspan="2" align="left"><?php if ($form->{$element}->getErrorMessage()): ?>
                        <div class="error_message">
                        <?php echo $form->{$element}->getErrorMessage(); ?>
                        </div>
                        <?php endif; ?>
                        <?php echo $form->{$element}->input; ?>
                    </td>
                    <?php else: ?>
                    <td width="10%" nowrap="nowrap" bgcolor="#f0f0ee"><?php echo $form->{$element}->label; ?>:</td>
                    <td width="90%" bgcolor="#f0f0ee" align="left">
                        <?php if ($form->{$element}->getErrorMessage()): ?>
                        <div class="error_message">
                            <?php echo $form->{$element}->getErrorMessage(); ?>
                        </div>
                        <?php endif; ?>
                        
                        <?php if (is_array($form->{$element}->input)) : ?>
                            <?php foreach ($form->{$element}->input as $label => $input) : ?>
                            <?php echo $input; ?>&nbsp;<?php echo $label; ?><br />
                            <?php endforeach; ?>
                        <?php else: ?>
                            <?php echo $form->{$element}->input; ?>
                        <?php endif; ?>
                        
                        <?php if ($model->colExists($element) && $model->getCol($element)->getType() == 'Image' && $model->{$element}): ?>
                        <input type="checkbox" name="<?php echo $element; ?>_del" class="checkbox" />
                        Remover
                        <div style="padding-top:5px;">
                        <?php
                           $imagem = $model->{$element};
                           // $uploadPath = WWW_PATH .'/uploads/' . $model->getCol($element)->getParam('target') . '/';
                           $uploadPath = WWW_PATH . $model->getCol($element)->getParam('target') . '/';
                           if (file_exists($uploadPath . 'big_' . $imagem)) {
                              $imageSize = getimagesize($uploadPath . 'big_' . $imagem);
                              $imagem = 'big_' . $imagem;
                           } elseif (file_exists($uploadPath . 'medium_' . $imagem)) {
                              $imageSize = getimagesize($uploadPath . 'medium_' . $imagem);
                              $imagem = 'medium_' . $imagem;
                           } elseif  (file_exists($uploadPath . 'small_' . $imagem)) {
                              $imageSize = getimagesize($uploadPath . 'small_' . $imagem);
                              $imagem = 'small_' . $imagem;
                           } else {
                              $imageSize = getimagesize($uploadPath . 'medium_' . $imagem);
                           }
                        ?>
                            <a href="#" onclick="windowPopup('<?php echo $model->getCol($element)->getParam('target'); ?>/<?php echo $imagem; ?>', 'Imagem', '<?php echo $imageSize[0] + 15; ?>', '<?php echo $imageSize[1] + 15; ?>');"><img src="<?php echo $model->getCol($element)->getParam('target'); ?>/small_<?php echo $model->{$element}; ?>" border="0" /></a> </div>
                        <?php elseif ($model->colExists($element) && $model->getCol($element)->getType() == 'File' && $model->{$element}): ?>
                        <div style="padding-top:5px;">
                        <a href="<?php echo $upload_path; ?><?php echo $model->{$element}; ?>" target="_blank"><?php echo translateAdmin('Ver ficheiro');?></a> </div>
                        <input type="checkbox" name="<?php echo $element; ?>_del"  class="checkbox"/>
                        Remover 
                        <?php endif; ?>

                        <?php if ($form->{$element}->help): ?>
                        <br /><label class="helper"><?php echo $form->{$element}->help; ?></label>
                        <?php endif; ?>
                    </td>
                    <?php endif; ?>
                </tr>
                <?php endif; ?>
            <?php endforeach; ?>
        </table>
        <div align="right"></div>
        <br />
        <div class="acessibilidade">
        	<span>
            <?/*
            <img src="/media/images/previsualizar.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Pr&eacute-Visualizar');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Pr&eacute;-Visualizar');?></a>&nbsp;
            <img src="/media/images/permissoes.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Permiss&otilde;es');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Permiss&otilde;es');?></a>&nbsp;
            */?>
            <?php if (isset($delete_link)) : ?>
            <input type="button" id="delete_link" name="delete_link" value="<?php echo translateAdmin('Remover');?>" class="form_delete" onClick="if (confirm('<?php echo translateAdmin('Tem a certeza que deseja remover o item seleccionado');?>?')) { location='<?php echo $this->link($delete_link); ?>'; } "/>
            <?php endif; ?>
            <?php echo $form->submit->input; ?>
            </span>
        </div>
        
        </div>
        <?php echo $form->end(); ?>
        
    </td>
  </tr>
</table>
</div>
