<?php
/**
 * Joomla! 1.5 component simpleimage
 *
 * @version $Id: view.html.php 2010-06-09 12:02:32 svn $
 * @author Darlinton Prauchner
 * @package Joomla
 * @subpackage simpleimage
 * @license GNU/GPL
 *
 * Componente para o envio de imagens com legenda e redimensionamento automático.
 *
 * This component file was created using the Joomla Component Creator by Not Web Design
 * http://www.notwebdesign.com/joomla_component_creator/
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

// Import Joomla! libraries
jimport( 'joomla.application.component.view');
class SimpleimageViewDefault extends JView {
    function display($tpl = null) {
	
		if ($msg = JRequest::getVar('msg'))
			$this->assignRef('msg', $msg);
		if ($galeria = JRequest::getVar('galeria'))
			$this->assignRef('galeria', $galeria);
	
		$model =& JModel::getInstance("Simpleimage","SimpleimageModel");
		$resultado = $model->getCategories();
		$categorias = array();
		foreach ($resultado as $key)
			$categorias[] = JHTML::_('select.option',  $key->ALIAS, $key->TITLE );
		$this->assignRef('categorias', JHTML::_('select.genericlist',   $categorias, 'nomeCategoria', '', 'value', 'text', '' ));
		


		$resultado = array();
		$list = scandir(ABSOLUTE_GALERIA_DIR);
		foreach ($list as $item)
			if (is_dir(ABSOLUTE_GALERIA_DIR.DS.$item))
				if ($item != "." && $item != "..")	
					$resultado[] = JHTML::_('select.option',  $item, $item);
		$this->assignRef('galeriasExistentes', JHTML::_('select.genericlist',   $resultado, 'galeriaExistente', '', 'value', 'text', '' ));


		$image_big = array();
		$image_mini = array();
		$y = 140;

		$image_big[] = JHTML::_('select.option',  'Usar tamanho original', '0' );
		$image_mini[] = JHTML::_('select.option',  'Não criar miniatura', '0' );
		for ($x=1000; $x>=200; $x-=200)
		{
			$image_big[] = JHTML::_('select.option',  $x, JText::_( 'WIDTH').': '.$x );
			$y += 20;
			$image_mini[] = JHTML::_('select.option',  $y, JText::_( 'WIDTH').': '.$y );;
		}

		$this->assignRef('selectPequeno', JHTML::_('select.genericlist',   $image_mini, 'miniatura[]', '', 'value', 'text', '200' ));
		$this->assignRef('selectGrande', JHTML::_('select.genericlist',   $image_big, 'redimensionamento[]', '', 'value', 'text', '800' ));
		

        parent::display($tpl);
    }
}
?>