Commit ecbcffdba9ed477f775cd423b6e7e2341b181614
1 parent
eec120c0
Exists in
master
and in
7 other branches
--no commit message
Showing
14 changed files
with
719 additions
and
337 deletions
Show diff stats
admin/html/i3geoadmin_tags.html
... | ... | @@ -1,35 +0,0 @@ |
1 | -<html> | |
2 | -<head> | |
3 | -<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> | |
4 | -<link rel="stylesheet" type="text/css" href="admin.css"> | |
5 | -<script src="../../pacotes/cpaint/cpaint2.inc.compressed.js" type="text/javascript"></script> | |
6 | -<script src="../js/admin.js" type="text/javascript"></script> | |
7 | -<script src="../js/menutemas.js" type="text/javascript"></script> | |
8 | - | |
9 | -</head> | |
10 | -<body> | |
11 | -<div style=width:80%;text-align:center;> | |
12 | -<h1>Administração do i3geo - menu de temas <img src="../imagens/04.png" style="cursor:pointer" onclick="$i('ajuda').style.display='block'"/></h1> | |
13 | -<p><a href="../index.html">Voltar</a></p> | |
14 | -<div id=ajuda style="display:none"> | |
15 | -<p>Este programa permite editar a lista de tags (palavras-chave)</p> | |
16 | -<p>A lista de IPs dos usuários que podem editar os arquivos de configuração do i3geo e | |
17 | -dos que podem navegar pelos diretórios do servidor, não são mostradas aqui. Para | |
18 | -alterar essas variáveis, vc deve editar diretamente o arquivo i3geo/ms_configura.php.</p> | |
19 | -</div></div> | |
20 | -<div id=aguarde style="color:red" ><img src="../../imagens/aguarde.gif" /></div> | |
21 | -</body> | |
22 | -<script> | |
23 | -/* | |
24 | -Title: Administração da lista de menus do menu de temas | |
25 | - | |
26 | -File: i3geo/admin/i3geoadmin_tags.htm | |
27 | -*/ | |
28 | -$parametros = { | |
29 | - "simples": [ | |
30 | - { mensagem: "Adicione, altere ou elimine tags cadastrados",cabeca: "Tags",variavel:"tags"} | |
31 | - ]}; | |
32 | -iniciaAdmin() | |
33 | -document.getElementById("aguarde").style.display="none" | |
34 | -</script> | |
35 | -</html> | |
36 | 0 | \ No newline at end of file |
admin/html/mapas.html
1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
1 | 2 | <html> |
2 | 3 | <head> |
3 | -<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> | |
4 | -<link rel="stylesheet" type="text/css" href="admin.css"> | |
5 | -<script src="../../pacotes/cpaint/cpaint2.inc.compressed.js" type="text/javascript"></script> | |
6 | -<script src="../js/admin.js" type="text/javascript"></script> | |
7 | -<script src="../js/mapas.js" type="text/javascript"></script> | |
4 | + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> | |
5 | + <title>Mapas</title> | |
6 | + <style type="text/css"> | |
7 | + /*margin and padding on body element | |
8 | + can introduce errors in determining | |
9 | + element position and are not recommended; | |
10 | + we turn them off as a foundation for YUI | |
11 | + CSS treatments. */ | |
12 | + body { | |
13 | + margin:0; | |
14 | + padding:0; | |
15 | + } | |
16 | + </style> | |
17 | + <script type="text/javascript" src="../js/core.js"></script> | |
18 | + <script type="text/javascript" src="../js/mapas.js"></script> | |
8 | 19 | </head> |
9 | -<body> | |
20 | +<body class=" yui-skin-sam"> | |
21 | +<div style="margin:20px"> | |
10 | 22 | <div style=width:80%;text-align:center;> |
11 | -<h1>Administração do i3geo - mapas <img src="../imagens/04.png" style="cursor:pointer" onclick="$i('ajuda').style.display='block'"/></h1> | |
12 | -<p><a href="../index.html">Voltar</a></p> | |
13 | -<div id=ajuda style="display:none"> | |
14 | -<p>Este programa permite editar a lista de mapas</p> | |
15 | -<p>O menu é baseado no banco admin.db.</p> | |
16 | -<p>A lista de IPs dos usuários que podem editar os arquivos de configuração do i3geo e | |
17 | -dos que podem navegar pelos diretórios do servidor, não são mostradas aqui. Para | |
18 | -alterar essas variáveis, vc deve editar diretamente o arquivo i3geo/ms_configura.php.</p> | |
19 | -<p>Parâmetros:</p> | |
20 | -<p>Extensão: extensão geográfica no formato xmin ymin xmax ymax</p> | |
21 | -<p>Imagem: link para a imagem miniatura</p> | |
22 | -<p>Direto: link direto com todos os parâmetros de abertura do mapa. Se for usado, os outros parâmetros são desconsiderados</p> | |
23 | -<p>Outros: outros parâmetros que podem ser utilizados pelo ms_criamapa.php. São encadeados no final da URL de montagem do mapa.</p> | |
24 | -<p>Temas: códigos dos temas que serão mostrados no mapa</p> | |
25 | -<p>Ligados: códigos dos temas que estarão ligados no mapa (visíveis). Os códigos devem constar no item Temas</p> | |
26 | -<p>Perfil: lista de perfis de usuários que podem ver o mapa. Separe com vírgulas</p> | |
27 | -</div></div> | |
28 | -<div id=aguarde style="color:red" ><img src="../../imagens/aguarde.gif" /></div> | |
29 | -</body> | |
30 | -<script> | |
31 | -/* | |
32 | -Title: Administração da lista de mapas | |
33 | - | |
34 | -File: i3geo/admin/mapas.htm | |
35 | -*/ | |
36 | -function iniciaM(retorno) | |
37 | -{ | |
38 | - iniciaAdmin() | |
39 | - document.getElementById("aguarde").style.display="none" | |
40 | -} | |
41 | -temas = function(retorno){$temas = retorno.data;pegaPerfis()} | |
42 | -listaPerfis = function(retorno){$perfis = retorno.data;iniciaM()} | |
43 | -function pegaTemas() | |
44 | -{ | |
45 | - var cp = new cpaint(); | |
46 | - //cp.set_async("false"); | |
47 | - cp.set_response_type("JSON"); | |
48 | - var p = "../php/menutemas.php?funcao=pegaTemas"; | |
49 | - cp.call(p,"pegaTemas",temas); | |
50 | -} | |
51 | -function pegaPerfis() | |
52 | -{ | |
53 | - var cp = new cpaint(); | |
54 | - //cp.set_async("false"); | |
55 | - cp.set_response_type("JSON"); | |
56 | - var p = "../php/menutemas.php?funcao=pegaPerfis"; | |
57 | - cp.call(p,"pegaPerfis",listaPerfis); | |
58 | -} | |
59 | -pegaTemas() | |
23 | +<h1>Administração do i3geo - mapas <img src="../imagens/04.png" style="cursor:pointer" id=botaoAjuda /></h1> | |
60 | 24 | |
61 | -</script> | |
62 | -</html> | |
63 | 25 | \ No newline at end of file |
26 | +</div> | |
27 | +<div id="ajuda"> | |
28 | + <div class="hd">Ajuda</div> | |
29 | + <div class="bd" style="height:144px;overflow:auto"> | |
30 | + Este programa permite editar a lista de mapas.<br><br> | |
31 | + Os mapas nada mais são que links especiais com definições de parâmetros | |
32 | + para a abertura do i3geo. Os links permitem definir os temas que serão mostrados, | |
33 | + a extensão geográfica, interface, etc. Normalmente, a lista de mapas é mostrada | |
34 | + na guia "mapas" do i3geo.<br><br> | |
35 | + A lista de mapas é baseada no banco admin.db.<br><br> | |
36 | + A lista de IPs dos usuários que podem administrar o i3geo é definida no | |
37 | + arquivo i3geo/ms_configura.php | |
38 | + </div> | |
39 | + <div class="ft"></div> | |
40 | +</div> | |
41 | +<input onclick="adicionaLinha()" type=button id=adiciona value="Adicionar um novo mapa" /> | |
42 | +<br> | |
43 | +<p>Mapas existentes:</p> | |
44 | +<div id="tabela" style="left:-5px;"></div> | |
45 | +</div> | |
46 | +<div id=logajax style="display:block" ></div> | |
47 | +</body> | ... | ... |
... | ... | @@ -0,0 +1,43 @@ |
1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
2 | +<html> | |
3 | +<head> | |
4 | + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> | |
5 | + <title>Tags</title> | |
6 | + <style type="text/css"> | |
7 | + /*margin and padding on body element | |
8 | + can introduce errors in determining | |
9 | + element position and are not recommended; | |
10 | + we turn them off as a foundation for YUI | |
11 | + CSS treatments. */ | |
12 | + body { | |
13 | + margin:0; | |
14 | + padding:0; | |
15 | + } | |
16 | + </style> | |
17 | + <script type="text/javascript" src="../js/core.js"></script> | |
18 | + <script type="text/javascript" src="../js/tags.js"></script> | |
19 | +</head> | |
20 | +<body class=" yui-skin-sam"> | |
21 | +<div style="margin:20px"> | |
22 | +<div style=width:80%;text-align:center;> | |
23 | +<h1>Administração do i3geo - tags <img src="../imagens/04.png" style="cursor:pointer" id=botaoAjuda /></h1> | |
24 | + | |
25 | +</div> | |
26 | +<div id="ajuda"> | |
27 | + <div class="hd">Ajuda</div> | |
28 | + <div class="bd" style="height:144px;overflow:auto"> | |
29 | + Este programa permite editar a lista de tags.<br><br> | |
30 | + Tags são como palavras-chave que podem ser adicionadas aos temas para a realização de buscas.<br><br> | |
31 | + A lista de tags é baseada no banco admin.db.<br><br> | |
32 | + A lista de IPs dos usuários que podem administrar o i3geo é definida no | |
33 | + arquivo i3geo/ms_configura.php | |
34 | + </div> | |
35 | + <div class="ft"></div> | |
36 | +</div> | |
37 | +<input onclick="adicionaLinha()" type=button id=adiciona value="Adicionar um novo tag" /> | |
38 | +<br> | |
39 | +<p>Tags existentes: (clique na célula para editar e salve a linha editada)</p> | |
40 | +<div id="tabela" style="left:-5px;"></div> | |
41 | +</div> | |
42 | +<div id=logajax style="display:block" ></div> | |
43 | +</body> | ... | ... |
admin/index.html
... | ... | @@ -84,7 +84,7 @@ que por sua vez contém temas.</p> |
84 | 84 | <table class=lista1 > |
85 | 85 | <tr onclick="ajuda('a2',this)"><td><div class=ajuda ></div></td><td>Ajuda</td></tr> |
86 | 86 | <tr onclick="abre('html/perfis.html')"><td><div class=aplicar ></div></td><td>Editar a lista de perfis</td></tr> |
87 | -<tr onclick="abre('html/i3geoadmin_tags.html')"><td><div class=aplicar ></div></td><td>Editar a lista de tags (palavras-chave)</td></tr> | |
87 | +<tr onclick="abre('html/tags.html')"><td><div class=aplicar ></div></td><td>Editar a lista de tags (palavras-chave)</td></tr> | |
88 | 88 | <tr onclick="abre('html/menus.html')"><td><div class=aplicar ></div></td><td>Editar a lista de menus</td></tr> |
89 | 89 | <tr onclick="abre('html/grupos.html')"><td><div class=aplicar ></div></td><td>Editar a lista de grupos</td></tr> |
90 | 90 | <tr onclick="abre('html/subgrupos.html')"><td><div class=aplicar ></div></td><td>Editar a lista de sub-grupos</td></tr> | ... | ... |
admin/js/core.js
... | ... | @@ -54,7 +54,12 @@ Variable: $tags |
54 | 54 | Armazena o objeto com a lista de tags |
55 | 55 | */ |
56 | 56 | var $tags = ""; |
57 | +/* | |
58 | +Variable: $perfis | |
57 | 59 | |
60 | +Armazena o objeto com a lista de perfis | |
61 | +*/ | |
62 | +var $perfis = ""; | |
58 | 63 | /* |
59 | 64 | Function: core_handleSuccess |
60 | 65 | |
... | ... | @@ -296,22 +301,62 @@ onde - id do elemento que receberá o combo |
296 | 301 | id - id do combo que será criado |
297 | 302 | |
298 | 303 | marcar - valor que será marcado como selecionado |
304 | + | |
305 | +funcao - string com o nome da função que será executada no evento onchange | |
299 | 306 | */ |
300 | -function core_comboMapfiles(onde,id,marcar) | |
307 | +function core_comboMapfiles(onde,id,marcar,funcao) | |
301 | 308 | { |
309 | + if(arguments.length == 3) | |
310 | + {var funcao = "";} | |
302 | 311 | if($mapfiles == "") |
303 | 312 | { |
304 | - core_pegaMapfiles("core_comboMapfiles('"+onde+"','"+id+"','"+marcar+"')") | |
313 | + core_pegaMapfiles("core_comboMapfiles('"+onde+"','"+id+"','"+marcar+"','"+funcao+"')") | |
305 | 314 | } |
306 | 315 | else |
307 | 316 | { |
308 | - ins = "<select id='"+id+"' >" | |
317 | + if (funcao != "") | |
318 | + {var funcao = "onchange='"+funcao+"'";} | |
319 | + ins = "<select id='"+id+"' "+funcao+" >" | |
309 | 320 | ins += core_comboObjeto($mapfiles,"","",marcar) |
310 | 321 | ins += "</select></p>" |
311 | 322 | $i(onde).innerHTML = ins; |
312 | 323 | } |
313 | 324 | } |
314 | 325 | /* |
326 | +Function: core_comboPerfis | |
327 | + | |
328 | +Cria um combo para escolha de perfil | |
329 | + | |
330 | +Parameters: | |
331 | + | |
332 | +onde - id do elemento que receberá o combo | |
333 | + | |
334 | +id - id do combo que será criado | |
335 | + | |
336 | +marcar - valor que será marcado como selecionado | |
337 | + | |
338 | +funcao - string com o nome da função que será executada no evento onchange | |
339 | +*/ | |
340 | +function core_comboPerfis(onde,id,marcar,funcao) | |
341 | +{ | |
342 | + if(arguments.length == 3) | |
343 | + {var funcao = "";} | |
344 | + if($perfis == "") | |
345 | + { | |
346 | + core_pegaPerfis("core_comboPerfis('"+onde+"','"+id+"','"+marcar+"','"+funcao+"')") | |
347 | + } | |
348 | + else | |
349 | + { | |
350 | + if (funcao != "") | |
351 | + {var funcao = "onchange='"+funcao+"'";} | |
352 | + ins = "<select id='"+id+"' "+funcao+" >" | |
353 | + ins += core_comboObjeto($perfis,"perfil","perfil",marcar) | |
354 | + ins += "</select></p>" | |
355 | + $i(onde).innerHTML = ins; | |
356 | + } | |
357 | +} | |
358 | + | |
359 | +/* | |
315 | 360 | function: core_pegaTags |
316 | 361 | |
317 | 362 | Pega a lista de tags | ... | ... |
admin/js/grupos.js
... | ... | @@ -152,6 +152,8 @@ function gravaLinha(row) |
152 | 152 | { |
153 | 153 | success:function(o) |
154 | 154 | { |
155 | + var rec = myDataTable.getRecordSet().getRecord(row); | |
156 | + myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]) | |
155 | 157 | core_carregando("desativa"); |
156 | 158 | }, |
157 | 159 | failure:core_handleFailure, | ... | ... |
admin/js/mapas.js
1 | -/* | |
2 | -Title: Arvore | |
3 | - | |
4 | -Funções javascript utilizadas no sistema de administração do menu de mapas | |
5 | - | |
6 | -File: i3geo/admin/mapas.js | |
7 | - | |
8 | -About: Licença | |
9 | - | |
10 | -I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
11 | - | |
12 | -Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
13 | -Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br | |
14 | - | |
15 | -Este programa é software livre; você pode redistribuí-lo | |
16 | -e/ou modificá-lo sob os termos da Licença Pública Geral | |
17 | -GNU conforme publicada pela Free Software Foundation; | |
18 | -tanto a versão 2 da Licença. | |
19 | -Este programa é distribuído na expectativa de que seja útil, | |
20 | -porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
21 | -de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
22 | -Consulte a Licença Pública Geral do GNU para mais detalhes. | |
23 | -Você deve ter recebido uma cópia da Licença Pública Geral do | |
24 | -GNU junto com este programa; se não, escreva para a | |
25 | -Free Software Foundation, Inc., no endereço | |
26 | -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
27 | -*/ | |
28 | -/* | |
29 | -Function: iniciaAdmin | |
30 | - | |
31 | -Inicializa as variáveis globais e checa o cadastro do editor do sistema de administração | |
32 | - | |
33 | -Ao retornar, por default, executa a função montaParametros() | |
34 | -*/ | |
35 | -function iniciaAdmin() | |
1 | +YAHOO.namespace("example.container"); | |
2 | +function initMenu() | |
36 | 3 | { |
37 | - verificaEditores() | |
4 | + ativaBotaoAdicionaMapa() | |
5 | + core_carregando("ativa"); | |
6 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
7 | + //core_pegaPerfis("pegaMapas()"); | |
8 | + pegaMapas(); | |
38 | 9 | } |
39 | -function montaParametros() | |
10 | +function ativaBotaoAdicionaMapa() | |
40 | 11 | { |
41 | - if(!$i("resultado")) | |
42 | - {document.body.innerHTML += "<div id=resultado ></div>"} | |
43 | - listaMapas() | |
12 | + var adicionalinha = function() | |
13 | + { | |
14 | + core_carregando("ativa"); | |
15 | + core_carregando(" adicionando um novo registro"); | |
16 | + var sUrl = "../php/mapas.php?funcao=alterarMapa"; | |
17 | + var callback = | |
18 | + { | |
19 | + success:function(o) | |
20 | + { | |
21 | + try | |
22 | + { | |
23 | + myDataTable.addRow(YAHOO.lang.JSON.parse(o.responseText)[0],0); | |
24 | + core_carregando("desativa"); | |
25 | + } | |
26 | + catch(e){core_handleFailure(e,o.responseText);} | |
27 | + }, | |
28 | + failure:core_handleFailure, | |
29 | + argument: { foo:"foo", bar:"bar" } | |
30 | + }; | |
31 | + core_makeRequest(sUrl,callback) | |
32 | + }; | |
33 | + //cria o botão de adição de um novo menu | |
34 | + var adiciona = new YAHOO.widget.Button("adiciona",{ onclick: { fn: adicionalinha } }); | |
44 | 35 | } |
45 | -/* | |
46 | -Function: listaMapas | |
47 | - | |
48 | -Monta o html com os parametros e os divs que receberão os dados dos formulários. | |
49 | - | |
50 | -Para cada registro na variável $parameters, é montado um formulário. | |
51 | -*/ | |
52 | -function listaMapas() | |
36 | +function pegaMapas() | |
53 | 37 | { |
54 | - $i("resultado").innerHTML = $mensagemAguarde | |
55 | - var ins = "<fieldset><legend>Mapas</legend>" | |
56 | - var comboMapas = function(retorno) | |
38 | + core_carregando("buscando mapas..."); | |
39 | + var sUrl = "../php/mapas.php?funcao=pegaMapas"; | |
40 | + var callback = | |
57 | 41 | { |
58 | - var d = retorno.data; | |
59 | - var nm = retorno.data.length | |
60 | - ins += "<p><table><tr><td><b>Selecione o mapa:</b></td><td></td></tr>" | |
61 | - ins += "<tr><td><input style=font-size:10px onclick='alterarMapa(\"\")' type=button value='Adicionar um novo mapa' /></td><td><select onchange='pegaDadosMapa(this.value)'>" | |
62 | - ins += "<option>---</option>" | |
63 | - for (i=0;i<nm;i++) | |
42 | + success:function(o) | |
43 | + { | |
44 | + try | |
45 | + {montaTabela(YAHOO.lang.JSON.parse(o.responseText));} | |
46 | + catch(e){core_handleFailure(e,o.responseText);} | |
47 | + }, | |
48 | + failure:core_handleFailure, | |
49 | + argument: { foo:"foo", bar:"bar" } | |
50 | + }; | |
51 | + core_makeRequest(sUrl,callback) | |
52 | +} | |
53 | +function montaTabela(dados) | |
54 | +{ | |
55 | + YAHOO.example.InlineCellEditing = new function() | |
56 | + { | |
57 | + // Custom formatter for "address" column to preserve line breaks | |
58 | + var formatTextoId = function(elCell, oRecord, oColumn, oData) | |
59 | + { | |
60 | + elCell.innerHTML = "<p>" + oData + "</p>"; | |
61 | + }; | |
62 | + | |
63 | + var formatMais = function(elCell, oRecord, oColumn) | |
64 | + { | |
65 | + elCell.innerHTML = "<div class=mais style='text-align:center' ></div>"; | |
66 | + }; | |
67 | + var formatExclui = function(elCell, oRecord, oColumn) | |
68 | + { | |
69 | + elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>"; | |
70 | + }; | |
71 | + var myColumnDefs = [ | |
72 | + {key:"excluir",label:"excluir",formatter:formatExclui}, | |
73 | + {key:"mais",label:"mais",formatter:formatMais}, | |
74 | + {label:"id",key:"id_mapa", formatter:formatTextoId}, | |
75 | + {label:"nome",key:"nome_mapa", formatter:formatTextoId}, | |
76 | + {label:"ordem",key:"ordem_mapa", formatter:formatTextoId} | |
77 | + ]; | |
78 | + myDataSource = new YAHOO.util.DataSource(dados); | |
79 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
80 | + myDataSource.responseSchema = | |
81 | + { | |
82 | + fields: ["id_mapa","nome_mapa","ordem_mapa"] | |
83 | + }; | |
84 | + myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | |
85 | + // Set up editing flow | |
86 | + myDataTable.subscribe('cellClickEvent',function(ev) | |
64 | 87 | { |
65 | - ins += "<option value='"+d[i].id_mapa+"'>"+d[i].nome_mapa+"</option>" | |
66 | - } | |
67 | - $i("resultado").innerHTML = ins+"</select></tr></table></p><p><div id='dadosMapa'></div></fieldset>" | |
68 | - } | |
69 | - var cp = new cpaint(); | |
70 | - cp.set_response_type("JSON"); | |
71 | - var p = "../php/mapas.php?funcao=pegaMapas"; | |
72 | - cp.call(p,"pegaMapas",comboMapas); | |
88 | + var target = YAHOO.util.Event.getTarget(ev); | |
89 | + var column = this.getColumn(target); | |
90 | + if (column.key == 'excluir') | |
91 | + { | |
92 | + var record = this.getRecord(target); | |
93 | + excluiLinha(record.getData('id_mapa'),target); | |
94 | + } | |
95 | + if (column.key == 'mais') | |
96 | + { | |
97 | + var record = this.getRecord(target); | |
98 | + core_carregando("ativa"); | |
99 | + core_carregando("buscando dados..."); | |
100 | + $clicouId = record.getData('id_mapa'); | |
101 | + $recordid = record.getId(); | |
102 | + var sUrl = "../php/mapas.php?funcao=pegaDadosMapa&id_mapa="+record.getData('id_mapa'); | |
103 | + var callback = | |
104 | + { | |
105 | + success:function(o) | |
106 | + { | |
107 | + try | |
108 | + { | |
109 | + montaEditorMapa(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
110 | + } | |
111 | + catch(e){core_handleFailure(e,o.responseText);} | |
112 | + }, | |
113 | + failure:core_handleFailure, | |
114 | + argument: { foo:"foo", bar:"bar" } | |
115 | + }; | |
116 | + core_makeRequest(sUrl,callback) | |
117 | + } | |
118 | + | |
119 | + }); | |
120 | + // Hook into custom event to customize save-flow of "radio" editor | |
121 | + myDataTable.subscribe("editorUpdateEvent", function(oArgs) | |
122 | + { | |
123 | + if(oArgs.editor.column.key === "active") | |
124 | + { | |
125 | + this.saveCellEditor(); | |
126 | + } | |
127 | + }); | |
128 | + myDataTable.subscribe("editorBlurEvent", function(oArgs) | |
129 | + { | |
130 | + this.cancelCellEditor(); | |
131 | + }); | |
132 | + }; | |
133 | + core_carregando("desativa"); | |
73 | 134 | } |
74 | -function pegaDadosMapa(id_mapa) | |
135 | +function montaEditorMapa(dados,id,recordid) | |
75 | 136 | { |
76 | - $i("dadosMapa").innerHTML = $mensagemAguarde | |
77 | - var retorna = function(retorno) | |
137 | + function on_editorCheckBoxChange(p_oEvent) | |
78 | 138 | { |
79 | - var d = retorno.data.mapa[0] | |
80 | - var ins = "<table class=lista ><tr><td></td><td></td></tr>"; | |
81 | - var param = { | |
82 | - "linhas":[ | |
83 | - {titulo:"Nome",prefixoid:"nome_",id:"id_mapa",valor:"nome_mapa"}, | |
84 | - {titulo:"Descrição",prefixoid:"desc_",id:"id_mapa",valor:"desc_mapa"}, | |
85 | - {titulo:"Extensão",prefixoid:"ext_",id:"id_mapa",valor:"ext_mapa"}, | |
86 | - {titulo:"Imagem",prefixoid:"imagem_",id:"id_mapa",valor:"imagem_mapa"}, | |
87 | - {titulo:"Outros",prefixoid:"outros_",id:"id_mapa",valor:"outros_mapa"}, | |
88 | - {titulo:"Direto",prefixoid:"linkdireto_",id:"id_mapa",valor:"linkdireto_mapa"}, | |
89 | - {titulo:"Ordem",prefixoid:"ordem_",id:"id_mapa",valor:"ordem_mapa"} | |
90 | - ] | |
139 | + var ins = ""; | |
140 | + if(p_oEvent.newValue.get("value") == "OK") | |
141 | + { | |
142 | + gravaDadosMapa(id,recordid); | |
91 | 143 | } |
92 | - ins += (geraLinhas(d,param,3)); | |
93 | - ins += "<tr>" | |
94 | - ins += "<td>Temas: </td>" | |
95 | - ins += "<td><input size=30 onchange='this.style.color=\"blue\"' type=text id='temas_"+d.id_mapa+"' value='"+d.temas_mapa+"' /></td>" | |
96 | - ins += "<td><select onchange='adicionaTema(\""+d.id_mapa+"\",this.value)'>" | |
97 | - ins += comboObjeto($temas,"codigo_tema","nome_tema","") | |
98 | - ins += "</select>" | |
99 | - ins += "</td>" | |
100 | - ins += "</tr>" | |
101 | - ins += "<tr>" | |
102 | - ins += "<td>Perfis: </td>" | |
103 | - ins += "<td><input size=30 onchange='this.style.color=\"blue\"' type=text id='perfis_"+d.id_mapa+"' value='"+d.perfil_mapa+"' /></td>" | |
104 | - var idtemp = "perfis_"+d.id_mapa | |
105 | - ins += "<td><select onchange=\"registraPerfil('"+idtemp+"',this.value);this.style.color='blue'\" >" | |
106 | - ins += comboObjeto($perfis,"perfil","perfil","") | |
107 | - ins += "</select></td></tr>" | |
108 | - ins += "</select>" | |
109 | - ins += "</td>" | |
110 | - ins += "</tr>" | |
111 | - ins += "<tr>" | |
112 | - ins += "<td>Ligados: </td>" | |
113 | - ins += "<td><input size=30 onchange='this.style.color=\"blue\"' type=text id='ligados_"+d.id_mapa+"' value='"+d.ligados_mapa+"' /></td>" | |
114 | - ins += "</tr>" | |
115 | - | |
116 | - ins += "<tr>" | |
117 | - ins += "<td>Publicado: </td>" | |
118 | - ins += "<td><select onchange=this.style.color='blue' id='publicado_"+d.id_mapa+"' >" | |
119 | - ins += combosimnao(d.publicado_mapa) | |
120 | - ins += "</td></tr>" | |
121 | - | |
122 | - ins += "</table>" | |
123 | - ins += "<table><tr><td><div class=excluir title='Excluir' onclick='excluir(\""+d.id_mapa+"\")'/></td>" | |
124 | - ins += "<td><div class=aplicar title='Aplicar alterações' onclick='alterarMapa(\""+d.id_mapa+"\",\""+d.id_mapa+"\")'/></td>" | |
125 | - ins += "</tr></table>" | |
126 | - if(d.linkdireto_mapa != "") | |
127 | - {var l = d.linkdireto_mapa;} | |
128 | 144 | else |
129 | 145 | { |
130 | - var l = "../ms_criamapa.php?temasa="+d.temas_mapa+"&layers="+d.ligados_mapa | |
131 | - if (d.ext_mapa != "") | |
132 | - {l += "&mapext="+d.ext_mapa} | |
133 | - if (d.outros_mapa != "") | |
134 | - {l += "&"+d.outros_mapa} | |
146 | + YAHOO.example.container.panelEditorMapa.destroy(); | |
147 | + YAHOO.example.container.panelEditorMapa = null; | |
135 | 148 | } |
136 | - ins += "<br>Testar: <a href='"+l+"' target=blank >"+l+"</a>" | |
137 | - if(d.imagem_mapa != "") | |
138 | - ins += "<br><img src='"+d.imagem_mapa+"' />" | |
139 | - ins += "</div></fieldset><br>" | |
140 | - if(!$i(d.id_mapa)) | |
141 | - ins += "</div>" | |
142 | - $i("dadosMapa").innerHTML = ins | |
149 | + }; | |
150 | + if(!YAHOO.example.container.panelEditorMapa) | |
151 | + { | |
152 | + var novoel = document.createElement("div"); | |
153 | + novoel.id = "janela_editor"; | |
154 | + var ins = '<div class="hd">Editor</div>'; | |
155 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
156 | + ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>"; | |
157 | + novoel.innerHTML = ins; | |
158 | + document.body.appendChild(novoel); | |
159 | + var editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id", name: "okcancel_checkbox_id", container: "okcancel_checkbox" }); | |
160 | + editorBotoes.addButtons([ | |
161 | + { label: "Salva", value: "OK", checked: false}, | |
162 | + { label: "Cancela", value: "CANCEL", checked: false } | |
163 | + ]); | |
164 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
165 | + YAHOO.example.container.panelEditorMapa = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:false,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
166 | + YAHOO.example.container.panelEditorMapa.render(); | |
143 | 167 | } |
144 | - var cp = new cpaint(); | |
145 | - cp.set_response_type("JSON"); | |
146 | - var p = "../php/mapas.php?funcao=pegaDadosMapa&id_mapa="+id_mapa; | |
147 | - cp.call(p,"pegaDadosMapa",retorna); | |
168 | + YAHOO.example.container.panelEditorMapa.show(); | |
169 | + //carrega os dados na janela | |
170 | + $i("editor_bd").innerHTML = montaDivMapas(dados[0]) | |
171 | + core_carregando("desativa"); | |
172 | + // | |
173 | + //preenche a div com a lista de mapfiles e perfis | |
174 | + // | |
175 | + core_comboMapfiles("comboMapfiles","Etemas_mapa","",'registraMapfile(this.value,\"Etemas_mapa\")'); | |
176 | + core_comboPerfis("comboPerfis","Eperfil_mapa","","registraPerfil(this.value)"); | |
148 | 177 | } |
149 | -function adicionaTema(id,codigo) | |
178 | +function registraPerfil(valor) | |
150 | 179 | { |
151 | - var valor = $i("temas_"+id).value | |
152 | - if(valor == "") | |
153 | - $i("temas_"+id).value = codigo | |
180 | + var inp = $i("Eperfil_mapa") | |
181 | + var perfis = inp.value | |
182 | + if(perfis == "") | |
183 | + inp.value = valor | |
154 | 184 | else |
155 | - $i("temas_"+id).value += " "+codigo | |
185 | + inp.value = perfis+" "+valor | |
156 | 186 | } |
157 | -function alterarMapa(id_mapa,onde) | |
187 | + | |
188 | +function registraMapfile(valor,onde) | |
158 | 189 | { |
159 | - var retorna = function(retorno) | |
160 | - { | |
161 | - if(id_mapa == "") | |
162 | - listaMapas(retorno); | |
163 | - else | |
164 | - {ins = "";pegaDadosMapa(id_mapa)} | |
165 | - } | |
166 | - if (id_mapa != "") | |
167 | - { | |
168 | - var nome = $i("nome_"+id_mapa).value | |
169 | - var desc = $i("desc_"+id_mapa).value | |
170 | - var ext = $i("ext_"+id_mapa).value | |
171 | - var imagem = $i("imagem_"+id_mapa).value | |
172 | - var outros = $i("outros_"+id_mapa).value | |
173 | - var linkdireto = $i("linkdireto_"+id_mapa).value | |
174 | - var temas = $i("temas_"+id_mapa).value | |
175 | - var ligados = $i("ligados_"+id_mapa).value | |
176 | - var perfil = $i("perfis_"+id_mapa).value | |
177 | - var ordem_mapa = $i("ordem_"+id_mapa).value | |
178 | - var publicado_mapa = $i("publicado_"+id_mapa).value | |
179 | - } | |
190 | + var inp = $i(onde) | |
191 | + var temas = inp.value | |
192 | + if(temas == "") | |
193 | + inp.value = valor | |
180 | 194 | else |
181 | - { | |
182 | - var nome = "" | |
183 | - var desc = "" | |
184 | - var ext = "" | |
185 | - var imagem = "" | |
186 | - var outros = "" | |
187 | - var linkdireto = "" | |
188 | - var temas = "" | |
189 | - var ligados = "" | |
190 | - var perfil = "" | |
191 | - var ordem_mapa = "" | |
192 | - var publicado_mapa = "" | |
193 | - var id_mapa = ""; | |
194 | - var perfil = ""; | |
195 | - var nome = prompt("Nome do novo Mapa",""); | |
196 | - if (nome==null || nome=="") | |
195 | + inp.value = temas+" "+valor | |
196 | +} | |
197 | +function montaDivMapas(i) | |
198 | +{ | |
199 | + var ins = "" | |
200 | + | |
201 | + //ins += "<p>Mapfile (código do mapfile que será utilizado para criar a camada no i3geo):" | |
202 | + //ins += "<div id=comboMapfiles >Buscando...</div>"; | |
203 | + ins += "<p>Ordem de apresentação do mapa:<br>"; | |
204 | + ins += "<input size=10 type=text id=Eordem_mapa value='"+i.ordem_mapa+"' /></p>" | |
205 | + | |
206 | + ins += "<p>Nome do mapa:<br>"; | |
207 | + ins += "<input size=50 type=text id=Enome_mapa value='"+i.nome_mapa+"' /></p>" | |
208 | + | |
209 | + ins += "<p>Publicado?<br>" | |
210 | + ins += "<select id='Epublicado_mapa' >" | |
211 | + ins += core_combosimnao(i.publicado_mapa) | |
212 | + ins += "</select></p>" | |
213 | + | |
214 | + ins += "<p>Descrição:<br>"; | |
215 | + ins += "<input size=50 type=text id=Edesc_mapa value='"+i.desc_mapa+"' /></p>" | |
216 | + | |
217 | + ins += "<p>Extensão geográfica:<br>"; | |
218 | + ins += "<input size=50 type=text id=Eext_mapa value='"+i.ext_mapa+"' /></p>" | |
219 | + | |
220 | + ins += "<p>URL da imagem miniatura:<br>"; | |
221 | + ins += "<input size=50 type=text id=Eimagem_mapa value='"+i.imagem_mapa+"' /></p>" | |
222 | + ins += "<img src='"+i.imagem_mapa+"' />" | |
223 | + | |
224 | + ins += "<p>Temas que serão incluídos nesse mapa (utilize os códigos dos mapfiles mostrados na lista abaixo): </p>" | |
225 | + ins += "<input size=50 type=text id='Etemas_mapa' value='"+i.temas_mapa+"' /></p>" | |
226 | + ins += "<div id=comboMapfiles >Buscando...</div>"; | |
227 | + | |
228 | + ins += "<p>Temas que serão ligados. Devem constar na lista de temas incluídos: </p>" | |
229 | + ins += "<input size=50 type=text id='Eligados_mapa' value='"+i.ligados_mapa+"' /></p>" | |
230 | + //ins += "<div id=comboMapfilesLigados >Buscando...</div>"; | |
231 | + | |
232 | + ins += "<p>Perfis que podem ver este mapa: </p>" | |
233 | + ins += "<input size=50 type=text id='Eperfil_mapa' value='"+i.perfil_mapa+"' /></p>" | |
234 | + ins += "<div id=comboPerfis >Buscando...</div>"; | |
235 | + | |
236 | + ins += "<p>Outros parâmetros (separe com '&'):<br>"; | |
237 | + ins += "<input size=50 type=text id=Eoutros_mapa value='"+i.outros_mapa+"' /></p>" | |
238 | + | |
239 | + ins += "<p>Link direto para abertura do mapa (despreza os outros parâmetros):<br>"; | |
240 | + ins += "<input size=50 type=text id=Elinkdireto_mapa value='"+i.linkdireto_mapa+"' /></p>" | |
241 | + return(ins) | |
242 | +} | |
243 | +function excluiLinha(id,row) | |
244 | +{ | |
245 | + //dialogo | |
246 | + // Define various event handlers for Dialog | |
247 | + var handleYes = function() { | |
248 | + this.hide(); | |
249 | + core_carregando("ativa"); | |
250 | + core_carregando(" excluindo o registro do id= "+id); | |
251 | + var sUrl = "../php/mapas.php?funcao=excluirMapa&id="+id; | |
252 | + var callback = | |
197 | 253 | { |
198 | - return; | |
199 | - } | |
200 | - } | |
201 | - var p = "../php/mapas.php?funcao=alterarMapa&publicado_mapa="+publicado_mapa+"&ordem_mapa="+ordem_mapa+"&id_mapa="+id_mapa+"&nome="+nome+"&desc="+desc+"&ext="+ext+"&imagem="+imagem+"&outros="+outros+"&linkdireto="+linkdireto+"&temas="+temas+"&ligados="+ligados+"&perfil="+perfil | |
202 | - cPaint.call(p,"",retorna); | |
254 | + success:function(o) | |
255 | + { | |
256 | + try | |
257 | + { | |
258 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
259 | + { | |
260 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem elementos vinculados a este mapa</span>"); | |
261 | + setTimeout("core_carregando('desativa')",3000) | |
262 | + } | |
263 | + else | |
264 | + { | |
265 | + myDataTable.deleteRow(row); | |
266 | + core_carregando("desativa"); | |
267 | + } | |
268 | + } | |
269 | + catch(e){core_handleFailure(e,o.responseText);} | |
270 | + }, | |
271 | + failure:core_handleFailure, | |
272 | + argument: { foo:"foo", bar:"bar" } | |
273 | + }; | |
274 | + core_makeRequest(sUrl,callback) | |
275 | + }; | |
276 | + var handleNo = function() | |
277 | + { | |
278 | + this.hide(); | |
279 | + }; | |
280 | + var mensagem = "Exclui o registro?"; | |
281 | + var largura = "300" | |
282 | + core_dialogoContinua(handleYes,handleNo,mensagem,largura) | |
203 | 283 | } |
204 | -function excluir(id) | |
284 | +function gravaDadosMapa(id,recordid) | |
205 | 285 | { |
206 | - if(confirm("Você realmente quer fazer isso?")) | |
286 | + var campos = new Array("publicado","ordem","perfil","ligados","temas","desc","ext","imagem","linkdireto","nome","outros") | |
287 | + var par = "" | |
288 | + for (i=0;i<campos.length;i++) | |
207 | 289 | { |
208 | - $i("resultado").innerHTML = $mensagemAguarde; | |
209 | - var retorna = function() | |
210 | - { | |
211 | - montaParametros() | |
212 | - } | |
213 | - var p = "../php/mapas.php?funcao=excluir&id="+id; | |
214 | - cPaint.call(p,"",retorna); | |
290 | + par += "&"+campos[i]+"_mapa="+($i("E"+campos[i]+"_mapa").value) | |
215 | 291 | } |
292 | + par += "&id_mapa="+id | |
293 | + core_carregando("ativa"); | |
294 | + core_carregando(" gravando o registro do id= "+id); | |
295 | + var sUrl = "../php/mapas.php?funcao=alterarMapa"+par; | |
296 | + var callback = | |
297 | + { | |
298 | + success:function(o) | |
299 | + { | |
300 | + try | |
301 | + { | |
302 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
303 | + { | |
304 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem víncilos com outros elementos</span>"); | |
305 | + setTimeout("core_carregando('desativa')",3000) | |
306 | + } | |
307 | + else | |
308 | + { | |
309 | + var rec = myDataTable.getRecordSet().getRecord(recordid); | |
310 | + myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]) | |
311 | + core_carregando("desativa"); | |
312 | + } | |
313 | + YAHOO.example.container.panelEditorMapa.destroy(); | |
314 | + YAHOO.example.container.panelEditorMapa = null; | |
315 | + } | |
316 | + catch(e){core_handleFailure(e,o.responseText);} | |
317 | + }, | |
318 | + failure:core_handleFailure, | |
319 | + argument: { foo:"foo", bar:"bar" } | |
320 | + }; | |
321 | + core_makeRequest(sUrl,callback) | |
216 | 322 | } |
217 | -function importarXmlMapas() | |
218 | -{ | |
219 | - $i("resultado").innerHTML = $mensagemAguarde | |
220 | - var retorna = function(retorno) | |
221 | - {$i("resultado").innerHTML = retorno.data} | |
222 | - var p = "../php/mapas.php?funcao=importarXmlMapas&xml="+$i("arquivo").value; | |
223 | - cPaint.call(p,"",retorna); | |
224 | -} | |
225 | 323 | \ No newline at end of file |
324 | +YAHOO.util.Event.addListener(window, "load", initMenu); | |
226 | 325 | \ No newline at end of file | ... | ... |
admin/js/menu.js
... | ... | @@ -163,6 +163,8 @@ function gravaLinha(row) |
163 | 163 | { |
164 | 164 | success:function(o) |
165 | 165 | { |
166 | + var rec = myDataTable.getRecordSet().getRecord(row); | |
167 | + myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]) | |
166 | 168 | core_carregando("desativa"); |
167 | 169 | }, |
168 | 170 | failure:core_handleFailure, | ... | ... |
admin/js/perfis.js
... | ... | @@ -149,6 +149,8 @@ function gravaLinha(row) |
149 | 149 | { |
150 | 150 | success:function(o) |
151 | 151 | { |
152 | + var rec = myDataTable.getRecordSet().getRecord(row); | |
153 | + myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]) | |
152 | 154 | core_carregando("desativa"); |
153 | 155 | }, |
154 | 156 | failure:core_handleFailure, | ... | ... |
admin/js/subgrupos.js
... | ... | @@ -152,6 +152,8 @@ function gravaLinha(row) |
152 | 152 | { |
153 | 153 | success:function(o) |
154 | 154 | { |
155 | + var rec = myDataTable.getRecordSet().getRecord(row); | |
156 | + myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]) | |
155 | 157 | core_carregando("desativa"); |
156 | 158 | }, |
157 | 159 | failure:core_handleFailure, | ... | ... |
... | ... | @@ -0,0 +1,202 @@ |
1 | +YAHOO.namespace("example.container"); | |
2 | +function initMenu() | |
3 | +{ | |
4 | + ativaBotaoAdicionaTag(); | |
5 | + core_carregando("ativa"); | |
6 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
7 | + pegaTags(); | |
8 | +} | |
9 | +function ativaBotaoAdicionaTag() | |
10 | +{ | |
11 | + var adicionalinha = function() | |
12 | + { | |
13 | + core_carregando("ativa"); | |
14 | + core_carregando(" adicionando um novo registro"); | |
15 | + var sUrl = "../php/menutemas.php?funcao=alteraTags"; | |
16 | + var callback = | |
17 | + { | |
18 | + success:function(o) | |
19 | + { | |
20 | + try | |
21 | + { | |
22 | + myDataTable.addRow(YAHOO.lang.JSON.parse(o.responseText)[0],0); | |
23 | + core_carregando("desativa"); | |
24 | + } | |
25 | + catch(e){core_handleFailure(o,o.responseText);} | |
26 | + }, | |
27 | + failure:core_handleFailure, | |
28 | + argument: { foo:"foo", bar:"bar" } | |
29 | + }; | |
30 | + core_makeRequest(sUrl,callback) | |
31 | + }; | |
32 | + //cria o botão de adição de um novo menu | |
33 | + var adiciona = new YAHOO.widget.Button("adiciona",{ onclick: { fn: adicionalinha } }); | |
34 | +} | |
35 | +function pegaTags() | |
36 | +{ | |
37 | + core_carregando("buscando tags..."); | |
38 | + var sUrl = "../php/menutemas.php?funcao=pegaTags"; | |
39 | + var callback = | |
40 | + { | |
41 | + success:function(o) | |
42 | + { | |
43 | + try | |
44 | + {montaTabela(YAHOO.lang.JSON.parse(o.responseText));} | |
45 | + catch(e){core_handleFailure(o,o.responseText);} | |
46 | + }, | |
47 | + failure:core_handleFailure, | |
48 | + argument: { foo:"foo", bar:"bar" } | |
49 | + }; | |
50 | + core_makeRequest(sUrl,callback) | |
51 | +} | |
52 | +function montaTabela(dados) | |
53 | +{ | |
54 | + YAHOO.example.InlineCellEditing = new function() | |
55 | + { | |
56 | + // Custom formatter for "address" column to preserve line breaks | |
57 | + var formatTexto = function(elCell, oRecord, oColumn, oData) | |
58 | + { | |
59 | + elCell.innerHTML = "<p style=width:250px >" + oData + "</p>"; | |
60 | + }; | |
61 | + var formatTextoId = function(elCell, oRecord, oColumn, oData) | |
62 | + { | |
63 | + elCell.innerHTML = "<p style=width:20px >" + oData + "</p>"; | |
64 | + }; | |
65 | + | |
66 | + var formatSalva = function(elCell, oRecord, oColumn) | |
67 | + { | |
68 | + elCell.innerHTML = "<div class=aplicar style='text-align:center' onclick='gravaLinha(\""+oRecord._sId+"\")'></div>"; | |
69 | + }; | |
70 | + var formatExclui = function(elCell, oRecord, oColumn) | |
71 | + { | |
72 | + elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>"; | |
73 | + }; | |
74 | + var myColumnDefs = [ | |
75 | + {key:"excluir",label:"excluir",formatter:formatExclui}, | |
76 | + {label:"salvar",formatter:formatSalva}, | |
77 | + {label:"id",key:"id_tag", formatter:formatTextoId}, | |
78 | + {label:"nome",resizeable:true,key:"nome", formatter:formatTexto, editor:"textbox"} | |
79 | + ]; | |
80 | + myDataSource = new YAHOO.util.DataSource(dados); | |
81 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
82 | + myDataSource.responseSchema = | |
83 | + { | |
84 | + fields: ["id_tag","nome"] | |
85 | + }; | |
86 | + myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | |
87 | + // Set up editing flow | |
88 | + myDataTable.highlightEditableCell = function(oArgs) | |
89 | + { | |
90 | + var elCell = oArgs.target; | |
91 | + var column = myDataTable.getColumn(oArgs.target); | |
92 | + if(!YAHOO.lang.isNull(column.editor)) | |
93 | + { | |
94 | + YAHOO.util.Dom.addClass(elCell,'yui-dt-highlighted'); | |
95 | + } | |
96 | + }; | |
97 | + myDataTable.unhighlightEditableCell = function(oArgs) | |
98 | + { | |
99 | + var elCell = oArgs.target; | |
100 | + if(elCell.style.cursor="pointer") | |
101 | + { | |
102 | + YAHOO.util.Dom.removeClass(elCell,'yui-dt-highlighted'); | |
103 | + } | |
104 | + }; | |
105 | + myDataTable.subscribe("cellMouseoverEvent", myDataTable.highlightEditableCell); | |
106 | + myDataTable.subscribe("cellMouseoutEvent", myDataTable.unhighlightEditableCell); | |
107 | + myDataTable.subscribe('cellClickEvent',function(ev) | |
108 | + { | |
109 | + var target = YAHOO.util.Event.getTarget(ev); | |
110 | + var column = this.getColumn(target); | |
111 | + if(YAHOO.example.container.panelCK) | |
112 | + { | |
113 | + YAHOO.example.container.panelCK.destroy(); | |
114 | + YAHOO.example.container.panelCK = null; | |
115 | + } | |
116 | + if (column.key == 'excluir') | |
117 | + { | |
118 | + var record = this.getRecord(target); | |
119 | + excluiLinha(record.getData('id_tag'),target); | |
120 | + } | |
121 | + else | |
122 | + {this.onEventShowCellEditor(ev);} | |
123 | + }); | |
124 | + // Hook into custom event to customize save-flow of "radio" editor | |
125 | + myDataTable.subscribe("editorUpdateEvent", function(oArgs) | |
126 | + { | |
127 | + if(oArgs.editor.column.key === "active") | |
128 | + { | |
129 | + this.saveCellEditor(); | |
130 | + | |
131 | + } | |
132 | + }); | |
133 | + myDataTable.subscribe("editorBlurEvent", function(oArgs) | |
134 | + { | |
135 | + this.cancelCellEditor(); | |
136 | + }); | |
137 | + }; | |
138 | + core_carregando("desativa"); | |
139 | +} | |
140 | +function gravaLinha(row) | |
141 | +{ | |
142 | + var r = myDataTable.getRecordSet().getRecord(row); | |
143 | + var id_tag = r.getData("id_tag"); | |
144 | + var nome = r.getData("nome"); | |
145 | + core_carregando("ativa"); | |
146 | + core_carregando(" gravando registro do id= "+id_tag); | |
147 | + var sUrl = "../php/menutemas.php?funcao=alteraTags&nome="+nome+"&id="+id_tag; | |
148 | + var callback = | |
149 | + { | |
150 | + success:function(o) | |
151 | + { | |
152 | + var rec = myDataTable.getRecordSet().getRecord(row); | |
153 | + myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]) | |
154 | + core_carregando("desativa"); | |
155 | + }, | |
156 | + failure:core_handleFailure, | |
157 | + argument: { foo:"foo", bar:"bar" } | |
158 | + }; | |
159 | + core_makeRequest(sUrl,callback) | |
160 | +} | |
161 | +function excluiLinha(id,row) | |
162 | +{ | |
163 | + //dialogo | |
164 | + // Define various event handlers for Dialog | |
165 | + var handleYes = function() { | |
166 | + this.hide(); | |
167 | + core_carregando("ativa"); | |
168 | + core_carregando(" excluindo o registro do id= "+id); | |
169 | + var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=tags"; | |
170 | + var callback = | |
171 | + { | |
172 | + success:function(o) | |
173 | + { | |
174 | + try | |
175 | + { | |
176 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
177 | + { | |
178 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem itens vinculados a este tag</span>"); | |
179 | + setTimeout("core_carregando('desativa')",3000) | |
180 | + } | |
181 | + else | |
182 | + { | |
183 | + myDataTable.deleteRow(row); | |
184 | + core_carregando("desativa"); | |
185 | + } | |
186 | + } | |
187 | + catch(e){core_handleFailure(o,o.responseText);} | |
188 | + }, | |
189 | + failure:core_handleFailure, | |
190 | + argument: { foo:"foo", bar:"bar" } | |
191 | + }; | |
192 | + core_makeRequest(sUrl,callback) | |
193 | + }; | |
194 | + var handleNo = function() | |
195 | + { | |
196 | + this.hide(); | |
197 | + }; | |
198 | + var mensagem = "Exclui o registro?"; | |
199 | + var largura = "300" | |
200 | + core_dialogoContinua(handleYes,handleNo,mensagem,largura) | |
201 | +} | |
202 | +YAHOO.util.Event.addListener(window, "load", initMenu); | |
0 | 203 | \ No newline at end of file | ... | ... |
admin/php/admin.php
... | ... | @@ -79,6 +79,13 @@ if($funcao == "limpar") |
79 | 79 | $dbh = null; |
80 | 80 | exit; |
81 | 81 | } |
82 | +function retornaJSON($obj) | |
83 | +{ | |
84 | + if(extension_loaded('zlib')){ob_start('ob_gzhandler');} | |
85 | + echo json_encode($obj); | |
86 | + if(extension_loaded('zlib')){ob_end_flush();} | |
87 | + exit; | |
88 | +} | |
82 | 89 | function verificaDuplicados($sql,$dbh) |
83 | 90 | { |
84 | 91 | $res = $dbh->query($sql,PDO::FETCH_ASSOC); | ... | ... |
admin/php/mapas.php
... | ... | @@ -28,7 +28,6 @@ File: i3geo/admin/mapas.php |
28 | 28 | |
29 | 29 | */ |
30 | 30 | include_once("admin.php"); |
31 | -$cp = new cpaint(); | |
32 | 31 | //faz a busca da função que deve ser executada |
33 | 32 | switch ($funcao) |
34 | 33 | { |
... | ... | @@ -39,24 +38,26 @@ switch ($funcao) |
39 | 38 | break; |
40 | 39 | |
41 | 40 | case "pegaMapas": |
42 | - $cp->set_data(pegaDados('SELECT id_mapa,nome_mapa,publicado_mapa from i3geoadmin_mapas order by ordem_mapa')); | |
43 | - $cp->return_data(); | |
41 | + retornaJSON(pegaDados('SELECT id_mapa,nome_mapa,ordem_mapa from i3geoadmin_mapas order by ordem_mapa')); | |
42 | + exit; | |
44 | 43 | break; |
45 | 44 | |
46 | 45 | case "pegaDadosMapa": |
47 | 46 | $dadosMapa = pegaDados('SELECT * from i3geoadmin_mapas where id_mapa ='.$id_mapa); |
48 | - $cp->set_data(array("mapa"=>$dadosMapa)); | |
49 | - $cp->return_data(); | |
47 | + retornaJSON($dadosMapa); | |
48 | + exit; | |
50 | 49 | break; |
51 | 50 | |
52 | 51 | case "alterarMapa": |
53 | - $cp->set_data(alterarMapa()); | |
54 | - $cp->return_data(); | |
52 | + $novo = alterarMapa(); | |
53 | + $sql = "SELECT * from i3geoadmin_mapas WHERE id_mapa = '".$novo."'"; | |
54 | + retornaJSON(pegaDados($sql)); | |
55 | + exit; | |
55 | 56 | break; |
56 | 57 | |
57 | - case "excluir": | |
58 | - $cp->set_data(excluirMapa()); | |
59 | - $cp->return_data(); | |
58 | + case "excluirMapa": | |
59 | + retornaJSON(excluirMapa()); | |
60 | + exit; | |
60 | 61 | break; |
61 | 62 | |
62 | 63 | case "importarXmlMapas": |
... | ... | @@ -71,19 +72,29 @@ Altera o registro de um mapa |
71 | 72 | */ |
72 | 73 | function alterarMapa() |
73 | 74 | { |
74 | - global $publicado_mapa,$ordem_mapa,$id_mapa,$desc,$ext,$imagem,$outros,$nome,$linkdireto,$temas,$ligados,$perfil; | |
75 | + global $publicado_mapa,$ordem_mapa,$id_mapa,$desc_mapa,$ext_mapa,$imagem_mapa,$outros_mapa,$nome_mapa,$linkdireto_mapa,$temas_mapa,$ligados_mapa,$perfil_mapa; | |
75 | 76 | try |
76 | 77 | { |
77 | - $nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | |
78 | - $desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | |
78 | + //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | |
79 | + //$desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | |
79 | 80 | require_once("conexao.php"); |
81 | + $retorna = ""; | |
80 | 82 | if($id_mapa != "") |
81 | - $dbhw->query("UPDATE i3geoadmin_mapas SET publicado_mapa='$publicado_mapa',ordem_mapa='$ordem_mapa',desc_mapa = '$desc',ext_mapa = '$ext',imagem_mapa = '$imagem',outros_mapa = '$outros',nome_mapa = '$nome', linkdireto_mapa = '$linkdireto',temas_mapa = '$temas',ligados_mapa = '$ligados',perfil_mapa = '$perfil' WHERE id_mapa = $id_mapa"); | |
83 | + { | |
84 | + $dbhw->query("UPDATE i3geoadmin_mapas SET publicado_mapa='$publicado_mapa',ordem_mapa='$ordem_mapa',desc_mapa = '$desc_mapa',ext_mapa = '$ext_mapa',imagem_mapa = '$imagem_mapa',outros_mapa = '$outros_mapa',nome_mapa = '$nome_mapa', linkdireto_mapa = '$linkdireto_mapa',temas_mapa = '$temas_mapa',ligados_mapa = '$ligados_mapa',perfil_mapa = '$perfil_mapa' WHERE id_mapa = $id_mapa"); | |
85 | + $retorna = $id_mapa; | |
86 | + } | |
82 | 87 | else |
83 | - $dbhw->query("INSERT INTO i3geoadmin_mapas (publicado_mapa,ordem_mapa,perfil_mapa,desc_mapa,ext_mapa,imagem_mapa,linkdireto_mapa,outros_mapa,temas_mapa,ligados_mapa,nome_mapa) VALUES ('','','','','','','','','','','$nome')"); | |
88 | + { | |
89 | + $dbhw->query("INSERT INTO i3geoadmin_mapas (publicado_mapa,ordem_mapa,perfil_mapa,desc_mapa,ext_mapa,imagem_mapa,linkdireto_mapa,outros_mapa,temas_mapa,ligados_mapa,nome_mapa) VALUES ('','','','','','','','','','','')"); | |
90 | + $id = $dbh->query("SELECT * FROM i3geoadmin_mapas"); | |
91 | + $id = $id->fetchAll(); | |
92 | + $id = intval($id[count($id)-1]['id_mapa']); | |
93 | + $retorna = $id; | |
94 | + } | |
84 | 95 | $dbhw = null; |
85 | 96 | $dbh = null; |
86 | - return "ok"; | |
97 | + return $retorna; | |
87 | 98 | } |
88 | 99 | catch (PDOException $e) |
89 | 100 | { | ... | ... |
admin/php/menutemas.php
... | ... | @@ -47,6 +47,7 @@ switch ($funcao) |
47 | 47 | case "pegaMenus": |
48 | 48 | $dados = pegaDados('SELECT * from i3geoadmin_menus order by nome_menu'); |
49 | 49 | retornaJSON($dados); |
50 | + exit; | |
50 | 51 | break; |
51 | 52 | |
52 | 53 | case "pegaTags": |
... | ... | @@ -115,8 +116,10 @@ switch ($funcao) |
115 | 116 | break; |
116 | 117 | |
117 | 118 | case "alteraTags": |
118 | - $cp->set_data(alteraTags()); | |
119 | - $cp->return_data(); | |
119 | + $novo = alteraTags(); | |
120 | + $sql = "SELECT * from i3geoadmin_tags WHERE id_tag = '".$novo."'"; | |
121 | + retornaJSON(pegaDados($sql)); | |
122 | + exit; | |
120 | 123 | break; |
121 | 124 | |
122 | 125 | case "alteraPerfis": |
... | ... | @@ -139,12 +142,15 @@ switch ($funcao) |
139 | 142 | } |
140 | 143 | } |
141 | 144 | if($tabela == "tags") |
142 | - {excluiTagTemas($id);$tabela = "i3geoadmin_tags";$coluna = "id_tag";} | |
145 | + { | |
146 | + $tabela = "i3geoadmin_tags"; | |
147 | + $coluna = "id_tag"; | |
148 | + excluiTagTemas($id); | |
149 | + } | |
143 | 150 | if($tabela == "perfis") |
144 | 151 | { |
145 | 152 | $tabela = "i3geoadmin_perfis"; |
146 | 153 | $coluna = "id_perfil"; |
147 | - if($id != "") | |
148 | 154 | excluiPerfil($id); |
149 | 155 | } |
150 | 156 | if($tabela == "subgrupos") |
... | ... | @@ -189,18 +195,13 @@ switch ($funcao) |
189 | 195 | exit; |
190 | 196 | break; |
191 | 197 | } |
192 | -function retornaJSON($obj) | |
193 | -{ | |
194 | - if(extension_loaded('zlib')){ob_start('ob_gzhandler');} | |
195 | - echo json_encode($obj); | |
196 | - if(extension_loaded('zlib')){ob_end_flush();} | |
197 | - exit; | |
198 | -} | |
199 | 198 | function excluiPerfil($id) |
200 | 199 | { |
201 | 200 | require_once("conexao.php"); |
202 | 201 | foreach($dbh->query("select * from i3geoadmin_perfis where perfil = $id") as $row) |
203 | 202 | {$perfil = $row["perfil"];} |
203 | + if($perfil == "") | |
204 | + {return;} | |
204 | 205 | $q = $dbh->query("select * from i3geoadmin_mapas"); |
205 | 206 | foreach($q as $row) |
206 | 207 | { |
... | ... | @@ -270,11 +271,14 @@ function excluiTagTemas($id) |
270 | 271 | require_once("conexao.php"); |
271 | 272 | foreach($dbh->query("select * from i3geoadmin_tags where id_tag = $id") as $row) |
272 | 273 | {$nometag = $row["nome"];} |
273 | - foreach($dbh->query("select * from i3geoadmin_temas") as $row) | |
274 | + if($nometag == ""){return;} | |
275 | + $q = $dbh->query("select * from i3geoadmin_temas"); | |
276 | + foreach($q as $row) | |
274 | 277 | { |
275 | - $ts = $row['tags_tema']; | |
278 | + $t = $row['tags_tema']; | |
276 | 279 | $i = $row['id_tema']; |
277 | - $ts = str_replace($nometag,"",$ts); | |
280 | + $ts = str_replace($nometag,"",$t); | |
281 | + if($t != $ts) | |
278 | 282 | $dbhw->query("UPDATE i3geoadmin_temas SET tags_tema = '$ts' WHERE id_tema = $i"); |
279 | 283 | } |
280 | 284 | } |
... | ... | @@ -385,7 +389,7 @@ function alteraMenus() |
385 | 389 | if($id != "") |
386 | 390 | { |
387 | 391 | $dbhw->query("UPDATE i3geoadmin_menus SET publicado_menu = '$publicado_menu',aberto = '$aberto', nome_menu = '$nome', desc_menu = '$desc', perfil_menu = '$perfil' WHERE id_menu = $id"); |
388 | - $retorna = "ok"; | |
392 | + $retorna = $id; | |
389 | 393 | } |
390 | 394 | else |
391 | 395 | { |
... | ... | @@ -493,7 +497,7 @@ function alteraPerfis() |
493 | 497 | $dbhw->query("UPDATE i3geoadmin_sistemasf SET perfil_funcao = '$ts' WHERE id_funcao = $i"); |
494 | 498 | } |
495 | 499 | } |
496 | - $retorna = "ok"; | |
500 | + $retorna = $id; | |
497 | 501 | } |
498 | 502 | else |
499 | 503 | { |
... | ... | @@ -520,29 +524,42 @@ function alteraTags() |
520 | 524 | $dbh = ""; |
521 | 525 | //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); |
522 | 526 | include("conexao.php"); |
527 | + $retorna = ""; | |
523 | 528 | if($id != "") |
524 | 529 | { |
525 | 530 | if(!verificaDuplicados("select * from i3geoadmin_tags where nome = '$nome'",$dbh)) |
526 | 531 | { |
527 | 532 | $original = ""; |
528 | - foreach($dbh->query("select * from i3geoadmin_tags where id_tag = $id") as $row) | |
533 | + $q = $dbh->query("select * from i3geoadmin_tags where id_tag = $id"); | |
534 | + foreach($q as $row) | |
529 | 535 | {$original = $row["nome"];} |
530 | 536 | $dbhw->query("UPDATE i3geoadmin_tags SET nome = '$nome' WHERE id_tag = $id"); |
531 | 537 | //exclui os registros do tag alterado nos temas |
532 | - foreach($dbh->query("select * from i3geoadmin_temas") as $row) | |
533 | - { | |
534 | - $ts = $row['tags_tema']; | |
535 | - $i = $row['id_tema']; | |
536 | - $ts = str_replace($original,$nome,$ts); | |
537 | - $dbhw->query("UPDATE i3geoadmin_temas SET tags_tema = '$ts' WHERE id_tema = $i"); | |
538 | - } | |
538 | + if($original != "") | |
539 | + { | |
540 | + $q = $dbh->query("select * from i3geoadmin_temas"); | |
541 | + foreach($q as $row) | |
542 | + { | |
543 | + $ts = $row['tags_tema']; | |
544 | + $i = $row['id_tema']; | |
545 | + $ts = str_replace($original,$nome,$ts); | |
546 | + $dbhw->query("UPDATE i3geoadmin_temas SET tags_tema = '$ts' WHERE id_tema = $i"); | |
547 | + } | |
548 | + } | |
539 | 549 | } |
550 | + $retorna = $id; | |
540 | 551 | } |
541 | 552 | else |
542 | - $dbhw->query("INSERT INTO i3geoadmin_tags (nome) VALUES ('$nome')"); | |
553 | + { | |
554 | + $dbhw->query("INSERT INTO i3geoadmin_tags (nome) VALUES ('$nome')"); | |
555 | + $id = $dbh->query("SELECT * FROM i3geoadmin_tags"); | |
556 | + $id = $id->fetchAll(); | |
557 | + $id = intval($id[count($id)-1]['id_tag']); | |
558 | + $retorna = $id; | |
559 | + } | |
543 | 560 | $dbhw = null; |
544 | 561 | $dbh = null; |
545 | - return "ok"; | |
562 | + return $retorna; | |
546 | 563 | } |
547 | 564 | catch (PDOException $e) |
548 | 565 | { |
... | ... | @@ -566,7 +583,7 @@ function alteraGrupos() |
566 | 583 | if($id != "") |
567 | 584 | { |
568 | 585 | $dbhw->query("UPDATE i3geoadmin_grupos SET nome_grupo = '$nome', desc_grupo = '$desc' WHERE id_grupo = $id"); |
569 | - $retorna = "ok"; | |
586 | + $retorna = $id; | |
570 | 587 | } |
571 | 588 | else |
572 | 589 | { |
... | ... | @@ -602,7 +619,7 @@ function alteraSubGrupos() |
602 | 619 | if($id != "") |
603 | 620 | { |
604 | 621 | $dbhw->query("UPDATE i3geoadmin_subgrupos SET nome_subgrupo = '$nome', desc_subgrupo = '$desc' WHERE id_subgrupo = $id"); |
605 | - $retorna = "ok"; | |
622 | + $retorna = $id; | |
606 | 623 | } |
607 | 624 | else |
608 | 625 | { |
... | ... | @@ -639,6 +656,7 @@ function alteraTemas() |
639 | 656 | if($id != "") |
640 | 657 | { |
641 | 658 | $dbhw->query("UPDATE i3geoadmin_temas SET tags_tema='$tags', link_tema='$link', nome_tema ='$nome',desc_tema='$desc',codigo_tema='$codigo',tipoa_tema='$tipoa',download_tema='$download',ogc_tema='$ogc',kml_tema='$kml' WHERE id_tema = $id"); |
659 | + $retorna = $id; | |
642 | 660 | } |
643 | 661 | else |
644 | 662 | { | ... | ... |