Commit 53f60421869294d86afe4a8432597beba80da1b4

Authored by Edmar Moretti
1 parent 459f80cb

Opção de upload de imagem para o publicador de mapas do sistema METAESTAT

admin/admin.db
No preview for this file type
admin/html/estat_mapa.html
... ... @@ -49,13 +49,14 @@ body {
49 49 <div class="hd">Ajuda</div>
50 50 <div class="bd" style="height: 144px; overflow: auto">
51 51 <p>Nesse formul&aacute;rio s&atilde;o definidos os par&acirc;metros para a publica&ccedil;&atilde;o de mapas que ir&atilde;o conter cartogramas estat&iacute;sticos.
52   - Os mapas s&atilde;o baseados em templates que definem como ser&aacute; a interface do mapa. Observação: a pasta onde ficam
  52 + Os mapas s&atilde;o baseados em templates que definem como ser&aacute; a interface do mapa. Utilizer a op&ccedil;&atilde;o de upload
  53 + para enviar as imagens que ser&atilde;o utilizadas no cabe&ccedil;alho do mapa. Observa&ccedil;&atilde;o: a pasta onde ficam
53 54 os templates &eacute; definida como uma vari&aacute;vel no arquivo i3geo/ms_configura.php
54 55 </div>
55 56 <div class="ft"></div>
56 57 </div>
57   - <input onclick="adicionaLinha()" type=button id=adiciona
58   - value="Adicionar Mapa" />
  58 + <input type=button id=adiciona value="Adicionar Mapa" />
  59 + <input type=button id=upload value="Upload de imagem" />
59 60 <br>
60 61 <p>Mapas cadastrados:</p>
61 62 <div id="tabela" style="left: -5px;"></div>
... ...
admin/js/estat_mapa.js
... ... @@ -7,6 +7,10 @@ Inicializa o editor de mapas
7 7 function initMenu()
8 8 {
9 9 ativaBotaoAdiciona("../php/metaestat.php?funcao=alteraMapa","adiciona");
  10 + new YAHOO.widget.Button("upload",{ onclick: { fn: function(){
  11 + core_montaEditor();
  12 + $i("editor_bd").innerHTML = formUploadImagem();
  13 + } } });
10 14 core_carregando("ativa");
11 15 core_ativaPainelAjuda("ajuda","botaoAjuda");
12 16 core_pegaDados("buscando mapas...","../php/metaestat.php?funcao=listaMapas","montaArvore");
... ... @@ -36,6 +40,16 @@ function ativaBotaoAdiciona(sUrl,idBotao)
36 40 };
37 41 new YAHOO.widget.Button(idBotao,{ onclick: { fn: adiciona } });
38 42 }
  43 +function formUploadImagem(){
  44 + var ins = '' +
  45 + '<form id=uploadimagem target="i3GEOuploadiframe" action="../php/estat_mapa_upload.php" method="post" ENCTYPE="multipart/form-data" >' +
  46 + '<p>Imagem (jpg ou png) se o arquivo j&aacute; existir, ser&aacute; substitu&iacute;do: <br><input type="file" size=22 name="uploadimagem" style="top:0px;left:0px;cursor:pointer;"></p>' +
  47 + '<p><input type="submit" size=12 name="submit">' +
  48 + '<input type="hidden" name="MAX_FILE_SIZE" value="1000000">' +
  49 + '</form>' +
  50 + '<iframe name=i3GEOuploadiframe style="text-align:left;border:1px solid gray;" width="98%" height="160px"></iframe>';
  51 + return ins;
  52 +}
