Commit 58c46468d67b0b12290eee5a4fea3f97d5c93114
1 parent
005d2fd1
Exists in
master
and in
7 other branches
Inclusão de opção para remover temas órfãos no sistema de admnistração (temas qu…
…e não possuem mapfile)
Showing
10 changed files
with
137 additions
and
65 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/html/editormapfile.html
... | ... | @@ -40,10 +40,13 @@ |
40 | 40 | arquivo i3geo/ms_configura.php |
41 | 41 | <p>Apenas os mapfiles que forem vinculados a um tema poderão ser vistos na janela de inclusão de temas na árvore de temas. |
42 | 42 | Se você criou um mapfile manualmente, utilize a opção de edição (ícone apresentado ao lado de cada mapfile) para fazer essa associação. |
43 | + <p>A opção "Verifica temas sem mapfiles" possibilita resolver problemas decorrentes da eliminação manual de um arquivo mapfile do servidor. | |
44 | + Nesses casos, o registro no banco de dados permanece. Com essa opção é possível apagar os registros ou recriar o mapfile perdido. | |
43 | 45 | </div> |
44 | 46 | <div class="ft"></div> |
45 | 47 | </div> |
46 | 48 | <input onclick="adicionaLinha()" type=button id=adiciona value="Criar um novo mapfile" /> |
49 | +<input onclick="adicionaLinha()" type=button id=semmapfiles value="Verificar temas sem mapfiles" /> | |
47 | 50 | <br><br> |
48 | 51 | Além de criar os mapfiles, é necessário definir as características de cada LAYER nas opções abaixo. |
49 | 52 | <br> | ... | ... |
admin/js/core.js
... | ... | @@ -69,7 +69,7 @@ function cabecalhoGeral(id,excluir){ |
69 | 69 | var i,n,temp, |
70 | 70 | ins = "<fieldset><legend>Opções principais</legend>", |
71 | 71 | botoes = [ |
72 | - {id:"principal",titulo:"Principal",link:"../index.html"}, | |
72 | + {id:"principal",titulo:"Início",link:"../index.html"}, | |
73 | 73 | {id:"menus",titulo:"Menus",link:"menus.html"}, |
74 | 74 | {id:"arvore",titulo:"Árvore de temas",link:"arvore.html"}, |
75 | 75 | {id:"editormapfile",titulo:"Mapfiles",link:"editormapfile.html"}, |
... | ... | @@ -248,6 +248,8 @@ function core_carregando(tipo) |
248 | 248 | YAHOO.example.container.wait.setBody("<img src=\"../../imagens/aguarde.gif\"/>"); |
249 | 249 | YAHOO.example.container.wait.render(document.body); |
250 | 250 | } |
251 | + else | |
252 | + {YAHOO.example.container.wait.show();} | |
251 | 253 | YAHOO.example.container.wait.setBody("<img src=\"../../imagens/aguarde.gif\"/>"); |
252 | 254 | if(tipo == "ativa") |
253 | 255 | {YAHOO.example.container.wait.show();} |
... | ... | @@ -1018,14 +1020,13 @@ function core_pegaDados(mensagem,sUrl,funcaoRetorno) |
1018 | 1020 | try |
1019 | 1021 | { |
1020 | 1022 | if(funcaoRetorno != "") |
1021 | - eval(funcaoRetorno+"(YAHOO.lang.JSON.parse(o.responseText))"); | |
1022 | - else | |
1023 | + {eval(funcaoRetorno+"(YAHOO.lang.JSON.parse(o.responseText))");} | |
1023 | 1024 | core_carregando("desativa"); |
1024 | 1025 | } |
1025 | 1026 | catch(e) |
1026 | 1027 | { |
1027 | 1028 | if("mensagem" != "") |
1028 | - core_carregando("desativa"); | |
1029 | + {core_carregando("desativa");} | |
1029 | 1030 | core_handleFailure(o,o.responseText); |
1030 | 1031 | } |
1031 | 1032 | }, |
... | ... | @@ -1176,9 +1177,11 @@ function core_excluiNoTree(sUrl,no,mensagem) |
1176 | 1177 | } |
1177 | 1178 | else |
1178 | 1179 | { |
1179 | - tree.removeNode(no); | |
1180 | - tree.draw(); | |
1181 | - core_carregando("desativa"); | |
1180 | + if(no){ | |
1181 | + tree.removeNode(no); | |
1182 | + tree.draw(); | |
1183 | + } | |
1184 | + core_carregando("desativa"); | |
1182 | 1185 | } |
1183 | 1186 | } |
1184 | 1187 | catch(e){core_handleFailure(o,o.responseText);} |
... | ... | @@ -1222,7 +1225,7 @@ function core_montaEditor(funcaoOK,w,h,funcaoClose) |
1222 | 1225 | var w = "400px"; |
1223 | 1226 | var h = w; |
1224 | 1227 | } |
1225 | - if(!YAHOO.example.container.panelEditor) | |
1228 | + if(!$i("janela_editor")) | |
1226 | 1229 | { |
1227 | 1230 | var novoel = document.createElement("div"); |
1228 | 1231 | novoel.id = "janela_editor"; |
... | ... | @@ -1256,7 +1259,7 @@ function core_montaEditor(funcaoOK,w,h,funcaoClose) |
1256 | 1259 | else |
1257 | 1260 | { |
1258 | 1261 | if($i("editor_bd")) |
1259 | - $i("editor_bd").innerHTML == "" | |
1262 | + {$i("editor_bd").innerHTML == "";} | |
1260 | 1263 | } |
1261 | 1264 | var fecha = function() |
1262 | 1265 | { | ... | ... |
admin/js/editormapfile.js
... | ... | @@ -140,12 +140,23 @@ Inicializa a árvore de edição |
140 | 140 | */ |
141 | 141 | function initMenu() |
142 | 142 | { |
143 | - ativaBotaoAdicionaMapfile("adiciona") | |
143 | + ativaBotaoAdicionaMapfile("adiciona"); | |
144 | + ativaBotaoVerificarOrfaos("semmapfiles"); | |
145 | + | |
144 | 146 | core_carregando("ativa"); |
145 | 147 | core_carregando("buscando temas..."); |
146 | 148 | core_ativaPainelAjuda("ajuda","botaoAjuda"); |
147 | 149 | core_pegaMapfiles("montaArvore()") |
148 | 150 | } |
151 | +function ativaBotaoVerificarOrfaos(idBotao) | |
152 | +{ | |
153 | + var temp = function(){ | |
154 | + core_montaEditor("","450px","660px"); | |
155 | + verificaOrfaos(); | |
156 | + }; | |
157 | + //cria o botão de adição de um novo menu | |
158 | + var verifica = new YAHOO.widget.Button(idBotao,{ onclick: { fn: temp } }); | |
159 | +} | |
149 | 160 | function ativaBotaoAdicionaMapfile(idBotao) |
150 | 161 | { |
151 | 162 | var adiciona = function() |
... | ... | @@ -518,6 +529,58 @@ function editorDeTexto(codigoMap) |
518 | 529 | core_makeRequest(sUrl,callback) |
519 | 530 | } |
520 | 531 | /* |
532 | +Function: verificaOrfaos | |
533 | + | |
534 | +Verifica se existem temas cadastrados no banco de dados e que não possuem mapfile associado. | |
535 | + | |
536 | +É mostrada ujma lista dos casos e opção para apagar o registro do banco ou criar novamente o mapfile | |
537 | + | |
538 | +<VERIFICAORFAOS> | |
539 | +*/ | |
540 | +function verificaOrfaos() | |
541 | +{ | |
542 | + sUrl = "../php/menutemas.php?funcao=verificaOrfaos"; | |
543 | + core_carregando("ativa"); | |
544 | + core_carregando(" verificando"); | |
545 | + | |
546 | + var callback = | |
547 | + { | |
548 | + success:function(o) | |
549 | + { | |
550 | + try | |
551 | + { | |
552 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
553 | + { | |
554 | + core_carregando("<span style=color:red >Erro</span>"); | |
555 | + setTimeout("core_carregando('desativa')",3000) | |
556 | + } | |
557 | + else | |
558 | + { | |
559 | + core_carregando("desativa"); | |
560 | + var ins = "<p>Os temas listados a seguir não possuem mapfiles criados. Você pode excluir o registro do tema (remoção do banco de dados) clicando na opção 'excluir' ou criar o mapfile na opção existente no formulário principal.", | |
561 | + d = YAHOO.lang.JSON.parse(o.responseText), | |
562 | + n = d.length, | |
563 | + i,ima; | |
564 | + for(i=0;i<n;i++){ | |
565 | + ima = '<img src="../imagens/01.png" title="excluir" onclick="excluirOrfao(\''+d[i].codigo_tema+'\')" style="position:relative;cursor:pointer;top:4px;left:-2px">'; | |
566 | + ins += "<p>"+ima+d[i].nome_tema+" <span style=color:gray >"+d[i].codigo_tema+" id: "+d[i].id_tema+"</span>"; | |
567 | + } | |
568 | + $i("editor_bd").innerHTML = ins; | |
569 | + } | |
570 | + } | |
571 | + catch(e){core_handleFailure(e,o.responseText);} | |
572 | + }, | |
573 | + failure:core_handleFailure, | |
574 | + argument: { foo:"foo", bar:"bar" } | |
575 | + }; | |
576 | + core_makeRequest(sUrl,callback) | |
577 | +} | |
578 | +function excluirOrfao(codigo_tema){ | |
579 | + excluirMapfile(codigo_tema); | |
580 | + YAHOO.example.container.panelEditor.destroy(); | |
581 | + YAHOO.example.container.panelEditor = null; | |
582 | +} | |
583 | +/* | |
521 | 584 | Function: adicionaNovoMapfile |
522 | 585 | |
523 | 586 | Adiciona um novo mapfile |
... | ... | @@ -701,7 +764,7 @@ function classesAuto(codigoMap,codigoLayer) |
701 | 764 | if(!YAHOO.example.container.panelEditorAutoClasses) |
702 | 765 | { |
703 | 766 | var novoel = document.createElement("div"); |
704 | - novoel.id = "janela_editor"; | |
767 | + novoel.id = "janela_editor_auto"; | |
705 | 768 | var ins = '<div class="hd">Editor</div>'; |
706 | 769 | ins += "<div class='bd' style='height:354px;overflow:auto'>"; |
707 | 770 | ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>"; |
... | ... | @@ -713,7 +776,7 @@ function classesAuto(codigoMap,codigoLayer) |
713 | 776 | { label: "Cancela", value: "CANCEL", checked: false } |
714 | 777 | ]); |
715 | 778 | editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); |
716 | - YAHOO.example.container.panelEditorAutoClasses = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:true,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
779 | + YAHOO.example.container.panelEditorAutoClasses = new YAHOO.widget.Panel("janela_editor_auto", { fixedcenter:true,close:true,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
717 | 780 | YAHOO.example.container.panelEditorAutoClasses.render(); |
718 | 781 | var sUrl = "../php/editormapfile.php?funcao=pegaItensLayer&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer; |
719 | 782 | var callback = |
... | ... | @@ -831,7 +894,7 @@ function excluirMapfile(codigoMap) |
831 | 894 | var mensagem = " excluindo "+codigoMap; |
832 | 895 | var no = tree.getNodeByProperty("id",codigoMap) |
833 | 896 | var sUrl = "../php/editormapfile.php?funcao=excluirMapfile&codigoMap="+codigoMap; |
834 | - core_excluiNoTree(sUrl,no,mensagem) | |
897 | + core_excluiNoTree(sUrl,no,mensagem) | |
835 | 898 | } |
836 | 899 | /* |
837 | 900 | Function: clonarMapfile | ... | ... |
admin/js/listatemas.js
... | ... | @@ -24,7 +24,7 @@ function montaEditorTema(dados) |
24 | 24 | if(!YAHOO.example.container.panelEditorTema) |
25 | 25 | { |
26 | 26 | var novoel = document.createElement("div"); |
27 | - novoel.id = "janela_editor"; | |
27 | + novoel.id = "janela_editor_tema"; | |
28 | 28 | var ins = '<div class="hd">Editor</div>'; |
29 | 29 | ins += "<div class='bd' style='height:354px;overflow:auto'>"; |
30 | 30 | ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>"; |
... | ... | @@ -36,7 +36,7 @@ function montaEditorTema(dados) |
36 | 36 | { label: "Cancela", value: "CANCEL", checked: false } |
37 | 37 | ]); |
38 | 38 | editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); |
39 | - YAHOO.example.container.panelEditorTema = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:true,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
39 | + YAHOO.example.container.panelEditorTema = new YAHOO.widget.Panel("janela_editor_tema", { fixedcenter:true,close:true,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
40 | 40 | YAHOO.example.container.panelEditorTema.render(); |
41 | 41 | var fecha = function() |
42 | 42 | { | ... | ... |
admin/php/editormapfile.php
... | ... | @@ -304,6 +304,7 @@ switch (strtoupper($funcao)) |
304 | 304 | retornaJSON(excluirLayer()); |
305 | 305 | exit; |
306 | 306 | break; |
307 | + | |
307 | 308 | /* |
308 | 309 | Valor: LISTACLASSES |
309 | 310 | |
... | ... | @@ -1312,6 +1313,7 @@ function alterarConexao() |
1312 | 1313 | function pegaMetadados() |
1313 | 1314 | { |
1314 | 1315 | global $codigoMap,$codigoLayer,$locaplic,$postgis_mapa; |
1316 | + //error_reporting(E_ALL); | |
1315 | 1317 | $dados = array(); |
1316 | 1318 | $mapfile = $locaplic."/temas/".$codigoMap.".map"; |
1317 | 1319 | $mapa = ms_newMapObj($mapfile); |
... | ... | @@ -1361,7 +1363,7 @@ function pegaMetadados() |
1361 | 1363 | $dados["permitecomentario"] = $layer->getmetadata("permitecomentario"); |
1362 | 1364 | $dados["itembuscarapida"] = $layer->getmetadata("itembuscarapida"); |
1363 | 1365 | $dados["legendaimg"] = $layer->getmetadata("legendaimg"); |
1364 | - if($layer->connectiontype == 7 || $layer->connectiontype== 9){ | |
1366 | + if($layer->connectiontype == 7 || $layer->connectiontype == 9){ | |
1365 | 1367 | $dados["wms_srs"] = $layer->getmetadata("wms_srs"); |
1366 | 1368 | $dados["wms_name"] = $layer->getmetadata("wms_name"); |
1367 | 1369 | $dados["wms_server_version"] = $layer->getmetadata("wms_server_version"); | ... | ... |
admin/php/menutemas.php
... | ... | @@ -558,6 +558,19 @@ switch (strtoupper($funcao)) |
558 | 558 | retornaJSON(listaMapsTemas()); |
559 | 559 | exit; |
560 | 560 | break; |
561 | + /* | |
562 | + Valor: VERIFICAORFAOS | |
563 | + | |
564 | + Verifica se existem temas sem o correspondente mapfile | |
565 | + | |
566 | + Retorno: | |
567 | + | |
568 | + {JSON} | |
569 | + */ | |
570 | + case "VERIFICAORFAOS": | |
571 | + retornaJSON(verificaOrfaos()); | |
572 | + exit; | |
573 | + break; | |
561 | 574 | } |
562 | 575 | function excluiPerfil($id) |
563 | 576 | { |
... | ... | @@ -1131,7 +1144,31 @@ function listaMapsTemas() |
1131 | 1144 | } |
1132 | 1145 | return $lista; |
1133 | 1146 | } |
1147 | +/* | |
1148 | +Retorna a lista de temas sem mapfiles | |
1134 | 1149 | |
1150 | +*/ | |
1151 | +function verificaOrfaos() | |
1152 | +{ | |
1153 | + global $cp,$locaplic; | |
1154 | + $arquivos = array(); | |
1155 | + // | |
1156 | + //pega o nome de cada tema | |
1157 | + // | |
1158 | + $sql = "select nome_tema,codigo_tema,id_tema from i3geoadmin_temas "; | |
1159 | + $dbh = ""; | |
1160 | + include($locaplic."/admin/php/conexao.php"); | |
1161 | + $q = $dbh->query($sql,PDO::FETCH_ASSOC); | |
1162 | + $regs = $q->fetchAll(); | |
1163 | + $nomes = array(); | |
1164 | + foreach($regs as $reg){ | |
1165 | + if(!file_exists($locaplic."/temas/".$reg["codigo_tema"].".map") && !file_exists($locaplic."/temas/".$reg["codigo_tema"].".php")){ | |
1166 | + $nomes[] = array("nome_tema"=>$reg["nome_tema"],"codigo_tema"=>$reg["codigo_tema"],"id_tema"=>$reg["id_tema"]); | |
1167 | + } | |
1168 | + } | |
1169 | + sort($nomes); | |
1170 | + return $nomes; | |
1171 | +} | |
1135 | 1172 | function removeCabecalho($arq,$symbolset=true) |
1136 | 1173 | { |
1137 | 1174 | $handle = fopen($arq, "r"); | ... | ... |
classesphp/funcoes_gerais.php
... | ... | @@ -1356,6 +1356,8 @@ function pegaItens($layer,$mapa="") |
1356 | 1356 | $url = $url."&SERVICE=wfs&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=".$layer->getmetadata("wms_name"); |
1357 | 1357 | //$url = "http://ogi.state.ok.us/geoserver/wfs?VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=okcounties"; |
1358 | 1358 | $xml = simplexml_load_file($url); |
1359 | + if($xml == false) | |
1360 | + {return array();} | |
1359 | 1361 | $dom = new DOMDocument(); |
1360 | 1362 | $dom->loadXML($xml->asxml()); |
1361 | 1363 | $items = array(); | ... | ... |
temas/biomashp.map
... | ... | @@ -6,30 +6,30 @@ MAP |
6 | 6 | DATA "c:\ms4w\apache\htdocs\i3geo\aplicmap\dados\biomas.shp" |
7 | 7 | GROUP "Grupo 1" |
8 | 8 | METADATA |
9 | - "cache" "" | |
10 | 9 | "ltempoitemimagem" "" |
11 | - "ltempoitemdescricao" "" | |
10 | + "cache" "" | |
12 | 11 | "CLASSE" "SIM" |
13 | - "ltempoiteminicio" "" | |
12 | + "ltempoitemdescricao" "" | |
14 | 13 | "palletestep" "" |
15 | - "ltempoitemtip" "" | |
14 | + "ltempoiteminicio" "" | |
16 | 15 | "permitekmz" "sim" |
17 | - "ltempoitemtitulo" "" | |
18 | - "description_template" "" | |
16 | + "ltempoitemtip" "" | |
19 | 17 | "iconetema" "http://www.gpsdrive.de/development/map-icons/square.small/leisure/park.png" |
18 | + "description_template" "" | |
19 | + "ltempoitemtitulo" "" | |
20 | 20 | "ltempoitemlink" "" |
21 | - "extensao" "-44 -23 -39 -21" | |
22 | 21 | "palletefile" "" |
23 | - "ltempoformatodata" "" | |
22 | + "extensao" "-44 -23 -39 -21" | |
24 | 23 | "permitedownload" "sim" |
24 | + "ltempoformatodata" "" | |
25 | 25 | "ltempoitemicone" "" |
26 | 26 | "download" "SIM" |
27 | - "permiteogc" "" | |
28 | 27 | "permitekml" "sim" |
28 | + "permiteogc" "" | |
29 | 29 | "TEMA" "biomashp" |
30 | - "aplicaextensao" "SIM" | |
31 | - "editorsql" "" | |
32 | 30 | "identifica" "NAO" |
31 | + "editorsql" "" | |
32 | + "aplicaextensao" "SIM" | |
33 | 33 | "ltempoitemfim" "" |
34 | 34 | END |
35 | 35 | NAME "biomashp" |
... | ... | @@ -44,7 +44,6 @@ MAP |
44 | 44 | STYLE |
45 | 45 | ANGLE 360 |
46 | 46 | COLOR 21 44 114 |
47 | - SYMBOL 0 | |
48 | 47 | WIDTH 1 |
49 | 48 | END |
50 | 49 | END | ... | ... |
temas/geopr_aneel_linhas.map
... | ... | @@ -1,37 +0,0 @@ |
1 | -MAP | |
2 | - FONTSET "../symbols/fontes.txt" | |
3 | - SYMBOLSET "../symbols/simbolos.sym" | |
4 | - LAYER | |
5 | - CONNECTION "http://sigel.aneel.gov.br/wmsconnector/com.esri.wms.Esrimap/gsiwms?" | |
6 | - CONNECTIONTYPE WMS | |
7 | - DATA "" | |
8 | - METADATA | |
9 | - "wms_srs" "EPSG:4326" | |
10 | - "wms_exceptions_format" "application/vnd.ogc.se_xml" | |
11 | - "CLASSE" "SIM" | |
12 | - "wfs" "nao" | |
13 | - "wms_force_separate_request" "1" | |
14 | - "TEXTO" "NAO" | |
15 | - "legendawms" "http://sigel.aneel.gov.br/wmsconnector/com.esri.wms.Esrimap/gsiwms?&service=wms&request=getlegendgraphic&version=1.1.1&service=wms&layer=3&format=image/png" | |
16 | - "formatosinfo" "application/vnd.ogc.wms_xml,text/xml,text/html,text/plain" | |
17 | - "wms_name" "3" | |
18 | - "wms_format" "image/png" | |
19 | - "wms_formatlist" "image/png,image/jpeg" | |
20 | - "wms_connectiontimeout" "30" | |
21 | - "TEMA" "Linhas de Transmissão" | |
22 | - "wms_server_version" "1.1.1" | |
23 | - "wms_style" "default" | |
24 | - END | |
25 | - NAME "geopr_aneel_linhas" | |
26 | - OFFSITE 255 255 255 | |
27 | - STATUS DEFAULT | |
28 | - TOLERANCE 0 | |
29 | - TYPE RASTER | |
30 | - UNITS METERS | |
31 | - CLASS | |
32 | - NAME " " | |
33 | - END | |
34 | - END | |
35 | - | |
36 | -END | |
37 | - |