Commit 1609b6c72c01d3c79ae6da8e448fee044a18f2d6

Authored by Edmar Moretti
1 parent 4589fa5c

Inclusão de busca no menu de temas na opção de busca rápida

classesphp/classe_menutemas.php
@@ -360,10 +360,11 @@ $procurar - String que será procurada. @@ -360,10 +360,11 @@ $procurar - String que será procurada.
360 foreach($this->xml->GRUPO as $grupo) 360 foreach($this->xml->GRUPO as $grupo)
361 { 361 {
362 $incluigrupo = TRUE; 362 $incluigrupo = TRUE;
363 - if ($grupo->PERFIL != "") 363 + $temp = mb_convert_encoding($grupo->PERFIL,"HTML-ENTITIES","auto");
  364 + if ($temp != "")
364 { 365 {
365 $incluigrupo = FALSE; 366 $incluigrupo = FALSE;
366 - $perfis = explode(",",$grupo->PERFIL); 367 + $perfis = explode(",",$temp);
367 if (in_array($this->perfil,$perfis)) 368 if (in_array($this->perfil,$perfis))
368 {$incluigrupo = TRUE;} 369 {$incluigrupo = TRUE;}
369 } 370 }
@@ -374,7 +375,8 @@ $procurar - String que será procurada. @@ -374,7 +375,8 @@ $procurar - String que será procurada.
374 $incluisgrupo = TRUE; 375 $incluisgrupo = TRUE;
375 if ($this->perfil != "") 376 if ($this->perfil != "")
376 { 377 {
377 - $perfis = explode(",",$sgrupo->PERFIL); 378 + $temp = mb_convert_encoding($sgrupo->PERFIL,"HTML-ENTITIES","auto");
  379 + $perfis = explode(",",$temp);
378 if (!in_array($this->perfil,$perfis)) 380 if (!in_array($this->perfil,$perfis))
379 {$incluisgrupo = FALSE;} 381 {$incluisgrupo = FALSE;}
380 } 382 }
@@ -385,22 +387,24 @@ $procurar - String que será procurada. @@ -385,22 +387,24 @@ $procurar - String que será procurada.
385 $inclui = TRUE; 387 $inclui = TRUE;
386 if ($this->perfil != "") 388 if ($this->perfil != "")
387 { 389 {
388 - $perfis = explode(",",$tema->PERFIL); 390 + $temp = mb_convert_encoding($tema->PERFIL,"HTML-ENTITIES","auto");
  391 + $perfis = explode(",",$temp);
389 if (!in_array($this->perfil,$perfis)) 392 if (!in_array($this->perfil,$perfis))
390 {$inclui = FALSE;} 393 {$inclui = FALSE;}
391 } 394 }
392 if ($inclui == TRUE) 395 if ($inclui == TRUE)
393 { 396 {
394 $down = "nao"; 397 $down = "nao";
395 - if (($tema->DOWNLOAD == "sim") || ($tema->DOWNLOAD == "SIM")) 398 + $temp = mb_convert_encoding($tema->DOWNLOAD,"HTML-ENTITIES","auto");
  399 + if (($temp == "sim") || ($temp == "SIM"))
396 {$down = "sim";} 400 {$down = "sim";}
397 - $link = mb_convert_encoding($tema->TLINK,"HTML-ENTITIES","auto");; 401 + $link = mb_convert_encoding($tema->TLINK,"HTML-ENTITIES","auto");
398 $tid = mb_convert_encoding($tema->TID,"HTML-ENTITIES","auto"); 402 $tid = mb_convert_encoding($tema->TID,"HTML-ENTITIES","auto");
399 if (function_exists("mb_convert_encoding")) 403 if (function_exists("mb_convert_encoding"))
400 {$texto = array("tid"=>$tid,"nome"=>(mb_convert_encoding($tema->TNOME,"HTML-ENTITIES","auto")),"link"=>$link,"download"=>$down);} 404 {$texto = array("tid"=>$tid,"nome"=>(mb_convert_encoding($tema->TNOME,"HTML-ENTITIES","auto")),"link"=>$link,"download"=>$down);}
401 else 405 else
402 {$texto = array("tid"=>$tid,"nome"=>$tema->TNOME,"link"=>$link,"download"=>$down);} 406 {$texto = array("tid"=>$tid,"nome"=>$tema->TNOME,"link"=>$link,"download"=>$down);}
403 - if (stristr((mb_convert_encoding($tema->TNOME,"HTML-ENTITIES","auto")),$procurar)) 407 + if ((stristr(mb_convert_encoding($tema->TNOME,"HTML-ENTITIES","auto"),$procurar)) || (stristr(mb_convert_encoding($tema->TNOME,"HTML-ENTITIES","auto"),htmlentities($procurar))))
404 {$listadetemas[] = $texto;} 408 {$listadetemas[] = $texto;}
405 } 409 }
406 } 410 }
ferramentas/buscarapida/index.js
@@ -48,6 +48,13 @@ function busca() @@ -48,6 +48,13 @@ function busca()
48 ins += "</table>" 48 ins += "</table>"
49 } 49 }
50 $i("resultado").innerHTML = ins 50 $i("resultado").innerHTML = ins
  51 + var palavra = window.parent.document.getElementById("valorBuscaRapida").value
  52 + var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=procurartemas&procurar="+palavra+"&g_sid="+g_sid;
  53 + var cp = new cpaint();
  54 + //cp.set_debug(2);
  55 + cp.set_response_type("json");
  56 + cp.call(p,"procurartemas",resultadoTemas);
  57 +