39 53 /*
40 54 Function: montaArvore
41 55  
... ... @@ -223,7 +237,7 @@ function editar(tipo,id)
223 237 {
224 238 var dados = YAHOO.lang.JSON.parse(o.responseText);
225 239 core_montaEditor("gravaDados('tema','"+id+"')");
226   - $i("editor_bd").innerHTML = montaDivTema(dados);
  240 + montaDivTema(dados);
227 241 core_carregando("desativa");
228 242 }
229 243 core_carregando("desativa");
... ... @@ -244,16 +258,24 @@ function editar(tipo,id)
244 258 }
245 259 function montaDivTema(i)
246 260 {
247   - var param =
248   - {
249   - "linhas":[
250   - {titulo:"T&iacute;tulo:",id:"Etitulo",size:"50",value:i.titulo,tipo:"text",div:""},
251   - {titulo:"ID da medida de uma vari&aacute;vel:",id:"Eid_medida_variavel",size:"50",value:i.id_medida_variavel,tipo:"text",div:""}
252   - ]
253   - };
254   - var ins = "";
  261 + var sUrl = "../php/metaestat.php?funcao=relatorioCompleto&dadosGerenciais=nao&detalhes=nao",
  262 + ins = "",
  263 + callback = {
  264 + success:function(o){
  265 + ins += "<br><div>"+YAHOO.lang.JSON.parse(o.responseText)+"</div>";
  266 + $i("editor_bd").innerHTML = ins;
  267 + },
  268 + failure: function(){return ins;},
  269 + argument: { foo:"foo", bar:"bar" }
  270 + },
  271 + param = {
  272 + "linhas":[
  273 + {titulo:"T&iacute;tulo:",id:"Etitulo",size:"50",value:i.titulo,tipo:"text",div:""},
  274 + {titulo:"ID da medida de uma vari&aacute;vel (veja em ID no relat&oacute;rio abaixo):",id:"Eid_medida_variavel",size:"50",value:i.id_medida_variavel,tipo:"text",div:""}
  275 + ]
  276 + };
255 277 ins += core_geraLinhas(param);
256   - return(ins);
  278 + core_makeRequest(sUrl,callback);
257 279 }
258 280 function montaDivGrupo(i)
259 281 {
... ...
admin/php/classe_metaestat.php
... ... @@ -1645,35 +1645,37 @@ class Metaestat{
1645 1645 return $dados;
1646 1646 }
1647 1647 //$dados vem de relatorioCompleto
1648   - function formataRelatorioHtml($dados){
  1648 + function formataRelatorioHtml($dados,$detalhes="sim"){
1649 1649 $html[] = "<div class='var_div_relatorio'>";
1650 1650 $var_cor = "var_cor1";
1651 1651 foreach($dados as $variavel){
1652 1652 $html[] = "<div class='".$var_cor."'>";
1653   - $html[] = "<h1>".$variavel["titulo"]."</h1>";
1654   - $html[] = "<p><i>".$variavel["descricao"]."</i></p>";
  1653 + $html[] = "<h1>".$variavel["titulo"];
  1654 + $html[] = "<span style='color:rgb(190,190,190)'> (<i>".$variavel["descricao"]."</i>)</span></h1>";
1655 1655 $filhos = $variavel["filhos"];
1656 1656 foreach($filhos as $f){
1657   - $html[] = "<h2 style='position:relative;left:10px;'>".$f["titulo"]."</h2>";
  1657 + $html[] = "<h2 style='position:relative;left:10px;'>ID: <u>".$f["id"]."</u> - ".$f["titulo"]."</h2>";
1658 1658 $html[] = "<div style='position:relative;left:20px;'>";
1659 1659 $html[] = "<p><i>".$f["descricao"]."</i></p>";
1660   - $html[] = "<p><b>Fontes:</b></p>";
1661   - foreach($f["fontes"] as $fonte){
1662   - $html[] = "<p><a href='".$fonte["link"]."' >".$fonte["titulo"]."</a></p>";
1663   - }
1664   - $html[] = "<p><b>Links:</b></p>";
1665   - foreach($f["links"] as $link){
1666   - $html[] = "<p><a href='".$link["link"]."' >".$link["nome"]."</a></p>";
1667   - }
1668   - if($f["dadosgerenciais"] != ""){
1669   - $html[] = "<span style='color:gray'>";
1670   - $html[] = "esquemadb = ".$f["dadosgerenciais"][esquemadb].", ";
1671   - $html[] = "tabela = ".$f["dadosgerenciais"][tabela].", ";
1672   - $html[] = "colunavalor = ".$f["dadosgerenciais"][colunavalor].", ";
1673   - $html[] = "colunaidgeo = ".$f["dadosgerenciais"][colunaidgeo].", ";
1674   - $html[] = "filtro = ".$f["dadosgerenciais"][filtro].", ";
1675   - $html[] = "colunaidunico = ".$f["dadosgerenciais"][colunaidunico];
1676   - $html[] = "</span>";
  1660 + if($detalhes == "sim"){
  1661 + $html[] = "<p><b>Fontes:</b></p>";
  1662 + foreach($f["fontes"] as $fonte){
  1663 + $html[] = "<p><a href='".$fonte["link"]."' >".$fonte["titulo"]."</a></p>";
  1664 + }
  1665 + $html[] = "<p><b>Links:</b></p>";
  1666 + foreach($f["links"] as $link){
  1667 + $html[] = "<p><a href='".$link["link"]."' >".$link["nome"]."</a></p>";
  1668 + }
  1669 + if($f["dadosgerenciais"] != ""){
  1670 + $html[] = "<span style='color:gray'>";
  1671 + $html[] = "esquemadb = ".$f["dadosgerenciais"][esquemadb].", ";
  1672 + $html[] = "tabela = ".$f["dadosgerenciais"][tabela].", ";
  1673 + $html[] = "colunavalor = ".$f["dadosgerenciais"][colunavalor].", ";
  1674 + $html[] = "colunaidgeo = ".$f["dadosgerenciais"][colunaidgeo].", ";
  1675 + $html[] = "filtro = ".$f["dadosgerenciais"][filtro].", ";
  1676 + $html[] = "colunaidunico = ".$f["dadosgerenciais"][colunaidunico];
  1677 + $html[] = "</span>";
  1678 + }
1677 1679 }
1678 1680 $html[] = "</div>";
1679 1681 }
... ...
admin/php/estat_mapa_upload.php 0 → 100755
... ... @@ -0,0 +1,58 @@
  1 +<?php
  2 +include_once("admin.php");
  3 +include_once("login.php");
  4 +if(verificaOperacaoSessao("admin/metaestat/geral") == false){
  5 + echo "Vc nao pode realizar essa operacao.";exit;
  6 +}
  7 +error_reporting(E_ALL);
  8 +?>
  9 +<html>
  10 +<head>
  11 +<link rel="stylesheet" type="text/css" href="../../css/geral.css" />
  12 +<title></title>
  13 +</head>
  14 +<body bgcolor="white" style="background-color:white;text-align:left;">
  15 +<p>
  16 +<?php
  17 +if (isset($_FILES['uploadimagem']['name'])){
  18 + require_once ("../../ms_configura.php");
  19 + echo "<p class='paragrafo' >Carregando o arquivo...</p>";
  20 + $arq = $metaestatTemplates."/logos/".$_FILES['uploadimagem']['name'];
  21 + //verifica nomes
  22 + verificaNome($_FILES['uploadimagem']['name']);
  23 + //chmod($metaestatTemplates."/logos",777);
  24 + if(file_exists($arq)){
  25 + unlink($arq);
  26 + }
  27 + //sobe arquivo
  28 + $Arquivo = $_FILES['uploadimagem']['tmp_name'];
  29 + //echo $Arquivo;
  30 + $status = move_uploaded_file($Arquivo,$arq);
  31 + if($status != 1)
  32 + {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo. Verifique as permissoes de escrita";exit;}
  33 + if($status == 1){
  34 + echo "<p class='paragrafo' >Arquivo enviado.</p>";
  35 + chmod($arq,0777);
  36 + }
  37 + else{
  38 + echo "<p class='paragrafo' >Erro ao enviar o arquivo.</p>";
  39 + exit;
  40 + }
  41 +}
  42 +else{
  43 + echo "<p class='paragrafo' >Erro ao enviar o arquivo. Talvez o tamanho do arquivo seja maior do que o permitido.</p>";
  44 +}
  45 +function verificaNome($nome)
  46 +{
  47 + $nome = strtolower($nome);
  48 + $lista = explode(".",$nome);
  49 + $extensao = $lista[count($lista) - 1];
  50 + if($extensao != "png" && $extensao != "jpg")
  51 + {
  52 + echo "Nome de arquivo inv&aacute;lido.";
  53 + exit;
  54 + }
  55 +}
  56 +?>
  57 +</body>
  58 +</html>
0 59 \ No newline at end of file
... ...
admin/php/metaestat.php
... ... @@ -1346,7 +1346,10 @@ switch (strtoupper($funcao))
1346 1346 $codigo_variavel = "";
1347 1347 }
1348 1348 $dados = $m->relatorioCompleto($codigo_variavel,$dadosGerenciais);
1349   - $dados = $m->formataRelatorioHtml($dados);
  1349 + if(empty($detalhes)){
  1350 + $detalhes = "sim";
  1351 + }
  1352 + $dados = $m->formataRelatorioHtml($dados,$detalhes);
1350 1353 retornaJSON($dados);
1351 1354 exit;
1352 1355 break;
... ...
admin/php/uploadgvp.php
1 1 <?php
2   -require_once("../../classesphp/pega_variaveis.php");
3   -require_once("../../classesphp/funcoes_gerais.php");
4   -include_once ("../../classesphp/carrega_ext.php");
  2 +include_once("admin.php");
  3 +include_once("login.php");
  4 +if(verificaOperacaoSessao("admin/metaestat/geral") == false){
  5 + echo "Vc nao pode realizar essa operacao.";exit;
  6 +}
5 7 error_reporting(E_ALL);
6 8 ?>
7 9 <html>
... ... @@ -12,6 +14,7 @@ error_reporting(E_ALL);
12 14 <body bgcolor="white" style="background-color:white;text-align:left;">
13 15 <p>
14 16 <?php
  17 +var_dump($_FILES);exit;
15 18 if (isset($_FILES['i3GEOuploadgvp']['name'])){
16 19 require_once ("../../ms_configura.php");
17 20 echo "<p class='paragrafo' >Carregando o arquivo...</p>";
... ...