From 3010dad2059576fe52a6b7bdeac2f4982b00a8e1 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Wed, 9 Aug 2017 09:58:03 -0300 Subject: [PATCH] Adaptação da ferramenta Seleção para uso do Bootstrap --- classesphp/classe_temas.php | 23 ++++++++++++++--------- ferramentas/animacao/index.js | 6 +++++- ferramentas/filtro/index.js | 5 ----- ferramentas/selecao/dependencias.php | 23 +++++++++++++++++++++++ ferramentas/selecao/dicionario.js | 23 ++++------------------- ferramentas/selecao/index.js | 503 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ferramentas/selecao/template_linhafiltro_mst.html | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/selecao/template_mst.html | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ js/mapa.js | 8 +++++++- 9 files changed, 384 insertions(+), 381 deletions(-) create mode 100755 ferramentas/selecao/dependencias.php create mode 100755 ferramentas/selecao/template_linhafiltro_mst.html create mode 100755 ferramentas/selecao/template_mst.html diff --git a/classesphp/classe_temas.php b/classesphp/classe_temas.php index 16d6cf3..06c06fb 100755 --- a/classesphp/classe_temas.php +++ b/classesphp/classe_temas.php @@ -526,6 +526,7 @@ $testa - Testa o filtro e retorna uma imagem. return "erro"; } $layer->setmetadata("cache",""); + $layer->set("template","none.htm"); $fil = $layer->getFilterString(); $filtro = str_replace("|","'",$filtro); if ($layer->connectiontype == MS_POSTGIS){ @@ -541,18 +542,22 @@ $testa - Testa o filtro e retorna uma imagem. } else{ //testa o filtro - $teste = $layer->querybyattributes($items[0],$filtro,1); - if($teste != MS_SUCCESS){ - $teste = $this->layer->queryByAttributes($items[0], mb_convert_encoding($filtro,"ISO-8859-1","UTF-8"), 1); + if(mb_convert_encoding($filtro,"UTF-8","ISO-8859-1") != mb_convert_encoding($filtro,"ISO-8859-1","UTF-8")){ + $teste = $layer->querybyattributes($items[0],$filtro,1); if($teste != MS_SUCCESS){ - $teste = $this->layer->queryByAttributes($items[0], mb_convert_encoding($filtro,"UTF-8","ISO-8859-1"), 1); - $filtro = mb_convert_encoding($filtro,"UTF-8","ISO-8859-1"); + $teste = $this->layer->queryByAttributes($items[0], mb_convert_encoding($filtro,"ISO-8859-1","UTF-8"), 1); + if($teste != MS_SUCCESS){ + $teste = $this->layer->queryByAttributes($items[0], mb_convert_encoding($filtro,"UTF-8","ISO-8859-1"), 1); + $filtro = mb_convert_encoding($filtro,"UTF-8","ISO-8859-1"); + } + else{ + $filtro = mb_convert_encoding($filtro,"ISO-8859-1","UTF-8"); + } } - else{ - $filtro = mb_convert_encoding($filtro,"ISO-8859-1","UTF-8"); + if($teste == MS_SUCCESS){ + $layer->setfilter($filtro); } - } - if($teste == MS_SUCCESS){ + } else { $layer->setfilter($filtro); } } diff --git a/ferramentas/animacao/index.js b/ferramentas/animacao/index.js index d6c7aa6..68745a2 100755 --- a/ferramentas/animacao/index.js +++ b/ferramentas/animacao/index.js @@ -140,7 +140,11 @@ i3GEOF.animacao = { cabecalho, minimiza, "", - true + true, + "", + "", + "", + "" ); divid = janela[2].id; $i("i3GEOF.animacao_corpo").style.backgroundColor = "white"; diff --git a/ferramentas/filtro/index.js b/ferramentas/filtro/index.js index 6050bf0..186b777 100755 --- a/ferramentas/filtro/index.js +++ b/ferramentas/filtro/index.js @@ -193,11 +193,6 @@ i3GEOF.filtro = { i3GEOF.filtro.inicia(divid,modoCalculadora,idRetorno); }, - /* - Function: adicionaLinhaFiltro - - Adiciona uma nova linha de filtro - */ removeLinha : function(obj,id){ var linha = $i("linhaFiltro"+id); linha.parentNode.removeChild(linha); diff --git a/ferramentas/selecao/dependencias.php b/ferramentas/selecao/dependencias.php new file mode 100755 index 0000000..593ef1b --- /dev/null +++ b/ferramentas/selecao/dependencias.php @@ -0,0 +1,23 @@ + ou com a funcao scripttag do i3Geo + * Alem de carregar os scripts, carrega tambem o template no formato MUSTACHE, definindo a variavel + * javascript i3GEOF.animacao.MUSTACHE + * O template e substituido pelos valores definidos em index.js no momento da inicializacao da ferramenta + */ +if(extension_loaded('zlib')){ + ob_start('ob_gzhandler'); +} +header("Content-type: text/javascript"); +include("index.js"); +include("dicionario.js"); +echo "\n"; +if(extension_loaded('zlib')){ + ob_end_flush(); +} +?> \ No newline at end of file diff --git a/ferramentas/selecao/dicionario.js b/ferramentas/selecao/dicionario.js index 0542d06..2dfcb2b 100755 --- a/ferramentas/selecao/dicionario.js +++ b/ferramentas/selecao/dicionario.js @@ -170,28 +170,13 @@ i3GEOF.selecao.dicionario = { en : "", es : "" } ], - 35 : [ { - pt : "", + "fonte" : [ { + pt : "Escolha um ou mais temas que serão alvo da seleção", en : "", es : "" } ], - 36 : [ { - pt : "", - en : "", - es : "" - } ], - 37 : [ { - pt : "", - en : "", - es : "" - } ], - 38 : [ { - pt : "", - en : "", - es : "" - } ], - 39 : [ { - pt : "", + "opsel" : [ { + pt : "Opções de seleção. Clique no ícone para ativar.", en : "", es : "" } ] diff --git a/ferramentas/selecao/index.js b/ferramentas/selecao/index.js index 8c6b350..68829e7 100755 --- a/ferramentas/selecao/index.js +++ b/ferramentas/selecao/index.js @@ -50,28 +50,26 @@ i3GEOF.selecao = * Estilo do objeto DOM com a imagem de aguarde existente no cabeçalho da janela. */ aguarde : "", - /* - * Para efeitos de compatibilidade antes da versão 4.7 que não tinha dicionário + comboTemas: "", + /** + * Template no formato mustache. E preenchido na carga do javascript com o programa dependencias.php */ - criaJanelaFlutuante : function() { - i3GEOF.selecao.iniciaDicionario(); - }, - /* - * Function: iniciaDicionario - * - * Carrega o dicionário e chama a função que inicia a ferramenta - * - * O Javascript é carregado com o id i3GEOF.nomedaferramenta.dicionario_script + MUSTACHE : "", + MUSTACHELINHAFILTRO: "", + /** + * Susbtitutos para o template */ - iniciaDicionario : function() { - if (typeof (i3GEOF.selecao.dicionario) === 'undefined') { - i3GEO.util.scriptTag( - i3GEO.configura.locaplic + "/ferramentas/selecao/dicionario.js", - "i3GEOF.selecao.iniciaJanelaFlutuante()", - "i3GEOF.selecao.dicionario_script"); - } else { - i3GEOF.selecao.iniciaJanelaFlutuante(); + mustacheHash : function() { + var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.selecao.dicionario); + dicionario["locaplic"] = i3GEO.configura.locaplic; + if (i3GEO.Interface.ATUAL === "openlayers"){ + dicionario["i3GEOselecaoboxHidden"] = "hidden"; } + else { + dicionario["i3GEOselecaoboxHidden"] = ""; + } + dicionario["p8"] = $trad("p8"); + return dicionario; }, /* * Function: inicia @@ -83,8 +81,21 @@ i3GEOF.selecao = * iddiv {String} - id do div que receberá o conteudo HTML da ferramenta */ inicia : function(iddiv) { + var t1 = i3GEO.configura.locaplic + "/ferramentas/selecao/template_mst.html", + t2 = i3GEO.configura.locaplic + "/ferramentas/selecao/template_linhafiltro_mst.html"; + if(i3GEOF.selecao.MUSTACHE == ""){ + $.when( $.get(t1),$.get(t2) ).done(function(r1,r2) { + i3GEOF.selecao.MUSTACHE = r1[0]; + i3GEOF.selecao.MUSTACHELINHAFILTRO = r2[0]; + i3GEOF.selecao.inicia(iddiv); + }).fail(function() { + i3GEO.janela.closeMsg($trad("erroTpl")); + return; + }); + return; + } var b, i, n, ics; - try { + $i(iddiv).innerHTML += i3GEOF.selecao.html(); i3GEO.guias.mostraGuiaFerramenta("i3GEOselecaoguia1", "i3GEOselecaoguia"); // eventos das guias @@ -106,49 +117,45 @@ i3GEOF.selecao = $i("i3GEOselecaoparametros").innerHTML = ""; } catch (e) { } - i3GEOF.selecao.adicionaLinhaFiltro(); + // + //pega a lista de itens e chama a função de montagem das opções de criação do filtro + // + var tema = i3GEOF.selecao.pegaTemasSel(); + tema = tema[1][0]; + i3GEO.util.comboItens( + "", + tema, + function(retorno){ + i3GEOF.selecao.comboTemas = retorno.dados; + i3GEOF.selecao.adicionaLinhaFiltro(); + }, + "", + "coluna", + "", + "", + "form-control" + ); } }; $i("i3GEOselecaoguia3").onclick = function() { i3GEO.guias.mostraGuiaFerramenta("i3GEOselecaoguia3", "i3GEOselecaoguia"); - i3GEO.util.comboTemas("i3GEOselecaoTemaoverlay", function(retorno) { - $i("i3GEOselecaooverlay").innerHTML = retorno.dados; - }, "i3GEOselecaooverlay", "", false, "naolinearSelecionados", "display:block"); + i3GEO.util.comboTemas( + "i3GEOselecaoTemaoverlay", + function(retorno) { + $i("i3GEOselecaooverlay").innerHTML = retorno.dados; + }, + "i3GEOselecaooverlay", + "", + false, + "naolinearSelecionados", + "", + "", + "", + "form-control" + ); }; i3GEOF.selecao.criaCombosTemas(); - - i3GEO.util.mensagemAjuda("i3GEOselecaomen1", $i("i3GEOselecaomen1").innerHTML); - i3GEO.util.mensagemAjuda("i3GEOselecaomen2", $i("i3GEOselecaomen2").innerHTML); - b = new YAHOO.widget.Button("i3GEOselecaobotao1", { - onclick : { - fn : i3GEOF.selecao.atributo - } - }); - b.addClass("rodar"); - b = new YAHOO.widget.Button("i3GEOselecaobotao2", { - onclick : { - fn : i3GEOF.selecao.aplicaselecaoTema - } - }); - b.addClass("rodar"); - - b = new YAHOO.widget.Button("i3GEOFSelecaoQuery", { - onclick : { - fn : i3GEO.mapa.dialogo.queryMap - } - }); - b.addClass("abrir"); - i3GEOF.selecao.ativaFoco(); - ics = $i("i3GEOselecaoguia1obj").getElementsByTagName("button"); - n = ics.length; - for (i = 0; i < n; i++) { - ics[i].style.backgroundColor = "white"; - ics[i].className = "iconeGuiaMovel"; - } - } catch (erro) { - i3GEO.janela.tempoMsg(erro); - } }, /* * Function: html @@ -160,162 +167,7 @@ i3GEOF.selecao = * String com o código html */ html : function() { - var ins = - '' + '
' - + ' ' - + '

' - + '' - + '' - + '' - + ' ' - + ''; + var ins = Mustache.render(i3GEOF.selecao.MUSTACHE, i3GEOF.selecao.mustacheHash()); return ins; }, /* @@ -340,7 +192,25 @@ i3GEOF.selecao = + "" + $trad("x51") + ""; - janela = i3GEO.janela.cria("510px", "230px", "", "", "", titulo, "i3GEOF.selecao", false, "hd", cabecalho, minimiza); + janela = i3GEO.janela.cria( + "510px", + "230px", + "", + "", + "", + titulo, + "i3GEOF.selecao", + false, + "hd", + cabecalho, + minimiza, + "", + true, + "", + "", + "", + "" + ); divid = janela[2].id; i3GEOF.selecao.aguarde = $i("i3GEOF.selecao_imagemCabecalho").style; $i("i3GEOF.selecao_corpo").style.backgroundColor = "white"; @@ -359,7 +229,7 @@ i3GEOF.selecao = if(i3GEO.Interface["ATUAL"] === "openlayers"){ if (typeof OpenLayers.Control == "undefined") { api = "ol3"; - i3GEO.Interface.openlayers.interacoes[0].setActive(true);//duplo clique + //i3GEO.Interface.openlayers.interacoes[0].setActive(true);//duplo clique } else { api = "openlayers"; } @@ -395,25 +265,36 @@ i3GEOF.selecao = * Cria os combos de seleção de temas */ criaCombosTemas : function() { - i3GEO.util.comboTemas("i3GEOselecaotemasLigados", function(retorno) { - var nsel, temp; - temp = $i("i3GEOselecaoComboTemas"); - if (!temp) { - return; - } - temp.innerHTML = retorno.dados; - if ($i("i3GEOselecaotemasLigados")) { - $i("i3GEOselecaotemasLigados").value = i3GEO.temaAtivo; - // verifica qts elementos selecionados - if (i3GEO.temaAtivo != "") { - nsel = i3GEO.arvoreDeCamadas.pegaTema(i3GEO.temaAtivo); - $i("i3GEOselecaoNsel").innerHTML = $trad('selecionados', i3GEOF.selecao.dicionario) + ": " + (nsel.nsel) + "
"; - } - $i("i3GEOselecaotemasLigados").onchange = function() { - i3GEOF.selecao.pegaTemasSel(); - }; - } - }, "i3GEOselecaoComboTemas", "", true, "ligados", "width:440px;font-size:12px"); + i3GEO.util.comboTemas( + "i3GEOselecaotemasLigados", + function(retorno) { + var nsel, temp; + temp = $i("i3GEOselecaoComboTemas"); + if (!temp) { + return; + } + temp.innerHTML = retorno.dados; + if ($i("i3GEOselecaotemasLigados")) { + $i("i3GEOselecaotemasLigados").value = i3GEO.temaAtivo; + // verifica qts elementos selecionados + if (i3GEO.temaAtivo != "") { + nsel = i3GEO.arvoreDeCamadas.pegaTema(i3GEO.temaAtivo); + $i("i3GEOselecaoNsel").innerHTML = $trad('selecionados', i3GEOF.selecao.dicionario) + ": " + (nsel.nsel) + "
"; + } + $i("i3GEOselecaotemasLigados").onchange = function() { + i3GEOF.selecao.pegaTemasSel(); + }; + } + }, + "i3GEOselecaoComboTemas", + "", + true, + "ligados", + "", + "", + "", + "form-control" + ); }, /* * Function: mudaicone @@ -442,7 +323,7 @@ i3GEOF.selecao = $i("i3GEOselecaoNsel").innerHTML = $trad('selecionados', i3GEOF.selecao.dicionario) + ": " + (nsel.nsel) + "
"; } } - return selectedArray.toString(); + return [selectedArray.toString(),selectedArray]; }, /* * Function: fimSelecao @@ -519,6 +400,8 @@ i3GEOF.selecao = var api, fim = function(retorno) { i3GEOF.selecao.fimSelecao(retorno); }, tema = i3GEOF.selecao.pegaTemasSel(); + tema = tema[0]; + if (i3GEO.Interface["ATUAL"] === "openlayers") { if (typeof OpenLayers.Control == "undefined") { api = "ol3"; @@ -535,25 +418,25 @@ i3GEOF.selecao = } if (obj.value == "i3GEOselecaobox") { i3GEOF.selecao.tipoSel = obj.value; - obj.style.backgroundColor = "#cedff2"; + i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); i3GEOF.selecao.box[api].inicia(); } if (obj.value == "i3GEOselecaopt") { i3GEOF.selecao.tipoSel = obj.value; - obj.style.backgroundColor = "#cedff2"; + i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); i3GEOF.selecao.clique[api].inicia(); } if (obj.value == "i3GEOselecaopoli") { i3GEOF.selecao.tipoSel = obj.value; - obj.style.backgroundColor = "#cedff2"; + i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); i3GEOF.selecao.poligono[api].inicia(); } if (obj.value == "i3GEOselecaofigura") { i3GEOF.selecao.tipoSel = obj.value; - obj.style.backgroundColor = "#cedff2"; + i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); i3GEOF.selecao.figura[api].inicia(); } @@ -1200,120 +1083,48 @@ i3GEOF.selecao = i3GEOF.selecao.aguarde.visibility = "hidden"; } }, + removeLinha : function(obj,id){ + var linha = $i("linhaFiltro"+id); + linha.parentNode.removeChild(linha); + }, + listaValores: function(id){ + var itemTema = $("#linhaFiltro" + id + " [name='coluna']").val(); + i3GEO.util.comboValoresItem( + "i3GEOselecaocbitens", + i3GEOF.selecao.tema, + itemTema, + function(retorno){ + $i("i3GEOselecaovalores").innerHTML = "" + + retorno.dados; + if ($i("i3GEOselecaocbitens")){ + $i("i3GEOselecaocbitens").onchange = function() { + $("#linhaFiltro" + id + " [name='valor']").val(this.value); + }; + } + }, + "i3GEOselecaovalores", + "form-control" + ); + }, /* * Function: adicionaLinhaFiltro * * Adiciona uma nova linha de filtro */ adicionaLinhaFiltro : function() { - var add, xis, interrogacao, operador, conector, valor, ntr, ntad, ntd, ntd1, ntd2, ntd3, ntd4, ntd5, tabela; - try { - add = document.createElement("img"); - add.src = i3GEO.configura.locaplic + '/imagens/oxygen/16x16/list-add.png'; - add.style.cursor = "pointer"; - add.onclick = function() { - i3GEOF.selecao.adicionaLinhaFiltro(); - }; - - xis = document.createElement("img"); - xis.src = i3GEO.configura.locaplic + '/imagens/oxygen/16x16/edit-delete.png'; - xis.style.cursor = "pointer"; - xis.onclick = function() { - var p = this.parentNode.parentNode.parentNode, i; - for (i = 0; i < p.childNodes.length; i++) { - p.removeChild(p.childNodes[i]); - } - }; - interrogacao = document.createElement("img"); - interrogacao.src = i3GEO.configura.locaplic + '/imagens/oxygen/16x16/format-line-spacing-normal.png'; - interrogacao.title = 'mostra valores'; - interrogacao.style.cursor = "pointer"; - interrogacao.style.margin = "5px"; - interrogacao.onclick = - function() { - var obj = (this.parentNode.parentNode.getElementsByTagName("input"))[0], itemTema = - (this.parentNode.parentNode.getElementsByTagName("select"))[0].value; - i3GEO.util.comboValoresItem("i3GEOselecaocbitens", i3GEO.temaAtivo, itemTema, function(retorno) { - $i("i3GEOselecaovalores").innerHTML = - "

" + $trad('selecionaValor', i3GEOF.selecao.dicionario) - + ":

" - + "
" - + retorno.dados - + "
"; - if ($i("i3GEOselecaocbitens")) { - $i("i3GEOselecaocbitens").onchange = function() { - obj.value = this.value; - }; - } - }, "i3GEOselecaovalores", "display:block"); - }; - operador = "
"; - - conector = "
"; - - valor = document.createElement("div"); - valor.className = 'i3geoForm100 i3geoFormIconeEdita'; - valor.style.marginLeft = "5px"; - valor.innerHTML = ""; - - ntr = document.createElement("tr"); - ntad = document.createElement("td"); - ntad.appendChild(add); - ntr.appendChild(ntad); - - ntd = document.createElement("td"); - ntd.appendChild(xis); - ntr.appendChild(ntd); - - ntd1 = document.createElement("td"); - i3GEO.util.comboItens("i3GEOselecaoItensAtrib", i3GEO.temaAtivo, function(retorno) { - ntd1.innerHTML = "
" + retorno.dados + "
"; - $i("i3GEOselecaoItensAtrib").onchange = function() { - $i("i3GEOselecaovalores").innerHTML = ""; - }; - }); - ntr.appendChild(ntd1); - - ntd2 = document.createElement("td"); - ntd2.innerHTML = operador; - ntr.appendChild(ntd2); - - ntd3 = document.createElement("td"); - ntd3.appendChild(valor); - ntr.appendChild(ntd3); - - ntd4 = document.createElement("td"); - ntd4.appendChild(interrogacao); - ntr.appendChild(ntd4); - - ntd5 = document.createElement("td"); - ntd5.innerHTML = conector; - ntr.appendChild(ntd5); - - // ntb = document.createElement("tbody"); - // ntb.appendChild(ntr); - if (navm) { - tabela = $i("i3GEOselecaoparametros").getElementsByTagName("tbody")[0]; - } else { - tabela = $i("i3GEOselecaoparametros"); - } - tabela.appendChild(ntr); - } catch (e) { - i3GEO.janela.tempoMsg("Erro: " + e); - } + i3GEOF.selecao.CONTADOR++; + var temp,ntr,tabela; + ntr = document.createElement("tr"); + ntr.id = "linhaFiltro"+i3GEOF.selecao.CONTADOR; + temp = Mustache.render( + "{{#data}}" + i3GEOF.selecao.MUSTACHELINHAFILTRO + "{{/data}}", + {"data":{"comboTemas": i3GEOF.selecao.comboTemas,"contador": i3GEOF.selecao.CONTADOR, "escondeGuias": i3GEOF.selecao.dicionario["escondeGuias"]}} + ); + $(ntr).html(temp); + tabela = $i("i3GEOselecaoparametros"); + tabela.appendChild(ntr); }, /* * Function: atributo diff --git a/ferramentas/selecao/template_linhafiltro_mst.html b/ferramentas/selecao/template_linhafiltro_mst.html new file mode 100755 index 0000000..1a30352 --- /dev/null +++ b/ferramentas/selecao/template_linhafiltro_mst.html @@ -0,0 +1,48 @@ + + + + + + + +
{{{comboTemas}}}
+ + +
+ +
+ + +
+ +
+ + + + + +
+ +
+ diff --git a/ferramentas/selecao/template_mst.html b/ferramentas/selecao/template_mst.html new file mode 100755 index 0000000..6896e90 --- /dev/null +++ b/ferramentas/selecao/template_mst.html @@ -0,0 +1,126 @@ +
+ +
+
+
+ +
+
+ + +
+ +
{{{ajuda}}}
+
+
+ +
+ + + + + + + + + + +
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+ + + +
+ + + + + + + + + + +
{{{item}}}{{{operador}}}{{{valor}}} {{{conector}}}
+
+
+
+ {{{separaComVirgula}}} +
+
+
+
+ {{{temaSelecaoMapa}}} +
+
+ + + +
diff --git a/js/mapa.js b/js/mapa.js index 30342d5..188b925 100755 --- a/js/mapa.js +++ b/js/mapa.js @@ -888,7 +888,13 @@ i3GEO.mapa = * Abre a janela de dialogo da ferramenta selecao */ selecao : function() { - i3GEO.util.dialogoFerramenta("i3GEO.mapa.dialogo.selecao()", "selecao", "selecao"); + i3GEO.util.dialogoFerramenta( + "i3GEO.mapa.dialogo.selecao()", + "selecao", + "selecao", + "dependencias.php", + "i3GEOF.selecao.iniciaJanelaFlutuante()" + ); }, /** * Function: cliquePonto -- libgit2 0.21.2