From 0390af3623de793273cd72f5cd3d36d27c418536 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Sat, 14 Jun 2008 01:04:46 +0000 Subject: [PATCH] Adaptações para funcionamento com o sistema de administração --- classesphp/atlas_controle.php | 8 ++++++++ classesphp/classe_atlas.php | 11 ++--------- classesphp/classe_menutemas.php | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------- classesphp/mapa_controle.php | 44 ++++++++++++++++++-------------------------- classesphp/mapa_inicia.php | 13 +++++++++++-- datadownload.htm | 2 +- kml.php | 39 +++++++++++++++++++++++++++++++-------- menutemas/admin.db | Bin 67584 -> 0 bytes mobile/adicionatema.php | 12 +++++++++--- ms_configura.default | 16 ++++++++-------- ms_configura.php | 22 +++++++++++----------- ogc.php | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------- 12 files changed, 322 insertions(+), 266 deletions(-) diff --git a/classesphp/atlas_controle.php b/classesphp/atlas_controle.php index 48c6526..963e5c1 100644 --- a/classesphp/atlas_controle.php +++ b/classesphp/atlas_controle.php @@ -114,6 +114,14 @@ if ($map_file != "") substituiCon($map_file,$postgis_mapa); } // +//identifica qual a url do i3geo +// +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); +$protocolo = $protocolo[0] . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; +$urli3geo = str_replace("/classesphp/atlas_controle.php","",$protocolo.$_SERVER["PHP_SELF"]); +if($atlasxml == "") +{$atlasxml = $urli3geo."/admin/xmlatlas.php";} +// //faz a busca da função que deve ser executada // switch ($funcao) diff --git a/classesphp/classe_atlas.php b/classesphp/classe_atlas.php index 5e137d6..0f3ac6f 100644 --- a/classesphp/classe_atlas.php +++ b/classesphp/classe_atlas.php @@ -33,11 +33,6 @@ Class: Atlas */ class Atlas { - /* - Variable: $atlas - - Objeto Atlas - */ public $atlas; /* Function: __construct @@ -50,9 +45,9 @@ $atlasxml - Endereço do arquivo xml com as definições do Atlas. */ function __construct($atlasxml) { - - $this->arquivo = $atlasxml; + error_reporting(0); $this->xml = simplexml_load_file($atlasxml); + $this->arquivo = $atlasxml; } /* Method: pegaListaDeAtlas @@ -243,7 +238,5 @@ locaplic - localização do i3geo no servidor if($h == ""){$h = 300;} return (array("link"=>$link,"w"=>$w,"h"=>$h)); } - } - ?> \ No newline at end of file diff --git a/classesphp/classe_menutemas.php b/classesphp/classe_menutemas.php index 8e605ea..355547b 100644 --- a/classesphp/classe_menutemas.php +++ b/classesphp/classe_menutemas.php @@ -35,49 +35,35 @@ Class: Menutemas */ class Menutemas { - /* - Variable: $mapa - - Objeto mapa - */ - protected $mapa; - /* - Variable: $arquivo - - Arquivo map file - */ - protected $arquivo; - /* - Variable: $layers - - Array com os layers - */ - protected $layers; - /* - Variable: $perfil - - Perfil do usuário atual - */ - protected $perfil; - /* - Variable: $xmlsistemas - - xml com a lista de sistemas - */ - protected $xmlsistemas; /* function: __construct Cria um objeto Menutemas parameters: -$map_file - string $map_file Endereço do mapfile no servidor. + +$map_file - (opcional) endereço do mapfile no servidor + +$perfil - (opcional) lista dos perfis, separados por espaços, que devem restringir a lista de menus, grupos, temas e etc. + +$locsistemas - (opcional) endereço do xml com a lista de sistemas adicionais que serão listados na opção de adiçao de temas + +$locaplic - (opcional) endereço físico do i3geo + +$menutemas - (opcional) array contendo a lista de menus para compor a árvore de temas (veja o i3geo/ms_configura) + +$urli3geo - (opcional) url onde está o i3geo (p.ex. http://localhost/i3geo */ - function __construct($map_file="",$perfil="",$locsistemas="") + function __construct($map_file="",$perfil="",$locsistemas="",$locaplic="",$menutemas="",$urli3geo="") { - //error_reporting(E_ALL); + error_reporting(0); $this->perfil = explode(",",$perfil); + if(count($this->perfil) == 0) + $this->perfil = explode(" ",$perfil); $this->xmlsistemas = ""; + $this->locaplic = $locaplic; + $this->menutemas = $menutemas; + $this->urli3geo = $urli3geo; if ($locsistemas != "") $this->xmlsistemas = simplexml_load_file($locsistemas); if (($map_file != "") && (file_exists($map_file))) @@ -93,6 +79,53 @@ $map_file - string $map_file Endereço do mapfile no servidor. } } /* +function: pegaListaDeMenus + +Pega a lista de menus do banco de dados de administração. + +O perfil do usuário é armazenado na seção na inicialização do I3Geo. + +Parameters: + +locmapas - endereço do arquivo xml. + +return: +array +*/ + function pegaListaDeMenus() + { + $resultado = array(); + if($this->menutemas == "") + { + if(!isset($this->locaplic)) + {return "locaplic nao foi definido";} + if(!isset($this->locaplic)) + {return "locaplic nao foi definido";} + include_once($this->locaplic."/admin/php/conexao.php"); + $sql = 'SELECT * from i3geoadmin_menus order by nome_menu'; + $q = $dbh->query($sql,PDO::FETCH_ASSOC); + $regs = $q->fetchAll(); + $dbh = null; + $resultado = array(); + foreach($regs as $reg) + { + $status = "fechado"; + if(strtolower($reg["aberto"]) == "sim") + $status = "aberto"; + $arquivo = "admin/xmlmenutemas.php?id_menu=".$reg["id_menu"]."&perfil=".$reg["perfil_menu"]; + $url = $this->urli3geo."/admin/xmlmenutemas.php?id_menu=".$reg["id_menu"]."&perfil=".$reg["perfil_menu"]; + $resultado[] = array("idmenu"=>$reg["nome_menu"],"arquivo"=>$arquivo,"status"=>$status,"url"=>$url); + } + } + else + {$resultado = $this->menutemas;} + if(count($resultado) == 0) + { + $resultado[] = array("idmenu"=>"i3geo (xml)","arquivo"=>"../menutemas/menutemas.xml","status"=>"aberto"); + } + return ($resultado); + } +/* function: pegaListaDeMapas Le o arquivo xml com a lista de mapas existente no xml $locmapas. @@ -152,42 +185,36 @@ return: array */ - function pegaListaDeGrupos($idmenu="",$listasistemas="sim",$listasgrupos="sim",$menutemas=null) + function pegaListaDeGrupos($idmenu="",$listasistemas="sim",$listasgrupos="sim") { + // + //lê os arquivos xml + //"&tipo=gruposeraiz" pega apenas os nomes dos grupos e temas na raiz + // + if($listasgrupos == "sim") + {$tipo = "";} + else + {$tipo = "&tipo=gruposeraiz";} $this->xml = ""; - //echo $menutemas; - if(isset($menutemas)) - { - if (file_exists("../ms_configura.php")) - {include_once("../ms_configura.php");} - } - if ((isset($menutemas)) && ($menutemas != "") && ($idmenu != "")) + foreach($this->pegaListaDeMenus() as $menu) { - foreach ($menutemas as $m) + if($menu["idmenu"] == $idmenu || $idmenu == "") { - if (($m["idmenu"] == $idmenu)) - {$this->xml = simplexml_load_file($m["arquivo"]);} - } - } - if (($this->xml == "") && ($menutemas == "")) - { - if (file_exists("../menutemas/menutemas.xml")) - {$this->xml = simplexml_load_file("../menutemas/menutemas.xml");} - else - {$this->xml = simplexml_load_file("menutemas/menutemas.xml");} - } - if ($this->xml == "") - { - if (file_exists("../menutemas/menutemas.xml")) - {$this->xml = simplexml_load_file("../menutemas/menutemas.xml");} - else - {$this->xml = simplexml_load_file("menutemas/menutemas.xml");} + $ondexml = $menu["arquivo"]; + if(isset($menu["url"])){$ondexml = $menu["url"];} + $this->xml = simplexml_load_file($ondexml.$tipo); + } } + // + //varre o xml para pegar os dados + // $sistemas = array(); $grupos = array(); $temasraiz = array(); + // //pega os grupos //verifica se existem temas na raiz do menu + // foreach($this->xml->TEMA as $temar) { $down = "nao"; @@ -329,29 +356,14 @@ array function pegaListaDeSubGrupos($codgrupo,$idmenu="") { $this->xml = ""; - if (file_exists("../ms_configura.php")) - {include_once("../ms_configura.php");} - if ((isset($menutemas)) && ($menutemas != "") && ($idmenu != "")) + foreach($this->pegaListaDeMenus() as $menu) { - foreach ($menutemas as $m) + if($menu["idmenu"] == $idmenu) { - if (($m["idmenu"] == $idmenu)) - {$this->xml = simplexml_load_file($m["arquivo"]);} - } - } - if (($this->xml == "") && ($menutemas == "")) - { - if (file_exists("../menutemas/menutemas.xml")) - {$this->xml = simplexml_load_file("../menutemas/menutemas.xml");} - else - {$this->xml = simplexml_load_file("menutemas/menutemas.xml");} - } - if ($this->xml == "") - { - if (file_exists("../menutemas/menutemas.xml")) - {$this->xml = simplexml_load_file("../menutemas/menutemas.xml");} - else - {$this->xml = simplexml_load_file("menutemas/menutemas.xml");} + $ondexml = $menu["arquivo"]; + if(isset($menu["url"])){$ondexml = $menu["url"];} + $this->xml = simplexml_load_file($ondexml."&tipo=subgrupos"); + } } $conta = 0; $subgrupos[] = array(); @@ -433,22 +445,14 @@ array function pegaListaDeTemas($grupo,$subgrupo,$idmenu) { $this->xml = ""; - if (file_exists("../ms_configura.php")) - {include_once("../ms_configura.php");} - if ((isset($menutemas)) && ($menutemas != "") && ($idmenu != "")) + foreach($this->pegaListaDeMenus() as $menu) { - foreach ($menutemas as $m) + if($menu["idmenu"] == $idmenu) { - if (($m["idmenu"] == $idmenu)) - {$this->xml = simplexml_load_file($m["arquivo"]);} - } - } - if ($this->xml == "") - { - if (file_exists("../menutemas/menutemas.xml")) - {$this->xml = simplexml_load_file("../menutemas/menutemas.xml");} - else - {$this->xml = simplexml_load_file("menutemas/menutemas.xml");} + $ondexml = $menu["arquivo"]; + if(isset($menu["url"])){$ondexml = $menu["url"];} + $this->xml = simplexml_load_file($ondexml); + } } $contagrupo = 0; $temas = array(); @@ -532,26 +536,18 @@ $procurar - String que será procurada. function procurartemas($procurar) { $this->xml = array(); - if (file_exists("../ms_configura.php")) - {include_once("../ms_configura.php");} - if ((isset($menutemas)) && ($menutemas != "")) - { - foreach ($menutemas as $m) - { - $this->xml[] = simplexml_load_file($m["arquivo"]); - } - } - if ($this->xml == "") + foreach($this->pegaListaDeMenus() as $menu) { - if (file_exists("../menutemas/menutemas.xml")) - {$this->xml[] = simplexml_load_file("../menutemas/menutemas.xml");} - else - {$this->xml[] = simplexml_load_file("menutemas/menutemas.xml");} - } + $ondexml = $menu["arquivo"]; + if(isset($menu["url"])){$ondexml = $menu["url"];} + $this->xml[] = simplexml_load_file($ondexml); + } $resultado = array(); - $listadetemas = array(); + $texto = array(); foreach ($this->xml as $xml) { + $listadetemas = array(); + $subgrupo = array(); foreach($xml->GRUPO as $grupo) { $incluigrupo = TRUE; @@ -595,23 +591,27 @@ $procurar - String que será procurada. {$down = "sim";} $link = ixml($tema,"TLINK"); $tid = ixml($tema,"TID"); - $texto = array("tid"=>$tid,"nome"=>(ixml($tema,"TNOME")),"link"=>$link,"download"=>$down); - $p1 = $this->removeAcentos($procurar); - $p1 = $this->removeAcentos(htmlentities($p1)); - - $pp1 = $this->removeAcentos(ixml($tema,"TNOME")); - $pp1 = $this->removeAcentos($pp1); - $pp1 = $this->removeAcentos(htmlentities($pp1)); - if (stristr($pp1,$p1) || stristr(ixml($tema,"TNOME"),htmlentities($procurar))) - {$listadetemas[] = $texto;} - - if(ixml($tema,"TAGS") != "") + if(!isset($texto[$tid])) { - $pp1 = ixml($tema,"TAGS"); + $texto[$tid] = array("tid"=>$tid,"nome"=>(ixml($tema,"TNOME")),"link"=>$link,"download"=>$down); + $p1 = $this->removeAcentos($procurar); + $p1 = $this->removeAcentos(htmlentities($p1)); + $pp1 = $this->removeAcentos(ixml($tema,"TNOME")); $pp1 = $this->removeAcentos($pp1); - if (stristr($pp1,$p1)) - {$listadetemas[] = $texto;} + $pp1 = $this->removeAcentos(htmlentities($pp1)); + if (stristr($pp1,$p1) || stristr(ixml($tema,"TNOME"),htmlentities($procurar))) + { + $listadetemas[] = $texto[$tid]; + } + else + if(ixml($tema,"TAGS") != "") + { + $pp1 = ixml($tema,"TAGS"); + $pp1 = $this->removeAcentos($pp1); + if (stristr($pp1,$p1)) + {$listadetemas[] = $texto[$tid];} + } } } } @@ -619,8 +619,9 @@ $procurar - String que será procurada. { $subgrupo[] = array("subgrupo"=>(ixml($sgrupo,"SDTIPO")),"temas"=>$listadetemas); } + $listadetemas = array(); } - $listadetemas = array(); + } if (count($subgrupo) > 0) { @@ -659,21 +660,13 @@ nrss - (opcional) número de registros no rss que serão considerados } } $this->xml = array(); - if (file_exists("../ms_configura.php")) - {include_once("../ms_configura.php");} - if ((isset($menutemas)) && ($menutemas != "")) + $menus = $this->pegaListaDeMenus(); + foreach ($menus as $m) { - foreach ($menutemas as $m) - { - $this->xml[] = simplexml_load_file($m["arquivo"]); - } - } - if ($this->xml == "") - { - if (file_exists("../menutemas/menutemas.xml")) - {$this->xml[] = simplexml_load_file("../menutemas/menutemas.xml");} + if(isset($m["url"])) + $this->xml[] = simplexml_load_file($m["url"]); else - {$this->xml[] = simplexml_load_file("menutemas/menutemas.xml");} + $this->xml[] = simplexml_load_file($m["arquivo"]); } $resultado = array(); $noticias = array(); @@ -722,7 +715,7 @@ nrss - (opcional) número de registros no rss que serão considerados { if($tag != "") { - if(!$resultado[$tag]) + if(!isset($resultado[$tag])) { $resultado[$tag] = array($tid); //busca noticias @@ -735,7 +728,7 @@ nrss - (opcional) número de registros no rss que serão considerados if(in_array(strtolower($t),$titulo)) { //echo $noticia["link"]."
"; - if(!$noticias[$tag]) + if(!isset($noticias[$tag])) $noticias[$tag] = array("titulo"=>$noticia["titulo"],"link"=>$noticia["link"]); else $noticias[$tag] = array_merge($noticias[$tag],array("titulo"=>$noticia["titulo"],"link"=>$noticia["link"])); @@ -760,7 +753,7 @@ nrss - (opcional) número de registros no rss que serão considerados foreach(array_keys($resultado) as $k) { - if($noticias[$k]) + if(isset($noticias[$k])) {$not = array($noticias[$k]);} else {$not = array();} @@ -804,6 +797,5 @@ nrss - (opcional) número de registros no rss que serão considerados //Return FALSE if none of the values from $needle are found in $haystack return FALSE; } - } ?> \ No newline at end of file diff --git a/classesphp/mapa_controle.php b/classesphp/mapa_controle.php index 5064ead..fc91ad4 100644 --- a/classesphp/mapa_controle.php +++ b/classesphp/mapa_controle.php @@ -125,19 +125,6 @@ include_once("../pacotes/cpaint/cpaint2.inc.php"); // $cp = new cpaint(); $cp->set_data(""); -/* -// -//grava na sessão o PID do processo PHP -// -if ($funcao == "terminaProcesso") -{ - $pid = $_SESSION["ultimopid"]; - @exec("taskkill /f /PID $pid 2>&1"); - $cp->set_data($pid); - $cp->return_data(); -} -$_SESSION["ultimopid"] = getmypid(); -*/ if ($funcao == "criaMapa") { session_destroy(); @@ -145,7 +132,7 @@ if ($funcao == "criaMapa") //primeiro é necessário carregar o ms_configura.php para pegar a variável $locaplic // $d = ""; - if(!file_exists($d."ms_configura.php")) + if(!file_exists("ms_configura.php")) $d = "../"; include_once($d."ms_configura.php"); // @@ -169,6 +156,12 @@ include_once("classe_vermultilayer.php"); include_once("classe_estatistica.php"); include_once("funcoes_gerais.php"); // +//identifica qual a url do i3geo +// +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); +$protocolo = $protocolo[0] . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; +$urli3geo = str_replace("/classesphp/mapa_controle.php","",$protocolo.$_SERVER["PHP_SELF"]); +// //substitui a string de conexão // substituiCon($map_file,$postgis_mapa); @@ -1623,7 +1616,7 @@ Pega a lista de tags registrados nos menus de temas. */ case "listaTags": include_once("classe_menutemas.php"); - $m = new Menutemas($map_file,$perfil,$locsistemas); + $m = new Menutemas($map_file,$perfil,$locsistemas,$locaplic,$menutemas,$urli3geo); $cp->set_data($m->listatags($rss,$nrss)); break; /* @@ -1634,10 +1627,9 @@ Pega a lista de menus para incluir na guia adiciona. Parameters: */ case "pegalistademenus": - $menutemas = ""; - if (file_exists("../ms_configura.php")) - {include_once("../ms_configura.php");} - $cp->set_data($menutemas); + include_once("classe_menutemas.php"); + $m = new Menutemas($map_file,$perfil,$locsistemas,$locaplic,$menutemas,$urli3geo); + $cp->set_data($m->pegaListaDeMenus()); break; /* Property: pegalistadegrupos @@ -1660,11 +1652,11 @@ Include: if (file_exists("../ms_configura.php")) {include_once("../ms_configura.php");} include_once("classe_menutemas.php"); - $m = new Menutemas($map_file,$perfil,$locsistemas); + $m = new Menutemas($map_file,$perfil,$locsistemas,$locaplic,$menutemas,$urli3geo); if(!isset($idmenu)){$idmenu="";} if(!isset($listasistemas)){$listasistemas="nao";} - if(!isset($listasgrupos)){$listasgrupos="sim";} - $cp->set_data(array("grupos"=>$m->pegaListaDeGrupos($idmenu,$listasistemas,$listasgrupos,$menutemas))); + if(!isset($listasgrupos)){$listasgrupos="nao";} + $cp->set_data(array("grupos"=>$m->pegaListaDeGrupos($idmenu,$listasistemas,$listasgrupos))); break; /* Property: pegalistadeSubgrupos @@ -1676,7 +1668,7 @@ Include: */ case "pegalistadeSubgrupos": include_once("classe_menutemas.php"); - $m = new Menutemas($map_file,$perfil,$locsistemas); + $m = new Menutemas($map_file,$perfil,$locsistemas,$locaplic,$menutemas,$urli3geo); $cp->set_data($m->pegaListaDeSubGrupos($grupo,$idmenu)); break; /* @@ -1689,7 +1681,7 @@ Include: */ case "pegalistadetemas": include_once("classe_menutemas.php"); - $m = new Menutemas($map_file,$perfil,$locsistemas); + $m = new Menutemas($map_file,$perfil,$locsistemas,$locaplic,$menutemas,$urli3geo); $cp->set_data(array("temas"=>$m->pegaListaDeTemas($grupo,$subgrupo,$idmenu))); break; /* @@ -1702,7 +1694,7 @@ Include: */ case "procurartemas": include_once("classe_menutemas.php"); - $m = new Menutemas($map_file,$perfil); + $m = new Menutemas($map_file,$perfil,$locsistemas,$locaplic,$menutemas,$urli3geo); $cp->set_data($m->procurartemas($procurar)); break; /* @@ -1717,7 +1709,7 @@ Include: */ case "pegaMapas": include_once("classe_menutemas.php"); - $m = new Menutemas($map_file,$perfil); + $m = new Menutemas($map_file,$perfil,$locsistemas,$locaplic,$menutemas,$urli3geo); $cp->set_data($m->pegaListaDeMapas($locmapas)); break; /* diff --git a/classesphp/mapa_inicia.php b/classesphp/mapa_inicia.php index 2a8886a..a39c01a 100644 --- a/classesphp/mapa_inicia.php +++ b/classesphp/mapa_inicia.php @@ -87,6 +87,17 @@ Se $expoeMapfile = "nao", o nome do mapfile não é retornado function iniciaMapa() { global $tituloInstituicao,$tempo,$navegadoresLocais,$locaplic,$cp,$embedLegenda,$map_file,$mapext,$w,$h,$locsistemas,$locidentifica,$R_path,$locmapas,$locmapserv,$postgis_con,$utilizacgi,$expoeMapfile; + // + //pega o xml com os sietmas para identificação + // + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); + $protocolo = $protocolo[0]; + $protocolo = $protocolo . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; + $urli3geo = str_replace("/classesphp/mapa_controle.php","",$protocolo.$_SERVER["PHP_SELF"]); + if($locidentifica == "") + { + $locidentifica = $urli3geo."/admin/xmlidentifica.php"; + } if (!file_exists($locaplic)) {$cp->set_data("erro. $locaplic nao existe (variavel locaplic - corrija o ms_configura.php)");return;} if (!file_exists($map_file)) @@ -127,8 +138,6 @@ function iniciaMapa() } } } - //if($utilizacgi == "sim") - //{$m->ligaDesligaTemas("","todos");} // //cuidado ao mexer aqui //o mapa precisa ser salvo para registrar a extensão geográfica diff --git a/datadownload.htm b/datadownload.htm index e969ca3..4e5b7de 100644 --- a/datadownload.htm +++ b/datadownload.htm @@ -56,7 +56,7 @@ O formato "shape file" é composto por três arquivos (shp, shx e dbf