Commit 3cb0ebac66ddb27f7dfc3eee7f327f48d50592fa
1 parent
63410653
Exists in
master
and in
7 other branches
--no commit message
Showing
6 changed files
with
663 additions
and
56 deletions
Show diff stats
admin/html/admin.css
... | ... | @@ -57,6 +57,20 @@ input |
57 | 57 | width: 20px; |
58 | 58 | height: 20px; |
59 | 59 | } |
60 | +.sobe | |
61 | +{ | |
62 | + background-image:URL('../imagens/34.png'); | |
63 | + background-repeat: no-repeat; | |
64 | + background-position: 0px 0px; | |
65 | + cursor:pointer; | |
66 | +} | |
67 | +.desce | |
68 | +{ | |
69 | + background-image:URL('../imagens/35.png'); | |
70 | + background-repeat: no-repeat; | |
71 | + background-position: 0px 0px; | |
72 | + cursor:pointer; | |
73 | +} | |
60 | 74 | .mostrar |
61 | 75 | { |
62 | 76 | background-image:URL('../imagens/03.png'); | ... | ... |
284 Bytes
269 Bytes
... | ... | @@ -0,0 +1,449 @@ |
1 | +YAHOO.namespace("example.container"); | |
2 | +function initMenu() | |
3 | +{ | |
4 | + ativaBotaoAdicionaRaiz("../php/atlas.php?funcao=alterarAtlas","adiciona") | |
5 | + core_carregando("ativa"); | |
6 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
7 | + core_pegaPerfis("pegaAtlas()"); | |
8 | +} | |
9 | +function ativaBotaoAdicionaRaiz(sUrl,idBotao) | |
10 | +{ | |
11 | + var adiciona = function() | |
12 | + { | |
13 | + core_carregando("ativa"); | |
14 | + core_carregando(" adicionando um novo registro"); | |
15 | + var callback = | |
16 | + { | |
17 | + success:function(o) | |
18 | + { | |
19 | + try | |
20 | + { | |
21 | + adicionaNosRaiz(YAHOO.lang.JSON.parse(o.responseText),true); | |
22 | + core_carregando("desativa"); | |
23 | + } | |
24 | + catch(e){core_handleFailure(e,o.responseText);} | |
25 | + }, | |
26 | + failure:core_handleFailure, | |
27 | + argument: { foo:"foo", bar:"bar" } | |
28 | + }; | |
29 | + core_makeRequest(sUrl,callback) | |
30 | + }; | |
31 | + //cria o botão de adição de um novo menu | |
32 | + var adiciona = new YAHOO.widget.Button(idBotao,{ onclick: { fn: adiciona } }); | |
33 | +} | |
34 | +function pegaAtlas() | |
35 | +{ | |
36 | + core_pegaDados("buscando atlas...","../php/atlas.php?funcao=pegaAtlas","montaArvore") | |
37 | +} | |
38 | +function montaArvore(dados) | |
39 | +{ | |
40 | + YAHOO.example.treeExample = new function() | |
41 | + { | |
42 | + var currentIconMode; | |
43 | + tree = ""; | |
44 | + function changeIconMode() | |
45 | + { | |
46 | + var newVal = parseInt(this.value); | |
47 | + if (newVal != currentIconMode) | |
48 | + {currentIconMode = newVal;} | |
49 | + buildTree(); | |
50 | + } | |
51 | + function loadNodeData(node, fnLoadComplete) | |
52 | + { | |
53 | + var sUrl = "../php/atlas.php?funcao=pegaPranchas&id_atlas="+node.data.id_atlas; | |
54 | + var callback = | |
55 | + { | |
56 | + success: function(oResponse) | |
57 | + { | |
58 | + var dados = YAHOO.lang.JSON.parse(oResponse.responseText) | |
59 | + adicionaNos(node,dados,false) | |
60 | + oResponse.argument.fnLoadComplete(); | |
61 | + }, | |
62 | + failure: function(oResponse) | |
63 | + { | |
64 | + oResponse.argument.fnLoadComplete(); | |
65 | + }, | |
66 | + argument: | |
67 | + { | |
68 | + "node": node, | |
69 | + "fnLoadComplete": fnLoadComplete | |
70 | + }, | |
71 | + timeout: 7000 | |
72 | + }; | |
73 | + YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); | |
74 | + } | |
75 | + function buildTree() | |
76 | + { | |
77 | + tree = new YAHOO.widget.TreeView("tabela"); | |
78 | + tree.setDynamicLoad(loadNodeData, currentIconMode); | |
79 | + var root = tree.getRoot(); | |
80 | + var tempNode = new YAHOO.widget.TextNode('', root, false); | |
81 | + tempNode.isLeaf = true; | |
82 | + core_carregando("desativa"); | |
83 | + } | |
84 | + buildTree(); | |
85 | + }(); | |
86 | + adicionaNosRaiz(dados) | |
87 | + tree.draw(); | |
88 | +} | |
89 | +function adicionaNosTemas(no,dados,redesenha) | |
90 | +{ | |
91 | + if(!redesenha) | |
92 | + { | |
93 | + var d = {html:"<i>Temas:</i>"} | |
94 | + var tempNode = new YAHOO.widget.HTMLNode(d, no, false,true); | |
95 | + tempNode.isLeaf = true; | |
96 | + } | |
97 | + for (var i=0, j=dados.length; i<j; i++) | |
98 | + { | |
99 | + var conteudo = " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('sobe','tema','"+dados[i].id_tema+"')\" title=sobe src=\"../imagens/34.png\" />" | |
100 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('desce','tema','"+dados[i].id_tema+"')\" title=desce src=\"../imagens/33.png\" />" | |
101 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"excluir('tema','"+dados[i].id_tema+"')\" title=excluir width='10px' heigth='10px' src=\"../imagens/01.png\" />" | |
102 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"editar('tema','"+dados[i].id_tema+"')\" title=editar width='10px' heigth='10px' src=\"../imagens/06.png\" /> <span>"+dados[i].codigo_tema+"</span>" | |
103 | + var d = {html:conteudo,id_tema:dados[i].id_tema,tipo:"tema"} | |
104 | + var tempNode = new YAHOO.widget.HTMLNode(d, no, false,true); | |
105 | + tempNode.isLeaf = true; | |
106 | + } | |
107 | + if(redesenha){tree.draw();} | |
108 | +} | |
109 | +function adicionaNos(no,dados,redesenha) | |
110 | +{ | |
111 | + function temaIconMode() | |
112 | + { | |
113 | + var newVal = parseInt(this.value); | |
114 | + if (newVal != currentIconMode) | |
115 | + {currentIconMode = newVal;} | |
116 | + } | |
117 | + function loadTemasData(node, fnLoadComplete) | |
118 | + { | |
119 | + var sUrl = "../php/atlas.php?funcao=pegaTemas&id_prancha="+node.data.id_prancha; | |
120 | + var callback = | |
121 | + { | |
122 | + success: function(oResponse) | |
123 | + { | |
124 | + var dados = YAHOO.lang.JSON.parse(oResponse.responseText) | |
125 | + adicionaNosTemas(node,dados,false) | |
126 | + oResponse.argument.fnLoadComplete(); | |
127 | + }, | |
128 | + failure: function(oResponse) | |
129 | + { | |
130 | + oResponse.argument.fnLoadComplete(); | |
131 | + }, | |
132 | + argument: | |
133 | + { | |
134 | + "node": node, | |
135 | + "fnLoadComplete": fnLoadComplete | |
136 | + }, | |
137 | + timeout: 7000 | |
138 | + }; | |
139 | + YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); | |
140 | + } | |
141 | + if(!redesenha) | |
142 | + { | |
143 | + var d = {html:"<i>Pranchas:</i>"} | |
144 | + var tempNode = new YAHOO.widget.HTMLNode(d, no, false,true); | |
145 | + tempNode.isLeaf = true; | |
146 | + } | |
147 | + for (var i=0, j=dados.length; i<j; i++) | |
148 | + { | |
149 | + var conteudo = " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('sobe','prancha','"+dados[i].id_prancha+"')\" title=sobe src=\"../imagens/34.png\" />" | |
150 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('desce','prancha','"+dados[i].id_prancha+"')\" title=desce src=\"../imagens/33.png\" />" | |
151 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"excluir('prancha','"+dados[i].id_prancha+"')\" title=excluir width='10px' heigth='10px' src=\"../imagens/01.png\" />" | |
152 | + conteudo += "<img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"adicionarTema('"+dados[i].id_prancha+"')\" title='adiciona tema' width='10px' heigth='10px' src=\"../imagens/05.png\" />" | |
153 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"editar('prancha','"+dados[i].id_prancha+"')\" title=editar width='10px' heigth='10px' src=\"../imagens/06.png\" /> <span>"+dados[i].titulo_prancha+"</span>" | |
154 | + var d = {html:conteudo,id_prancha:dados[i].id_prancha,tipo:"prancha"} | |
155 | + var tempNode = new YAHOO.widget.HTMLNode(d, no, false,true); | |
156 | + //tempNode.isLeaf = true; | |
157 | + tempNode.setDynamicLoad(loadTemasData, temaIconMode); | |
158 | + } | |
159 | + if(redesenha){tree.draw();} | |
160 | +} | |
161 | + | |
162 | +function adicionaNosRaiz(dados,redesenha) | |
163 | +{ | |
164 | + var root = tree.getRoot(); | |
165 | + for (var i=0, j=dados.length; i<j; i++) | |
166 | + { | |
167 | + var conteudo = " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('sobe','atlas','"+dados[i].id_atlas+"')\" title=sobe src=\"../imagens/34.png\" />" | |
168 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('desce','atlas','"+dados[i].id_atlas+"')\" title=desce src=\"../imagens/33.png\" />" | |
169 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:2px\" onclick=\"excluir('atlas','"+dados[i].id_atlas+"')\" title=excluir src=\"../imagens/01.png\" />" | |
170 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:2px\" onclick=\"adicionarPrancha('"+dados[i].id_atlas+"')\" title='adiciona prancha' src=\"../imagens/05.png\" />" | |
171 | + conteudo += " <img style=\"position:relative;cursor:pointer;top:2px\" onclick=\"editar('atlas','"+dados[i].id_atlas+"')\" title=editar src=\"../imagens/06.png\" /><b> <span>"+dados[i].titulo_atlas+"</span>" | |
172 | + var d = {html:conteudo,id_atlas:dados[i].id_atlas,tipo:"atlas"}; | |
173 | + var tempNode = new YAHOO.widget.HTMLNode(d, root, false,true); | |
174 | + } | |
175 | + if(redesenha){tree.draw();} | |
176 | +} | |
177 | +function editar(tipo,id) | |
178 | +{ | |
179 | + core_carregando("ativa"); | |
180 | + core_carregando(" buscando dados"); | |
181 | + var callback = | |
182 | + { | |
183 | + success:function(o) | |
184 | + { | |
185 | + try | |
186 | + { | |
187 | + if(tipo == "atlas") | |
188 | + { | |
189 | + var dados = YAHOO.lang.JSON.parse(o.responseText)[0]; | |
190 | + core_montaEditor("gravaDados('atlas','"+id+"')") | |
191 | + $i("editor_bd").innerHTML = montaDivAtlas(dados) | |
192 | + core_carregando("desativa"); | |
193 | + core_comboPranchas("comboPranchaIni","Epranchadefault_atlas",dados.pranchadefault_atlas,"",id) | |
194 | + } | |
195 | + if(tipo == "prancha") | |
196 | + { | |
197 | + var dados = YAHOO.lang.JSON.parse(o.responseText)[0]; | |
198 | + core_montaEditor("gravaDados('prancha','"+id+"')") | |
199 | + $i("editor_bd").innerHTML = montaDivPrancha(dados) | |
200 | + core_carregando("desativa"); | |
201 | + } | |
202 | + if(tipo == "tema") | |
203 | + { | |
204 | + var dados = YAHOO.lang.JSON.parse(o.responseText)[0]; | |
205 | + core_montaEditor("gravaDados('tema','"+id+"')") | |
206 | + $i("editor_bd").innerHTML = montaDivTema(dados) | |
207 | + core_carregando("desativa"); | |
208 | + core_comboMapfiles("comboTemaIni","Ecodigo_tema",dados.codigo_tema,"",id) | |
209 | + } | |
210 | + core_carregando("desativa"); | |
211 | + } | |
212 | + catch(e){core_handleFailure(e,o.responseText);} | |
213 | + }, | |
214 | + failure:core_handleFailure, | |
215 | + argument: { foo:"foo", bar:"bar" } | |
216 | + }; | |
217 | + if(tipo == "atlas") | |
218 | + {var sUrl = "../php/atlas.php?funcao=pegaDadosAtlas&id_atlas="+id;} | |
219 | + if(tipo == "prancha") | |
220 | + {var sUrl = "../php/atlas.php?funcao=pegaDadosPrancha&id_prancha="+id;} | |
221 | + if(tipo == "tema") | |
222 | + {var sUrl = "../php/atlas.php?funcao=pegaDadosTema&id_tema="+id;} | |
223 | + core_makeRequest(sUrl,callback) | |
224 | +} | |
225 | +function montaDivTema(i) | |
226 | +{ | |
227 | + var param = | |
228 | + { | |
229 | + "linhas":[ | |
230 | + {titulo:"Ordem de desenho:",id:"Eordem_tema",size:"5",value:i.ordem_tema,tipo:"text",div:""} | |
231 | + ] | |
232 | + } | |
233 | + var ins = "" | |
234 | + ins += "<br>Código do tema:<br>" | |
235 | + ins += "<div id=comboTemaIni ></div>" | |
236 | + | |
237 | + ins += core_geraLinhas(param) | |
238 | + ins += "Ligado (ao abrir a prancha, esse tema estará visível)?<br>" | |
239 | + ins += "<select id='Eligado_tema' >" | |
240 | + ins += core_combosimnao(i.ligado_tema) | |
241 | + ins += "</select>" | |
242 | + return(ins) | |
243 | +} | |
244 | +function montaDivPrancha(i) | |
245 | +{ | |
246 | + var param = | |
247 | + { | |
248 | + "linhas":[ | |
249 | + {titulo:"Título:",id:"Etitulo_prancha",size:"50",value:i.titulo_prancha,tipo:"text",div:""}, | |
250 | + {titulo:"(opcional) Descrição:",id:"Edesc_prancha",size:"50",value:i.desc_prancha,tipo:"text",div:""}, | |
251 | + {titulo:"(opcional) Link para o texto que será mostrado na inicialização:",id:"Elink_prancha",size:"50",value:i.link_prancha,tipo:"text",div:""}, | |
252 | + {titulo:"Largura da janela do texto inicial:",id:"Ew_prancha",size:"5",value:i.w_prancha,tipo:"text",div:""}, | |
253 | + {titulo:"Altura:",id:"Eh_prancha",size:"5",value:i.h_prancha,tipo:"text",div:""}, | |
254 | + {titulo:"(opcional) Ícone que será utilizado na apresentação da prancha:",id:"Eicone_prancha",size:"50",value:i.icone_prancha,tipo:"text",div:""}, | |
255 | + {titulo:"Extensão geográfica:",id:"Emapext_prancha",size:"30",value:i.mapext_prancha,tipo:"text",div:""}, | |
256 | + {titulo:"Ordem de apresentação na lista de pranchas:",id:"Eordem_prancha",size:"5",value:i.ordem_prancha,tipo:"text",div:""} | |
257 | + ] | |
258 | + } | |
259 | + var ins = "" | |
260 | + ins += core_geraLinhas(param) | |
261 | + return(ins) | |
262 | +} | |
263 | +function montaDivAtlas(i) | |
264 | +{ | |
265 | + var param = | |
266 | + { | |
267 | + "linhas":[ | |
268 | + {titulo:"Título:",id:"Etitulo_atlas",size:"50",value:i.titulo_atlas,tipo:"text",div:""}, | |
269 | + {titulo:"(opcional) Descrição:",id:"Edesc_atlas",size:"50",value:i.desc_atlas,tipo:"text",div:""}, | |
270 | + {titulo:"(opcional) Link para o texto que será mostrado na inicialização do Atlas:",id:"Elink_atlas",size:"50",value:i.link_atlas,tipo:"text",div:""}, | |
271 | + {titulo:"Largura da janela do texto inicial:",id:"Ew_atlas",size:"5",value:i.w_atlas,tipo:"text",div:""}, | |
272 | + {titulo:"Altura:",id:"Eh_atlas",size:"5",value:i.h_atlas,tipo:"text",div:""}, | |
273 | + {titulo:"(opcional) Mapfile inicial (mapfile que será usado como base para montagem do mapa inicial. Se não for definido, será usado o default do i3geo. Utilize o endereço completo do aquivo mapfile no servidor.):",id:"Ebasemapfile_atlas",size:"50",value:i.basemapfile_atlas,tipo:"text",div:""}, | |
274 | + {titulo:"(opcional) Ícone que será utilizado na montagem da lista de todos os Atlas:",id:"Eicone_atlas",size:"50",value:i.icone_atlas,tipo:"text",div:""}, | |
275 | + {titulo:"(opcional) Template HTML (se não for especificado, será usado o default do i3geo. Utilize o caminho completo do arquivo html no servidor):",id:"Etemplate_atlas",size:"50",value:i.template_atlas,tipo:"text",div:""}, | |
276 | + {titulo:"Ordem de apresentação na lista de atlas:",id:"Eordem_atlas",size:"5",value:i.ordem_atlas,tipo:"text",div:""} | |
277 | + ] | |
278 | + } | |
279 | + var ins = "" | |
280 | + ins += core_geraLinhas(param) | |
281 | + ins += "Prancha inicial (será mostrada quando iniciar o atlas):<br>" | |
282 | + ins += "<div id=comboPranchaIni ></div><br>" | |
283 | + ins += "Tipo da apresentação das guias:<br>" | |
284 | + ins += "<select id='Etipoguias_atlas' />" | |
285 | + ins += "<option value='' >---</option>" | |
286 | + ins += "<option value='automatica' " | |
287 | + if (i.tipoguias_atlas == "automatica"){ins += "selected";} | |
288 | + ins += " >automática</option>" | |
289 | + ins += "<option value='expandida' " | |
290 | + if (i.tipoguias_atlas == "expandida"){ins += "selected";} | |
291 | + ins += " >expandida</option></select><br><br>" | |
292 | + ins += "Publicado (os não publicados são mostrados apenas para os usuários administradores)?<br>" | |
293 | + ins += "<select id='Epublicado_atlas' >" | |
294 | + ins += core_combosimnao(i.publicado_atlas) | |
295 | + ins += "</select>" | |
296 | + return(ins) | |
297 | +} | |
298 | +function sobeDesce(movimento,tipo,id) | |
299 | +{ | |
300 | + if(tipo == "atlas") | |
301 | + { | |
302 | + var no = tree.getNodeByProperty("id_atlas",id) | |
303 | + var movimenta = core_movimentaNo(movimento,no) | |
304 | + } | |
305 | + if(tipo == "prancha") | |
306 | + { | |
307 | + var no = tree.getNodeByProperty("id_prancha",id) | |
308 | + var movimenta = core_movimentaNo(movimento,no) | |
309 | + } | |
310 | + if(tipo == "tema") | |
311 | + { | |
312 | + var no = tree.getNodeByProperty("id_tema",id) | |
313 | + var movimenta = core_movimentaNo(movimento,no) | |
314 | + } | |
315 | + var callback = | |
316 | + { | |
317 | + success: function(oResponse) | |
318 | + {core_carregando("desativa");}, | |
319 | + failure:core_handleFailure, | |
320 | + argument: { foo:"foo", bar:"bar" } | |
321 | + }; | |
322 | + if (movimenta) | |
323 | + { | |
324 | + var sUrl = "../php/atlas.php?funcao=movimentaNo&tipo="+tipo+"&movimento="+movimento+"&id="+id; | |
325 | + core_carregando("ativa"); | |
326 | + core_carregando(" modificando a ordem no banco de dados"); | |
327 | + core_makeRequest(sUrl,callback) | |
328 | + } | |
329 | +} | |
330 | +function excluir(tipo,id) | |
331 | +{ | |
332 | + var mensagem = " excluindo o registro do id= "+id; | |
333 | + if(tipo == "atlas") | |
334 | + { | |
335 | + var no = tree.getNodeByProperty("id_atlas",id) | |
336 | + var sUrl = "../php/atlas.php?funcao=excluirAtlas&id="+id; | |
337 | + } | |
338 | + if(tipo == "prancha") | |
339 | + { | |
340 | + var no = tree.getNodeByProperty("id_prancha",id) | |
341 | + var sUrl = "../php/atlas.php?funcao=excluirPrancha&id="+id; | |
342 | + } | |
343 | + if(tipo == "tema") | |
344 | + { | |
345 | + var no = tree.getNodeByProperty("id_tema",id) | |
346 | + var sUrl = "../php/atlas.php?funcao=excluirTema&id="+id; | |
347 | + } | |
348 | + core_excluiNoTree(sUrl,no,mensagem) | |
349 | +} | |
350 | +function adicionarTema(id) | |
351 | +{ | |
352 | + var mensagem = " adicionando tema..."; | |
353 | + var no = tree.getNodeByProperty("id_prancha",id) | |
354 | + var sUrl = "../php/atlas.php?funcao=alterarTema&id_prancha="+id; | |
355 | + var callback = | |
356 | + { | |
357 | + success: function(oResponse) | |
358 | + { | |
359 | + var dados = YAHOO.lang.JSON.parse(oResponse.responseText) | |
360 | + adicionaNosTemas(no,dados,true) | |
361 | + }, | |
362 | + failure:core_handleFailure, | |
363 | + argument: { foo:"foo", bar:"bar" } | |
364 | + }; | |
365 | + core_makeRequest(sUrl,callback) | |
366 | +} | |
367 | +function adicionarPrancha(id) | |
368 | +{ | |
369 | + var mensagem = " adicionando prancha..."; | |
370 | + var no = tree.getNodeByProperty("id_atlas",id) | |
371 | + var sUrl = "../php/atlas.php?funcao=alterarPrancha&id_atlas="+id; | |
372 | + var callback = | |
373 | + { | |
374 | + success: function(oResponse) | |
375 | + { | |
376 | + var dados = YAHOO.lang.JSON.parse(oResponse.responseText) | |
377 | + adicionaNos(no,dados,true) | |
378 | + }, | |
379 | + failure:core_handleFailure, | |
380 | + argument: { foo:"foo", bar:"bar" } | |
381 | + }; | |
382 | + core_makeRequest(sUrl,callback) | |
383 | +} | |
384 | +function gravaDados(tipo,id) | |
385 | +{ | |
386 | + if(tipo == "atlas") | |
387 | + { | |
388 | + var campos = new Array("publicado_atlas","ordem_atlas","basemapfile_atlas","desc_atlas","h_atlas","w_atlas","icone_atlas","link_atlas","pranchadefault_atlas","template_atlas","tipoguias_atlas","titulo_atlas") | |
389 | + var par = "&id_atlas="+id | |
390 | + var prog = "../php/atlas.php?funcao=alterarAtlas" | |
391 | + } | |
392 | + if(tipo == "prancha") | |
393 | + { | |
394 | + var campos = new Array("ordem_prancha","desc_prancha","h_prancha","icone_prancha","link_prancha","mapext_prancha","titulo_prancha","w_prancha"); | |
395 | + var par = "&id_prancha="+id; | |
396 | + var prog = "../php/atlas.php?funcao=alterarPrancha" | |
397 | + } | |
398 | + if(tipo == "tema") | |
399 | + { | |
400 | + var campos = new Array("codigo_tema","ordem_tema","ligado_tema"); | |
401 | + var par = "&id_tema="+id; | |
402 | + var prog = "../php/atlas.php?funcao=alterarTema" | |
403 | + } | |
404 | + for (i=0;i<campos.length;i++) | |
405 | + {par += "&"+campos[i]+"="+($i("E"+campos[i]).value)} | |
406 | + core_carregando("ativa"); | |
407 | + core_carregando(" gravando o registro do id= "+id); | |
408 | + var sUrl = prog+par; | |
409 | + var callback = | |
410 | + { | |
411 | + success:function(o) | |
412 | + { | |
413 | + try | |
414 | + { | |
415 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
416 | + { | |
417 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem menus vinculados a este tema</span>"); | |
418 | + setTimeout("core_carregando('desativa')",3000) | |
419 | + } | |
420 | + else | |
421 | + { | |
422 | + if(tipo == "atlas") | |
423 | + { | |
424 | + var no = tree.getNodeByProperty("id_atlas",id) | |
425 | + no.getContentEl().getElementsByTagName("span")[0].innerHTML = document.getElementById("Etitulo_atlas").value | |
426 | + } | |
427 | + if(tipo == "prancha") | |
428 | + { | |
429 | + var no = tree.getNodeByProperty("id_prancha",id) | |
430 | + no.getContentEl().getElementsByTagName("span")[0].innerHTML = document.getElementById("Etitulo_prancha").value | |
431 | + } | |
432 | + if(tipo == "tema") | |
433 | + { | |
434 | + var no = tree.getNodeByProperty("id_tema",id) | |
435 | + no.getContentEl().getElementsByTagName("span")[0].innerHTML = document.getElementById("Ecodigo_tema").value | |
436 | + } | |
437 | + core_carregando("desativa"); | |
438 | + } | |
439 | + YAHOO.example.container.panelEditor.destroy(); | |
440 | + YAHOO.example.container.panelEditor = null; | |
441 | + } | |
442 | + catch(e){core_handleFailure(e,o.responseText);} | |
443 | + }, | |
444 | + failure:core_handleFailure, | |
445 | + argument: { foo:"foo", bar:"bar" } | |
446 | + }; | |
447 | + core_makeRequest(sUrl,callback,'POST') | |
448 | +} | |
449 | +YAHOO.util.Event.addListener(window, "load", initMenu); | |
0 | 450 | \ No newline at end of file | ... | ... |
admin/js/core.js
... | ... | @@ -61,6 +61,53 @@ Armazena o objeto com a lista de perfis |
61 | 61 | */ |
62 | 62 | var $perfis = ""; |
63 | 63 | /* |
64 | +Function: core_movimentaNo | |
65 | + | |
66 | +Movimenta um nó para cima ou para baixo na árvore. | |
67 | + | |
68 | +Essa função utiliza uma árvore que deve estar armazenada no objeto tree | |
69 | + | |
70 | +Parameters: | |
71 | + | |
72 | +tipo - sobe|desce | |
73 | + | |
74 | +no - objeto no que será movimentado | |
75 | + | |
76 | +Return: | |
77 | + | |
78 | +true|false - se o movimento ocorreu | |
79 | +*/ | |
80 | +function core_movimentaNo(tipo,no) | |
81 | +{ | |
82 | + var movimenta = false | |
83 | + if(tipo == "sobe") | |
84 | + { | |
85 | + var noanterior = no.previousSibling | |
86 | + if(noanterior) | |
87 | + { | |
88 | + if(noanterior.previousSibling) | |
89 | + { | |
90 | + tree.popNode(no) | |
91 | + no.insertBefore(noanterior) | |
92 | + tree.draw() | |
93 | + var movimenta = true | |
94 | + } | |
95 | + } | |
96 | + } | |
97 | + if(tipo == "desce") | |
98 | + { | |
99 | + var noseguinte = no.nextSibling | |
100 | + if(noseguinte) | |
101 | + { | |
102 | + tree.popNode(no) | |
103 | + no.insertAfter(noseguinte) | |
104 | + tree.draw() | |
105 | + var movimenta = true | |
106 | + } | |
107 | + } | |
108 | + return movimenta; | |
109 | +} | |
110 | +/* | |
64 | 111 | Function: core_handleSuccess |
65 | 112 | |
66 | 113 | Processa o retorno da chamada em ajax quando tiver sucesso. Esta é uma |
... | ... | @@ -130,9 +177,11 @@ sUrl - url que será executada |
130 | 177 | |
131 | 178 | callback - função que processará o retorno |
132 | 179 | */ |
133 | -function core_makeRequest(sUrl,callback) | |
180 | +function core_makeRequest(sUrl,callback,tipo) | |
134 | 181 | { |
135 | - var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); | |
182 | + if(arguments.length == 2) | |
183 | + {var tipo = "GET";} | |
184 | + var request = YAHOO.util.Connect.asyncRequest(tipo, sUrl, callback); | |
136 | 185 | YAHOO.log("Initiating request; tId: " + request.tId + ".", "info", "example"); |
137 | 186 | } |
138 | 187 | /* |
... | ... | @@ -355,6 +404,47 @@ function core_comboPerfis(onde,id,marcar,funcao) |
355 | 404 | $i(onde).innerHTML = ins; |
356 | 405 | } |
357 | 406 | } |
407 | +/* | |
408 | +Function: core_comboPranchas | |
409 | + | |
410 | +Cria um combo para escolha de pranchas de um atlas | |
411 | + | |
412 | +Parameters: | |
413 | + | |
414 | +onde - id do elemento que receberá o combo | |
415 | + | |
416 | +id - id do combo que será criado | |
417 | + | |
418 | +marcar - valor que será marcado como selecionado | |
419 | + | |
420 | +funcao - string com o nome da função que será executada no evento onchange | |
421 | +*/ | |
422 | +function core_comboPranchas(onde,id,marcar,funcao,id_atlas) | |
423 | +{ | |
424 | + var sUrl = "../php/atlas.php?funcao=pegaPranchas&id_atlas="+id_atlas; | |
425 | + var callback = | |
426 | + { | |
427 | + success:function(o) | |
428 | + { | |
429 | + try | |
430 | + { | |
431 | + var valores = YAHOO.lang.JSON.parse(o.responseText); | |
432 | + if(arguments.length == 3) | |
433 | + {var funcao = "";} | |
434 | + if (funcao != "") | |
435 | + {var funcao = "onchange='"+funcao+"'";} | |
436 | + ins = "<select id='"+id+"' "+funcao+" >" | |
437 | + ins += core_comboObjeto(valores,"id_prancha","titulo_prancha",marcar) | |
438 | + ins += "</select></p>" | |
439 | + $i(onde).innerHTML = ins; | |
440 | + } | |
441 | + catch(e){core_handleFailure(e,o.responseText);} | |
442 | + }, | |
443 | + failure:core_handleFailure, | |
444 | + argument: { foo:"foo", bar:"bar" } | |
445 | + }; | |
446 | + core_makeRequest(sUrl,callback) | |
447 | +} | |
358 | 448 | |
359 | 449 | /* |
360 | 450 | function: core_pegaTags | ... | ... |
admin/php/atlas.php
... | ... | @@ -34,71 +34,125 @@ $cp = new cpaint(); |
34 | 34 | switch ($funcao) |
35 | 35 | { |
36 | 36 | case "pegaAtlas": |
37 | - retornaJSON(pegaDados('SELECT id_atlas,titulo_atlas from i3geoadmin_atlas order by ordem_atlas')); | |
38 | - exit; | |
37 | + retornaJSON(pegaDados('SELECT id_atlas,titulo_atlas from i3geoadmin_atlas order by ordem_atlas')); | |
38 | + exit; | |
39 | 39 | break; |
40 | 40 | case "pegaPranchas": |
41 | - retornaJSON(pegaDados("SELECT id_prancha,titulo_prancha from i3geoadmin_atlasp where id_atlas='$id_atlas' order by ordem_prancha")); | |
42 | - exit; | |
41 | + retornaJSON(pegaDados("SELECT id_prancha,titulo_prancha from i3geoadmin_atlasp where id_atlas='$id_atlas' order by ordem_prancha")); | |
42 | + exit; | |
43 | 43 | break; |
44 | - case "alterarAtlas": | |
45 | - $novo = alterarAtlas(); | |
46 | - $sql = "SELECT * from i3geoadmin_atlas WHERE id_atlas = '".$novo."'"; | |
47 | - retornaJSON(pegaDados($sql)); | |
48 | - exit; | |
44 | + case "pegaTemas": | |
45 | + retornaJSON(pegaDados("SELECT * from i3geoadmin_atlast where id_prancha = '$id_prancha' order by ordem_tema")); | |
46 | + exit; | |
49 | 47 | break; |
50 | - case "excluirAtlas": | |
51 | - $tabela = "i3geoadmin_atlas"; | |
52 | - $f = verificaFilhos(); | |
53 | - if(!$f) | |
54 | - retornaJSON(excluirAtlas()); | |
55 | - else | |
56 | - retornaJSON("erro"); | |
57 | - exit; | |
48 | + case "pegaDadosAtlas": | |
49 | + retornaJSON(pegaDados('SELECT * from i3geoadmin_atlas where id_atlas ='.$id_atlas)); | |
50 | + exit; | |
58 | 51 | break; |
59 | - case "excluirPrancha": | |
60 | - $tabela = "i3geoadmin_atlasp"; | |
61 | - $f = verificaFilhos(); | |
62 | - if(!$f) | |
63 | - retornaJSON(excluirPrancha()); | |
64 | - else | |
65 | - retornaJSON("erro"); | |
66 | - exit; | |
52 | + case "pegaDadosPrancha": | |
53 | + retornaJSON(pegaDados('SELECT * from i3geoadmin_atlasp where id_prancha ='.$id_prancha)); | |
54 | + exit; | |
67 | 55 | break; |
68 | - case "alterarPrancha": | |
69 | - $novo = alterarPrancha(); | |
70 | - $sql = "SELECT * from i3geoadmin_atlasp WHERE id_prancha = '".$novo."'"; | |
71 | - retornaJSON(pegaDados($sql)); | |
56 | + case "pegaDadosTema": | |
57 | + retornaJSON(pegaDados("SELECT * from i3geoadmin_atlast where id_tema = '$id_tema'")); | |
58 | + exit; | |
72 | 59 | break; |
73 | - case "pegaTemas": | |
74 | - retornaJSON(pegaDados("SELECT * from i3geoadmin_atlast where id_prancha = '$id_prancha' order by ordem_tema")); | |
75 | - exit; | |
60 | + case "alterarAtlas": | |
61 | + $novo = alterarAtlas(); | |
62 | + $sql = "SELECT * from i3geoadmin_atlas WHERE id_atlas = '".$novo."'"; | |
63 | + retornaJSON(pegaDados($sql)); | |
64 | + exit; | |
65 | + break; | |
66 | + case "alterarPrancha": | |
67 | + $novo = alterarPrancha(); | |
68 | + $sql = "SELECT * from i3geoadmin_atlasp WHERE id_prancha = '".$novo."'"; | |
69 | + retornaJSON(pegaDados($sql)); | |
70 | + exit; | |
76 | 71 | break; |
77 | 72 | case "alterarTema": |
78 | - $novo = alterarTema(); | |
79 | - $sql = "SELECT * from i3geoadmin_atlast WHERE id_tema = '".$novo."'"; | |
80 | - retornaJSON(pegaDados($sql)); | |
73 | + $novo = alterarTema(); | |
74 | + $sql = "SELECT * from i3geoadmin_atlast WHERE id_tema = '".$novo."'"; | |
75 | + retornaJSON(pegaDados($sql)); | |
81 | 76 | break; |
82 | - case "excluirTema": | |
83 | - retornaJSON(excluirTema()); | |
84 | - exit; | |
77 | + case "excluirAtlas": | |
78 | + $tabela = "i3geoadmin_atlas"; | |
79 | + $f = verificaFilhos(); | |
80 | + if(!$f) | |
81 | + retornaJSON(excluirAtlas()); | |
82 | + else | |
83 | + retornaJSON("erro"); | |
84 | + exit; | |
85 | 85 | break; |
86 | - case "pegaDadosAtlas": | |
87 | - retornaJSON(pegaDados('SELECT * from i3geoadmin_atlas where id_atlas ='.$id_atlas)); | |
88 | - exit; | |
86 | + case "excluirPrancha": | |
87 | + $tabela = "i3geoadmin_atlasp"; | |
88 | + $f = verificaFilhos(); | |
89 | + if(!$f) | |
90 | + retornaJSON(excluirPrancha()); | |
91 | + else | |
92 | + retornaJSON("erro"); | |
93 | + exit; | |
89 | 94 | break; |
90 | - | |
91 | - case "pegaDadosPranchas": | |
92 | - $dadosPrancha = pegaDados("SELECT * from i3geoadmin_atlasp where id_atlas ='$id_atlas' and id_prancha = '$id_prancha'"); | |
93 | - $cp->set_data(array("prancha"=>$dadosPrancha)); | |
94 | - $cp->return_data(); | |
95 | + case "excluirTema": | |
96 | + retornaJSON(excluirTema()); | |
97 | + exit; | |
98 | + break; | |
99 | + case "movimentaNo": | |
100 | + movimentaNo(); | |
101 | + retornaJSON("ok"); | |
102 | + exit; | |
95 | 103 | break; |
96 | 104 | |
97 | 105 | case "importarXmlAtlas": |
98 | - $cp->set_data(importarXmlAtlas()); | |
99 | - $cp->return_data(); | |
106 | + $cp->set_data(importarXmlAtlas()); | |
107 | + $cp->return_data(); | |
100 | 108 | break; |
101 | 109 | } |
110 | +function movimentaNo() | |
111 | +{ | |
112 | + global $tipo,$movimento,$id; | |
113 | + if($tipo == "tema") | |
114 | + { | |
115 | + //pega a ordem atual | |
116 | + $ordematual = pegaDados("SELECT ordem_tema from i3geoadmin_atlast where id_tema = '$id'"); | |
117 | + $ordematual = $ordematual[0]["ordem_tema"]; | |
118 | + $posfixo = "tema"; | |
119 | + $tabela = "atlast"; | |
120 | + } | |
121 | + if($tipo == "prancha") | |
122 | + { | |
123 | + //pega a ordem atual | |
124 | + $ordematual = pegaDados("SELECT ordem_prancha from i3geoadmin_atlasp where id_prancha = '$id'"); | |
125 | + $ordematual = $ordematual[0]["ordem_prancha"]; | |
126 | + $posfixo = "prancha"; | |
127 | + $tabela = "atlasp"; | |
128 | + } | |
129 | + if($tipo == "atlas") | |
130 | + { | |
131 | + //pega a ordem atual | |
132 | + $ordematual = pegaDados("SELECT ordem_atlas from i3geoadmin_atlas where id_atlas = '$id'"); | |
133 | + $ordematual = $ordematual[0]["ordem_atlas"]; | |
134 | + $posfixo = "atlas"; | |
135 | + $tabela = "atlas"; | |
136 | + } | |
137 | + include("conexao.php"); | |
138 | + if($movimento == "sobe") | |
139 | + { | |
140 | + $menos = $ordematual - 1; | |
141 | + $dbhw->query("UPDATE i3geoadmin_$tabela SET 'ordem_$posfixo' = $ordematual where ordem_$posfixo = '$menos'"); | |
142 | + $dbhw->query("UPDATE i3geoadmin_$tabela SET 'ordem_$posfixo' = $menos where id_$posfixo = '$id'"); | |
143 | + $dbhw->query("UPDATE i3geoadmin_$tabela SET 'ordem_$posfixo' = (ordem_$posfixo - 1) where ordem_$posfixo < $menos and ordem_$posfixo > 1"); | |
144 | + } | |
145 | + if($movimento == "desce") | |
146 | + { | |
147 | + $mais = $ordematual + 1; | |
148 | + $dbhw->query("UPDATE i3geoadmin_$tabela SET 'ordem_$posfixo' = $ordematual where ordem_$posfixo = '$mais'"); | |
149 | + $dbhw->query("UPDATE i3geoadmin_$tabela SET 'ordem_$posfixo' = $mais where id_$posfixo = '$id'"); | |
150 | + $dbhw->query("UPDATE i3geoadmin_$tabela SET 'ordem_$posfixo' = (ordem_$posfixo + 1) where ordem_$posfixo > $mais and ordem_$posfixo > 1"); | |
151 | + } | |
152 | + $dbhw = null; | |
153 | + $dbh = null; | |
154 | + return "ok"; | |
155 | +} | |
102 | 156 | function dadosAtlas() |
103 | 157 | { |
104 | 158 | global $id_atlas; |
... | ... | @@ -139,11 +193,11 @@ function alterarAtlas() |
139 | 193 | } |
140 | 194 | else |
141 | 195 | { |
142 | - $dbhw->query("INSERT INTO i3geoadmin_atlas (publicado_atlas,ordem_atlas,basemapfile_atlas,desc_atlas,h_atlas,w_atlas,icone_atlas,link_atlas,pranchadefault_atlas,template_atlas,tipoguias_atlas,titulo_atlas) VALUES ('','','','',null,null,'','','','','','')"); | |
196 | + $dbhw->query("INSERT INTO i3geoadmin_atlas (publicado_atlas,ordem_atlas,basemapfile_atlas,desc_atlas,h_atlas,w_atlas,icone_atlas,link_atlas,pranchadefault_atlas,template_atlas,tipoguias_atlas,titulo_atlas) VALUES ('',1,'','',null,null,'','','','','','')"); | |
143 | 197 | $id = $dbhw->query("SELECT id_atlas FROM i3geoadmin_atlas"); |
144 | 198 | $id = $id->fetchAll(); |
145 | 199 | $id = intval($id[count($id)-1]['id_atlas']); |
146 | - $retorna = $id; | |
200 | + $retorna = $id; | |
147 | 201 | } |
148 | 202 | $dbhw = null; |
149 | 203 | $dbh = null; |
... | ... | @@ -164,12 +218,12 @@ function alterarPrancha() |
164 | 218 | include("conexao.php"); |
165 | 219 | if($id_prancha != "") |
166 | 220 | { |
167 | - $dbhw->query("UPDATE i3geoadmin_atlasp SET ordem_prancha='$ordem_prancha', mapext_prancha='$mapext_prancha',desc_prancha='$desc_prancha',h_prancha='$h_prancha',w_prancha='$w_prancha',icone_prancha='$icone_prancha',link_prancha='$link_prancha',titulo_prancha='$titulo_prancha' WHERE id_prancha = $id_prancha and id_atlas='$id_atlas'"); | |
221 | + $dbhw->query("UPDATE i3geoadmin_atlasp SET ordem_prancha='$ordem_prancha', mapext_prancha='$mapext_prancha',desc_prancha='$desc_prancha',h_prancha='$h_prancha',w_prancha='$w_prancha',icone_prancha='$icone_prancha',link_prancha='$link_prancha',titulo_prancha='$titulo_prancha' WHERE id_prancha = '$id_prancha'"); | |
168 | 222 | $retorna = $id_prancha; |
169 | 223 | } |
170 | 224 | else |
171 | 225 | { |
172 | - $dbhw->query("INSERT INTO i3geoadmin_atlasp (ordem_prancha,mapext_prancha,desc_prancha,h_prancha,w_prancha,icone_prancha,link_prancha,titulo_prancha,id_atlas) VALUES ('','','','$h_prancha','$w_prancha','','','$titulo_prancha','$id_atlas')"); | |
226 | + $dbhw->query("INSERT INTO i3geoadmin_atlasp (ordem_prancha,mapext_prancha,desc_prancha,h_prancha,w_prancha,icone_prancha,link_prancha,titulo_prancha,id_atlas) VALUES (1,'','','$h_prancha','$w_prancha','','','$titulo_prancha','$id_atlas')"); | |
173 | 227 | $id = $dbhw->query("SELECT id_prancha FROM i3geoadmin_atlasp"); |
174 | 228 | $id = $id->fetchAll(); |
175 | 229 | $id = intval($id[count($id)-1]['id_prancha']); |
... | ... | @@ -192,12 +246,12 @@ function alterarTema() |
192 | 246 | include("conexao.php"); |
193 | 247 | if($id_tema != "") |
194 | 248 | { |
195 | - $dbhw->query("UPDATE i3geoadmin_atlast SET ordem_tema='$ordem_tema',codigo_tema='$codigo_tema',ligado_tema='$ligado_tema' WHERE id_prancha = $id_prancha and id_tema='$id_tema'"); | |
249 | + $dbhw->query("UPDATE i3geoadmin_atlast SET ordem_tema='$ordem_tema',codigo_tema='$codigo_tema',ligado_tema='$ligado_tema' WHERE id_tema='$id_tema'"); | |
196 | 250 | $retorna = $id_tema; |
197 | 251 | } |
198 | 252 | else |
199 | 253 | { |
200 | - $dbhw->query("INSERT INTO i3geoadmin_atlast (ordem_tema,codigo_tema,ligado_tema,id_prancha) VALUES ('','','','$id_prancha')"); | |
254 | + $dbhw->query("INSERT INTO i3geoadmin_atlast (ordem_tema,codigo_tema,ligado_tema,id_prancha) VALUES (1,'','','$id_prancha')"); | |
201 | 255 | $id = $dbhw->query("SELECT id_tema FROM i3geoadmin_atlast"); |
202 | 256 | $id = $id->fetchAll(); |
203 | 257 | $id = intval($id[count($id)-1]['id_tema']); | ... | ... |