51 } 58 }
52 $i("resultado").innerHTML = "Aguarde..." 59 $i("resultado").innerHTML = "Aguarde..."
53 var palavra = window.parent.document.getElementById("valorBuscaRapida").value 60 var palavra = window.parent.document.getElementById("valorBuscaRapida").value
@@ -58,6 +65,50 @@ function busca() @@ -58,6 +65,50 @@ function busca()
58 cp.set_response_type("json"); 65 cp.set_response_type("json");
59 cp.call(p,"buscaRapida",listaretorno); 66 cp.call(p,"buscaRapida",listaretorno);
60 } 67 }
  68 +function resultadoTemas(retorno)
  69 +{
  70 + var retorno = retorno.data;
  71 + if ((retorno != "erro") && (retorno != undefined))
  72 + {
  73 + var ins = "";
  74 + for (ig=0;ig<retorno.length;ig++)
  75 + {
  76 + var ngSgrupo = retorno[ig].subgrupos;
  77 + for (sg=0;sg<ngSgrupo.length;sg++)
  78 + {
  79 + var nomeSgrupo = ngSgrupo[sg].subgrupo;
  80 + var ngTema = ngSgrupo[sg].temas;
  81 + for (st=0;st<ngTema.length;st++)
  82 + {
  83 + if ( ngTema[st].link != " ")
  84 + {var lk = "<a href="+ngTema[st].link+" target=blank>&nbsp;fonte</a>";}
  85 + var tid = ngTema[st].tid;
  86 + var inp = "<input style='text-align:left;cursor:pointer;' onclick='adicionatema(this)' class=inputsb style='cursor:pointer' type=\"checkbox\" value='"+tid+"' /> ("+nomeSgrupo+")";
  87 + var nomeTema = inp+(ngTema[st].nome)+lk+"<br>";
  88 + ins += nomeTema;
  89 + }
  90 + }
  91 + }
  92 + if (ins != "")
  93 + {
  94 + $i("resultado").innerHTML += "<br><b>Temas:</b><br>"+ins
  95 + }
  96 + }
  97 +}
  98 +function adicionatema(obj)
  99 +{
  100 + if (obj.checked)
  101 + {
  102 + window.parent.objaguarde.abre("ajaxredesenha","Aguarde...");
  103 + var temp = function()
  104 + {window.parent.ajaxredesenha("");}
  105 + var p = window.parent.g_locaplic+"/classesphp/mapa_controle.php?funcao=adtema&temas="+obj.value+"&g_sid="+g_sid;
  106 + var cp = new cpaint();
  107 + //cp.set_debug(2)
  108 + cp.set_response_type("JSON");
  109 + cp.call(p,"adicionaTema",temp);
  110 + }
  111 +}
61 function mostraxy(wkt) 112 function mostraxy(wkt)
62 { 113 {
63 var re = new RegExp("POLYGON", "g") 114 var re = new RegExp("POLYGON", "g")