<?php
include_once "base/lista.class.php";
include_once "include/images/images.class.php";
include_once("include/css.inc.php");
class listaFotosGaleria extends lista{
	
    function toolbars(){            
        $toolbar= new toolbar(); 
		$toolbar->botao_l("Novo");
		$toolbar->ini();
		$toolbar->nav($this->req['offset'], $this->req['limit'], $this->req['total']);
		$toolbar->ini();
		$toolbar->categoria($this->tipo, "categoria", $this->req['idCat'], true);
		$toolbar->procurar($this->req['procurar']);   //mudar para campo
		$toolbar->botao_l("procurar", 90);
		$toolbar->fim();
    }	

	function tabela($setas=false, $caixas=true){
            $max= sizeof($this->dados);
			$i=0;
			foreach($this->dados as $t){
                $linha=($i % 4)?"1":"0";
                if (($i % 2)==0) echo '<tr class="linha' . $linha . '">';
				echo "<td>";
				$this->imageTable($t);	
		
				if (($i % 2)==1)  echo "</td></tr>\n"; else   echo  "</td>";     
				$i++;
    		}
    }
	
	function desc($label, $value, $link){
	?><table width="220" border="0" >
      <tr>
        <td width="70" class="miniLabel"><?=$label?>:</td>
        <td width="150"><?=$link?>><?=$value?></a></td>
      </tr>
    </table>    
	<? }

	function imageTable($t){
		global $css;
		$db= new dbElemento;

		$temp=$db->getLinha("galeriaCategoria", $t['idCat']);

		$image_name="../netimages/galeria/thumb/". $t["imagem"];
		$ori_image="../netimages/galeria/" . $t["imagem"];
		
		$size=@getimagesize($ori_image);
		$largura=$size[0];
		$altura=$size[1];

		if (!(file_exists($image_name))){
			$img=new image();
			$thumb=$img->thumbnail2($ori_image,$image_name, 100,100);
		} else 
			$thumb=$image_name;
			
		$linkId='?id=' . $t["id"];
		$linkEditar='<a href='. $linkId . "&cmd=editar";
		$linkApagar='<a href='. $linkId . "&cmd=apagar";		
		
		?><table width="320" border="0" cellpadding="0" cellspacing="0" class="miniTable">
		  <tr>
			<td width="100" height="100" align="center" valign="middle">
			<?=$linkEditar?>><img src="<?=$thumb?>" border="0"></a></td>
			<td width="220"><?
					$this->desc("Titulo", $t["titulo"], $linkEditar);
					$this->desc("Descrição", $t["palavras"], $linkEditar);
					$this->desc("Dimensões", $largura."x".$altura, $linkEditar);
					$this->desc("Nome", basename($t["imagem"]), $linkEditar);
					if (!$this->idCat)$this->desc("Categoria", $temp["categoria"], $linkEditar);
					if($_SESSION['authdata']['super']) print $linkApagar . '>
				<img src="images/'.$css.'/apagar20.gif" alt="apagar" border=0/></a>
				<a href="#" onclick="open_pop(\'imagem_editor\', \''.$ori_image.'\')">
					<img border=0 src="images/'.$css.'/img_editar.png" alt="editar imagem" title="editar imagem">
				</a>';
			?></td>
		  </tr>
		</table>   
	<? 
	}
	
	function layer11(){
	    $f= new formElemento; 
		$db=new dbElemento;      
        ?><div id="Layer1"><div id="Label1" class="mybg"></div><table><?
		$dadosSel=$db->getListaCategorias("galeriaCategoria", array("Id"=>"id", "Categoria"=>"categoria") );
		foreach($dadosSel as $l=>$v)$dados[$l]=$v;
		
		$f->campoSeleccao("Categoria", "newIdCat", $dados);
		$f->botoesLayer();
		?></table></div><?
	}
}
?>
