Commit 59565c1a1f3bf5b59bcb7a21f1ff8bf7452aee46
1 parent
99da5de9
Exists in
master
and in
7 other branches
Correção na ferramenta de download para permitir a substituição de string de con…
…exão. Depreciada a função downloadtema em prol da downloadtema2
Showing
7 changed files
with
88 additions
and
21 deletions
Show diff stats
classesjs/classe_tema.js
| ... | ... | @@ -425,7 +425,7 @@ i3GEO.tema = { |
| 425 | 425 | var js = i3GEO.configura.locaplic+"/ferramentas/download/index.js.php"; |
| 426 | 426 | i3GEO.mapa.ativaTema(idtema); |
| 427 | 427 | i3GEO.util.scriptTag(js,"i3GEOF.download.criaJanelaFlutuante('"+idtema+"')","i3GEOF.download_script"); |
| 428 | - } | |
| 428 | + } | |
| 429 | 429 | }, |
| 430 | 430 | /* |
| 431 | 431 | Function: sld | ... | ... |
classesjs/datadownload.js
| ... | ... | @@ -293,7 +293,7 @@ function datadownload_download(tema) |
| 293 | 293 | { |
| 294 | 294 | if(!$i("panellistaarquivos")){ |
| 295 | 295 | YAHOO.namespace("datadownloadLista"); |
| 296 | - YAHOO.datadownloadLista.panel = new YAHOO.widget.Panel("panellistaarquivos", {zIndex:2000, iframe:false, width:"450px", visible:false, draggable:true, close:true, modal:true } ); | |
| 296 | + YAHOO.datadownloadLista.panel = new YAHOO.widget.Panel("panellistaarquivos", {zIndex:2000, iframe:false, width:"450px",align:"left", visible:false, draggable:true, close:true, modal:true } ); | |
| 297 | 297 | YAHOO.datadownloadLista.panel.setHeader("Arquivos"); |
| 298 | 298 | YAHOO.datadownloadLista.panel.setBody(""); |
| 299 | 299 | YAHOO.datadownloadLista.panel.setFooter(""); |
| ... | ... | @@ -303,11 +303,11 @@ function datadownload_download(tema) |
| 303 | 303 | YAHOO.datadownloadLista.panel.setBody($trad("d28")); |
| 304 | 304 | YAHOO.datadownloadLista.panel.show(); |
| 305 | 305 | //document.getElementById("corpo").innerHTML = "Aguarde. Gerando arquivos..." |
| 306 | - var p = g_locaplic+"/classesphp/mapa_controle.php?map_file=&funcao=download&tema="+tema; | |
| 306 | + var p = g_locaplic+"/classesphp/mapa_controle.php?map_file=&funcao=download2&tema="+tema; | |
| 307 | 307 | var cp = new cpaint(); |
| 308 | 308 | //cp.set_debug(2) |
| 309 | 309 | cp.set_response_type("JSON"); |
| 310 | - cp.call(p,"downloadTema",mostraDownload); | |
| 310 | + cp.call(p,"downloadTema2",mostraDownload); | |
| 311 | 311 | } |
| 312 | 312 | /* |
| 313 | 313 | Function: mostraDownload |
| ... | ... | @@ -319,7 +319,7 @@ function mostraDownload(retorno) |
| 319 | 319 | if (retorno.data != undefined) |
| 320 | 320 | { |
| 321 | 321 | var retorno = retorno.data |
| 322 | - var arqs = retorno.split(",") | |
| 322 | + var arqs = retorno.arquivos.split(",") | |
| 323 | 323 | var n = arqs.length; |
| 324 | 324 | if(retorno == "erro") |
| 325 | 325 | {var ins = "<p style=color:red >Ocorreu um erro. O tema não foi encontrado. Pode ser que o código do tema não existe na definição do mapfile. Informe o administrador do sistema.<br>";} |
| ... | ... | @@ -328,8 +328,10 @@ function mostraDownload(retorno) |
| 328 | 328 | var ins = "<b>Clique nos links para pegar os arquivos. Para obter os metadados, veja o link na árvore ao lado (o link é mostrado ao expandir o nó correspondente ao tema).</b><br><br>" |
| 329 | 329 | for (var arq=0;arq<n;arq++) |
| 330 | 330 | { |
| 331 | - ins += "<a href='"+window.location.protocol+"//"+window.location.host+"/"+arqs[arq]+"'>"+arqs[arq]+"<br>" | |
| 331 | + ins += "<a href='"+window.location.protocol+"//"+window.location.host+"/"+arqs[arq]+"'>"+arqs[arq]+"</a><br>" | |
| 332 | 332 | } |
| 333 | + if(retorno.nreg) | |
| 334 | + {ins += "<br><br>Número de registros ="+retorno.nreg;} | |
| 333 | 335 | } |
| 334 | 336 | } |
| 335 | 337 | else | ... | ... |
classesphp/funcoes_gerais.php
| ... | ... | @@ -1729,6 +1729,7 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1729 | 1729 | $novonomelayer = nomeRandomico(20); |
| 1730 | 1730 | else |
| 1731 | 1731 | $novonomelayer = $tema; |
| 1732 | + | |
| 1732 | 1733 | $nomeshp = $dir_tmp."/".$novonomelayer; |
| 1733 | 1734 | if(file_exists($nomeshp.".shp")) |
| 1734 | 1735 | {return $nomeshp;} |
| ... | ... | @@ -1786,13 +1787,16 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1786 | 1787 | $existesel = "nao"; |
| 1787 | 1788 | if (file_exists($map_file."qy")) |
| 1788 | 1789 | {$map->loadquery($map_file."qy");} |
| 1789 | - if ($layer->getNumresults() > 0){$existesel = "sim";} | |
| 1790 | + if ($layer->getNumresults() > 0) | |
| 1791 | + {$existesel = "sim";} | |
| 1792 | + | |
| 1790 | 1793 | if ($existesel == "nao") |
| 1791 | 1794 | { |
| 1792 | 1795 | @$layer->queryByrect($map->extent); |
| 1793 | 1796 | } |
| 1794 | 1797 | //pega cada registro |
| 1795 | 1798 | $res_count = $layer->getNumresults(); |
| 1799 | + | |
| 1796 | 1800 | if ($res_count > 0) |
| 1797 | 1801 | { |
| 1798 | 1802 | $sopen = $layer->open(); |
| ... | ... | @@ -1825,7 +1829,17 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1825 | 1829 | return $nomeshp; |
| 1826 | 1830 | } |
| 1827 | 1831 | /* |
| 1828 | -Function: downloadTema | |
| 1832 | +Function: downloadTema (depreciado) | |
| 1833 | + | |
| 1834 | +Utilize downloadTema2 | |
| 1835 | +*/ | |
| 1836 | +function downloadTema($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) | |
| 1837 | +{ | |
| 1838 | + $resultado = downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa); | |
| 1839 | + return $resultado["arquivos"]; | |
| 1840 | +} | |
| 1841 | +/* | |
| 1842 | +Function: downloadTema2 | |
| 1829 | 1843 | |
| 1830 | 1844 | Faz o download dos dados de um tema. |
| 1831 | 1845 | |
| ... | ... | @@ -1839,6 +1853,8 @@ $locaplic {string} - Diretório da aplicação. |
| 1839 | 1853 | |
| 1840 | 1854 | $dir_tmp {string} - Diretório temporário |
| 1841 | 1855 | |
| 1856 | +$postgismapa - variavel definida em ms_configura.php | |
| 1857 | + | |
| 1842 | 1858 | Retorno: |
| 1843 | 1859 | |
| 1844 | 1860 | {array} com o nome do diretório e nome do arquivo |
| ... | ... | @@ -1846,7 +1862,7 @@ Retorno: |
| 1846 | 1862 | Include: |
| 1847 | 1863 | <ms_configura.php> |
| 1848 | 1864 | */ |
| 1849 | -function downloadTema($map_file,$tema,$locaplic,$dir_tmp) | |
| 1865 | +function downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) | |
| 1850 | 1866 | { |
| 1851 | 1867 | ini_set("max_execution_time","1800"); |
| 1852 | 1868 | if(file_exists($locaplic."/ms_configura.php")) |
| ... | ... | @@ -1897,8 +1913,9 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
| 1897 | 1913 | // |
| 1898 | 1914 | //salva o mapfile com um outro nome para evitar que o mapa atual, se estiver aberto, seja modificado |
| 1899 | 1915 | // |
| 1900 | - $ma_file = str_replace(".map","tmp.map",$map_file); | |
| 1916 | + $map_file = str_replace(".map","tmp.map",$map_file); | |
| 1901 | 1917 | $map->save($map_file); |
| 1918 | + substituiCon($map_file,$postgis_mapa); | |
| 1902 | 1919 | $map = ms_newMapObj($map_file); |
| 1903 | 1920 | // |
| 1904 | 1921 | //verifica se existe mais de um tema (grupo) montando o array com os temas |
| ... | ... | @@ -1928,6 +1945,16 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
| 1928 | 1945 | foreach ($temas as $tema) |
| 1929 | 1946 | { |
| 1930 | 1947 | $l = $map->getlayerbyname($tema); |
| 1948 | + $novonomelayer = $tema; | |
| 1949 | + $nomeshp = $dir_tmp."/".$novonomelayer; | |
| 1950 | + if(file_exists($nomeshp.".dbf")){ | |
| 1951 | + $verificaDBF = verificaDBF($nomeshp.".dbf"); | |
| 1952 | + if($verificaDBF == false){ | |
| 1953 | + unlink($nomeshp.".dbf"); | |
| 1954 | + unlink($nomeshp.".shp"); | |
| 1955 | + unlink($nomeshp.".shx"); | |
| 1956 | + } | |
| 1957 | + } | |
| 1931 | 1958 | $meta = $l->getmetadata("arquivodownload"); |
| 1932 | 1959 | if($meta != "") |
| 1933 | 1960 | { |
| ... | ... | @@ -1965,7 +1992,7 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
| 1965 | 1992 | else |
| 1966 | 1993 | { |
| 1967 | 1994 | $sp = $map->shapepath; |
| 1968 | - $arq = ""; | |
| 1995 | + $arq = ""; | |
| 1969 | 1996 | if (file_exists($dados)) |
| 1970 | 1997 | {$arq = $dados;} |
| 1971 | 1998 | if (file_exists($dados.".shp")) |
| ... | ... | @@ -1976,8 +2003,6 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
| 1976 | 2003 | {$arq = $sp.$dados;} |
| 1977 | 2004 | if ($arq != "") |
| 1978 | 2005 | { |
| 1979 | - $novonomelayer = $tema; //nomeRandomico(20); | |
| 1980 | - $nomeshp = $dir_tmp."/".$novonomelayer; | |
| 1981 | 2006 | $arq = explode(".shp",$arq); |
| 1982 | 2007 | if(!file_exists($nomeshp.".shp")) |
| 1983 | 2008 | { |
| ... | ... | @@ -1991,6 +2016,7 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
| 1991 | 2016 | } |
| 1992 | 2017 | else |
| 1993 | 2018 | { |
| 2019 | + | |
| 1994 | 2020 | $nomeshp = criaSHP($tema,$map_file,$locaplic,$dir_tmp,FALSE); |
| 1995 | 2021 | $resultado[] = str_replace($radtmp."/","",$nomeshp).".shp"; |
| 1996 | 2022 | $resultado[] = str_replace($radtmp."/","",$nomeshp).".shx"; |
| ... | ... | @@ -1999,7 +2025,37 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
| 1999 | 2025 | } |
| 2000 | 2026 | } |
| 2001 | 2027 | } |
| 2002 | - return(implode(",",$resultado)); | |
| 2028 | + $nreg = ""; | |
| 2029 | + if(count($resultado) == 3){ | |
| 2030 | + $arq = $radtmp."/".$resultado[2]; | |
| 2031 | + $db = dbase_open($arq, 0); | |
| 2032 | + if ($db) {$nreg = dbase_numrecords($db);} | |
| 2033 | + } | |
| 2034 | + return array("arquivos"=>implode(",",$resultado),"nreg"=>$nreg); | |
| 2035 | +} | |
| 2036 | +/* | |
| 2037 | +Function: verificaDBF | |
| 2038 | + | |
| 2039 | +Verifica se um arquivo dbf está ou não vazio | |
| 2040 | + | |
| 2041 | +Parametros: | |
| 2042 | + | |
| 2043 | +$arq {string} - nome do arquivo dbf | |
| 2044 | + | |
| 2045 | +Return: | |
| 2046 | + | |
| 2047 | +{boolean} - true indica que não está vazio | |
| 2048 | +*/ | |
| 2049 | +function verificaDBF($arq){ | |
| 2050 | + $db = dbase_open($arq, 0); | |
| 2051 | + if ($db) { | |
| 2052 | + $record_numbers = dbase_numrecords($db); | |
| 2053 | + if ($record_numbers > 0) | |
| 2054 | + {return true;} | |
| 2055 | + else | |
| 2056 | + {return false;} | |
| 2057 | + } | |
| 2058 | + else {return false;} | |
| 2003 | 2059 | } |
| 2004 | 2060 | /* |
| 2005 | 2061 | Section: Outros | ... | ... |
classesphp/mapa_controle.php
| ... | ... | @@ -1011,13 +1011,20 @@ Gera uma imagem que será utilizada para destacar um determinado tema. |
| 1011 | 1011 | $retorno = $m->geraDestaque(); |
| 1012 | 1012 | break; |
| 1013 | 1013 | /* |
| 1014 | -Valor: DOWNLOAD | |
| 1014 | +Valor: DOWNLOAD (depreciado, utilize DOWNLOAD2 | |
| 1015 | +*/ | |
| 1016 | + case "DOWNLOAD": | |
| 1017 | + $retorno = downloadTema($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa); | |
| 1018 | + break; | |
| 1019 | +/* | |
| 1020 | +Valor: DOWNLOAD2 | |
| 1015 | 1021 | |
| 1016 | 1022 | Gera os arquivos para download de um tema. |
| 1017 | 1023 | */ |
| 1018 | - case "DOWNLOAD": | |
| 1019 | - $retorno = downloadTema($map_file,$tema,$locaplic,$dir_tmp); | |
| 1024 | + case "DOWNLOAD2": | |
| 1025 | + $retorno = downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa); | |
| 1020 | 1026 | break; |
| 1027 | + | |
| 1021 | 1028 | /* |
| 1022 | 1029 | function: INSEREFEATURE |
| 1023 | 1030 | ... | ... |
ferramentas/download/index.js.php
| ... | ... | @@ -51,15 +51,17 @@ i3GEOF.download = { |
| 51 | 51 | retorno,arqs,n,arq; |
| 52 | 52 | if (retorno.data != undefined){ |
| 53 | 53 | retorno = retorno.data; |
| 54 | - arqs = retorno.split(","); | |
| 54 | + arqs = retorno.arquivos.split(","); | |
| 55 | 55 | n = arqs.length; |
| 56 | 56 | if(retorno == "erro") |
| 57 | 57 | {ins = "<p style=color:red >Ocorreu um erro. O tema não foi encontrado. Pode ser que o código do tema não existe na definição do mapfile. Informe o administrador do sistema.<br>";} |
| 58 | 58 | else{ |
| 59 | 59 | for (arq=0;arq<n;arq++){ |
| 60 | - ins += "<a href='"+window.location.protocol+"//"+window.location.host+"/"+arqs[arq]+"'>"+arqs[arq]+"<br>"; | |
| 60 | + ins += "<a href='"+window.location.protocol+"//"+window.location.host+"/"+arqs[arq]+"'>"+arqs[arq]+"</a><br>"; | |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | + if(retorno.nreg) | |
| 64 | + {ins += "<br><br>Número de registros ="+retorno.nreg;} | |
| 63 | 65 | } |
| 64 | 66 | else |
| 65 | 67 | {ins = "<p style=color:red >Ocorreu um erro<br>";} |
| ... | ... | @@ -68,7 +70,7 @@ i3GEOF.download = { |
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | |
| 71 | - p = i3GEO.configura.locaplic+"/classesphp/mapa_controle.php?g_sid="+i3GEO.configura.sid+"&funcao=download&tema="+tema; | |
| 73 | + p = i3GEO.configura.locaplic+"/classesphp/mapa_controle.php?g_sid="+i3GEO.configura.sid+"&funcao=download2&tema="+tema; | |
| 72 | 74 | cp = new cpaint(); |
| 73 | 75 | cp.set_response_type("JSON"); |
| 74 | 76 | cp.call(p,"downloadTema",mostraDownload); | ... | ... |
menutemas/admin.db
No preview for this file type
temas/testeutf8postgis.map