From e2e0ef616dd12856f2a15fe2e40c870af4f45709 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Fri, 25 Jan 2008 17:00:53 +0000 Subject: [PATCH] ticket #28 - acrescentada a possibilidade de inclusão de temas dinâmicos (temas que são programas em PHP) no menu de temas --- classesphp/classe_mapa.php | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------- menutemas/menutemas.xml | 6 ++++++ temas/testephp.php | 19 +++++++++++++++++++ 3 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 temas/testephp.php diff --git a/classesphp/classe_mapa.php b/classesphp/classe_mapa.php index fc5ee4c..28bef7f 100644 --- a/classesphp/classe_mapa.php +++ b/classesphp/classe_mapa.php @@ -661,66 +661,73 @@ $locaplic - string Diretório onde fica a aplicação. foreach ($temas as $nome) { $nomemap = ""; - if (file_exists($locaplic."/temas/".$nome.".map")) - {$nomemap = $locaplic."/temas/".$nome.".map";} - if (file_exists($nome)) - {$nomemap = $nome;} - if (file_exists($nome.".map")) - {$nomemap = $nome.".map";} - if ($nomemap != "") + // + //verifica se o tema é um arquivo php + // + if (file_exists($locaplic."/temas/".$nome.".php")) + {include_once($locaplic."/temas/".$nome.".php");} + else { - $nmap = ms_newMapObj($nomemap); - $novosnomes = $nmap->getAllLayerNames(); - //define nomes unicos para os temas - foreach ($novosnomes as $n) - {$nomeunico[$n] = nomeRandomico();} - //altera os temas para incluir o nome unico - foreach ($novosnomes as $n) + if (file_exists($locaplic."/temas/".$nome.".map")) + {$nomemap = $locaplic."/temas/".$nome.".map";} + if (file_exists($nome)) + {$nomemap = $nome;} + if (file_exists($nome.".map")) + {$nomemap = $nome.".map";} + if ($nomemap != "") { - $nlayer = $nmap->getlayerbyname($n); - // - //muda para RGB para melhorar o desenho da imagem raster - // - if($nlayer->type == MS_LAYER_RASTER) - { - $of = $this->mapa->outputformat; - $of->set("imagemode",MS_IMAGEMODE_RGB); - } - $nlayer->set("status",MS_DEFAULT); - $nlayer->setmetadata("nomeoriginal",$nlayer->name); - $nlayer->set("name",$nomeunico[$n]); - //altera o nome do grupo se existir - if ($nlayer->group != " ") + $nmap = ms_newMapObj($nomemap); + $novosnomes = $nmap->getAllLayerNames(); + //define nomes unicos para os temas + foreach ($novosnomes as $n) + {$nomeunico[$n] = nomeRandomico();} + //altera os temas para incluir o nome unico + foreach ($novosnomes as $n) { - $lr = $nlayer->group; - $nlayer->set("group",$nomeunico[$lr]); - } - ms_newLayerObj($this->mapa, $nlayer); - $l = $this->mapa->getlayerbyname($nlayer->name); - //reposiciona o layer se for o caso - if ($l->group == "") - { - $ltipo = $l->type; - if (($ltipo == 2) || ($ltipo == 3))//poligono = 2 + $nlayer = $nmap->getlayerbyname($n); + // + //muda para RGB para melhorar o desenho da imagem raster + // + if($nlayer->type == MS_LAYER_RASTER) { - $indicel = $l->index; - $numlayers = $this->mapa->numlayers; - $nummove = 0; - for ($i = $numlayers-1;$i > 0;$i--) - { - $layerAbaixo = $this->mapa->getlayer($i); - $tipo = $layerAbaixo->type; - if (($tipo != 2) && ($tipo != 3)) - {$nummove++;} - } - if ($nummove > 2) + $of = $this->mapa->outputformat; + $of->set("imagemode",MS_IMAGEMODE_RGB); + } + $nlayer->set("status",MS_DEFAULT); + $nlayer->setmetadata("nomeoriginal",$nlayer->name); + $nlayer->set("name",$nomeunico[$n]); + //altera o nome do grupo se existir + if ($nlayer->group != " ") + { + $lr = $nlayer->group; + $nlayer->set("group",$nomeunico[$lr]); + } + ms_newLayerObj($this->mapa, $nlayer); + $l = $this->mapa->getlayerbyname($nlayer->name); + //reposiciona o layer se for o caso + if ($l->group == "") + { + $ltipo = $l->type; + if (($ltipo == 2) || ($ltipo == 3))//poligono = 2 { - for ($i=0;$i<=($nummove - 3);$i++) + $indicel = $l->index; + $numlayers = $this->mapa->numlayers; + $nummove = 0; + for ($i = $numlayers-1;$i > 0;$i--) { - $this->mapa->movelayerup($indicel); + $layerAbaixo = $this->mapa->getlayer($i); + $tipo = $layerAbaixo->type; + if (($tipo != 2) && ($tipo != 3)) + {$nummove++;} + } + if ($nummove > 2) + { + for ($i=0;$i<=($nummove - 3);$i++) + { + $this->mapa->movelayerup($indicel); + } } } - } } } diff --git a/menutemas/menutemas.xml b/menutemas/menutemas.xml index 9ab1e4f..1edb325 100644 --- a/menutemas/menutemas.xml +++ b/menutemas/menutemas.xml @@ -112,6 +112,12 @@ File: i3geo/menutemas/menutemas.xml + + testephp + Teste de inclusao de tema PHP + + + \ No newline at end of file diff --git a/temas/testephp.php b/temas/testephp.php new file mode 100644 index 0000000..38427d3 --- /dev/null +++ b/temas/testephp.php @@ -0,0 +1,19 @@ +mapa +//$this->arquivo +// +// exemplo +// +$layer = $this->mapa->getlayerbyname("copyright"); +$layer->set("status",MS_DEFAULT); +$shp = ms_newshapeobj(MS_SHAPE_POINT); +$shp->set("text","teste .... teste"); +$lin = ms_newlineobj(); +$lin->addxy(200,100); +$shp->add($lin); +$layer->addfeature($shp); +$shp->free(); +?> \ No newline at end of file -- libgit2 0.21.2