diff --git a/admin1/catalogo/mapfile/cdados/funcoes.php b/admin1/catalogo/mapfile/cdados/funcoes.php index e928411..5066009 100755 --- a/admin1/catalogo/mapfile/cdados/funcoes.php +++ b/admin1/catalogo/mapfile/cdados/funcoes.php @@ -45,8 +45,7 @@ function alterar($locaplic, $id_tema, $codigo, $escala, $extensao, $encoding) { } try { $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return true; } catch (Exception $e) { return false; @@ -59,8 +58,8 @@ function calculaExtensao($locaplic, $id_tema, $codigo){ return false; } $mapa = ms_newMapObj ( $arq ); - include (dirname ( __FILE__ ) . "/../../../php/substituiConObj.php"); - substituiConObj($mapa,$postgis_mapa); + + \admin\php\funcoesAdmin\substituiConObj($mapa,$postgis_mapa); $extatual = $mapa->extent; $extatual->setextent(-180,-90,180,90); $layer = @$mapa->getlayerbyname ( $codigo ); @@ -75,8 +74,7 @@ function calculaExtensao($locaplic, $id_tema, $codigo){ } try { $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return $ret; } catch (Exception $e) { return false; diff --git a/admin1/catalogo/mapfile/comportamento/funcoes.php b/admin1/catalogo/mapfile/comportamento/funcoes.php index 4172509..ea10f1e 100755 --- a/admin1/catalogo/mapfile/comportamento/funcoes.php +++ b/admin1/catalogo/mapfile/comportamento/funcoes.php @@ -71,8 +71,7 @@ function alterar($locaplic, $id_tema, $codigo, $aplicaextensao, $permitecomentar $layer->set("status",$status); try { $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return true; } catch (Exception $e) { return false; diff --git a/admin1/catalogo/mapfile/conexao/local/funcoes.php b/admin1/catalogo/mapfile/conexao/local/funcoes.php index 5ec00f3..ff162ac 100755 --- a/admin1/catalogo/mapfile/conexao/local/funcoes.php +++ b/admin1/catalogo/mapfile/conexao/local/funcoes.php @@ -127,8 +127,7 @@ function alterar($locaplic,$codigo,$connection,$connectiontype,$data,$tileindex, try { $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return true; } catch ( Exception $e ) { return false; diff --git a/admin1/catalogo/mapfile/disponibilidade/funcoes.php b/admin1/catalogo/mapfile/disponibilidade/funcoes.php index 5b47667..9a1cf70 100755 --- a/admin1/catalogo/mapfile/disponibilidade/funcoes.php +++ b/admin1/catalogo/mapfile/disponibilidade/funcoes.php @@ -74,8 +74,7 @@ function alterar($locaplic, $id_tema, $codigo, $permiteogc, $permitedownload, $p } try { $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return true; } catch (Exception $e) { return false; diff --git a/admin1/catalogo/mapfile/editavel/funcoes.php b/admin1/catalogo/mapfile/editavel/funcoes.php index 985a3de..b4ed703 100755 --- a/admin1/catalogo/mapfile/editavel/funcoes.php +++ b/admin1/catalogo/mapfile/editavel/funcoes.php @@ -42,8 +42,7 @@ function alterar($locaplic, $id_tema, $codigo, $editavel, $esquematabelaeditavel $layer->setmetadata ( "colunageometria", $colunageometria ); try { $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return true; } catch (Exception $e) { return false; diff --git a/admin1/catalogo/mapfile/funcoes.php b/admin1/catalogo/mapfile/funcoes.php index bcd2047..c813b1f 100755 --- a/admin1/catalogo/mapfile/funcoes.php +++ b/admin1/catalogo/mapfile/funcoes.php @@ -97,8 +97,7 @@ function alterar($locaplic, $id_tema, $titulolegenda, $link_tema, $codigo, $aces return false; } $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return true; } catch ( PDOException $e ) { return false; @@ -524,8 +523,7 @@ function clonarMapfile($codigo,$novocodigo,$titulo,$dbh,$dbhw){ $layer->set("name",$novocodigo); $layer->setmetadata("TEMA",$titulo); $mapa->save($arqnovo); - include(dirname(__FILE__)."/../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile($arqnovo); + \admin\php\funcoesAdmin\removeCabecalhoMapfile($arqnovo); if (count ( $dados ) > 0) { //registra no banco de dados caso nao tenha ocorrido erro ao criar o mapfile \admin\php\funcoesAdmin\i3GeoAdminInsert ( $dbhw, "i3geoadmin_temas", $dataCol ); diff --git a/admin1/catalogo/mapfile/renderizacao/funcoes.php b/admin1/catalogo/mapfile/renderizacao/funcoes.php index a242793..9297842 100755 --- a/admin1/catalogo/mapfile/renderizacao/funcoes.php +++ b/admin1/catalogo/mapfile/renderizacao/funcoes.php @@ -47,8 +47,7 @@ function alterar($locaplic, $id_tema, $codigo, $cache, $tiles, $maxfeatures, $co try { $mapa->save ( $arq ); - include (dirname ( __FILE__ ) . "/../../../php/removeCabecalhoMapfile.php"); - removeCabecalhoMapfile ( $arq ); + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $arq ); return true; } catch (Exception $e) { return false; diff --git a/admin1/php/funcoesAdmin.php b/admin1/php/funcoesAdmin.php index 8c536a2..14ee422 100755 --- a/admin1/php/funcoesAdmin.php +++ b/admin1/php/funcoesAdmin.php @@ -720,28 +720,23 @@ function substituiCon($map_file,$postgis_mapa) } return true; } -function substituiConObj($objMap,$postgis_mapa){ +function substituiConObj($mapa,$postgis_mapa){ error_reporting(0); if (!empty($postgis_mapa)){ $numlayers = $objMap->numlayers; - for ($i=0;$i < $numlayers;++$i) - { + for ($i=0;$i < $numlayers;++$i){ $layer = $objMap->getlayer($i); - if ($layer->connectiontype == MS_POSTGIS) - { + if ($layer->connectiontype == MS_POSTGIS){ $lcon = $layer->connection; - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) - { + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) { // //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição // - if(($lcon == " ") || ($lcon == "")) - { + if(($lcon == " ") || ($lcon == "")) { $layer->set("connection",$postgis_mapa); $layer->setmetadata("CONEXAOORIGINAL",$lcon); } - else - { + else{ $layer->set("connection",$postgis_mapa[$lcon]); $layer->setmetadata("CONEXAOORIGINAL",$lcon); } @@ -825,7 +820,6 @@ function versao() $versao["inteiro"] = ms_GetVersionInt(); return $versao; } -//TODO verificar ao fechar \admin\php\funcoesAdmin\versao function seems_utf8($Str) { # by bmorel at ssi dot fr $length = strlen($Str); for ($i = 0; $i < $length; $i++) { @@ -968,4 +962,70 @@ function removeAcentos($string){ } return $string; } +function removeCabecalhoMapfile($arq,$symbolset=true){ + if(!file_exists($arq)){ + return false; + } + $arq = str_replace(".map","",$arq).".map"; + $handle = fopen($arq, "r"); + if ($handle){ + $cabeca = array(); + if($symbolset){ + $cabeca[] = "MAP\n"; + //$final[] = "SYMBOLSET ../symbols/simbolos.sym\n"; + //$final[] = "FONTSET ".'"'."../symbols/fontes.txt".'"'."\n"; + } + $grava = false; + while (!feof($handle)){ + $linha = fgets($handle); + if($symbolset){ + if(strpos(strtoupper($linha),"SYMBOLSET") !== false){ + $cabeca[] = $linha; + } + if(strpos(strtoupper($linha),"FONTSET") !== false){ + $cabeca[] = $linha; + } + } + if(strtoupper(trim($linha)) == "LAYER"){ + $grava = true; + } + if($grava){ + $final[] = rtrim($linha, "\r\n") . PHP_EOL; + } + } + fclose($handle); + } + $final = array_merge($cabeca,$final); + $handle = fopen($arq, "w+"); + if($handle !== false){ + $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"); + foreach ($final as $f){ + // + //remove resultados em branco + //e grava a linha + // + $teste = strtoupper($f); + $teste = trim($teste); + $teste = str_replace(array(" ","'",'"'),"",$teste); + //$teste = str_replace("'","",$teste); + //$teste = str_replace('"',"",$teste); + $teste = preg_replace('/[\n\r\t ]*/', '', $teste); + $passou = true; + foreach ($testar as $t) + { + if($teste == $t){ + $passou = false; + } + } + if($passou == true){ + fwrite($handle,$f); + } + } + fclose($handle); + return true; + } + else{ + return false; + } +} ?> diff --git a/admin1/php/removeCabecalhoMapfile.php b/admin1/php/removeCabecalhoMapfile.php deleted file mode 100755 index 4238ae8..0000000 --- a/admin1/php/removeCabecalhoMapfile.php +++ /dev/null @@ -1,68 +0,0 @@ - \ No newline at end of file diff --git a/admin1/php/substituiConObj.php b/admin1/php/substituiConObj.php deleted file mode 100755 index 800f218..0000000 --- a/admin1/php/substituiConObj.php +++ /dev/null @@ -1,28 +0,0 @@ -numlayers; - for ($i=0;$i < $numlayers;++$i){ - $layer = $objMap->getlayer($i); - if ($layer->connectiontype == MS_POSTGIS){ - $lcon = $layer->connection; - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) { - // - //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição - // - if(($lcon == " ") || ($lcon == "")) { - $layer->set("connection",$postgis_mapa); - $layer->setmetadata("CONEXAOORIGINAL",$lcon); - } - else{ - $layer->set("connection",$postgis_mapa[$lcon]); - $layer->setmetadata("CONEXAOORIGINAL",$lcon); - } - } - } - } - } -} -?> \ No newline at end of file -- libgit2 0.21.2