Commit 1f90886e8e7224e5727e2bfac817dd88d0661ace

Authored by Edmar Moretti
1 parent dd8d48c9

inclusão de preview no sistema de administração da versão 7

admin/admin.db
No preview for this file type
admin/php/login.php
... ... @@ -259,7 +259,6 @@ function verificaPapelSessao($id_papel){
259 259 //verifica se uma determinada operacao esta registrada na variavel SESSION
260 260 //
261 261 function verificaOperacaoSessao($operacao){
262   -
263 262 $resultado = false;
264 263 //a validacao consulta $_SESSION, que e definida no login
265 264 if(validaSessao()){
... ...
admin/php/preview.php
... ... @@ -8,6 +8,7 @@ include(dirname(__FILE__)."/login.php");
8 8 if(verificaOperacaoSessao("admin/php/editortexto") == false){
9 9 //echo "Vc nao pode realizar essa operacao.";exit;
10 10 }
  11 +
11 12 //
12 13 //pega os endereços para compor a url de chamada do gerador de web services
13 14 //ogc.php
... ... @@ -45,14 +46,16 @@ foreach ($_GET as $k=>$v){
45 46 $tema = $v;
46 47 }
47 48 }
  49 +if(empty($tema)){
  50 + $tema = $_GET["tema"];
  51 +}
48 52 $req->setParameter("srsName",$req->getValueByName("SRS"));
49 53 $listaepsg = $req->getValueByName("SRS")." EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185";
50   -if(isset($version) && !isset($VERSION)){
51   - $VERSION = $version;
52   -}
53   -if(!isset($VERSION)){
54   - $req->setParameter("VeRsIoN","1.0.0");
  54 +if(isset($_GET["version"]) && !isset($VERSION)){
  55 + $_GET["VERSION"] = $_GET["version"];
55 56 }
  57 +$req->setParameter("VeRsIoN",$_GET["VERSION"]);
  58 +
56 59 //
57 60 //compatibiliza chamadas fora do padrao
58 61 //
... ... @@ -77,10 +80,12 @@ $oMap->setmetadata("ows_onlineresource",$or);
77 80 $oMap->setmetadata("wms_onlineresource",$or);
78 81 $oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF']));
79 82 $oMap->setmetadata("ows_enable_request","*");
  83 +
80 84 //parametro mandatario
81 85 if($oMap->getmetadata("wms_srs") == ""){
82 86 $oMap->setmetadata("wms_srs","EPSG:4326");
83 87 }
  88 +
84 89 $e = $oMap->extent;
85 90 $extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy);
86 91 //gera o mapa
... ... @@ -103,6 +108,7 @@ $extensao = $l->getmetadata("EXTENSAO");
103 108 if($extensao == ""){
104 109 $extensao = $extensaoMap;
105 110 }
  111 +
106 112 $l->setmetadata("wms_extent",$extensao);
107 113 if (!empty($postgis_mapa)){
108 114 if ($l->connectiontype == MS_POSTGIS){
... ... @@ -161,7 +167,7 @@ ms_ioinstallstdouttobuffer();
161 167 $req->setParameter("format","image/png");
162 168 $oMap->owsdispatch($req);
163 169 $contenttype = ms_iostripstdoutbuffercontenttype();
164   -
  170 +$oMap->save("/tmp/ms_tmp/teste.map");
165 171 if(!isset($OUTPUTFORMAT)){
166 172 header("Content-type: $contenttype");
167 173 }
... ...
admin1/catalogo/mapfile/editor/index.js
... ... @@ -24,7 +24,6 @@ Free Software Foundation, Inc., no endereço
24 24 */
25 25 i3GEOadmin.mapfile = {};
26 26 i3GEOadmin.editor = {
27   -
28 27 init: function(onde,codigo,id_tema){
29 28  
30 29 },
... ... @@ -32,13 +31,18 @@ i3GEOadmin.editor = {
32 31 i3GEOadmin.core.iconeAguarde($("#titulo"));
33 32 $("form").submit();
34 33 },
35   - testa: function(codigo){
  34 + testar: function(codigo){
36 35 i3GEOadmin.core.modalAguarde(true);
37 36 i3GEOadmin.teste.testaImg("../../../..",codigo,"","",$("#modalGeral .modal-body"))
38 37 },
39 38 testaTabela: function(codigo){
40 39 i3GEOadmin.core.modalAguarde(true);
41 40 i3GEOadmin.teste.testaTabela("../../../..",codigo,$("#modalGeral .modal-body"))
  41 + },
  42 + preview: function(codigo){
  43 + i3GEOadmin.core.modalAguarde(true);
  44 + var w = $("#modalGeral .modal-body").width() - 20;
  45 + var p = "<iframe style='width:" + w + "px;height:650px;border:0px solid white;' src='../../../../mashups/openlayers3.php?servidor=" + i3GEOadmin.editor.servidorPreview + "&fundo=e_wsm&nocache=sim&DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=" + (w - 40) + "&altura=600&temas=" + codigo + "'>";
  46 + $("#modalGeral .modal-body").html(p);
42 47 }
43   -
44 48 };
45 49 \ No newline at end of file
... ...
admin1/catalogo/mapfile/editor/index.php
1 1 <?php
2 2 //TODO botoes de copiar, colar, limpar
3   -//TODO preview com openlayers
4 3 //TODO editor de cores
5 4 //
6 5 define ( ONDEI3GEO, "../../../.." );
... ... @@ -49,8 +48,8 @@ $textoMapfile = textoMapfile ( $codigo );
49 48 <a href="http://mapserver.org/mapfile/index.html#mapfile" target="_new">Mapserver</a>
50 49 </blockquote>
51 50 <a onclick="i3GEOadmin.editor.salvar()" class="btn btn-primary" style="color: #008579;" href="#" role="button"> {{{salva}}} </a>
52   - <a onclick="i3GEOadmin.editor.preview()" class="btn btn-primary" style="color: #008579;" href="#" role="button"> Preview </a>
53   - <a onclick="i3GEOadmin.editor.testa('<?php echo $codigo;?>')" href="javascript:void(0)" class="btn btn-primary" style="color: #008579;" role="button"> {{{testaLayer}}} </a>
  51 + <a onclick="i3GEOadmin.editor.preview('<?php echo $codigo;?>')" class="btn btn-primary" style="color: #008579;" href="#" role="button"> Preview </a>
  52 + <a onclick="i3GEOadmin.editor.testar('<?php echo $codigo;?>')" href="javascript:void(0)" class="btn btn-primary" style="color: #008579;" role="button"> {{{testaLayer}}} </a>
54 53 <a onclick="window.open('../../../../ms_criamapa.php?temasa=<?php echo $codigo;?>&layers=<?php echo $codigo;?>')" class="btn btn-primary" style="color: #008579;" href="javascript:void(0)" role="button"> {{{testarI3geo}}} </a>
55 54 <a onclick="i3GEOadmin.editor.testaTabela('<?php echo $codigo;?>')" class="btn btn-primary" style="color: #008579;" href="javascript:void(0)" role="button"> {{{tabela}}} </a>
56 55 </div>
... ... @@ -106,6 +105,14 @@ $(document).ready(function(){
106 105 $.material.init();
107 106 $("#editor").height(parseInt($("#editortemp").height()) + 50 + "px");
108 107 $("#editortemp").html("").hide();
  108 + //
  109 + //servidor utilizado no preview
  110 + //
  111 + var protocolo = window.location.href;
  112 + protocolo = protocolo.split(":")[0];
  113 +
  114 + i3GEOadmin.editor.servidorPreview = protocolo + "://" + window.location.host + "/<?php echo basename($locaplic); ?>/admin1/catalogo/mapfile/preview/index.php";
  115 +
109 116 });
110 117 </script>
111 118 </body>
... ...
admin1/catalogo/mapfile/preview/index.php 0 → 100755
... ... @@ -0,0 +1,198 @@
  1 +<?php
  2 +error_reporting ( 0 );
  3 +include_once (dirname ( __FILE__ ) . "/../../../../admin/php/login.php");
  4 +if(verificaOperacaoSessao("admin/php/editortexto") == false){
  5 + echo "Vc nao pode realizar essa operacao.";exit;
  6 +}
  7 +
  8 +
  9 +//
  10 +//pega os endere&ccedil;os para compor a url de chamada do gerador de web services
  11 +//ogc.php
  12 +//
  13 +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']);
  14 +$protocolo = $protocolo[0];
  15 +$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'];
  16 +$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT'];
  17 +$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]);
  18 +//
  19 +//cria o web service
  20 +//
  21 +error_reporting(0);
  22 +$versao = versao();
  23 +$versao = $versao["principal"];
  24 +
  25 +
  26 +if($_GET["SRS"] == "EPSG:900913"){
  27 + $_GET["SRS"] = "EPSG:3857";
  28 +}
  29 +if(isset($_GET["BBOX"])){
  30 + $_GET["BBOX"] = str_replace(" ",",",$_GET["BBOX"]);
  31 +}
  32 +$req = ms_newowsrequestobj();
  33 +
  34 +if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){
  35 + $_GET["srs"] = "EPSG:4326";
  36 +}
  37 +foreach ($_GET as $k=>$v){
  38 + $req->setParameter(strtoupper($k), $v);
  39 + if(strtolower($k) == "layers" && empty($_GET["tema"])){
  40 + $tema = $v;
  41 + }
  42 + if(strtolower($k) == "layer" && empty($_GET["tema"])){
  43 + $tema = $v;
  44 + }
  45 +}
  46 +$tema = $locaplic . "/temas/" . $_GET["tema"] . ".map";
  47 +if(!file_exists($tema)){
  48 + echo "Erro";
  49 + exit;
  50 +}
  51 +$req->setParameter("srsName",$req->getValueByName("SRS"));
  52 +$listaepsg = $req->getValueByName("SRS")." EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185";
  53 +if(isset($_GET["version"]) && !isset($VERSION)){
  54 + $_GET["VERSION"] = $_GET["version"];
  55 +}
  56 +$req->setParameter("VeRsIoN",$_GET["VERSION"]);
  57 +
  58 +//
  59 +//compatibiliza chamadas fora do padrao
  60 +//
  61 +if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){
  62 + $_GET["OUTPUTFORMAT"] = $_GET["outputFormat"];
  63 +}
  64 +//essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao
  65 +$cortePixels = 0;
  66 +
  67 +if(empty($ogcwsmap)){
  68 + $oMap = ms_newMapobj($locaplic."/aplicmap/ogcwsv".$versao.".map");
  69 +}
  70 +else{
  71 + $oMap = ms_newMapobj($ogcwsmap);
  72 +}
  73 +
  74 +$proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://";
  75 +$server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
  76 +$or = $proto.$server.$_SERVER['PHP_SELF'];
  77 +$or = $or."?tema=".$tema."&";
  78 +$oMap->setmetadata("ows_onlineresource",$or);
  79 +$oMap->setmetadata("wms_onlineresource",$or);
  80 +$oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF']));
  81 +$oMap->setmetadata("ows_enable_request","*");
  82 +
  83 +//parametro mandatario
  84 +if($oMap->getmetadata("wms_srs") == ""){
  85 + $oMap->setmetadata("wms_srs","EPSG:4326");
  86 +}
  87 +
  88 +$e = $oMap->extent;
  89 +$extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy);
  90 +//gera o mapa
  91 +
  92 +$nmap = ms_newMapobj($tema);
  93 +
  94 +$nmap->setmetadata("ows_enable_request","*");
  95 +$l = $nmap->getlayer(0);
  96 +
  97 +
  98 +//$l->setmetadata("ows_title",pegaNome($l));
  99 +$l->setmetadata("ows_srs",$listaepsg);
  100 +$l->set("group","");
  101 +$l->setmetadata("gml_include_items","all");
  102 +$l->set("template","none.htm");
  103 +$l->set("dump",MS_TRUE);
  104 +$l->setmetadata("WMS_INCLUDE_ITEMS","all");
  105 +$l->setmetadata("WFS_INCLUDE_ITEMS","all");
  106 +//inclui extensao geografica
  107 +$extensao = $l->getmetadata("EXTENSAO");
  108 +if($extensao == ""){
  109 + $extensao = $extensaoMap;
  110 +}
  111 +
  112 +$l->setmetadata("wms_extent",$extensao);
  113 +if (!empty($postgis_mapa)){
  114 + if ($l->connectiontype == MS_POSTGIS){
  115 + $lcon = $l->connection;
  116 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
  117 + //
  118 + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substitui&ccedil;&atilde;o
  119 + //
  120 + if(($lcon == " ") || ($lcon == "")){
  121 + $l->set("connection",$postgis_mapa);
  122 + $l->setmetadata("CONEXAOORIGINAL",$lcon);
  123 + }
  124 + else{
  125 + $l->set("connection",$postgis_mapa[$lcon]);
  126 + $l->setmetadata("CONEXAOORIGINAL",$lcon);
  127 + }
  128 + }
  129 + }
  130 +}
  131 +
  132 +autoClasses($l,$oMap);
  133 +if($versao > 5){
  134 + $pr = $l->getProcessing();
  135 + if(!in_array("LABEL_NO_CLIP=True",$pr)){
  136 + $l->setprocessing("LABEL_NO_CLIP=True");
  137 + }
  138 + if(!in_array("POLYLINE_NO_CLIP=True",$pr)){
  139 + $l->setprocessing("POLYLINE_NO_CLIP=True");
  140 + }
  141 +}
  142 +$l->set("status",MS_DEFAULT);
  143 +
  144 +ms_newLayerObj($oMap, $l);
  145 +
  146 +$oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename));
  147 +$oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename));
  148 +
  149 +if(ob_get_contents ()){
  150 + ob_end_clean();
  151 +}
  152 +cloneInlineSymbol($l,$nmap,$oMap);
  153 +
  154 +$l = $oMap->getlayer(0);
  155 +$req->setParameter("LAYERS",$l->name);
  156 +
  157 +if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo"){
  158 + $req->setParameter("LAYERS",$l->name);
  159 + $req->setParameter("QUERY_LAYERS",$l->name);
  160 + if(strtolower($req->getValueByName("SRS")) == "epsg:900913"){
  161 + $req->setParameter("SRS","EPSG:3857");
  162 + $_GET["SRS"] = "EPSG:3857";
  163 + }
  164 +}
  165 +
  166 +ms_ioinstallstdouttobuffer();
  167 +$req->setParameter("format","image/png");
  168 +$oMap->owsdispatch($req);
  169 +$contenttype = ms_iostripstdoutbuffercontenttype();
  170 +$oMap->save("/tmp/ms_tmp/teste.map");
  171 +if(!isset($OUTPUTFORMAT)){
  172 + header("Content-type: $contenttype");
  173 +}
  174 +
  175 +$buffer = ms_iogetStdoutBufferBytes();
  176 +ms_ioresethandlers();
  177 +
  178 +function texto2iso($texto){
  179 + if (function_exists("mb_convert_encoding")){
  180 + if (mb_detect_encoding($texto,"UTF-8",true)){
  181 + $texto = mb_convert_encoding($texto,"ISO-8859-1","UTF-8");
  182 + }
  183 + }
  184 + return $texto;
  185 +}
  186 +function nomeRand($n=10)
  187 +{
  188 + $nomes = "";
  189 + $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ';
  190 + $max = 51;
  191 + for($i=0; $i < $n; ++$i)
  192 + {
  193 + $nomes .= $a{mt_rand(0, $max)};
  194 + }
  195 + return $nomes;
  196 +}
  197 +
  198 +?>
... ...