Commit 7d915c2b6281515550dfe97b06d43a6e98e5a997

Authored by Edmar Moretti
1 parent 8b361743

Remoção de funções duplicadas

admin1/catalogo/mapfile/cdados/funcoes.php
@@ -45,8 +45,7 @@ function alterar($locaplic, $id_tema, $codigo, $escala, $extensao, $encoding) { @@ -45,8 +45,7 @@ function alterar($locaplic, $id_tema, $codigo, $escala, $extensao, $encoding) {
45 } 45 }
46 try { 46 try {
47 $mapa->save ( $arq ); 47 $mapa->save ( $arq );
48 - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php");  
49 - removeCabecalhoMapfile ( $arq ); 48 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
50 return true; 49 return true;
51 } catch (Exception $e) { 50 } catch (Exception $e) {
52 return false; 51 return false;
@@ -59,8 +58,8 @@ function calculaExtensao($locaplic, $id_tema, $codigo){ @@ -59,8 +58,8 @@ function calculaExtensao($locaplic, $id_tema, $codigo){
59 return false; 58 return false;
60 } 59 }
61 $mapa = ms_newMapObj ( $arq ); 60 $mapa = ms_newMapObj ( $arq );
62 - include (dirname ( __FILE__ ) . "/../../../php/substituiConObj.php");  
63 - substituiConObj($mapa,$postgis_mapa); 61 +
  62 + \admin\php\funcoesAdmin\substituiConObj($mapa,$postgis_mapa);
64 $extatual = $mapa->extent; 63 $extatual = $mapa->extent;
65 $extatual->setextent(-180,-90,180,90); 64 $extatual->setextent(-180,-90,180,90);
66 $layer = @$mapa->getlayerbyname ( $codigo ); 65 $layer = @$mapa->getlayerbyname ( $codigo );
@@ -75,8 +74,7 @@ function calculaExtensao($locaplic, $id_tema, $codigo){ @@ -75,8 +74,7 @@ function calculaExtensao($locaplic, $id_tema, $codigo){
75 } 74 }
76 try { 75 try {
77 $mapa->save ( $arq ); 76 $mapa->save ( $arq );
78 - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php");  
79 - removeCabecalhoMapfile ( $arq ); 77 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
80 return $ret; 78 return $ret;
81 } catch (Exception $e) { 79 } catch (Exception $e) {
82 return false; 80 return false;
admin1/catalogo/mapfile/comportamento/funcoes.php
@@ -71,8 +71,7 @@ function alterar($locaplic, $id_tema, $codigo, $aplicaextensao, $permitecomentar @@ -71,8 +71,7 @@ function alterar($locaplic, $id_tema, $codigo, $aplicaextensao, $permitecomentar
71 $layer->set("status",$status); 71 $layer->set("status",$status);
72 try { 72 try {
73 $mapa->save ( $arq ); 73 $mapa->save ( $arq );
74 - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php");  
75 - removeCabecalhoMapfile ( $arq ); 74 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
76 return true; 75 return true;
77 } catch (Exception $e) { 76 } catch (Exception $e) {
78 return false; 77 return false;
admin1/catalogo/mapfile/conexao/local/funcoes.php
@@ -127,8 +127,7 @@ function alterar($locaplic,$codigo,$connection,$connectiontype,$data,$tileindex, @@ -127,8 +127,7 @@ function alterar($locaplic,$codigo,$connection,$connectiontype,$data,$tileindex,
127 127
128 try { 128 try {
129 $mapa->save ( $arq ); 129 $mapa->save ( $arq );
130 - include (dirname ( __FILE__ ) . "/../../../../php/removeCabecalhoMapfile.php");  
131 - removeCabecalhoMapfile ( $arq ); 130 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
132 return true; 131 return true;
133 } catch ( Exception $e ) { 132 } catch ( Exception $e ) {
134 return false; 133 return false;
admin1/catalogo/mapfile/disponibilidade/funcoes.php
@@ -74,8 +74,7 @@ function alterar($locaplic, $id_tema, $codigo, $permiteogc, $permitedownload, $p @@ -74,8 +74,7 @@ function alterar($locaplic, $id_tema, $codigo, $permiteogc, $permitedownload, $p
74 } 74 }
75 try { 75 try {
76 $mapa->save ( $arq ); 76 $mapa->save ( $arq );
77 - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php");  
78 - removeCabecalhoMapfile ( $arq ); 77 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
79 return true; 78 return true;
80 } catch (Exception $e) { 79 } catch (Exception $e) {
81 return false; 80 return false;
admin1/catalogo/mapfile/editavel/funcoes.php
@@ -42,8 +42,7 @@ function alterar($locaplic, $id_tema, $codigo, $editavel, $esquematabelaeditavel @@ -42,8 +42,7 @@ function alterar($locaplic, $id_tema, $codigo, $editavel, $esquematabelaeditavel
42 $layer->setmetadata ( "colunageometria", $colunageometria ); 42 $layer->setmetadata ( "colunageometria", $colunageometria );
43 try { 43 try {
44 $mapa->save ( $arq ); 44 $mapa->save ( $arq );
45 - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php");  
46 - removeCabecalhoMapfile ( $arq ); 45 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
47 return true; 46 return true;
48 } catch (Exception $e) { 47 } catch (Exception $e) {
49 return false; 48 return false;
admin1/catalogo/mapfile/funcoes.php
@@ -97,8 +97,7 @@ function alterar($locaplic, $id_tema, $titulolegenda, $link_tema, $codigo, $aces @@ -97,8 +97,7 @@ function alterar($locaplic, $id_tema, $titulolegenda, $link_tema, $codigo, $aces
97 return false; 97 return false;
98 } 98 }
99 $mapa->save ( $arq ); 99 $mapa->save ( $arq );
100 - include (dirname ( __FILE__ ) . "/../../php/removeCabecalhoMapfile.php");  
101 - removeCabecalhoMapfile ( $arq ); 100 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
102 return true; 101 return true;
103 } catch ( PDOException $e ) { 102 } catch ( PDOException $e ) {
104 return false; 103 return false;
@@ -524,8 +523,7 @@ function clonarMapfile($codigo,$novocodigo,$titulo,$dbh,$dbhw){ @@ -524,8 +523,7 @@ function clonarMapfile($codigo,$novocodigo,$titulo,$dbh,$dbhw){
524 $layer->set("name",$novocodigo); 523 $layer->set("name",$novocodigo);
525 $layer->setmetadata("TEMA",$titulo); 524 $layer->setmetadata("TEMA",$titulo);
526 $mapa->save($arqnovo); 525 $mapa->save($arqnovo);
527 - include(dirname(__FILE__)."/../../php/removeCabecalhoMapfile.php");  
528 - removeCabecalhoMapfile($arqnovo); 526 + \admin\php\funcoesAdmin\removeCabecalhoMapfile($arqnovo);
529 if (count ( $dados ) > 0) { 527 if (count ( $dados ) > 0) {
530 //registra no banco de dados caso nao tenha ocorrido erro ao criar o mapfile 528 //registra no banco de dados caso nao tenha ocorrido erro ao criar o mapfile
531 \admin\php\funcoesAdmin\i3GeoAdminInsert ( $dbhw, "i3geoadmin_temas", $dataCol ); 529 \admin\php\funcoesAdmin\i3GeoAdminInsert ( $dbhw, "i3geoadmin_temas", $dataCol );
admin1/catalogo/mapfile/renderizacao/funcoes.php
@@ -47,8 +47,7 @@ function alterar($locaplic, $id_tema, $codigo, $cache, $tiles, $maxfeatures, $co @@ -47,8 +47,7 @@ function alterar($locaplic, $id_tema, $codigo, $cache, $tiles, $maxfeatures, $co
47 47
48 try { 48 try {
49 $mapa->save ( $arq ); 49 $mapa->save ( $arq );
50 - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php");  
51 - removeCabecalhoMapfile ( $arq ); 50 + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq );
52 return true; 51 return true;
53 } catch (Exception $e) { 52 } catch (Exception $e) {
54 return false; 53 return false;
admin1/php/funcoesAdmin.php
@@ -720,28 +720,23 @@ function substituiCon($map_file,$postgis_mapa) @@ -720,28 +720,23 @@ function substituiCon($map_file,$postgis_mapa)
720 } 720 }
721 return true; 721 return true;
722 } 722 }
723 -function substituiConObj($objMap,$postgis_mapa){ 723 +function substituiConObj($mapa,$postgis_mapa){
724 error_reporting(0); 724 error_reporting(0);
725 if (!empty($postgis_mapa)){ 725 if (!empty($postgis_mapa)){
726 $numlayers = $objMap->numlayers; 726 $numlayers = $objMap->numlayers;
727 - for ($i=0;$i < $numlayers;++$i)  
728 - { 727 + for ($i=0;$i < $numlayers;++$i){
729 $layer = $objMap->getlayer($i); 728 $layer = $objMap->getlayer($i);
730 - if ($layer->connectiontype == MS_POSTGIS)  
731 - { 729 + if ($layer->connectiontype == MS_POSTGIS){
732 $lcon = $layer->connection; 730 $lcon = $layer->connection;
733 - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa))))  
734 - { 731 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) {
735 // 732 //
736 //o metadata CONEXAOORIGINAL guarda o valor original para posterior substitui&ccedil;&atilde;o 733 //o metadata CONEXAOORIGINAL guarda o valor original para posterior substitui&ccedil;&atilde;o
737 // 734 //
738 - if(($lcon == " ") || ($lcon == ""))  
739 - { 735 + if(($lcon == " ") || ($lcon == "")) {
740 $layer->set("connection",$postgis_mapa); 736 $layer->set("connection",$postgis_mapa);
741 $layer->setmetadata("CONEXAOORIGINAL",$lcon); 737 $layer->setmetadata("CONEXAOORIGINAL",$lcon);
742 } 738 }
743 - else  
744 - { 739 + else{
745 $layer->set("connection",$postgis_mapa[$lcon]); 740 $layer->set("connection",$postgis_mapa[$lcon]);
746 $layer->setmetadata("CONEXAOORIGINAL",$lcon); 741 $layer->setmetadata("CONEXAOORIGINAL",$lcon);
747 } 742 }
@@ -825,7 +820,6 @@ function versao() @@ -825,7 +820,6 @@ function versao()
825 $versao["inteiro"] = ms_GetVersionInt(); 820 $versao["inteiro"] = ms_GetVersionInt();
826 return $versao; 821 return $versao;
827 } 822 }
828 -//TODO verificar ao fechar \admin\php\funcoesAdmin\versao  
829 function seems_utf8($Str) { # by bmorel at ssi dot fr 823 function seems_utf8($Str) { # by bmorel at ssi dot fr
830 $length = strlen($Str); 824 $length = strlen($Str);
831 for ($i = 0; $i < $length; $i++) { 825 for ($i = 0; $i < $length; $i++) {
@@ -968,4 +962,70 @@ function removeAcentos($string){ @@ -968,4 +962,70 @@ function removeAcentos($string){
968 } 962 }
969 return $string; 963 return $string;
970 } 964 }
  965 +function removeCabecalhoMapfile($arq,$symbolset=true){
  966 + if(!file_exists($arq)){
  967 + return false;
  968 + }
  969 + $arq = str_replace(".map","",$arq).".map";
  970 + $handle = fopen($arq, "r");
  971 + if ($handle){
  972 + $cabeca = array();
  973 + if($symbolset){
  974 + $cabeca[] = "MAP\n";
  975 + //$final[] = "SYMBOLSET ../symbols/simbolos.sym\n";
  976 + //$final[] = "FONTSET ".'"'."../symbols/fontes.txt".'"'."\n";
  977 + }
  978 + $grava = false;
  979 + while (!feof($handle)){
  980 + $linha = fgets($handle);
  981 + if($symbolset){
  982 + if(strpos(strtoupper($linha),"SYMBOLSET") !== false){
  983 + $cabeca[] = $linha;
  984 + }
  985 + if(strpos(strtoupper($linha),"FONTSET") !== false){
  986 + $cabeca[] = $linha;
  987 + }
  988 + }
  989 + if(strtoupper(trim($linha)) == "LAYER"){
  990 + $grava = true;
  991 + }
  992 + if($grava){
  993 + $final[] = rtrim($linha, "\r\n") . PHP_EOL;
  994 + }
  995 + }
  996 + fclose($handle);
  997 + }
  998 + $final = array_merge($cabeca,$final);
  999 + $handle = fopen($arq, "w+");
  1000 + if($handle !== false){
  1001 + $testar = array("LEGENDAWMS","LEGENDAIMG","KEYIMAGE","TILEINDEX","TILEITEM","SYMBOL","LABELITEM","FILTERITEM","GROUP","ENCODING","TIP","CLASSE","ITENSDESC","CLASSESNOME","ITENSLINK","ESCALA","CLASSESSIMBOLO","MENSAGEM","EXTENSAO","CLASSESITEM","ESCONDIDO","CLASSESCOR","DOWNLOAD","CLASSESTAMANHO","ITENS","TEMA","APLICAEXTENSAO","IDENTIFICA","TRANSITIONEFFECT");
  1002 + foreach ($final as $f){
  1003 + //
  1004 + //remove resultados em branco
  1005 + //e grava a linha
  1006 + //
  1007 + $teste = strtoupper($f);
  1008 + $teste = trim($teste);
  1009 + $teste = str_replace(array(" ","'",'"'),"",$teste);
  1010 + //$teste = str_replace("'","",$teste);
  1011 + //$teste = str_replace('"',"",$teste);
  1012 + $teste = preg_replace('/[\n\r\t ]*/', '', $teste);
  1013 + $passou = true;
  1014 + foreach ($testar as $t)
  1015 + {
  1016 + if($teste == $t){
  1017 + $passou = false;
  1018 + }
  1019 + }
  1020 + if($passou == true){
  1021 + fwrite($handle,$f);
  1022 + }
  1023 + }
  1024 + fclose($handle);
  1025 + return true;
  1026 + }
  1027 + else{
  1028 + return false;
  1029 + }
  1030 +}
971 ?> 1031 ?>
admin1/php/removeCabecalhoMapfile.php
@@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
1 -<?php  
2 -function removeCabecalhoMapfile($arq,$symbolset=true){  
3 - if(!file_exists($arq)){  
4 - return false;  
5 - }  
6 - $arq = str_replace(".map","",$arq).".map";  
7 - $handle = fopen($arq, "r");  
8 - if ($handle){  
9 - $cabeca = array();  
10 - if($symbolset){  
11 - $cabeca[] = "MAP\n";  
12 - //$final[] = "SYMBOLSET ../symbols/simbolos.sym\n";  
13 - //$final[] = "FONTSET ".'"'."../symbols/fontes.txt".'"'."\n";  
14 - }  
15 - $grava = false;  
16 - while (!feof($handle)){  
17 - $linha = fgets($handle);  
18 - if($symbolset){  
19 - if(strpos(strtoupper($linha),"SYMBOLSET") !== false){  
20 - $cabeca[] = $linha;  
21 - }  
22 - if(strpos(strtoupper($linha),"FONTSET") !== false){  
23 - $cabeca[] = $linha;  
24 - }  
25 - }  
26 - if(strtoupper(trim($linha)) == "LAYER"){  
27 - $grava = true;  
28 - }  
29 - if($grava){  
30 - $final[] = rtrim($linha, "\r\n") . PHP_EOL;  
31 - }  
32 - }  
33 - fclose($handle);  
34 - }  
35 - $final = array_merge($cabeca,$final);  
36 - $handle = fopen($arq, "w+");  
37 - if($handle !== false){  
38 - $testar = array("LEGENDAWMS","LEGENDAIMG","KEYIMAGE","TILEINDEX","TILEITEM","SYMBOL","LABELITEM","FILTERITEM","GROUP","ENCODING","TIP","CLASSE","ITENSDESC","CLASSESNOME","ITENSLINK","ESCALA","CLASSESSIMBOLO","MENSAGEM","EXTENSAO","CLASSESITEM","ESCONDIDO","CLASSESCOR","DOWNLOAD","CLASSESTAMANHO","ITENS","TEMA","APLICAEXTENSAO","IDENTIFICA","TRANSITIONEFFECT");  
39 - foreach ($final as $f){  
40 - //  
41 - //remove resultados em branco  
42 - //e grava a linha  
43 - //  
44 - $teste = strtoupper($f);  
45 - $teste = trim($teste);  
46 - $teste = str_replace(array(" ","'",'"'),"",$teste);  
47 - //$teste = str_replace("'","",$teste);  
48 - //$teste = str_replace('"',"",$teste);  
49 - $teste = preg_replace('/[\n\r\t ]*/', '', $teste);  
50 - $passou = true;  
51 - foreach ($testar as $t)  
52 - {  
53 - if($teste == $t){  
54 - $passou = false;  
55 - }  
56 - }  
57 - if($passou == true){  
58 - fwrite($handle,$f);  
59 - }  
60 - }  
61 - fclose($handle);  
62 - return true;  
63 - }  
64 - else{  
65 - return false;  
66 - }  
67 -}  
68 -?>  
69 \ No newline at end of file 0 \ No newline at end of file
admin1/php/substituiConObj.php
@@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
1 -<?php  
2 -//substituiu a palavra chave pela string de conexao com o banco de dados em um objeto map  
3 -function substituiConObj($mapa,$postgis_mapa){  
4 - error_reporting(0);  
5 - if (!empty($postgis_mapa)){  
6 - $numlayers = $objMap->numlayers;  
7 - for ($i=0;$i < $numlayers;++$i){  
8 - $layer = $objMap->getlayer($i);  
9 - if ($layer->connectiontype == MS_POSTGIS){  
10 - $lcon = $layer->connection;  
11 - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) {  
12 - //  
13 - //o metadata CONEXAOORIGINAL guarda o valor original para posterior substitui&ccedil;&atilde;o  
14 - //  
15 - if(($lcon == " ") || ($lcon == "")) {  
16 - $layer->set("connection",$postgis_mapa);  
17 - $layer->setmetadata("CONEXAOORIGINAL",$lcon);  
18 - }  
19 - else{  
20 - $layer->set("connection",$postgis_mapa[$lcon]);  
21 - $layer->setmetadata("CONEXAOORIGINAL",$lcon);  
22 - }  
23 - }  
24 - }  
25 - }  
26 - }  
27 -}  
28 -?>  
29 \ No newline at end of file 0 \ No newline at end of file