Commit 93b798350da2549ba70272d6dabae21cc6f8eea2
1 parent
c43522f2
Exists in
master
and in
7 other branches
--no commit message
Showing
20 changed files
with
1571 additions
and
269 deletions
Show diff stats
admin/html/admin.css
| @@ -39,6 +39,15 @@ input | @@ -39,6 +39,15 @@ input | ||
| 39 | width: 20px; | 39 | width: 20px; |
| 40 | height: 20px; | 40 | height: 20px; |
| 41 | } | 41 | } |
| 42 | +.mais | ||
| 43 | +{ | ||
| 44 | + background-image:URL('../imagens/05.png'); | ||
| 45 | + background-repeat: no-repeat; | ||
| 46 | + background-position: 0px 0px; | ||
| 47 | + cursor:pointer; | ||
| 48 | + width: 20px; | ||
| 49 | + height: 20px; | ||
| 50 | +} | ||
| 42 | .mostrar | 51 | .mostrar |
| 43 | { | 52 | { |
| 44 | background-image:URL('../imagens/03.png'); | 53 | background-image:URL('../imagens/03.png'); |
| @@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
| 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>Grupos</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/grupos.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 - grupos <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 grupos.<br><br> | ||
| 30 | + Você pode criar vários grupos para poder montar a árvore de temas de cada menu. | ||
| 31 | + Cada grupo é mostrado como nós de um ou mais menus das árvores mostradas na guia de adição de temas do i3geo.<br><br> | ||
| 32 | + A lista de grupos é baseada no banco admin.db e os usuários que não são editores podem | ||
| 33 | + ver apenas os grupos publicados.<br><br> | ||
| 34 | + A lista de IPs dos usuários que podem editar os menu é definida no | ||
| 35 | + arquivo i3geo/ms_configura.php | ||
| 36 | + </div> | ||
| 37 | + <div class="ft"></div> | ||
| 38 | +</div> | ||
| 39 | +<input onclick="adicionaLinha()" type=button id=adiciona value="Adicionar um novo grupo" /> | ||
| 40 | +<br> | ||
| 41 | +<p>Grupos existentes: (clique na célula para editar e salve a linha editada)</p> | ||
| 42 | +<div id="tabela" style="left:-5px;"></div> | ||
| 43 | +</div> | ||
| 44 | +<div id=logajax style="display:block" ></div> | ||
| 45 | +</body> |
admin/html/i3geoadmin_grupos.html
| @@ -1,35 +0,0 @@ | @@ -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 | -</head> | ||
| 9 | -<body> | ||
| 10 | -<div style=width:80%;text-align:center;> | ||
| 11 | -<h1>Administração do i3geo - menu de temas <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 grupos</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 | -</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 grupos do menu de temas | ||
| 25 | - | ||
| 26 | -File: i3geo/admin/i3geoadmin_grupos.htm | ||
| 27 | -*/ | ||
| 28 | -$parametros = { | ||
| 29 | - "simples": [ | ||
| 30 | - { mensagem: "Adicione, altere ou elimine grupos cadastrados",cabeca: "Grupos",variavel:"grupos"} | ||
| 31 | - ]}; | ||
| 32 | -iniciaAdmin() | ||
| 33 | -document.getElementById("aguarde").style.display="none" | ||
| 34 | -</script> | ||
| 35 | -</html> | ||
| 36 | \ No newline at end of file | 0 | \ No newline at end of file |
admin/html/i3geoadmin_subgrupos.html
| @@ -1,36 +0,0 @@ | @@ -1,36 +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 sub-grupos</p> | ||
| 16 | -<p>O menu é baseado no banco admin.db.</p> | ||
| 17 | -<p>A lista de IPs dos usuários que podem editar os arquivos de configuração do i3geo e | ||
| 18 | -dos que podem navegar pelos diretórios do servidor, não são mostradas aqui. Para | ||
| 19 | -alterar essas variáveis, vc deve editar diretamente o arquivo i3geo/ms_configura.php.</p> | ||
| 20 | -</div></div> | ||
| 21 | -<div id=aguarde style="color:red" ><img src="../../imagens/aguarde.gif" /></div> | ||
| 22 | -</body> | ||
| 23 | -<script> | ||
| 24 | -/* | ||
| 25 | -Title: Administração da lista de sub-grupos do menu de temas | ||
| 26 | - | ||
| 27 | -File: i3geo/admin/i3geoadmin_subgrupos.htm | ||
| 28 | -*/ | ||
| 29 | -$parametros = { | ||
| 30 | - "simples": [ | ||
| 31 | - { mensagem: "Adicione, altere ou elimine sub-grupos cadastrados",cabeca: "Sub-grupos",variavel:"subgrupos"} | ||
| 32 | - ]}; | ||
| 33 | -iniciaAdmin() | ||
| 34 | -document.getElementById("aguarde").style.display="none" | ||
| 35 | -</script> | ||
| 36 | -</html> | ||
| 37 | \ No newline at end of file | 0 | \ No newline at end of file |
| @@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
| 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>Temas</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/listatemas.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 - temas <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 temas.<br><br> | ||
| 30 | + Você pode criar vários temas para poder montar a árvore de temas de cada menu. | ||
| 31 | + Cada tema é vínculado a um arquivo mapfile, possuindo um nome e alguns parâmetros, | ||
| 32 | + como possibilidade de download, geração de Web Services, etc.<br><br> | ||
| 33 | + A lista de temas é baseada no banco admin.db.<br><br> | ||
| 34 | + A lista de IPs dos usuários que podem editar os menu é definida no | ||
| 35 | + arquivo i3geo/ms_configura.php | ||
| 36 | + </div> | ||
| 37 | + <div class="ft"></div> | ||
| 38 | +</div> | ||
| 39 | +<input onclick="adicionaLinha()" type=button id=adiciona value="Adicionar um novo tema" /> | ||
| 40 | +<br> | ||
| 41 | +<p>Temas existentes:</p> | ||
| 42 | +<div id="tabela" style="left:-5px;"></div> | ||
| 43 | +</div> | ||
| 44 | +<div id=logajax style="display:block" ></div> | ||
| 45 | +</body> |
| @@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
| 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>Sub-grupos</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/subgrupos.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 - sub-grupos <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 sub-grupos.<br><br> | ||
| 30 | + Você pode criar vários sub-grupos para poder montar a árvore de temas de cada menu. | ||
| 31 | + Cada sub-grupo é mostrado como nós de um ou mais menus das árvores mostradas na guia de adição de temas do i3geo.<br><br> | ||
| 32 | + A lista de sub-grupos é baseada no banco admin.db e os usuários que não são editores podem | ||
| 33 | + ver apenas os sub-grupos publicados.<br><br> | ||
| 34 | + A lista de IPs dos usuários que podem editar os menu é definida no | ||
| 35 | + arquivo i3geo/ms_configura.php | ||
| 36 | + </div> | ||
| 37 | + <div class="ft"></div> | ||
| 38 | +</div> | ||
| 39 | +<input onclick="adicionaLinha()" type=button id=adiciona value="Adicionar um novo sub-grupo" /> | ||
| 40 | +<br> | ||
| 41 | +<p>Sub-grupos existentes: (clique na célula para editar e salve a linha editada)</p> | ||
| 42 | +<div id="tabela" style="left:-5px;"></div> | ||
| 43 | +</div> | ||
| 44 | +<div id=logajax style="display:block" ></div> | ||
| 45 | +</body> |
| @@ -0,0 +1,68 @@ | @@ -0,0 +1,68 @@ | ||
| 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>Menus</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 | +div{color:yellow} | ||
| 17 | + </style> | ||
| 18 | + <script type="text/javascript" src="../js/core.js"></script> | ||
| 19 | +</head> | ||
| 20 | +<body class=" yui-skin-sam"> | ||
| 21 | +<div id=teste >oi</div> | ||
| 22 | +<div >oi</div> | ||
| 23 | +<div >oi</div> | ||
| 24 | +<div >oi</div> | ||
| 25 | +<script> | ||
| 26 | +/* | ||
| 27 | +var s = "ttttt" | ||
| 28 | +alert(YAHOO.lang.isNumber(s)) | ||
| 29 | + | ||
| 30 | +*/ | ||
| 31 | +/* | ||
| 32 | +alert(YAHOO.lang.substitute('Hello {world}', {'world':'earth'})) | ||
| 33 | +var processText = function(key, value) { | ||
| 34 | +return value.toUpperCase(); | ||
| 35 | +}; | ||
| 36 | +alert(YAHOO.lang.substitute('Hello {world}', {'world':'earth'}, processText)) | ||
| 37 | +*/ | ||
| 38 | +/* | ||
| 39 | +var foo = { | ||
| 40 | + count :0, | ||
| 41 | + 'method' : function(data) { | ||
| 42 | + this.count++; | ||
| 43 | + if(this.count == 5) { | ||
| 44 | + timer.cancel(); | ||
| 45 | + } | ||
| 46 | + document.getElementById("teste").innerHTML += this.count; | ||
| 47 | + } | ||
| 48 | +} | ||
| 49 | +var timer = YAHOO.lang.later(100, foo, 'method', [{data:'bar', data2:'zeta'}], true); | ||
| 50 | +*/ | ||
| 51 | +//YAHOO.util.Dom.batch(document.getElementsByTagName("div"),function(d){d.style.color="red";}) | ||
| 52 | +/* | ||
| 53 | + getChildrenBy | ||
| 54 | +Array getChildrenBy ( node , method ) | ||
| 55 | +Returns an array of HTMLElement childNodes that pass the test method. | ||
| 56 | + | ||
| 57 | +Parameters: | ||
| 58 | + node <HTMLElement> The HTMLElement to start from | ||
| 59 | + method <Function> A boolean function used to test children that receives the node being tested as its only argument | ||
| 60 | + | ||
| 61 | +Returns: Array | ||
| 62 | + A static array of HTMLElements | ||
| 63 | + | ||
| 64 | +*/ | ||
| 65 | +alert(YAHOO.util.Dom.getViewportHeight()) //getViewportWidth | ||
| 66 | + | ||
| 67 | +</script> | ||
| 68 | +</body> |
387 Bytes
admin/index.html
| @@ -86,8 +86,8 @@ que por sua vez contém temas.</p> | @@ -86,8 +86,8 @@ que por sua vez contém temas.</p> | ||
| 86 | <tr onclick="abre('html/i3geoadmin_perfis.html')"><td><div class=aplicar ></div></td><td>Editar a lista de perfis</td></tr> | 86 | <tr onclick="abre('html/i3geoadmin_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/i3geoadmin_tags.html')"><td><div class=aplicar ></div></td><td>Editar a lista de tags (palavras-chave)</td></tr> |
| 88 | <tr onclick="abre('html/menus.html')"><td><div class=aplicar ></div></td><td>Editar a lista de menus</td></tr> | 88 | <tr onclick="abre('html/menus.html')"><td><div class=aplicar ></div></td><td>Editar a lista de menus</td></tr> |
| 89 | -<tr onclick="abre('html/i3geoadmin_grupos.html')"><td><div class=aplicar ></div></td><td>Editar a lista de grupos</td></tr> | ||
| 90 | -<tr onclick="abre('html/i3geoadmin_subgrupos.html')"><td><div class=aplicar ></div></td><td>Editar a lista de sub-grupos</td></tr> | 89 | +<tr onclick="abre('html/grupos.html')"><td><div class=aplicar ></div></td><td>Editar a lista de grupos</td></tr> |
| 90 | +<tr onclick="abre('html/subgrupos.html')"><td><div class=aplicar ></div></td><td>Editar a lista de sub-grupos</td></tr> | ||
| 91 | <tr onclick="abre('html/i3geoadmin_temas.html')"><td><div class=aplicar ></div></td><td>Editar a lista de temas</td></tr> | 91 | <tr onclick="abre('html/i3geoadmin_temas.html')"><td><div class=aplicar ></div></td><td>Editar a lista de temas</td></tr> |
| 92 | <tr onclick="abre('html/i3geoadmin_arvore.html')"><td><div class=aplicar ></div></td><td>Editar a árvore dos menus</td></tr> | 92 | <tr onclick="abre('html/i3geoadmin_arvore.html')"><td><div class=aplicar ></div></td><td>Editar a árvore dos menus</td></tr> |
| 93 | <tr onclick="abre('html/i3geoadmin_importarmenu.html')"><td><div class=aplicar ></div></td><td>Importar XML</td></tr> | 93 | <tr onclick="abre('html/i3geoadmin_importarmenu.html')"><td><div class=aplicar ></div></td><td>Importar XML</td></tr> |
admin/js/core.js
| @@ -43,6 +43,19 @@ object - objeto javaScript | @@ -43,6 +43,19 @@ object - objeto javaScript | ||
| 43 | var $i = function(id) | 43 | var $i = function(id) |
| 44 | {return document.getElementById(id);}; | 44 | {return document.getElementById(id);}; |
| 45 | /* | 45 | /* |
| 46 | +Variable: $mapfiles | ||
| 47 | + | ||
| 48 | +Armazena o objeto com a lista de mapfiles | ||
| 49 | +*/ | ||
| 50 | +var $mapfiles = ""; | ||
| 51 | +/* | ||
| 52 | +Variable: $tags | ||
| 53 | + | ||
| 54 | +Armazena o objeto com a lista de tags | ||
| 55 | +*/ | ||
| 56 | +var $tags = ""; | ||
| 57 | + | ||
| 58 | +/* | ||
| 46 | Function: core_handleSuccess | 59 | Function: core_handleSuccess |
| 47 | 60 | ||
| 48 | Processa o retorno da chamada em ajax quando tiver sucesso. Esta é uma | 61 | Processa o retorno da chamada em ajax quando tiver sucesso. Esta é uma |
| @@ -82,7 +95,7 @@ function core_handleFailure(o,texto) | @@ -82,7 +95,7 @@ function core_handleFailure(o,texto) | ||
| 82 | { | 95 | { |
| 83 | //div onde será mostrado o log | 96 | //div onde será mostrado o log |
| 84 | if(!$i('logajax')) | 97 | if(!$i('logajax')) |
| 85 | - {document.body.innerHTML += "<div id=logajax ></div>";} | 98 | + {return;} |
| 86 | log = $i('logajax'); | 99 | log = $i('logajax'); |
| 87 | YAHOO.log("The failure handler was called. tId: " + o.tId + ".", "info", "example"); | 100 | YAHOO.log("The failure handler was called. tId: " + o.tId + ".", "info", "example"); |
| 88 | if(o.responseText !== undefined) | 101 | if(o.responseText !== undefined) |
| @@ -121,8 +134,12 @@ function core_makeRequest(sUrl,callback) | @@ -121,8 +134,12 @@ function core_makeRequest(sUrl,callback) | ||
| 121 | Function: core_carregando | 134 | Function: core_carregando |
| 122 | 135 | ||
| 123 | Mostra uma janela de aguarde | 136 | Mostra uma janela de aguarde |
| 137 | + | ||
| 138 | +Parameters: | ||
| 139 | + | ||
| 140 | +tipo - ativa|desativa|string com uma mensagem | ||
| 124 | */ | 141 | */ |
| 125 | -function core_carregando() | 142 | +function core_carregando(tipo) |
| 126 | { | 143 | { |
| 127 | if (!YAHOO.example.container.wait) | 144 | if (!YAHOO.example.container.wait) |
| 128 | { | 145 | { |
| @@ -131,7 +148,13 @@ function core_carregando() | @@ -131,7 +148,13 @@ function core_carregando() | ||
| 131 | YAHOO.example.container.wait.setBody("<img src=\"../../imagens/aguarde.gif\"/>"); | 148 | YAHOO.example.container.wait.setBody("<img src=\"../../imagens/aguarde.gif\"/>"); |
| 132 | YAHOO.example.container.wait.render(document.body); | 149 | YAHOO.example.container.wait.render(document.body); |
| 133 | } | 150 | } |
| 134 | - YAHOO.example.container.wait.show(); | 151 | + YAHOO.example.container.wait.setBody("<img src=\"../../imagens/aguarde.gif\"/>"); |
| 152 | + if(tipo == "ativa") | ||
| 153 | + {YAHOO.example.container.wait.show();} | ||
| 154 | + if(tipo == "desativa") | ||
| 155 | + {YAHOO.example.container.wait.hide();} | ||
| 156 | + if(tipo != "ativa" && tipo != "desativa") | ||
| 157 | + {YAHOO.example.container.wait.setBody("<img src=\"../../imagens/aguarde.gif\"/> "+tipo);} | ||
| 135 | } | 158 | } |
| 136 | /* | 159 | /* |
| 137 | Function: core_dialogoContinua | 160 | Function: core_dialogoContinua |
| @@ -150,8 +173,6 @@ largura - largura do diálogo em px | @@ -150,8 +173,6 @@ largura - largura do diálogo em px | ||
| 150 | */ | 173 | */ |
| 151 | function core_dialogoContinua(handleYes,handleNo,mensagem,largura) | 174 | function core_dialogoContinua(handleYes,handleNo,mensagem,largura) |
| 152 | { | 175 | { |
| 153 | - if(!$i("dialogoContinua")) | ||
| 154 | - {document.body.innerHTML += "<div id='dialogoContinua'></div>";} | ||
| 155 | // Instantiate the Dialog | 176 | // Instantiate the Dialog |
| 156 | YAHOO.namespace("continua.container"); | 177 | YAHOO.namespace("continua.container"); |
| 157 | YAHOO.continua.container.simpledialog1 = | 178 | YAHOO.continua.container.simpledialog1 = |
| @@ -169,7 +190,7 @@ function core_dialogoContinua(handleYes,handleNo,mensagem,largura) | @@ -169,7 +190,7 @@ function core_dialogoContinua(handleYes,handleNo,mensagem,largura) | ||
| 169 | { text:"Não", handler:handleNo } ] | 190 | { text:"Não", handler:handleNo } ] |
| 170 | } ); | 191 | } ); |
| 171 | YAHOO.continua.container.simpledialog1.setHeader("Tem certeza?"); | 192 | YAHOO.continua.container.simpledialog1.setHeader("Tem certeza?"); |
| 172 | - YAHOO.continua.container.simpledialog1.render("dialogoContinua"); | 193 | + YAHOO.continua.container.simpledialog1.render(document.body); |
| 173 | YAHOO.continua.container.simpledialog1.show(); | 194 | YAHOO.continua.container.simpledialog1.show(); |
| 174 | } | 195 | } |
| 175 | /* | 196 | /* |
| @@ -210,7 +231,7 @@ function core_pegaPerfis(funcao) | @@ -210,7 +231,7 @@ function core_pegaPerfis(funcao) | ||
| 210 | if(arguments.length == 0) | 231 | if(arguments.length == 0) |
| 211 | {var funcao = "";} | 232 | {var funcao = "";} |
| 212 | //pega a lista de perfis | 233 | //pega a lista de perfis |
| 213 | - var sUrl = "../php/menutemas.php?funcao=pegaPerfisYUI"; | 234 | + var sUrl = "../php/menutemas.php?funcao=pegaPerfis"; |
| 214 | var callback = | 235 | var callback = |
| 215 | { | 236 | { |
| 216 | success:function(o) | 237 | success:function(o) |
| @@ -224,14 +245,133 @@ function core_pegaPerfis(funcao) | @@ -224,14 +245,133 @@ function core_pegaPerfis(funcao) | ||
| 224 | if(funcao != "") | 245 | if(funcao != "") |
| 225 | eval(funcao); | 246 | eval(funcao); |
| 226 | } | 247 | } |
| 227 | - catch(e){core_handleFailure(o,o.responseText);} | 248 | + catch(e){core_handleFailure(e,o.responseText);} |
| 228 | }, | 249 | }, |
| 229 | failure:core_handleFailure, | 250 | failure:core_handleFailure, |
| 230 | argument: { foo:"foo", bar:"bar" } | 251 | argument: { foo:"foo", bar:"bar" } |
| 231 | - }; | 252 | + }; |
| 253 | + core_carregando("buscando perfis..."); | ||
| 232 | core_makeRequest(sUrl,callback) | 254 | core_makeRequest(sUrl,callback) |
| 233 | } | 255 | } |
| 234 | /* | 256 | /* |
| 257 | +function: core_pegaMapfiles | ||
| 258 | + | ||
| 259 | +Pega a lista de mapfiles | ||
| 260 | + | ||
| 261 | +Parameters: | ||
| 262 | + | ||
| 263 | +funcao - (opcional) nome da funcao que será executada ao terminar a busca pelos dados | ||
| 264 | +*/ | ||
| 265 | +function core_pegaMapfiles(funcaoM) | ||
| 266 | +{ | ||
| 267 | + if(arguments.length == 0) | ||
| 268 | + {var funcao = "";} | ||
| 269 | + var sUrl = "../php/menutemas.php?funcao=listaMapsTemas"; | ||
| 270 | + var callbackM = | ||
| 271 | + { | ||
| 272 | + success:function(o) | ||
| 273 | + { | ||
| 274 | + try | ||
| 275 | + { | ||
| 276 | + $mapfiles = YAHOO.lang.JSON.parse(o.responseText); | ||
| 277 | + if(funcaoM != "") | ||
| 278 | + eval(funcaoM); | ||
| 279 | + } | ||
| 280 | + catch(e){core_handleFailure(e.responseText);} | ||
| 281 | + }, | ||
| 282 | + failure:core_handleFailure, | ||
| 283 | + argument: { foo:"foo", bar:"bar" } | ||
| 284 | + }; | ||
| 285 | + core_makeRequest(sUrl,callbackM) | ||
| 286 | +} | ||
| 287 | +/* | ||
| 288 | +Function: core_comboMapfiles | ||
| 289 | + | ||
| 290 | +Cria um combo para escolha do mapfile | ||
| 291 | + | ||
| 292 | +Parameters: | ||
| 293 | + | ||
| 294 | +onde - id do elemento que receberá o combo | ||
| 295 | + | ||
| 296 | +id - id do combo que será criado | ||
| 297 | + | ||
| 298 | +marcar - valor que será marcado como selecionado | ||
| 299 | +*/ | ||
| 300 | +function core_comboMapfiles(onde,id,marcar) | ||
| 301 | +{ | ||
| 302 | + if($mapfiles == "") | ||
| 303 | + { | ||
| 304 | + core_pegaMapfiles("core_comboMapfiles('"+onde+"','"+id+"','"+marcar+"')") | ||
| 305 | + } | ||
| 306 | + else | ||
| 307 | + { | ||
| 308 | + ins = "<select id='"+id+"' >" | ||
| 309 | + ins += core_comboObjeto($mapfiles,"","",marcar) | ||
| 310 | + ins += "</select></p>" | ||
| 311 | + $i(onde).innerHTML = ins; | ||
| 312 | + } | ||
| 313 | +} | ||
| 314 | +/* | ||
| 315 | +function: core_pegaTags | ||
| 316 | + | ||
| 317 | +Pega a lista de tags | ||
| 318 | + | ||
| 319 | +Parameters: | ||
| 320 | + | ||
| 321 | +funcao - (opcional) nome da funcao que será executada ao terminar a busca pelos dados | ||
| 322 | +*/ | ||
| 323 | +function core_pegaTags(funcao) | ||
| 324 | +{ | ||
| 325 | + if(arguments.length == 0) | ||
| 326 | + {var funcao = "";} | ||
| 327 | + var sUrl = "../php/menutemas.php?funcao=pegaTags"; | ||
| 328 | + var callback = | ||
| 329 | + { | ||
| 330 | + success:function(o) | ||
| 331 | + { | ||
| 332 | + try | ||
| 333 | + { | ||
| 334 | + $tags = YAHOO.lang.JSON.parse(o.responseText); | ||
| 335 | + if(funcao != "") | ||
| 336 | + eval(funcao); | ||
| 337 | + } | ||
| 338 | + catch(e){core_handleFailure(e,o.responseText);} | ||
| 339 | + }, | ||
| 340 | + failure:core_handleFailure, | ||
| 341 | + argument: { foo:"foo", bar:"bar" } | ||
| 342 | + }; | ||
| 343 | + core_makeRequest(sUrl,callback) | ||
| 344 | +} | ||
| 345 | +/* | ||
| 346 | +Function: core_comboTags | ||
| 347 | + | ||
| 348 | +Cria um combo para escolha de tags | ||
| 349 | + | ||
| 350 | +Parameters: | ||
| 351 | + | ||
| 352 | +onde - id do elemento que receberá o combo | ||
| 353 | + | ||
| 354 | +id - id do combo que será criado | ||
| 355 | + | ||
| 356 | +marcar - valor que será marcado como selecionado | ||
| 357 | + | ||
| 358 | +change - nome da função do evento onchange | ||
| 359 | +*/ | ||
| 360 | +function core_comboTags(onde,id,change) | ||
| 361 | +{ | ||
| 362 | + if($tags == "") | ||
| 363 | + { | ||
| 364 | + core_pegaTags("core_comboTags('"+onde+"','"+id+"','"+change+"')") | ||
| 365 | + } | ||
| 366 | + else | ||
| 367 | + { | ||
| 368 | + ins = "<select onchange=\""+change+"(this.value)\" id='"+id+"' >" | ||
| 369 | + ins += core_comboObjeto($tags,"nome","nome","") | ||
| 370 | + ins += "</select></p>" | ||
| 371 | + $i(onde).innerHTML = ins; | ||
| 372 | + } | ||
| 373 | +} | ||
| 374 | +/* | ||
| 235 | Function: gera uma janela flutuante com opções de escolha baseadas em checkbox | 375 | Function: gera uma janela flutuante com opções de escolha baseadas em checkbox |
| 236 | 376 | ||
| 237 | Parameters: | 377 | Parameters: |
| @@ -243,6 +383,10 @@ textos - array com os nomes de cada checkbox | @@ -243,6 +383,10 @@ textos - array com os nomes de cada checkbox | ||
| 243 | selecionados - array com os valores marcados | 383 | selecionados - array com os valores marcados |
| 244 | 384 | ||
| 245 | target - objeto para receber o resultado | 385 | target - objeto para receber o resultado |
| 386 | + | ||
| 387 | +record - objeto record | ||
| 388 | + | ||
| 389 | +key - chave (nome do item) | ||
| 246 | */ | 390 | */ |
| 247 | function core_menuCheckBox(valores,textos,selecionados,target,record,key) | 391 | function core_menuCheckBox(valores,textos,selecionados,target,record,key) |
| 248 | { | 392 | { |
| @@ -262,8 +406,9 @@ function core_menuCheckBox(valores,textos,selecionados,target,record,key) | @@ -262,8 +406,9 @@ function core_menuCheckBox(valores,textos,selecionados,target,record,key) | ||
| 262 | record.setData(key,ins.toString()); | 406 | record.setData(key,ins.toString()); |
| 263 | } | 407 | } |
| 264 | YAHOO.example.container.panelCK.destroy(); | 408 | YAHOO.example.container.panelCK.destroy(); |
| 409 | + YAHOO.example.container.panelCK = null; | ||
| 265 | }; | 410 | }; |
| 266 | - if(!$i("core_menuCK")) | 411 | + if(!YAHOO.example.container.panelCK) |
| 267 | { | 412 | { |
| 268 | var novoel = document.createElement("div"); | 413 | var novoel = document.createElement("div"); |
| 269 | novoel.id = "core_menuCK"; | 414 | novoel.id = "core_menuCK"; |
| @@ -301,8 +446,54 @@ function core_menuCheckBox(valores,textos,selecionados,target,record,key) | @@ -301,8 +446,54 @@ function core_menuCheckBox(valores,textos,selecionados,target,record,key) | ||
| 301 | YAHOO.example.container.panelCK.moveTo(YAHOO.util.Dom.getX(target),YAHOO.util.Dom.getY(target)); | 446 | YAHOO.example.container.panelCK.moveTo(YAHOO.util.Dom.getX(target),YAHOO.util.Dom.getY(target)); |
| 302 | YAHOO.example.container.panelCK.show(); | 447 | YAHOO.example.container.panelCK.show(); |
| 303 | } | 448 | } |
| 449 | +/* | ||
| 450 | +Function: core_combosimnao | ||
| 451 | + | ||
| 452 | +Retorna os itens option de um combo sim nao | ||
| 453 | +*/ | ||
| 454 | +function core_combosimnao(marcar) | ||
| 455 | +{ | ||
| 456 | + var ins = "<option value='' " | ||
| 457 | + if (marcar == ""){ins += "selected"} | ||
| 458 | + ins += ">---</option>"; | ||
| 459 | + ins += "<option value='SIM' " | ||
| 460 | + if (marcar == "sim" || marcar == "SIM"){ins += "selected"} | ||
| 461 | + ins += ">sim</option>"; | ||
| 462 | + ins += "<option value='NAO' " | ||
| 463 | + if (marcar == "nao" || marcar == "NAO"){ins += "selected"} | ||
| 464 | + ins += ">nao</option>"; | ||
| 465 | + return(ins) | ||
| 466 | +} | ||
| 467 | +/* | ||
| 468 | +Function: core_comboObjeto | ||
| 469 | + | ||
| 470 | +Retorna os itens option de um combo baseado em um objeto json | ||
| 471 | +*/ | ||
| 472 | +function core_comboObjeto(obj,valor,texto,marcar) | ||
| 473 | +{ | ||
| 474 | + var ins = "<option value='' " | ||
| 475 | + ins += ">---</option>"; | ||
| 476 | + for (var k=0;k<obj.length;k++) | ||
| 477 | + { | ||
| 478 | + if(valor != "") | ||
| 479 | + var v = eval("obj[k]."+valor); | ||
| 480 | + else | ||
| 481 | + var v = obj[k]; | ||
| 482 | + if(texto != "") | ||
| 483 | + var t = eval("obj[k]."+texto); | ||
| 484 | + else | ||
| 485 | + var t = obj[k]; | ||
| 486 | + ins += "<option value='"+v+"' " | ||
| 487 | + if (marcar == v){ins += "selected"} | ||
| 488 | + ins += ">"+t+"</option>"; | ||
| 489 | + } | ||
| 490 | + return(ins) | ||
| 491 | +} | ||
| 492 | +// | ||
| 493 | +//carregador de javascript | ||
| 304 | // | 494 | // |
| 305 | //define o local correto dos programas | 495 | //define o local correto dos programas |
| 496 | +// | ||
| 306 | var scriptLocation = ""; | 497 | var scriptLocation = ""; |
| 307 | var scripts = document.getElementsByTagName('script'); | 498 | var scripts = document.getElementsByTagName('script'); |
| 308 | var i = 0; | 499 | var i = 0; |
| @@ -0,0 +1,203 @@ | @@ -0,0 +1,203 @@ | ||
| 1 | +YAHOO.namespace("example.container"); | ||
| 2 | +function initMenu() | ||
| 3 | +{ | ||
| 4 | + ativaBotaoAdicionaGrupo() | ||
| 5 | + core_carregando("ativa"); | ||
| 6 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | ||
| 7 | + core_pegaPerfis("pegaGrupos()"); | ||
| 8 | +} | ||
| 9 | +function ativaBotaoAdicionaGrupo() | ||
| 10 | +{ | ||
| 11 | + var adicionalinha = function() | ||
| 12 | + { | ||
| 13 | + core_carregando("ativa"); | ||
| 14 | + core_carregando(" adicionando um novo registro"); | ||
| 15 | + var sUrl = "../php/menutemas.php?funcao=alteraGrupos"; | ||
| 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 pegaGrupos() | ||
| 36 | +{ | ||
| 37 | + core_carregando("buscando grupos..."); | ||
| 38 | + var sUrl = "../php/menutemas.php?funcao=pegaGrupos"; | ||
| 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>";//onclick='excluiLinha(\""+oRecord.getData("id_menu")+"\",\""+oRecord.getId()+"\")'></div>"; | ||
| 73 | + }; | ||
| 74 | + var myColumnDefs = [ | ||
| 75 | + {key:"excluir",label:"excluir",formatter:formatExclui}, | ||
| 76 | + {label:"salvar",formatter:formatSalva}, | ||
| 77 | + {label:"id",key:"id_grupo", formatter:formatTextoId}, | ||
| 78 | + {label:"nome",resizeable:true,key:"nome_grupo", formatter:formatTexto, editor:"textbox"}, | ||
| 79 | + {label:"descrição",resizeable:true,key:"desc_grupo", formatter:formatTexto, editor:"textbox"} | ||
| 80 | + ]; | ||
| 81 | + myDataSource = new YAHOO.util.DataSource(dados); | ||
| 82 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | ||
| 83 | + myDataSource.responseSchema = | ||
| 84 | + { | ||
| 85 | + fields: ["desc_grupo","id_grupo","nome_grupo"] | ||
| 86 | + }; | ||
| 87 | + myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | ||
| 88 | + // Set up editing flow | ||
| 89 | + myDataTable.highlightEditableCell = function(oArgs) | ||
| 90 | + { | ||
| 91 | + var elCell = oArgs.target; | ||
| 92 | + var column = myDataTable.getColumn(oArgs.target); | ||
| 93 | + //if(column.editor != "null") | ||
| 94 | + if(!YAHOO.lang.isNull(column.editor)) | ||
| 95 | + { | ||
| 96 | + YAHOO.util.Dom.addClass(elCell,'yui-dt-highlighted'); | ||
| 97 | + } | ||
| 98 | + }; | ||
| 99 | + myDataTable.unhighlightEditableCell = function(oArgs) | ||
| 100 | + { | ||
| 101 | + var elCell = oArgs.target; | ||
| 102 | + if(elCell.style.cursor="pointer") | ||
| 103 | + { | ||
| 104 | + YAHOO.util.Dom.removeClass(elCell,'yui-dt-highlighted'); | ||
| 105 | + } | ||
| 106 | + }; | ||
| 107 | + myDataTable.subscribe("cellMouseoverEvent", myDataTable.highlightEditableCell); | ||
| 108 | + myDataTable.subscribe("cellMouseoutEvent", myDataTable.unhighlightEditableCell); | ||
| 109 | + myDataTable.subscribe('cellClickEvent',function(ev) | ||
| 110 | + { | ||
| 111 | + var target = YAHOO.util.Event.getTarget(ev); | ||
| 112 | + var column = this.getColumn(target); | ||
| 113 | + if(YAHOO.example.container.panelCK) | ||
| 114 | + { | ||
| 115 | + YAHOO.example.container.panelCK.destroy(); | ||
| 116 | + YAHOO.example.container.panelCK = null; | ||
| 117 | + } | ||
| 118 | + if (column.key == 'excluir') | ||
| 119 | + { | ||
| 120 | + var record = this.getRecord(target); | ||
| 121 | + excluiLinha(record.getData('id_grupo'),target); | ||
| 122 | + } | ||
| 123 | + else | ||
| 124 | + {this.onEventShowCellEditor(ev);} | ||
| 125 | + }); | ||
| 126 | + // Hook into custom event to customize save-flow of "radio" editor | ||
| 127 | + myDataTable.subscribe("editorUpdateEvent", function(oArgs) | ||
| 128 | + { | ||
| 129 | + if(oArgs.editor.column.key === "active") | ||
| 130 | + { | ||
| 131 | + this.saveCellEditor(); | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + }); | ||
| 135 | + myDataTable.subscribe("editorBlurEvent", function(oArgs) | ||
| 136 | + { | ||
| 137 | + this.cancelCellEditor(); | ||
| 138 | + }); | ||
| 139 | + }; | ||
| 140 | + core_carregando("desativa"); | ||
| 141 | +} | ||
| 142 | +function gravaLinha(row) | ||
| 143 | +{ | ||
| 144 | + var r = myDataTable.getRecordSet().getRecord(row); | ||
| 145 | + var id_grupo = r.getData("id_grupo"); | ||
| 146 | + var nome_grupo = r.getData("nome_grupo"); | ||
| 147 | + var desc_grupo = r.getData("desc_grupo"); | ||
| 148 | + core_carregando("ativa"); | ||
| 149 | + core_carregando(" gravando registro do id= "+id_grupo); | ||
| 150 | + var sUrl = "../php/menutemas.php?funcao=alteraGrupos&nome="+nome_grupo+"&desc="+desc_grupo+"&id="+id_grupo; | ||
| 151 | + var callback = | ||
| 152 | + { | ||
| 153 | + success:function(o) | ||
| 154 | + { | ||
| 155 | + core_carregando("desativa"); | ||
| 156 | + }, | ||
| 157 | + failure:core_handleFailure, | ||
| 158 | + argument: { foo:"foo", bar:"bar" } | ||
| 159 | + }; | ||
| 160 | + core_makeRequest(sUrl,callback) | ||
| 161 | +} | ||
| 162 | +function excluiLinha(id,row) | ||
| 163 | +{ | ||
| 164 | + //dialogo | ||
| 165 | + // Define various event handlers for Dialog | ||
| 166 | + var handleYes = function() { | ||
| 167 | + this.hide(); | ||
| 168 | + core_carregando("ativa"); | ||
| 169 | + core_carregando(" excluindo o registro do id= "+id); | ||
| 170 | + var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=grupos"; | ||
| 171 | + var callback = | ||
| 172 | + { | ||
| 173 | + success:function(o) | ||
| 174 | + { | ||
| 175 | + try | ||
| 176 | + { | ||
| 177 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | ||
| 178 | + { | ||
| 179 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem sub-grupos vinculados a este grupo</span>"); | ||
| 180 | + setTimeout("core_carregando('desativa')",3000) | ||
| 181 | + } | ||
| 182 | + else | ||
| 183 | + { | ||
| 184 | + myDataTable.deleteRow(row); | ||
| 185 | + core_carregando("desativa"); | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + catch(e){core_handleFailure(o,o.responseText);} | ||
| 189 | + }, | ||
| 190 | + failure:core_handleFailure, | ||
| 191 | + argument: { foo:"foo", bar:"bar" } | ||
| 192 | + }; | ||
| 193 | + core_makeRequest(sUrl,callback) | ||
| 194 | + }; | ||
| 195 | + var handleNo = function() | ||
| 196 | + { | ||
| 197 | + this.hide(); | ||
| 198 | + }; | ||
| 199 | + var mensagem = "Exclui o registro?"; | ||
| 200 | + var largura = "300" | ||
| 201 | + core_dialogoContinua(handleYes,handleNo,mensagem,largura) | ||
| 202 | +} | ||
| 203 | +YAHOO.util.Event.addListener(window, "load", initMenu); | ||
| 0 | \ No newline at end of file | 204 | \ No newline at end of file |
| @@ -0,0 +1,333 @@ | @@ -0,0 +1,333 @@ | ||
| 1 | +YAHOO.namespace("example.container"); | ||
| 2 | +function initMenu() | ||
| 3 | +{ | ||
| 4 | + ativaBotaoAdicionaTema() | ||
| 5 | + core_carregando("ativa"); | ||
| 6 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | ||
| 7 | + core_pegaPerfis("pegaTemas()"); | ||
| 8 | +} | ||
| 9 | +function ativaBotaoAdicionaTema() | ||
| 10 | +{ | ||
| 11 | + var adicionalinha = function() | ||
| 12 | + { | ||
| 13 | + core_carregando("ativa"); | ||
| 14 | + core_carregando(" adicionando um novo registro"); | ||
| 15 | + var sUrl = "../php/menutemas.php?funcao=alteraTemas"; | ||
| 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(e,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 pegaTemas() | ||
| 36 | +{ | ||
| 37 | + core_carregando("buscando temas..."); | ||
| 38 | + var sUrl = "../php/menutemas.php?funcao=pegaTemas2"; | ||
| 39 | + var callback = | ||
| 40 | + { | ||
| 41 | + success:function(o) | ||
| 42 | + { | ||
| 43 | + try | ||
| 44 | + {montaTabela(YAHOO.lang.JSON.parse(o.responseText));} | ||
| 45 | + catch(e){core_handleFailure(e,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 formatTextoId = function(elCell, oRecord, oColumn, oData) | ||
| 58 | + { | ||
| 59 | + elCell.innerHTML = "<p>" + oData + "</p>"; | ||
| 60 | + }; | ||
| 61 | + | ||
| 62 | + var formatMais = function(elCell, oRecord, oColumn) | ||
| 63 | + { | ||
| 64 | + elCell.innerHTML = "<div class=mais style='text-align:center' ></div>"; | ||
| 65 | + }; | ||
| 66 | + var formatExclui = function(elCell, oRecord, oColumn) | ||
| 67 | + { | ||
| 68 | + elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>"; | ||
| 69 | + }; | ||
| 70 | + var myColumnDefs = [ | ||
| 71 | + {key:"excluir",label:"excluir",formatter:formatExclui}, | ||
| 72 | + {key:"mais",label:"mais",formatter:formatMais}, | ||
| 73 | + {label:"id",key:"id_tema", formatter:formatTextoId}, | ||
| 74 | + {label:"codigo (mapfile)",key:"codigo_tema", formatter:formatTextoId}, | ||
| 75 | + {label:"nome",key:"nome_tema", formatter:formatTextoId}, | ||
| 76 | + ]; | ||
| 77 | + myDataSource = new YAHOO.util.DataSource(dados); | ||
| 78 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | ||
| 79 | + myDataSource.responseSchema = | ||
| 80 | + { | ||
| 81 | + fields: ["nome_tema","codigo_tema","id_tema"] | ||
| 82 | + }; | ||
| 83 | + myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | ||
| 84 | + // Set up editing flow | ||
| 85 | + myDataTable.subscribe('cellClickEvent',function(ev) | ||
| 86 | + { | ||
| 87 | + var target = YAHOO.util.Event.getTarget(ev); | ||
| 88 | + var column = this.getColumn(target); | ||
| 89 | + if (column.key == 'excluir') | ||
| 90 | + { | ||
| 91 | + var record = this.getRecord(target); | ||
| 92 | + excluiLinha(record.getData('id_tema'),target); | ||
| 93 | + } | ||
| 94 | + if (column.key == 'mais') | ||
| 95 | + { | ||
| 96 | + var record = this.getRecord(target); | ||
| 97 | + core_carregando("ativa"); | ||
| 98 | + core_carregando("buscando dados..."); | ||
| 99 | + $clicouId = record.getData('id_tema'); | ||
| 100 | + $recordid = record.getId(); | ||
| 101 | + var sUrl = "../php/menutemas.php?funcao=pegaTemas&id_tema="+record.getData('id_tema'); | ||
| 102 | + var callback = | ||
| 103 | + { | ||
| 104 | + success:function(o) | ||
| 105 | + { | ||
| 106 | + try | ||
| 107 | + { | ||
| 108 | + montaEditorTema(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | ||
| 109 | + } | ||
| 110 | + catch(e){core_handleFailure(e,o.responseText);} | ||
| 111 | + }, | ||
| 112 | + failure:core_handleFailure, | ||
| 113 | + argument: { foo:"foo", bar:"bar" } | ||
| 114 | + }; | ||
| 115 | + core_makeRequest(sUrl,callback) | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + }); | ||
| 119 | + // Hook into custom event to customize save-flow of "radio" editor | ||
| 120 | + myDataTable.subscribe("editorUpdateEvent", function(oArgs) | ||
| 121 | + { | ||
| 122 | + if(oArgs.editor.column.key === "active") | ||
| 123 | + { | ||
| 124 | + this.saveCellEditor(); | ||
| 125 | + } | ||
| 126 | + }); | ||
| 127 | + myDataTable.subscribe("editorBlurEvent", function(oArgs) | ||
| 128 | + { | ||
| 129 | + this.cancelCellEditor(); | ||
| 130 | + }); | ||
| 131 | + }; | ||
| 132 | + core_carregando("desativa"); | ||
| 133 | +} | ||
| 134 | +function montaEditorTema(dados,id,recordid) | ||
| 135 | +{ | ||
| 136 | + function on_editorCheckBoxChange(p_oEvent) | ||
| 137 | + { | ||
| 138 | + var ins = ""; | ||
| 139 | + if(p_oEvent.newValue.get("value") == "OK") | ||
| 140 | + { | ||
| 141 | + gravaDadosTema(id,recordid); | ||
| 142 | + } | ||
| 143 | + else | ||
| 144 | + { | ||
| 145 | + YAHOO.example.container.panelEditorTema.destroy(); | ||
| 146 | + YAHOO.example.container.panelEditorTema = null; | ||
| 147 | + } | ||
| 148 | + }; | ||
| 149 | + if(!YAHOO.example.container.panelEditorTema) | ||
| 150 | + { | ||
| 151 | + var novoel = document.createElement("div"); | ||
| 152 | + novoel.id = "janela_editor"; | ||
| 153 | + var ins = '<div class="hd">Editor</div>'; | ||
| 154 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | ||
| 155 | + ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>"; | ||
| 156 | + novoel.innerHTML = ins; | ||
| 157 | + document.body.appendChild(novoel); | ||
| 158 | + var editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id", name: "okcancel_checkbox_id", container: "okcancel_checkbox" }); | ||
| 159 | + editorBotoes.addButtons([ | ||
| 160 | + { label: "Salva", value: "OK", checked: false}, | ||
| 161 | + { label: "Cancela", value: "CANCEL", checked: false } | ||
| 162 | + ]); | ||
| 163 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | ||
| 164 | + YAHOO.example.container.panelEditorTema = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:false,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | ||
| 165 | + YAHOO.example.container.panelEditorTema.render(); | ||
| 166 | + } | ||
| 167 | + YAHOO.example.container.panelEditorTema.show(); | ||
| 168 | + //carrega os dados na janela | ||
| 169 | + $i("editor_bd").innerHTML = montaDivTemas(dados[0]) | ||
| 170 | + core_carregando("desativa"); | ||
| 171 | + // | ||
| 172 | + //preenche a div com a lista de tags | ||
| 173 | + // | ||
| 174 | + core_comboTags("comboTags","Etags_tema","registraTag"); | ||
| 175 | + // | ||
| 176 | + //preenche a div com a lista de mapfiles | ||
| 177 | + // | ||
| 178 | + core_comboMapfiles("comboMapfiles","Ecodigo_tema",dados[0].codigo_tema); | ||
| 179 | +} | ||
| 180 | +function registraTag(valor) | ||
| 181 | +{ | ||
| 182 | + var inp = $i("Etags_tema") | ||
| 183 | + var tags = inp.value | ||
| 184 | + if(tags == "") | ||
| 185 | + inp.value = valor | ||
| 186 | + else | ||
| 187 | + inp.value = tags+" "+valor | ||
| 188 | +} | ||
| 189 | +function montaDivTemas(i) | ||
| 190 | +{ | ||
| 191 | + var ins = "" | ||
| 192 | + ins += "<p>Nome do tema:<br>"; | ||
| 193 | + ins += "<input size=50 type=text id=Enome_tema value='"+i.nome_tema+"' /></p>" | ||
| 194 | + | ||
| 195 | + ins += "<p>Mapfile (código do mapfile que será utilizado para criar a camada no i3geo):" | ||
| 196 | + ins += "<div id=comboMapfiles >Buscando...</div>"; | ||
| 197 | + | ||
| 198 | + ins += "<p>Descrição:<br>"; | ||
| 199 | + ins += "<input size=50 type=text id=Edesc_tema value='"+i.desc_tema+"' /></p>" | ||
| 200 | + | ||
| 201 | + ins += "<p>Link para a fonte:<br>"; | ||
| 202 | + ins += "<input size=50 type=text id=Elink_tema value='"+i.link_tema+"' /></p>" | ||
| 203 | + | ||
| 204 | + ins += "<p>Tags (separe com espaço). Você pode digitar novos tags ou pegar da lista abaixo:" | ||
| 205 | + ins += "<input type=text size=50 value='"+i.tags_tema+"' id='Etags_tema' ><br>" | ||
| 206 | + ins += "<div id=comboTags >Buscando...</div>"; | ||
| 207 | + | ||
| 208 | + ins += "<p>Tipo:<br>" | ||
| 209 | + ins += "<select id='Etipo_tema' />" | ||
| 210 | + ins += "<option value='' " | ||
| 211 | + if (i.tipoa_tema == ""){ins += "selected";} | ||
| 212 | + ins += ">Normal</option>" | ||
| 213 | + ins += "<option value='WMS' " | ||
| 214 | + if (i.tipoa_tema == "WMS"){ins += "selected";} | ||
| 215 | + ins += " >WMS<option></select></p>" | ||
| 216 | + | ||
| 217 | + ins += "<p>Permite acesso via WMS/WFS?<br>" | ||
| 218 | + ins += "<select id='Eogc_tema' >" | ||
| 219 | + ins += core_combosimnao(i.ogc_tema) | ||
| 220 | + ins += "</select></p>" | ||
| 221 | + | ||
| 222 | + ins += "<p>Permite o download na aplicação datadownload.htm?<br>" | ||
| 223 | + ins += "<select id='Edownload_tema' >" | ||
| 224 | + ins += core_combosimnao(i.download_tema) | ||
| 225 | + ins += "</select></p>" | ||
| 226 | + | ||
| 227 | + ins += "<p>Permite acesso via kml?<br>" | ||
| 228 | + ins += "<select id='Ekml_tema' >" | ||
| 229 | + ins += core_combosimnao(i.kml_tema) | ||
| 230 | + ins += "</select></p>" | ||
| 231 | + return(ins) | ||
| 232 | +} | ||
| 233 | +function gravaLinha(row) | ||
| 234 | +{ | ||
| 235 | + var r = myDataTable.getRecordSet().getRecord(row); | ||
| 236 | + var id_grupo = r.getData("id_grupo"); | ||
| 237 | + var nome_grupo = r.getData("nome_grupo"); | ||
| 238 | + var desc_grupo = r.getData("desc_grupo"); | ||
| 239 | + core_carregando("ativa"); | ||
| 240 | + core_carregando(" gravando registro do id= "+id_grupo); | ||
| 241 | + var sUrl = "../php/menutemas.php?funcao=alteraGrupos&nome="+nome_grupo+"&desc="+desc_grupo+"&id="+id_grupo; | ||
| 242 | + var callback = | ||
| 243 | + { | ||
| 244 | + success:function(o) | ||
| 245 | + { | ||
| 246 | + core_carregando("desativa"); | ||
| 247 | + }, | ||
| 248 | + failure:core_handleFailure, | ||
| 249 | + argument: { foo:"foo", bar:"bar" } | ||
| 250 | + }; | ||
| 251 | + core_makeRequest(sUrl,callback) | ||
| 252 | +} | ||
| 253 | +function excluiLinha(id,row) | ||
| 254 | +{ | ||
| 255 | + //dialogo | ||
| 256 | + // Define various event handlers for Dialog | ||
| 257 | + var handleYes = function() { | ||
| 258 | + this.hide(); | ||
| 259 | + core_carregando("ativa"); | ||
| 260 | + core_carregando(" excluindo o registro do id= "+id); | ||
| 261 | + var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=temas"; | ||
| 262 | + var callback = | ||
| 263 | + { | ||
| 264 | + success:function(o) | ||
| 265 | + { | ||
| 266 | + try | ||
| 267 | + { | ||
| 268 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | ||
| 269 | + { | ||
| 270 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem menus vinculados a este tema</span>"); | ||
| 271 | + setTimeout("core_carregando('desativa')",3000) | ||
| 272 | + } | ||
| 273 | + else | ||
| 274 | + { | ||
| 275 | + myDataTable.deleteRow(row); | ||
| 276 | + core_carregando("desativa"); | ||
| 277 | + } | ||
| 278 | + } | ||
| 279 | + catch(e){core_handleFailure(e,o.responseText);} | ||
| 280 | + }, | ||
| 281 | + failure:core_handleFailure, | ||
| 282 | + argument: { foo:"foo", bar:"bar" } | ||
| 283 | + }; | ||
| 284 | + core_makeRequest(sUrl,callback) | ||
| 285 | + }; | ||
| 286 | + var handleNo = function() | ||
| 287 | + { | ||
| 288 | + this.hide(); | ||
| 289 | + }; | ||
| 290 | + var mensagem = "Exclui o registro?"; | ||
| 291 | + var largura = "300" | ||
| 292 | + core_dialogoContinua(handleYes,handleNo,mensagem,largura) | ||
| 293 | +} | ||
| 294 | +function gravaDadosTema(id,recordid) | ||
| 295 | +{ | ||
| 296 | + var campos = new Array("nome","codigo","desc","link","tags","tipo","ogc","download","kml") | ||
| 297 | + var par = "" | ||
| 298 | + for (i=0;i<campos.length;i++) | ||
| 299 | + { | ||
| 300 | + par += "&"+campos[i]+"="+($i("E"+campos[i]+"_tema").value) | ||
| 301 | + } | ||
| 302 | + par += "&id="+id | ||
| 303 | + core_carregando("ativa"); | ||
| 304 | + core_carregando(" gravando o registro do id= "+id); | ||
| 305 | + var sUrl = "../php/menutemas.php?funcao=alteraTemas"+par; | ||
| 306 | + var callback = | ||
| 307 | + { | ||
| 308 | + success:function(o) | ||
| 309 | + { | ||
| 310 | + try | ||
| 311 | + { | ||
| 312 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | ||
| 313 | + { | ||
| 314 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem menus vinculados a este tema</span>"); | ||
| 315 | + setTimeout("core_carregando('desativa')",3000) | ||
| 316 | + } | ||
| 317 | + else | ||
| 318 | + { | ||
| 319 | + var rec = myDataTable.getRecordSet().getRecord(recordid); | ||
| 320 | + myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]) | ||
| 321 | + core_carregando("desativa"); | ||
| 322 | + } | ||
| 323 | + YAHOO.example.container.panelEditorTema.destroy(); | ||
| 324 | + YAHOO.example.container.panelEditorTema = null; | ||
| 325 | + } | ||
| 326 | + catch(e){core_handleFailure(e,o.responseText);} | ||
| 327 | + }, | ||
| 328 | + failure:core_handleFailure, | ||
| 329 | + argument: { foo:"foo", bar:"bar" } | ||
| 330 | + }; | ||
| 331 | + core_makeRequest(sUrl,callback) | ||
| 332 | +} | ||
| 333 | +YAHOO.util.Event.addListener(window, "load", initMenu); | ||
| 0 | \ No newline at end of file | 334 | \ No newline at end of file |
admin/js/menu.js
| @@ -2,7 +2,7 @@ YAHOO.namespace("example.container"); | @@ -2,7 +2,7 @@ YAHOO.namespace("example.container"); | ||
| 2 | function initMenu() | 2 | function initMenu() |
| 3 | { | 3 | { |
| 4 | ativaBotaoAdicionaMenu() | 4 | ativaBotaoAdicionaMenu() |
| 5 | - core_carregando(); | 5 | + core_carregando("ativa"); |
| 6 | core_ativaPainelAjuda("ajuda","botaoAjuda"); | 6 | core_ativaPainelAjuda("ajuda","botaoAjuda"); |
| 7 | core_pegaPerfis("pegaMenus()"); | 7 | core_pegaPerfis("pegaMenus()"); |
| 8 | } | 8 | } |
| @@ -10,14 +10,18 @@ function ativaBotaoAdicionaMenu() | @@ -10,14 +10,18 @@ function ativaBotaoAdicionaMenu() | ||
| 10 | { | 10 | { |
| 11 | var adicionalinha = function() | 11 | var adicionalinha = function() |
| 12 | { | 12 | { |
| 13 | - core_carregando(); | 13 | + core_carregando("ativa"); |
| 14 | + core_carregando(" adicionando um novo registro"); | ||
| 14 | var sUrl = "../php/menutemas.php?funcao=alteraMenus&publicado_menu=&perfil=&nome=&desc=&id=&aberto="; | 15 | var sUrl = "../php/menutemas.php?funcao=alteraMenus&publicado_menu=&perfil=&nome=&desc=&id=&aberto="; |
| 15 | var callback = | 16 | var callback = |
| 16 | { | 17 | { |
| 17 | success:function(o) | 18 | success:function(o) |
| 18 | { | 19 | { |
| 19 | try | 20 | try |
| 20 | - {pegaMenus();} | 21 | + { |
| 22 | + myDataTable.addRow(YAHOO.lang.JSON.parse(o.responseText)[0],0); | ||
| 23 | + core_carregando("desativa"); | ||
| 24 | + } | ||
| 21 | catch(e){core_handleFailure(o,o.responseText);} | 25 | catch(e){core_handleFailure(o,o.responseText);} |
| 22 | }, | 26 | }, |
| 23 | failure:core_handleFailure, | 27 | failure:core_handleFailure, |
| @@ -30,7 +34,8 @@ function ativaBotaoAdicionaMenu() | @@ -30,7 +34,8 @@ function ativaBotaoAdicionaMenu() | ||
| 30 | } | 34 | } |
| 31 | function pegaMenus() | 35 | function pegaMenus() |
| 32 | { | 36 | { |
| 33 | - var sUrl = "../php/menutemas.php?funcao=pegaMenusYUI"; | 37 | + core_carregando("buscando menus..."); |
| 38 | + var sUrl = "../php/menutemas.php?funcao=pegaMenus"; | ||
| 34 | var callback = | 39 | var callback = |
| 35 | { | 40 | { |
| 36 | success:function(o) | 41 | success:function(o) |
| @@ -62,7 +67,7 @@ function montaTabela(dados) | @@ -62,7 +67,7 @@ function montaTabela(dados) | ||
| 62 | elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>";//onclick='excluiLinha(\""+oRecord.getData("id_menu")+"\",\""+oRecord.getId()+"\")'></div>"; | 67 | elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>";//onclick='excluiLinha(\""+oRecord.getData("id_menu")+"\",\""+oRecord.getId()+"\")'></div>"; |
| 63 | }; | 68 | }; |
| 64 | var myColumnDefs = [ | 69 | var myColumnDefs = [ |
| 65 | - {key:"excluir",label:"",formatter:formatExclui}, | 70 | + {key:"excluir",label:"excluir",formatter:formatExclui}, |
| 66 | {label:"salvar",formatter:formatSalva}, | 71 | {label:"salvar",formatter:formatSalva}, |
| 67 | {label:"id",key:"id_menu", formatter:formatTexto}, | 72 | {label:"id",key:"id_menu", formatter:formatTexto}, |
| 68 | {label:"nome",resizeable:true,key:"nome_menu", formatter:formatTexto, editor:"textbox"}, | 73 | {label:"nome",resizeable:true,key:"nome_menu", formatter:formatTexto, editor:"textbox"}, |
| @@ -82,18 +87,32 @@ function montaTabela(dados) | @@ -82,18 +87,32 @@ function montaTabela(dados) | ||
| 82 | myDataTable.highlightEditableCell = function(oArgs) | 87 | myDataTable.highlightEditableCell = function(oArgs) |
| 83 | { | 88 | { |
| 84 | var elCell = oArgs.target; | 89 | var elCell = oArgs.target; |
| 85 | - if(YAHOO.util.Dom.hasClass(elCell, "yui-dt-editable")) | 90 | + var column = myDataTable.getColumn(oArgs.target); |
| 91 | + //if(column.editor != "null") | ||
| 92 | + if(!YAHOO.lang.isNull(column.editor)) | ||
| 86 | { | 93 | { |
| 87 | - myDataTable.highlightCell(elCell); | 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'); | ||
| 88 | } | 103 | } |
| 89 | }; | 104 | }; |
| 90 | myDataTable.subscribe("cellMouseoverEvent", myDataTable.highlightEditableCell); | 105 | myDataTable.subscribe("cellMouseoverEvent", myDataTable.highlightEditableCell); |
| 91 | - myDataTable.subscribe("cellMouseoutEvent", myDataTable.onEventUnhighlightCell); | ||
| 92 | - //myDataTable.subscribe("cellClickEvent", myDataTable.onEventShowCellEditor); | 106 | + myDataTable.subscribe("cellMouseoutEvent", myDataTable.unhighlightEditableCell); |
| 93 | myDataTable.subscribe('cellClickEvent',function(ev) | 107 | myDataTable.subscribe('cellClickEvent',function(ev) |
| 94 | { | 108 | { |
| 95 | var target = YAHOO.util.Event.getTarget(ev); | 109 | var target = YAHOO.util.Event.getTarget(ev); |
| 96 | var column = this.getColumn(target); | 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 | + } | ||
| 97 | if (column.key == 'excluir') | 116 | if (column.key == 'excluir') |
| 98 | { | 117 | { |
| 99 | var record = this.getRecord(target); | 118 | var record = this.getRecord(target); |
| @@ -112,7 +131,6 @@ function montaTabela(dados) | @@ -112,7 +131,6 @@ function montaTabela(dados) | ||
| 112 | {this.onEventShowCellEditor(ev);} | 131 | {this.onEventShowCellEditor(ev);} |
| 113 | } | 132 | } |
| 114 | }); | 133 | }); |
| 115 | - | ||
| 116 | // Hook into custom event to customize save-flow of "radio" editor | 134 | // Hook into custom event to customize save-flow of "radio" editor |
| 117 | myDataTable.subscribe("editorUpdateEvent", function(oArgs) | 135 | myDataTable.subscribe("editorUpdateEvent", function(oArgs) |
| 118 | { | 136 | { |
| @@ -127,7 +145,7 @@ function montaTabela(dados) | @@ -127,7 +145,7 @@ function montaTabela(dados) | ||
| 127 | this.cancelCellEditor(); | 145 | this.cancelCellEditor(); |
| 128 | }); | 146 | }); |
| 129 | }; | 147 | }; |
| 130 | - YAHOO.example.container.wait.hide(); | 148 | + core_carregando("desativa"); |
| 131 | } | 149 | } |
| 132 | function gravaLinha(row) | 150 | function gravaLinha(row) |
| 133 | { | 151 | { |
| @@ -138,13 +156,14 @@ function gravaLinha(row) | @@ -138,13 +156,14 @@ function gravaLinha(row) | ||
| 138 | var desc_menu = r.getData("desc_menu") | 156 | var desc_menu = r.getData("desc_menu") |
| 139 | var id_menu = r.getData("id_menu") | 157 | var id_menu = r.getData("id_menu") |
| 140 | var nome_menu = r.getData("nome_menu") | 158 | var nome_menu = r.getData("nome_menu") |
| 141 | - core_carregando(); | 159 | + core_carregando("ativa"); |
| 160 | + core_carregando(" gravando registro do id= "+id_menu); | ||
| 142 | var sUrl = "../php/menutemas.php?funcao=alteraMenus&publicado_menu="+publicado_menu+"&perfil="+perfil_menu+"&nome="+nome_menu+"&desc="+desc_menu+"&id="+id_menu+"&aberto="+aberto+""; | 161 | var sUrl = "../php/menutemas.php?funcao=alteraMenus&publicado_menu="+publicado_menu+"&perfil="+perfil_menu+"&nome="+nome_menu+"&desc="+desc_menu+"&id="+id_menu+"&aberto="+aberto+""; |
| 143 | var callback = | 162 | var callback = |
| 144 | { | 163 | { |
| 145 | success:function(o) | 164 | success:function(o) |
| 146 | { | 165 | { |
| 147 | - YAHOO.example.container.wait.hide(); | 166 | + core_carregando("desativa"); |
| 148 | }, | 167 | }, |
| 149 | failure:core_handleFailure, | 168 | failure:core_handleFailure, |
| 150 | argument: { foo:"foo", bar:"bar" } | 169 | argument: { foo:"foo", bar:"bar" } |
| @@ -157,7 +176,8 @@ function excluiLinha(id,row) | @@ -157,7 +176,8 @@ function excluiLinha(id,row) | ||
| 157 | // Define various event handlers for Dialog | 176 | // Define various event handlers for Dialog |
| 158 | var handleYes = function() { | 177 | var handleYes = function() { |
| 159 | this.hide(); | 178 | this.hide(); |
| 160 | - core_carregando(); | 179 | + core_carregando("ativa"); |
| 180 | + core_carregando(" excluindo o registro do id= "+id); | ||
| 161 | var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=menus"; | 181 | var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=menus"; |
| 162 | var callback = | 182 | var callback = |
| 163 | { | 183 | { |
| @@ -165,8 +185,16 @@ function excluiLinha(id,row) | @@ -165,8 +185,16 @@ function excluiLinha(id,row) | ||
| 165 | { | 185 | { |
| 166 | try | 186 | try |
| 167 | { | 187 | { |
| 168 | - myDataTable.deleteRow(row); | ||
| 169 | - YAHOO.example.container.wait.hide(); | 188 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") |
| 189 | + { | ||
| 190 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem grupos vinculados a este menu</span>"); | ||
| 191 | + setTimeout("core_carregando('desativa')",3000) | ||
| 192 | + } | ||
| 193 | + else | ||
| 194 | + { | ||
| 195 | + myDataTable.deleteRow(row); | ||
| 196 | + core_carregando("desativa"); | ||
| 197 | + } | ||
| 170 | } | 198 | } |
| 171 | catch(e){core_handleFailure(o,o.responseText);} | 199 | catch(e){core_handleFailure(o,o.responseText);} |
| 172 | }, | 200 | }, |
| @@ -0,0 +1,203 @@ | @@ -0,0 +1,203 @@ | ||
| 1 | +YAHOO.namespace("example.container"); | ||
| 2 | +function initMenu() | ||
| 3 | +{ | ||
| 4 | + ativaBotaoAdicionaSubGrupo() | ||
| 5 | + core_carregando("ativa"); | ||
| 6 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | ||
| 7 | + core_pegaPerfis("pegaSubGrupos()"); | ||
| 8 | +} | ||
| 9 | +function ativaBotaoAdicionaSubGrupo() | ||
| 10 | +{ | ||
| 11 | + var adicionalinha = function() | ||
| 12 | + { | ||
| 13 | + core_carregando("ativa"); | ||
| 14 | + core_carregando(" adicionando um novo registro"); | ||
| 15 | + var sUrl = "../php/menutemas.php?funcao=alteraSubGrupos"; | ||
| 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 pegaSubGrupos() | ||
| 36 | +{ | ||
| 37 | + core_carregando("buscando sub-grupos..."); | ||
| 38 | + var sUrl = "../php/menutemas.php?funcao=pegaSubGrupos"; | ||
| 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>";//onclick='excluiLinha(\""+oRecord.getData("id_menu")+"\",\""+oRecord.getId()+"\")'></div>"; | ||
| 73 | + }; | ||
| 74 | + var myColumnDefs = [ | ||
| 75 | + {key:"excluir",label:"excluir",formatter:formatExclui}, | ||
| 76 | + {label:"salvar",formatter:formatSalva}, | ||
| 77 | + {label:"id",key:"id_subgrupo", formatter:formatTextoId}, | ||
| 78 | + {label:"nome",resizeable:true,key:"nome_subgrupo", formatter:formatTexto, editor:"textbox"}, | ||
| 79 | + {label:"descrição",resizeable:true,key:"desc_subgrupo", formatter:formatTexto, editor:"textbox"} | ||
| 80 | + ]; | ||
| 81 | + myDataSource = new YAHOO.util.DataSource(dados); | ||
| 82 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | ||
| 83 | + myDataSource.responseSchema = | ||
| 84 | + { | ||
| 85 | + fields: ["desc_subgrupo","id_subgrupo","nome_subgrupo"] | ||
| 86 | + }; | ||
| 87 | + myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | ||
| 88 | + // Set up editing flow | ||
| 89 | + myDataTable.highlightEditableCell = function(oArgs) | ||
| 90 | + { | ||
| 91 | + var elCell = oArgs.target; | ||
| 92 | + var column = myDataTable.getColumn(oArgs.target); | ||
| 93 | + //if(column.editor != "null") | ||
| 94 | + if(!YAHOO.lang.isNull(column.editor)) | ||
| 95 | + { | ||
| 96 | + YAHOO.util.Dom.addClass(elCell,'yui-dt-highlighted'); | ||
| 97 | + } | ||
| 98 | + }; | ||
| 99 | + myDataTable.unhighlightEditableCell = function(oArgs) | ||
| 100 | + { | ||
| 101 | + var elCell = oArgs.target; | ||
| 102 | + if(elCell.style.cursor="pointer") | ||
| 103 | + { | ||
| 104 | + YAHOO.util.Dom.removeClass(elCell,'yui-dt-highlighted'); | ||
| 105 | + } | ||
| 106 | + }; | ||
| 107 | + myDataTable.subscribe("cellMouseoverEvent", myDataTable.highlightEditableCell); | ||
| 108 | + myDataTable.subscribe("cellMouseoutEvent", myDataTable.unhighlightEditableCell); | ||
| 109 | + myDataTable.subscribe('cellClickEvent',function(ev) | ||
| 110 | + { | ||
| 111 | + var target = YAHOO.util.Event.getTarget(ev); | ||
| 112 | + var column = this.getColumn(target); | ||
| 113 | + if(YAHOO.example.container.panelCK) | ||
| 114 | + { | ||
| 115 | + YAHOO.example.container.panelCK.destroy(); | ||
| 116 | + YAHOO.example.container.panelCK = null; | ||
| 117 | + } | ||
| 118 | + if (column.key == 'excluir') | ||
| 119 | + { | ||
| 120 | + var record = this.getRecord(target); | ||
| 121 | + excluiLinha(record.getData('id_subgrupo'),target); | ||
| 122 | + } | ||
| 123 | + else | ||
| 124 | + {this.onEventShowCellEditor(ev);} | ||
| 125 | + }); | ||
| 126 | + // Hook into custom event to customize save-flow of "radio" editor | ||
| 127 | + myDataTable.subscribe("editorUpdateEvent", function(oArgs) | ||
| 128 | + { | ||
| 129 | + if(oArgs.editor.column.key === "active") | ||
| 130 | + { | ||
| 131 | + this.saveCellEditor(); | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + }); | ||
| 135 | + myDataTable.subscribe("editorBlurEvent", function(oArgs) | ||
| 136 | + { | ||
| 137 | + this.cancelCellEditor(); | ||
| 138 | + }); | ||
| 139 | + }; | ||
| 140 | + core_carregando("desativa"); | ||
| 141 | +} | ||
| 142 | +function gravaLinha(row) | ||
| 143 | +{ | ||
| 144 | + var r = myDataTable.getRecordSet().getRecord(row); | ||
| 145 | + var id_subgrupo = r.getData("id_subgrupo"); | ||
| 146 | + var nome_subgrupo = r.getData("nome_subgrupo"); | ||
| 147 | + var desc_subgrupo = r.getData("desc_subgrupo"); | ||
| 148 | + core_carregando("ativa"); | ||
| 149 | + core_carregando(" gravando registro do id= "+id_subgrupo); | ||
| 150 | + var sUrl = "../php/menutemas.php?funcao=alteraSubGrupos&nome="+nome_subgrupo+"&desc="+desc_subgrupo+"&id="+id_subgrupo; | ||
| 151 | + var callback = | ||
| 152 | + { | ||
| 153 | + success:function(o) | ||
| 154 | + { | ||
| 155 | + core_carregando("desativa"); | ||
| 156 | + }, | ||
| 157 | + failure:core_handleFailure, | ||
| 158 | + argument: { foo:"foo", bar:"bar" } | ||
| 159 | + }; | ||
| 160 | + core_makeRequest(sUrl,callback) | ||
| 161 | +} | ||
| 162 | +function excluiLinha(id,row) | ||
| 163 | +{ | ||
| 164 | + //dialogo | ||
| 165 | + // Define various event handlers for Dialog | ||
| 166 | + var handleYes = function() { | ||
| 167 | + this.hide(); | ||
| 168 | + core_carregando("ativa"); | ||
| 169 | + core_carregando(" excluindo o registro do id= "+id); | ||
| 170 | + var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=subgrupos"; | ||
| 171 | + var callback = | ||
| 172 | + { | ||
| 173 | + success:function(o) | ||
| 174 | + { | ||
| 175 | + try | ||
| 176 | + { | ||
| 177 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | ||
| 178 | + { | ||
| 179 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem temas vinculados a este sub-grupo</span>"); | ||
| 180 | + setTimeout("core_carregando('desativa')",3000) | ||
| 181 | + } | ||
| 182 | + else | ||
| 183 | + { | ||
| 184 | + myDataTable.deleteRow(row); | ||
| 185 | + core_carregando("desativa"); | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + catch(e){core_handleFailure(o,o.responseText);} | ||
| 189 | + }, | ||
| 190 | + failure:core_handleFailure, | ||
| 191 | + argument: { foo:"foo", bar:"bar" } | ||
| 192 | + }; | ||
| 193 | + core_makeRequest(sUrl,callback) | ||
| 194 | + }; | ||
| 195 | + var handleNo = function() | ||
| 196 | + { | ||
| 197 | + this.hide(); | ||
| 198 | + }; | ||
| 199 | + var mensagem = "Exclui o registro?"; | ||
| 200 | + var largura = "300" | ||
| 201 | + core_dialogoContinua(handleYes,handleNo,mensagem,largura) | ||
| 202 | +} | ||
| 203 | +YAHOO.util.Event.addListener(window, "load", initMenu); | ||
| 0 | \ No newline at end of file | 204 | \ No newline at end of file |
admin/php/admin.php
| @@ -156,4 +156,60 @@ function pegaDados($sql) | @@ -156,4 +156,60 @@ function pegaDados($sql) | ||
| 156 | return "Error!: " . $e->getMessage(); | 156 | return "Error!: " . $e->getMessage(); |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| 159 | +/* | ||
| 160 | +Function: verificaFilhos | ||
| 161 | + | ||
| 162 | +Verifica se o pai tem filhos | ||
| 163 | +*/ | ||
| 164 | +function verificaFilhos() | ||
| 165 | +{ | ||
| 166 | + global $tabela,$id; | ||
| 167 | + try | ||
| 168 | + { | ||
| 169 | + $res = false; | ||
| 170 | + if($tabela == "i3geoadmin_n2") | ||
| 171 | + { | ||
| 172 | + $r = pegaDados("select * from i3geoadmin_n3 where id_n2=$id"); | ||
| 173 | + if(count($r) > 0) | ||
| 174 | + $res = true; | ||
| 175 | + } | ||
| 176 | + if($tabela == "i3geoadmin_n1") | ||
| 177 | + { | ||
| 178 | + $r = pegaDados("select * from i3geoadmin_n2 where id_n1=$id"); | ||
| 179 | + if(count($r) > 0) | ||
| 180 | + $res = true; | ||
| 181 | + } | ||
| 182 | + if($tabela == "i3geoadmin_menus") | ||
| 183 | + { | ||
| 184 | + $r = pegaDados("select * from i3geoadmin_n1 where id_menu=$id"); | ||
| 185 | + if(count($r) > 0) | ||
| 186 | + $res = true; | ||
| 187 | + } | ||
| 188 | + if($tabela == "i3geoadmin_grupos") | ||
| 189 | + { | ||
| 190 | + $r = pegaDados("select n1.id_grupo from i3geoadmin_n1 as n1, i3geoadmin_n2 as n2 where n1.id_n1 = n2.id_n1 and n1.id_grupo = '$id'"); | ||
| 191 | + if(count($r) > 0) | ||
| 192 | + $res = true; | ||
| 193 | + } | ||
| 194 | + if($tabela == "i3geoadmin_subgrupos") | ||
| 195 | + { | ||
| 196 | + $r = pegaDados("select n2.id_subgrupo from i3geoadmin_n3 as n3, i3geoadmin_n2 as n2 where n2.id_n2 = n3.id_n3 and n2.id_subgrupo = '$id'"); | ||
| 197 | + if(count($r) > 0) | ||
| 198 | + $res = true; | ||
| 199 | + } | ||
| 200 | + if($tabela == "i3geoadmin_temas") | ||
| 201 | + { | ||
| 202 | + $r = pegaDados("select id_tema from i3geoadmin_n3 where id_tema = '$id'"); | ||
| 203 | + if(count($r) > 0) | ||
| 204 | + $res = true; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + return $res; | ||
| 208 | + } | ||
| 209 | + catch (PDOException $e) | ||
| 210 | + { | ||
| 211 | + return "Error!: " . $e->getMessage(); | ||
| 212 | + } | ||
| 213 | +} | ||
| 214 | + | ||
| 159 | ?> | 215 | ?> |
| 160 | \ No newline at end of file | 216 | \ No newline at end of file |
admin/php/arvore.php
| @@ -88,36 +88,6 @@ switch ($funcao) | @@ -88,36 +88,6 @@ switch ($funcao) | ||
| 88 | break; | 88 | break; |
| 89 | } | 89 | } |
| 90 | /* | 90 | /* |
| 91 | -Function: verificaFilhos | ||
| 92 | - | ||
| 93 | -Verifica se o pai tem filhos | ||
| 94 | -*/ | ||
| 95 | -function verificaFilhos() | ||
| 96 | -{ | ||
| 97 | - global $tabela,$coluna,$id; | ||
| 98 | - try | ||
| 99 | - { | ||
| 100 | - $res = false; | ||
| 101 | - if($tabela == "i3geoadmin_n2") | ||
| 102 | - { | ||
| 103 | - $r = pegaDados("select * from i3geoadmin_n3 where id_n2=$id"); | ||
| 104 | - if(count($r) > 0) | ||
| 105 | - $res = true; | ||
| 106 | - } | ||
| 107 | - if($tabela == "i3geoadmin_n1") | ||
| 108 | - { | ||
| 109 | - $r = pegaDados("select * from i3geoadmin_n2 where id_n1=$id"); | ||
| 110 | - if(count($r) > 0) | ||
| 111 | - $res = true; | ||
| 112 | - } | ||
| 113 | - return $res; | ||
| 114 | - } | ||
| 115 | - catch (PDOException $e) | ||
| 116 | - { | ||
| 117 | - return "Error!: " . $e->getMessage(); | ||
| 118 | - } | ||
| 119 | -} | ||
| 120 | -/* | ||
| 121 | Function: alteraN3 | 91 | Function: alteraN3 |
| 122 | 92 | ||
| 123 | Altera o registro de um nível 3 (temas) | 93 | Altera o registro de um nível 3 (temas) |
admin/php/menutemas.php
| @@ -43,70 +43,75 @@ switch ($funcao) | @@ -43,70 +43,75 @@ switch ($funcao) | ||
| 43 | $cp->set_data(importarXmlMenu()); | 43 | $cp->set_data(importarXmlMenu()); |
| 44 | $cp->return_data(); | 44 | $cp->return_data(); |
| 45 | break; | 45 | break; |
| 46 | - | ||
| 47 | - case "pegaMenus": | ||
| 48 | - $cp->set_data(pegaDados('SELECT * from i3geoadmin_menus order by nome_menu')); | ||
| 49 | - $cp->return_data(); | ||
| 50 | - break; | ||
| 51 | 46 | ||
| 52 | - case "pegaMenusYUI": | 47 | + case "pegaMenus": |
| 53 | $dados = pegaDados('SELECT * from i3geoadmin_menus order by nome_menu'); | 48 | $dados = pegaDados('SELECT * from i3geoadmin_menus order by nome_menu'); |
| 54 | retornaJSON($dados); | 49 | retornaJSON($dados); |
| 55 | break; | 50 | break; |
| 56 | 51 | ||
| 57 | case "pegaTags": | 52 | case "pegaTags": |
| 58 | - $cp->set_data(pegaDados('SELECT * from i3geoadmin_tags order by nome')); | ||
| 59 | - $cp->return_data(); | 53 | + $sql = "SELECT * from i3geoadmin_tags order by nome"; |
| 54 | + retornaJSON(pegaDados($sql)); | ||
| 55 | + exit; | ||
| 60 | break; | 56 | break; |
| 61 | 57 | ||
| 62 | case "pegaPerfis": | 58 | case "pegaPerfis": |
| 63 | - $cp->set_data(pegaDados('SELECT * from i3geoadmin_perfis order by perfil')); | ||
| 64 | - $cp->return_data(); | ||
| 65 | - break; | ||
| 66 | - | ||
| 67 | - case "pegaPerfisYUI": | ||
| 68 | $dados = pegaDados('SELECT * from i3geoadmin_perfis order by perfil'); | 59 | $dados = pegaDados('SELECT * from i3geoadmin_perfis order by perfil'); |
| 69 | retornaJSON($dados); | 60 | retornaJSON($dados); |
| 70 | break; | 61 | break; |
| 71 | 62 | ||
| 72 | case "alteraMenus": | 63 | case "alteraMenus": |
| 73 | - alteraMenus(); | 64 | + $novo = alteraMenus(); |
| 65 | + $sql = "SELECT * from i3geoadmin_menus WHERE id_menu = '".$novo."'"; | ||
| 66 | + retornaJSON(pegaDados($sql)); | ||
| 74 | exit; | 67 | exit; |
| 75 | break; | 68 | break; |
| 76 | 69 | ||
| 77 | case "pegaGrupos": | 70 | case "pegaGrupos": |
| 78 | - $cp->set_data(pegaDados('SELECT * from i3geoadmin_grupos order by nome_grupo')); | ||
| 79 | - $cp->return_data(); | 71 | + $dados = pegaDados('SELECT * from i3geoadmin_grupos order by nome_grupo'); |
| 72 | + retornaJSON($dados); | ||
| 73 | + exit; | ||
| 80 | break; | 74 | break; |
| 81 | - | 75 | + |
| 82 | case "alteraGrupos": | 76 | case "alteraGrupos": |
| 83 | - $cp->set_data(alteraGrupos()); | ||
| 84 | - $cp->return_data(); | 77 | + $novo = alteraGrupos(); |
| 78 | + $sql = "SELECT * from i3geoadmin_grupos WHERE id_grupo = '".$novo."'"; | ||
| 79 | + retornaJSON(pegaDados($sql)); | ||
| 80 | + exit; | ||
| 85 | break; | 81 | break; |
| 86 | - | 82 | + |
| 87 | case "pegaSubGrupos": | 83 | case "pegaSubGrupos": |
| 88 | - $cp->set_data(pegaDados('SELECT * from i3geoadmin_subgrupos order by nome_subgrupo')); | ||
| 89 | - $cp->return_data(); | 84 | + $dados = pegaDados('SELECT * from i3geoadmin_subgrupos order by nome_subgrupo'); |
| 85 | + retornaJSON($dados); | ||
| 86 | + exit; | ||
| 90 | break; | 87 | break; |
| 91 | 88 | ||
| 92 | case "alteraSubGrupos": | 89 | case "alteraSubGrupos": |
| 93 | - $cp->set_data(alteraSubGrupos()); | ||
| 94 | - $cp->return_data(); | 90 | + $novo = alteraSubGrupos(); |
| 91 | + $sql = "SELECT * from i3geoadmin_subgrupos WHERE id_subgrupo = '".$novo."'"; | ||
| 92 | + retornaJSON(pegaDados($sql)); | ||
| 93 | + exit; | ||
| 95 | break; | 94 | break; |
| 96 | 95 | ||
| 97 | case "pegaTemas": | 96 | case "pegaTemas": |
| 98 | - $cp->set_data(pegaTemas()); | ||
| 99 | - $cp->return_data(); | 97 | + $sql = "SELECT * from i3geoadmin_temas where id_tema = '$id_tema'"; |
| 98 | + retornaJSON(pegaDados($sql)); | ||
| 99 | + exit; | ||
| 100 | break; | 100 | break; |
| 101 | 101 | ||
| 102 | case "pegaTemas2": | 102 | case "pegaTemas2": |
| 103 | - $cp->set_data(pegaTemas2()); | ||
| 104 | - $cp->return_data(); | ||
| 105 | - break; | 103 | + retornaJSON(pegaTemas2()); |
| 104 | + exit; | ||
| 105 | + break; | ||
| 106 | 106 | ||
| 107 | case "alteraTemas": | 107 | case "alteraTemas": |
| 108 | - $cp->set_data(alteraTemas()); | ||
| 109 | - $cp->return_data(); | 108 | + //$r será igual ao novo id criado, no caso de inserção de um novo tema |
| 109 | + $r = alteraTemas(); | ||
| 110 | + if($id == "") | ||
| 111 | + retornaJSON($r); | ||
| 112 | + else | ||
| 113 | + retornaJSON(pegaDados("select * from i3geoadmin_temas where id_tema = '$id'")); | ||
| 114 | + exit; | ||
| 110 | break; | 115 | break; |
| 111 | 116 | ||
| 112 | case "alteraTags": | 117 | case "alteraTags": |
| @@ -118,32 +123,63 @@ switch ($funcao) | @@ -118,32 +123,63 @@ switch ($funcao) | ||
| 118 | $cp->set_data(alteraPerfis()); | 123 | $cp->set_data(alteraPerfis()); |
| 119 | $cp->return_data(); | 124 | $cp->return_data(); |
| 120 | break; | 125 | break; |
| 121 | - | ||
| 122 | - case "pegaSubXGrupos": | ||
| 123 | - $cp->set_data(pegaSubXGrupos()); | ||
| 124 | - $cp->return_data(); | ||
| 125 | - break; | ||
| 126 | 126 | ||
| 127 | case "excluirRegistro": | 127 | case "excluirRegistro": |
| 128 | if($tabela == "grupos") | 128 | if($tabela == "grupos") |
| 129 | - {$tabela = "i3geoadmin_grupos";$coluna = "id_grupo";} | 129 | + { |
| 130 | + $tabela = "i3geoadmin_grupos"; | ||
| 131 | + $coluna = "id_grupo"; | ||
| 132 | + $filhos = verificaFilhos(); | ||
| 133 | + if($filhos) | ||
| 134 | + { | ||
| 135 | + retornaJSON("erro"); | ||
| 136 | + exit; | ||
| 137 | + } | ||
| 138 | + } | ||
| 130 | if($tabela == "tags") | 139 | if($tabela == "tags") |
| 131 | {excluiTagTemas($id);$tabela = "i3geoadmin_tags";$coluna = "id_tag";} | 140 | {excluiTagTemas($id);$tabela = "i3geoadmin_tags";$coluna = "id_tag";} |
| 132 | if($tabela == "perfis") | 141 | if($tabela == "perfis") |
| 133 | {excluiPerfil($perfil);$tabela = "i3geoadmin_perfis";$coluna = "perfil";} | 142 | {excluiPerfil($perfil);$tabela = "i3geoadmin_perfis";$coluna = "perfil";} |
| 134 | if($tabela == "subgrupos") | 143 | if($tabela == "subgrupos") |
| 135 | - {$tabela = "i3geoadmin_subgrupos";$coluna = "id_subgrupo";} | 144 | + { |
| 145 | + $tabela = "i3geoadmin_subgrupos"; | ||
| 146 | + $coluna = "id_subgrupo"; | ||
| 147 | + $filhos = verificaFilhos(); | ||
| 148 | + if($filhos) | ||
| 149 | + { | ||
| 150 | + retornaJSON("erro"); | ||
| 151 | + exit; | ||
| 152 | + } | ||
| 153 | + } | ||
| 136 | if($tabela == "temas") | 154 | if($tabela == "temas") |
| 137 | - {$tabela = "i3geoadmin_temas";$coluna = "id_tema";} | 155 | + { |
| 156 | + $tabela = "i3geoadmin_temas"; | ||
| 157 | + $coluna = "id_tema"; | ||
| 158 | + $filhos = verificaFilhos(); | ||
| 159 | + if($filhos) | ||
| 160 | + { | ||
| 161 | + retornaJSON("erro"); | ||
| 162 | + exit; | ||
| 163 | + } | ||
| 164 | + } | ||
| 138 | if($tabela == "menus") | 165 | if($tabela == "menus") |
| 139 | - {$tabela = "i3geoadmin_menus";$coluna = "id_menu";} | ||
| 140 | - $cp->set_data(exclui()); | ||
| 141 | - $cp->return_data(); | 166 | + { |
| 167 | + $tabela = "i3geoadmin_menus"; | ||
| 168 | + $coluna = "id_menu"; | ||
| 169 | + $filhos = verificaFilhos(); | ||
| 170 | + if($filhos) | ||
| 171 | + { | ||
| 172 | + retornaJSON("erro"); | ||
| 173 | + exit; | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + retornaJSON(exclui()); | ||
| 177 | + exit; | ||
| 142 | break; | 178 | break; |
| 143 | 179 | ||
| 144 | case "listaMapsTemas": | 180 | case "listaMapsTemas": |
| 145 | - $cp->set_data(listaMapsTemas()); | ||
| 146 | - $cp->return_data(); | 181 | + retornaJSON(listaMapsTemas()); |
| 182 | + exit; | ||
| 147 | break; | 183 | break; |
| 148 | } | 184 | } |
| 149 | function retornaJSON($obj) | 185 | function retornaJSON($obj) |
| @@ -282,7 +318,7 @@ function pegaTemas2() | @@ -282,7 +318,7 @@ function pegaTemas2() | ||
| 282 | { | 318 | { |
| 283 | $resultado = array(); | 319 | $resultado = array(); |
| 284 | require_once("conexao.php"); | 320 | require_once("conexao.php"); |
| 285 | - foreach($dbh->query('SELECT codigo_tema,nome_tema from i3geoadmin_temas order by nome_tema') as $row) | 321 | + foreach($dbh->query('SELECT codigo_tema,nome_tema,id_tema from i3geoadmin_temas order by nome_tema') as $row) |
| 286 | { | 322 | { |
| 287 | $continua = true; | 323 | $continua = true; |
| 288 | if(isset($filtro) && $filtro != "") | 324 | if(isset($filtro) && $filtro != "") |
| @@ -298,7 +334,8 @@ function pegaTemas2() | @@ -298,7 +334,8 @@ function pegaTemas2() | ||
| 298 | if ($continua) | 334 | if ($continua) |
| 299 | $resultado[] = array( | 335 | $resultado[] = array( |
| 300 | "nome_tema"=>$row['nome_tema'], | 336 | "nome_tema"=>$row['nome_tema'], |
| 301 | - "codigo_tema"=>$row['codigo_tema'] | 337 | + "codigo_tema"=>$row['codigo_tema'], |
| 338 | + "id_tema"=>$row['id_tema'] | ||
| 302 | ); | 339 | ); |
| 303 | } | 340 | } |
| 304 | $dbh = null; | 341 | $dbh = null; |
| @@ -310,26 +347,6 @@ function pegaTemas2() | @@ -310,26 +347,6 @@ function pegaTemas2() | ||
| 310 | return "Error!: " . $e->getMessage(); | 347 | return "Error!: " . $e->getMessage(); |
| 311 | } | 348 | } |
| 312 | } | 349 | } |
| 313 | - | ||
| 314 | -/* | ||
| 315 | -Function: pegaSubXGrupos | ||
| 316 | - | ||
| 317 | -Pega a lista de sub-grupos por grupos | ||
| 318 | -*/ | ||
| 319 | -function pegaSubXGrupos() | ||
| 320 | -{ | ||
| 321 | -/* | ||
| 322 | -select i3geoadmin_subxgrupos.id_subxgrupo,i3geoadmin_grupos.nome_grupo,i3geoadmin_subgrupos.nome_subgrupo | ||
| 323 | -from | ||
| 324 | -i3geoadmin_grupos,i3geoadmin_subgrupos,i3geoadmin_subxgrupos | ||
| 325 | -where | ||
| 326 | -i3geoadmin_grupos.id_grupo = i3geoadmin_subxgrupos.id_grupo | ||
| 327 | -and | ||
| 328 | -i3geoadmin_subgrupos.id_subgrupo = i3geoadmin_subxgrupos.id_subgrupo | ||
| 329 | -order by nome_grupo,nome_subgrupo | ||
| 330 | -*/ | ||
| 331 | - | ||
| 332 | -} | ||
| 333 | /* | 350 | /* |
| 334 | Function: alteraMenus | 351 | Function: alteraMenus |
| 335 | 352 | ||
| @@ -340,18 +357,26 @@ function alteraMenus() | @@ -340,18 +357,26 @@ function alteraMenus() | ||
| 340 | global $nome,$desc,$id,$aberto,$perfil,$publicado_menu; | 357 | global $nome,$desc,$id,$aberto,$perfil,$publicado_menu; |
| 341 | try | 358 | try |
| 342 | { | 359 | { |
| 343 | - $nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | ||
| 344 | - $desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | 360 | + //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); |
| 361 | + //$desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | ||
| 362 | + $retorna = ""; | ||
| 345 | include("conexao.php"); | 363 | include("conexao.php"); |
| 346 | if($id != "") | 364 | if($id != "") |
| 347 | { | 365 | { |
| 348 | $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"); | 366 | $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"); |
| 367 | + $retorna = "ok"; | ||
| 349 | } | 368 | } |
| 350 | else | 369 | else |
| 351 | - $dbhw->query("INSERT INTO i3geoadmin_menus (publicado_menu, nome_menu, desc_menu, aberto, perfil_menu) VALUES ('','', '','SIM','')"); | 370 | + { |
| 371 | + $dbhw->query("INSERT INTO i3geoadmin_menus (publicado_menu, nome_menu, desc_menu, aberto, perfil_menu) VALUES ('','', '','SIM','')"); | ||
| 372 | + $id_menu = $dbhw->query("SELECT * FROM i3geoadmin_menus"); | ||
| 373 | + $id_menu = $id_menu->fetchAll(); | ||
| 374 | + $id_menu = intval($id_menu[count($id_menu)-1]['id_menu']); | ||
| 375 | + $retorna = $id_menu; | ||
| 376 | + } | ||
| 352 | $dbhw = null; | 377 | $dbhw = null; |
| 353 | $dbh = null; | 378 | $dbh = null; |
| 354 | - return "ok"; | 379 | + return $retorna; |
| 355 | } | 380 | } |
| 356 | catch (PDOException $e) | 381 | catch (PDOException $e) |
| 357 | { | 382 | { |
| @@ -448,7 +473,7 @@ function alteraTags() | @@ -448,7 +473,7 @@ function alteraTags() | ||
| 448 | try | 473 | try |
| 449 | { | 474 | { |
| 450 | $dbh = ""; | 475 | $dbh = ""; |
| 451 | - $nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | 476 | + //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); |
| 452 | include("conexao.php"); | 477 | include("conexao.php"); |
| 453 | if($id != "") | 478 | if($id != "") |
| 454 | { | 479 | { |
| @@ -489,18 +514,26 @@ function alteraGrupos() | @@ -489,18 +514,26 @@ function alteraGrupos() | ||
| 489 | global $nome,$desc,$id; | 514 | global $nome,$desc,$id; |
| 490 | try | 515 | try |
| 491 | { | 516 | { |
| 492 | - $nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | ||
| 493 | - $desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | 517 | + //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); |
| 518 | + //$desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | ||
| 494 | include("conexao.php"); | 519 | include("conexao.php"); |
| 520 | + $retorna = ""; | ||
| 495 | if($id != "") | 521 | if($id != "") |
| 496 | { | 522 | { |
| 497 | $dbhw->query("UPDATE i3geoadmin_grupos SET nome_grupo = '$nome', desc_grupo = '$desc' WHERE id_grupo = $id"); | 523 | $dbhw->query("UPDATE i3geoadmin_grupos SET nome_grupo = '$nome', desc_grupo = '$desc' WHERE id_grupo = $id"); |
| 524 | + $retorna = "ok"; | ||
| 498 | } | 525 | } |
| 499 | else | 526 | else |
| 500 | - $dbhw->query("INSERT INTO i3geoadmin_grupos (nome_grupo, desc_grupo) VALUES ('', '')"); | 527 | + { |
| 528 | + $dbhw->query("INSERT INTO i3geoadmin_grupos (nome_grupo, desc_grupo) VALUES ('', '')"); | ||
| 529 | + $id_grupo = $dbh->query("SELECT * FROM i3geoadmin_grupos"); | ||
| 530 | + $id_grupo = $id_grupo->fetchAll(); | ||
| 531 | + $id_grupo = intval($id_grupo[count($id_grupo)-1]['id_grupo']); | ||
| 532 | + $retorna = $id_grupo; | ||
| 533 | + } | ||
| 501 | $dbhw = null; | 534 | $dbhw = null; |
| 502 | $dbh = null; | 535 | $dbh = null; |
| 503 | - return "ok"; | 536 | + return $retorna; |
| 504 | } | 537 | } |
| 505 | catch (PDOException $e) | 538 | catch (PDOException $e) |
| 506 | { | 539 | { |
| @@ -517,18 +550,26 @@ function alteraSubGrupos() | @@ -517,18 +550,26 @@ function alteraSubGrupos() | ||
| 517 | global $nome,$desc,$id; | 550 | global $nome,$desc,$id; |
| 518 | try | 551 | try |
| 519 | { | 552 | { |
| 520 | - $nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | ||
| 521 | - $desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | 553 | + //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); |
| 554 | + //$desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | ||
| 522 | require_once("conexao.php"); | 555 | require_once("conexao.php"); |
| 556 | + $retorna = ""; | ||
| 523 | if($id != "") | 557 | if($id != "") |
| 524 | { | 558 | { |
| 525 | $dbhw->query("UPDATE i3geoadmin_subgrupos SET nome_subgrupo = '$nome', desc_subgrupo = '$desc' WHERE id_subgrupo = $id"); | 559 | $dbhw->query("UPDATE i3geoadmin_subgrupos SET nome_subgrupo = '$nome', desc_subgrupo = '$desc' WHERE id_subgrupo = $id"); |
| 560 | + $retorna = "ok"; | ||
| 526 | } | 561 | } |
| 527 | else | 562 | else |
| 528 | - $dbhw->query("INSERT INTO i3geoadmin_subgrupos (nome_subgrupo, desc_subgrupo) VALUES ('', '')"); | 563 | + { |
| 564 | + $dbhw->query("INSERT INTO i3geoadmin_subgrupos (nome_subgrupo, desc_subgrupo) VALUES ('', '')"); | ||
| 565 | + $id = $dbh->query("SELECT * FROM i3geoadmin_subgrupos"); | ||
| 566 | + $id = $id->fetchAll(); | ||
| 567 | + $id = intval($id[count($id)-1]['id_subgrupo']); | ||
| 568 | + $retorna = $id; | ||
| 569 | + } | ||
| 529 | $dbhw = null; | 570 | $dbhw = null; |
| 530 | $dbh = null; | 571 | $dbh = null; |
| 531 | - return "ok"; | 572 | + return $retorna; |
| 532 | } | 573 | } |
| 533 | catch (PDOException $e) | 574 | catch (PDOException $e) |
| 534 | { | 575 | { |
| @@ -545,16 +586,23 @@ function alteraTemas() | @@ -545,16 +586,23 @@ function alteraTemas() | ||
| 545 | global $nome,$desc,$id,$codigo,$tipoa,$download,$ogc,$kml,$link,$tags; | 586 | global $nome,$desc,$id,$codigo,$tipoa,$download,$ogc,$kml,$link,$tags; |
| 546 | try | 587 | try |
| 547 | { | 588 | { |
| 548 | - $nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | ||
| 549 | - $desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | ||
| 550 | - $tags = mb_convert_encoding($tags,"UTF-8","ISO-8859-1"); | 589 | + $retorna = "ok"; |
| 590 | + //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); | ||
| 591 | + //$desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); | ||
| 592 | + //$tags = mb_convert_encoding($tags,"UTF-8","ISO-8859-1"); | ||
| 551 | require_once("conexao.php"); | 593 | require_once("conexao.php"); |
| 552 | if($id != "") | 594 | if($id != "") |
| 553 | { | 595 | { |
| 554 | $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"); | 596 | $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"); |
| 555 | } | 597 | } |
| 556 | else | 598 | else |
| 557 | - $dbhw->query("INSERT INTO i3geoadmin_temas (link_tema,kml_tema,ogc_tema,download_tema,nome_tema,desc_tema,codigo_tema,tipoa_tema,tags_tema) VALUES ('','', '','','','','','','')"); | 599 | + { |
| 600 | + $dbhw->query("INSERT INTO i3geoadmin_temas (link_tema,kml_tema,ogc_tema,download_tema,nome_tema,desc_tema,codigo_tema,tipoa_tema,tags_tema) VALUES ('','', '','','','','','','')"); | ||
| 601 | + $id = $dbh->query("SELECT * FROM i3geoadmin_temas"); | ||
| 602 | + $id = $id->fetchAll(); | ||
| 603 | + $id = intval($id[count($id)-1]['id_tema']); | ||
| 604 | + $retorna = $id; | ||
| 605 | + } | ||
| 558 | //verifica se é necessário adicionar algum tag novo | 606 | //verifica se é necessário adicionar algum tag novo |
| 559 | $tags = explode(" ",$tags); | 607 | $tags = explode(" ",$tags); |
| 560 | foreach($tags as $tag) | 608 | foreach($tags as $tag) |
| @@ -566,7 +614,7 @@ function alteraTemas() | @@ -566,7 +614,7 @@ function alteraTemas() | ||
| 566 | } | 614 | } |
| 567 | $dbhw = null; | 615 | $dbhw = null; |
| 568 | $dbh = null; | 616 | $dbh = null; |
| 569 | - return "ok"; | 617 | + return $retorna; |
| 570 | } | 618 | } |
| 571 | catch (PDOException $e) | 619 | catch (PDOException $e) |
| 572 | { | 620 | { |
admin/php/parsemapfile.php
| 1 | <?php | 1 | <?php |
| 2 | include_once("../../ms_configura.php"); | 2 | include_once("../../ms_configura.php"); |
| 3 | include_once("../../classesphp/funcoes_gerais.php"); | 3 | include_once("../../classesphp/funcoes_gerais.php"); |
| 4 | - | 4 | +include_once("../../classesphp/carrega_ext.php"); |
| 5 | +include_once("../../classesphp/pega_variaveis.php"); | ||
| 6 | +error_reporting(0); | ||
| 5 | $objcontype[0] = "MS_INLINE"; | 7 | $objcontype[0] = "MS_INLINE"; |
| 6 | $objcontype[1] = "MS_SHAPEFILE"; | 8 | $objcontype[1] = "MS_SHAPEFILE"; |
| 7 | $objcontype[2] = "MS_TILED_SHAPEFILE"; | 9 | $objcontype[2] = "MS_TILED_SHAPEFILE"; |
| @@ -27,62 +29,189 @@ $objlayertypes[6] = "MS_LAYER_CIRCLE"; | @@ -27,62 +29,189 @@ $objlayertypes[6] = "MS_LAYER_CIRCLE"; | ||
| 27 | $objlayertypes[7] = "MS_LAYER_TILEINDEX"; | 29 | $objlayertypes[7] = "MS_LAYER_TILEINDEX"; |
| 28 | $objlayertypes[8] = "MS_LAYER_CHART"; | 30 | $objlayertypes[8] = "MS_LAYER_CHART"; |
| 29 | 31 | ||
| 30 | -$dados = array(); | ||
| 31 | $codigoLayer = $id; | 32 | $codigoLayer = $id; |
| 32 | $mapfile = "../../temas/".$codigoLayer.".map"; | 33 | $mapfile = "../../temas/".$codigoLayer.".map"; |
| 33 | $mapa = ms_newMapObj($mapfile); | 34 | $mapa = ms_newMapObj($mapfile); |
| 34 | -$layers = $mapa->getalllayernames(); | ||
| 35 | -$xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | ||
| 36 | -$xml .= "\n<parsemapfile>\n"; | ||
| 37 | -$xml .= "<tiposconexao>".implode(",",$objcontype)."</tiposconexao>\n"; | ||
| 38 | -$xml .= "<tiposlayer>".implode(",",$objlayertypes)."</tiposlayer>\n"; | ||
| 39 | -foreach ($layers as $layer) | 35 | +if(!isset($tipoparse) || $tipoparse=="") |
| 36 | +{mapfile();exit;} | ||
| 37 | + | ||
| 38 | +if($tipoparse == "legenda") | ||
| 40 | { | 39 | { |
| 41 | - $xml .= "\n<layer>\n"; | ||
| 42 | - $layer = $mapa->getlayerbyname($layer); | ||
| 43 | - $xml .= "<titulo>".$layer->getmetadata('tema')."</titulo>\n"; | ||
| 44 | - $xml .= "<connection>\n"; | ||
| 45 | - $con = $layer->connection; | ||
| 46 | - $xml .= "<user>".preg_replace('/.*user\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</user>\n"; | ||
| 47 | - $xml .= "<password>".preg_replace('/.*password\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</password>\n"; | ||
| 48 | - $xml .= "<dbname>".preg_replace('/.*dbname\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</dbname>\n"; | ||
| 49 | - $xml .= "<host>".preg_replace('/.*host\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</host>\n"; | ||
| 50 | - $xml .= "<port>".preg_replace('/.*port\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</port>\n"; | ||
| 51 | - $xml .= "</connection>\n"; | ||
| 52 | - $xml .= "<connectiontype>".$objcontype[$layer->connectiontype]."</connectiontype>\n"; | ||
| 53 | - $d = $layer->data; | ||
| 54 | - $xml .= "<data>$d</data>\n"; | ||
| 55 | - $d = explode("(",$d); | ||
| 56 | - $d = explode(")",$d[1]); | ||
| 57 | - $xml .= "<select>$d[0]</select>\n"; | ||
| 58 | - $xml .= "<type>".$objlayertypes[$layer->type]."</type>\n"; | ||
| 59 | - $xml .= "<filter>".$layer->getfilter()."</filter>\n"; | ||
| 60 | - $xml .= "<filteritem>$layer->filteritem</filteritem>\n"; | ||
| 61 | - $xml .= "<group>$layer->group</group>\n"; | ||
| 62 | - $xml .= "<labelangleitem>$layer->labelangleitem</labelangleitem>\n"; | ||
| 63 | - $xml .= "<labelitem>$layer->labelitem</labelitem>\n"; | ||
| 64 | - $xml .= "<labelmaxscale>$layer->labelmaxscale</labelmaxscale>\n"; | ||
| 65 | - $xml .= "<labelminscale>$layer->labelminscale</labelminscale>\n"; | ||
| 66 | - $xml .= "<labelsizeitem>$layer->labelsizeitem</labelsizeitem>\n"; | ||
| 67 | - $xml .= "<maxscale>$layer->maxscale</maxscale>\n"; | ||
| 68 | - $xml .= "<minscale>$layer->minscale</minscale>\n"; | ||
| 69 | - $xml .= "<offsite>".$layer->offsite->red.",".$layer->offsite->green.",".$layer->offsite->blue."</offsite>\n"; | ||
| 70 | - $xml .= "<opacity>$layer->opacity</opacity>\n"; | ||
| 71 | - $xml .= "<symbolscale>$layer->symbolscale</symbolscale>\n"; | ||
| 72 | - $xml .= "<tileindex>$layer->tileindex</tileindex>\n"; | ||
| 73 | - $xml .= "<tileitem>$layer->tileitem</tileitem>\n"; | ||
| 74 | - $xml .= "<tolerance>$layer->tolerance</tolerance>\n"; | ||
| 75 | - $xml .= "<toleranceunits>$layer->toleranceunits</toleranceunits>\n"; | ||
| 76 | - $xml .= "<sizeunits>$layer->sizeunits</sizeunits>\n"; | ||
| 77 | - $xml .= "<projection>$layer->getProjection</projection>\n"; | ||
| 78 | - $xml .= "<name>$layer->name</name>\n"; | ||
| 79 | - $xml .= "<classes>\n"; | ||
| 80 | - $xml .= pegaClasses(&$xml); | ||
| 81 | - $xml .= "</classes>\n"; | ||
| 82 | - $xml .= "</layer>"; | 40 | + $tipoLegenda = tipoLegenda($layername); |
| 41 | + //if($tipoLegenda == "simples") | ||
| 42 | + //{legendaSimples($layername);} | ||
| 43 | + legendaSimples($layername); | ||
| 44 | +} | ||
| 45 | +// | ||
| 46 | +//verifica o tipo de legenda | ||
| 47 | +//pode retornar: | ||
| 48 | +//simples - o layer não terá classes | ||
| 49 | +//valorunico - as classes são definidas por um item | ||
| 50 | +//intervalo - as classes são definidas por um intervalo do mesmo item | ||
| 51 | +// | ||
| 52 | +function tipoLegenda($layername) | ||
| 53 | +{ | ||
| 54 | + global $mapa; | ||
| 55 | + $tipolegenda = ""; | ||
| 56 | + $layer = $mapa->getlayerbyname($layername); | ||
| 57 | + $nclasses = $layer->numclasses; | ||
| 58 | + if($nclasses == 1) | ||
| 59 | + { | ||
| 60 | + $classe = $layer->getclass(0); | ||
| 61 | + $expressao = $classe->getExpression(); | ||
| 62 | + if($expressao == "") | ||
| 63 | + {return "simples";exit;} | ||
| 64 | + } | ||
| 65 | + $verItem = array(); | ||
| 66 | + for($i=0;$i<$nclasses;++$i) | ||
| 67 | + { | ||
| 68 | + $classe = $layer->getclass($i); | ||
| 69 | + $expressao = $classe->getExpression(); | ||
| 70 | + if(count(explode("[",$expressao)) > 2) | ||
| 71 | + { | ||
| 72 | + return "intervalo"; | ||
| 73 | + exit; | ||
| 74 | + } | ||
| 75 | + // | ||
| 76 | + //verifica se os itens são únicos nas expressões | ||
| 77 | + // | ||
| 78 | + $item = preg_replace('/.*\[|\].*/i','\1', $expressao); | ||
| 79 | + $verItem[$item] = 0; | ||
| 80 | + } | ||
| 81 | + if(count($verItem) == 1) | ||
| 82 | + return "valorunico"; | ||
| 83 | + else | ||
| 84 | + return "simples"; | ||
| 85 | +} | ||
| 86 | +function legendaSimples($layername) | ||
| 87 | +{ | ||
| 88 | + global $mapa; | ||
| 89 | + $tipolegenda = ""; | ||
| 90 | + $layer = $mapa->getlayerbyname($layername); | ||
| 91 | + $classe = $layer->getclass(0); | ||
| 92 | + $estilo = $classe->getstyle(0); | ||
| 93 | + $cor = $estilo->color; | ||
| 94 | + $outcor = $estilo->outlinecolor; | ||
| 95 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | ||
| 96 | + $xml .= "<xml-tag xmlns='http://www.gvsig.gva.es'>\n"; | ||
| 97 | + $xml .= "<property key='className' value='com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend'/>\n"; | ||
| 98 | + $xml .= "<property key='labelFieldName'/>\n"; | ||
| 99 | + $xml .= "<property key='labelHeightFieldName'/>\n"; | ||
| 100 | + $xml .= "<property key='labelRotationFieldName'/>\n"; | ||
| 101 | + $xml .= "<property key='followHeaderEncoding' value='true'/>\n"; | ||
| 102 | + $xml .= "<xml-tag>\n"; | ||
| 103 | + $xml .= "<property key='className' value='com.iver.cit.gvsig.fmap.core.v02.FSymbol'/>\n"; | ||
| 104 | + $xml .= "<property key='m_symbolType' value='4'/>\n"; | ||
| 105 | + $xml .= "<property key='m_Style' value='1'/>\n"; | ||
| 106 | + $xml .= "<property key='m_useOutline' value='true'/>\n"; | ||
| 107 | + $xml .= "<property key='m_Color' value='".$cor->red.",".$cor->green.",".$cor->blue.",255'/>\n"; | ||
| 108 | + if($outcor->red != -1) | ||
| 109 | + $xml .= "<property key='m_outlineColor' value='".$outcor->red.",".$outcor->green.",".$outcor->blue.",255'/>\n"; | ||
| 110 | + else | ||
| 111 | + $xml .= "<property key='m_outlineColor' value='0,0,0,255'/>\n"; | ||
| 112 | + $xml .= "<property key='m_bUseFontSize' value='true'/>\n"; | ||
| 113 | + $xml .= "<property key='m_bDrawShape' value='true'/>\n"; | ||
| 114 | + $xml .= "<property key='m_Size' value='2'/>\n"; | ||
| 115 | + $xml .= "<property key='m_Rotation' value='0'/>\n"; | ||
| 116 | + $xml .= "<property key='m_LinePattern' value='0'/>\n"; | ||
| 117 | + $xml .= "<property key='m_stroke' value='1.0'/>\n"; | ||
| 118 | + $xml .= "<property key='m_bUseSize' value='false'/>\n"; | ||
| 119 | + $xml .= "<property key='m_AlingVert' value='0'/>\n"; | ||
| 120 | + $xml .= "<property key='m_AlingHoriz' value='0'/>\n"; | ||
| 121 | + $xml .= "<property key='m_Descrip'/>\n"; | ||
| 122 | + $xml .= "<property key='rgb' value='-14902251'/>\n"; | ||
| 123 | + $xml .= "</xml-tag>\n"; | ||
| 124 | + $xml .= "</xml-tag>\n"; | ||
| 125 | + echo header("Content-type: application/xml"); | ||
| 126 | + echo $xml; | ||
| 127 | + exit; | ||
| 128 | +} | ||
| 129 | +// | ||
| 130 | +//gera xml com parâmetros do mapfile | ||
| 131 | +// | ||
| 132 | +function mapfile() | ||
| 133 | +{ | ||
| 134 | + global $codigoLayer,$mapfile,$mapa,$objcontype,$objlayertypes; | ||
| 135 | + $layers = $mapa->getalllayernames(); | ||
| 136 | + $dados = array(); | ||
| 137 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | ||
| 138 | + $xml .= "\n<parsemapfile>\n"; | ||
| 139 | + $xml .= "<tiposconexao>".implode(",",$objcontype)."</tiposconexao>\n"; | ||
| 140 | + $xml .= "<tiposlayer>".implode(",",$objlayertypes)."</tiposlayer>\n"; | ||
| 141 | + foreach ($layers as $layer) | ||
| 142 | + { | ||
| 143 | + $xml .= "\n<layer>\n"; | ||
| 144 | + $layer = $mapa->getlayerbyname($layer); | ||
| 145 | + $xml .= "<titulo>".$layer->getmetadata('tema')."</titulo>\n"; | ||
| 146 | + $d = $layer->data; | ||
| 147 | + $ct = $objcontype[$layer->connectiontype]; | ||
| 148 | + if ($ct == "MS_SHAPEFILE" || $ct == "" || $ct == "MS_RASTER") | ||
| 149 | + { | ||
| 150 | + $ct = "MS_WMS"; | ||
| 151 | + $d = "HTTP://mapas.mma.gov.br/i3geo/ogc.php?tema=".$codigoLayer; | ||
| 152 | + $xml .= "<version>1.1.1</version>"; | ||
| 153 | + $xml .= "<srs>EPSG:4291</srs>"; | ||
| 154 | + $xml .= "<format>image/png</format>"; | ||
| 155 | + } | ||
| 156 | + else | ||
| 157 | + {$xml .= "<geraxmllegenda>parsemapfile.php?id=".$codigoLayer."&layername=".$layer->name."&tipoparse=legenda</geraxmllegenda>";} | ||
| 158 | + $xml .= "<connectiontype>".$ct."</connectiontype>\n"; | ||
| 159 | + $xml .= "<data>$d</data>\n"; | ||
| 160 | + $xml .= "<name>$layer->name</name>\n"; | ||
| 161 | + if($ct != "MS_WMS") | ||
| 162 | + { | ||
| 163 | + $xml .= "<connection>\n"; | ||
| 164 | + $con = $layer->connection; | ||
| 165 | + $xml .= "<user>".preg_replace('/.*user\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</user>\n"; | ||
| 166 | + $xml .= "<password>".preg_replace('/.*password\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</password>\n"; | ||
| 167 | + $xml .= "<dbname>".preg_replace('/.*dbname\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</dbname>\n"; | ||
| 168 | + $xml .= "<host>".preg_replace('/.*host\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</host>\n"; | ||
| 169 | + $xml .= "<port>".preg_replace('/.*port\s*=\s*([a-zA-Z0-9_.]+).*/i', '\1', $con)."</port>\n"; | ||
| 170 | + $xml .= "</connection>\n"; | ||
| 171 | + $d = explode("(",$d); | ||
| 172 | + $d = explode(")",$d[1]); | ||
| 173 | + $xml .= "<select>$d[0]</select>\n"; | ||
| 174 | + $string = preg_replace('/.*from\s*(.+).*/i', '\1', $d[0]); | ||
| 175 | + $s = explode("WHERE",$string); | ||
| 176 | + if(count($s) == 1) | ||
| 177 | + $s = explode("where",$string); | ||
| 178 | + $esquemaTabela = explode(".",$s[0]); | ||
| 179 | + $xml .= "<esquema>".$esquemaTabela[0]."</esquema>"; | ||
| 180 | + $xml .= "<tabela>".$esquemaTabela[1]."</tabela>"; | ||
| 181 | + $xml .= "<where>".$s[1]."</where>"; | ||
| 182 | + $xml .= "<type>".$objlayertypes[$layer->type]."</type>\n"; | ||
| 183 | + $xml .= "<filter>".$layer->getfilter()."</filter>\n"; | ||
| 184 | + $xml .= "<filteritem>$layer->filteritem</filteritem>\n"; | ||
| 185 | + $xml .= "<labelangleitem>$layer->labelangleitem</labelangleitem>\n"; | ||
| 186 | + $xml .= "<labelitem>$layer->labelitem</labelitem>\n"; | ||
| 187 | + $xml .= "<labelmaxscale>$layer->labelmaxscale</labelmaxscale>\n"; | ||
| 188 | + $xml .= "<labelminscale>$layer->labelminscale</labelminscale>\n"; | ||
| 189 | + $xml .= "<labelsizeitem>$layer->labelsizeitem</labelsizeitem>\n"; | ||
| 190 | + } | ||
| 191 | + $xml .= "<group>$layer->group</group>\n"; | ||
| 192 | + $xml .= "<maxscale>$layer->maxscale</maxscale>\n"; | ||
| 193 | + $xml .= "<minscale>$layer->minscale</minscale>\n"; | ||
| 194 | + $xml .= "<offsite>".$layer->offsite->red.",".$layer->offsite->green.",".$layer->offsite->blue."</offsite>\n"; | ||
| 195 | + $xml .= "<opacity>$layer->opacity</opacity>\n"; | ||
| 196 | + if($ct != "MS_WMS") | ||
| 197 | + { | ||
| 198 | + $xml .= "<symbolscale>$layer->symbolscale</symbolscale>\n"; | ||
| 199 | + $xml .= "<tileindex>$layer->tileindex</tileindex>\n"; | ||
| 200 | + $xml .= "<tileitem>$layer->tileitem</tileitem>\n"; | ||
| 201 | + $xml .= "<tolerance>$layer->tolerance</tolerance>\n"; | ||
| 202 | + $xml .= "<toleranceunits>$layer->toleranceunits</toleranceunits>\n"; | ||
| 203 | + $xml .= "<sizeunits>$layer->sizeunits</sizeunits>\n"; | ||
| 204 | + $xml .= "<projection>$layer->getProjection</projection>\n"; | ||
| 205 | + $xml .= "<classes>\n"; | ||
| 206 | + $xml .= pegaClasses(&$xml); | ||
| 207 | + $xml .= "</classes>\n"; | ||
| 208 | + } | ||
| 209 | + $xml .= "</layer>"; | ||
| 210 | + } | ||
| 211 | + $xml .= "</parsemapfile>\n"; | ||
| 212 | + echo header("Content-type: application/xml"); | ||
| 213 | + echo $xml; | ||
| 83 | } | 214 | } |
| 84 | -$xml .= "</parsemapfile>\n"; | ||
| 85 | -echo $xml; | ||
| 86 | function pegaClasses($xml) | 215 | function pegaClasses($xml) |
| 87 | { | 216 | { |
| 88 | global $layer; | 217 | global $layer; |
admin/php/xml.php
| @@ -41,18 +41,18 @@ function geraXmlSistemas($perfil,$locaplic,$editores) | @@ -41,18 +41,18 @@ function geraXmlSistemas($perfil,$locaplic,$editores) | ||
| 41 | } | 41 | } |
| 42 | function geraRSStemas($locaplic,$id_n2) | 42 | function geraRSStemas($locaplic,$id_n2) |
| 43 | { | 43 | { |
| 44 | - $sql = "select t.nome_tema as nome_ws,'' as desc_ws,'php/parsemapfile.php?id='||t.codigo_tema as link_ws,'' as autor_ws from i3geoadmin_n3 as n3,i3geoadmin_temas as t where t.id_tema = n3.id_tema and n3.id_n2 = '$id_n2' and n3.n3_perfil = ''"; | 44 | + $sql = "select t.nome_tema as nome_ws,'' as desc_ws,'php/parsemapfile.php?id='||t.codigo_tema as link_ws,t.link_tema as autor_ws from i3geoadmin_n3 as n3,i3geoadmin_temas as t where t.id_tema = n3.id_tema and n3.id_n2 = '$id_n2' and n3.n3_perfil = '' order by nome_ws"; |
| 45 | return geraXmlRSS($locaplic,$sql,"Lista de temas"); | 45 | return geraXmlRSS($locaplic,$sql,"Lista de temas"); |
| 46 | } | 46 | } |
| 47 | function geraRSSsubgrupos($locaplic,$id_n1) | 47 | function geraRSSsubgrupos($locaplic,$id_n1) |
| 48 | { | 48 | { |
| 49 | - $sql = "select g.nome_subgrupo as nome_ws,'' as desc_ws,'rsstemas.php?id='||n2.id_n2 as link_ws,'' as autor_ws from i3geoadmin_n2 as n2,i3geoadmin_subgrupos as g where g.id_subgrupo = n2.id_subgrupo and n2.id_n1 = '$id_n1' and n2.n2_perfil = ''"; | 49 | + $sql = "select g.nome_subgrupo as nome_ws,'' as desc_ws,'rsstemas.php?id='||n2.id_n2 as link_ws,'' as autor_ws from i3geoadmin_n2 as n2,i3geoadmin_subgrupos as g where g.id_subgrupo = n2.id_subgrupo and n2.id_n1 = '$id_n1' and n2.n2_perfil = '' order by nome_ws"; |
| 50 | return geraXmlRSS($locaplic,$sql,"Lista de sub-grupos"); | 50 | return geraXmlRSS($locaplic,$sql,"Lista de sub-grupos"); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | function geraRSSgrupos($locaplic) | 53 | function geraRSSgrupos($locaplic) |
| 54 | { | 54 | { |
| 55 | - $sql = "select g.nome_grupo as nome_ws,'' as desc_ws,'rsssubgrupos.php?id='||n1.id_n1 as link_ws,'' as autor_ws from i3geoadmin_n1 as n1,i3geoadmin_grupos as g where g.id_grupo = n1.id_grupo and n1.n1_perfil = ''"; | 55 | + $sql = "select g.nome_grupo as nome_ws,'' as desc_ws,'rsssubgrupos.php?id='||n1.id_n1 as link_ws,'' as autor_ws from i3geoadmin_n1 as n1,i3geoadmin_grupos as g where g.id_grupo = n1.id_grupo and n1.n1_perfil = '' order by nome_ws"; |
| 56 | return geraXmlRSS($locaplic,$sql,"Lista de grupos"); | 56 | return geraXmlRSS($locaplic,$sql,"Lista de grupos"); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -101,7 +101,7 @@ function geraXmlRSS($locaplic,$sql,$descricao) | @@ -101,7 +101,7 @@ function geraXmlRSS($locaplic,$sql,$descricao) | ||
| 101 | $xml .= "<description>".entity_decode($row["desc_ws"])."</description>\n"; | 101 | $xml .= "<description>".entity_decode($row["desc_ws"])."</description>\n"; |
| 102 | $xml .= "<link>".xmlTexto_prepara($row["link_ws"])."</link>\n"; | 102 | $xml .= "<link>".xmlTexto_prepara($row["link_ws"])."</link>\n"; |
| 103 | $xml .= "<pubDate/>\n"; | 103 | $xml .= "<pubDate/>\n"; |
| 104 | - $xml .= "<author>".entity_decode($row["autor_ws"])."</author>\n"; | 104 | + $xml .= "<author>".xmlTexto_prepara($row["autor_ws"])."</author>\n"; |
| 105 | $xml .= "</item>\n"; | 105 | $xml .= "</item>\n"; |
| 106 | } | 106 | } |
| 107 | $xml .= "</channel></rss>\n"; | 107 | $xml .= "</channel></rss>\n"; |
menutemas/admin.db
No preview for this file type