From 181864dbcf81b7bd86c78bdfc48c09239f659e1c Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Sat, 22 Nov 2014 15:31:17 +0000 Subject: [PATCH] Correção na listagem de elementos selecionados na ferramenta tabela --- classesphp/classe_atributos.php | 15 ++++++++------- classesphp/funcoes_gerais.php | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/classesphp/classe_atributos.php b/classesphp/classe_atributos.php index 7c6f17d..adbbdef 100644 --- a/classesphp/classe_atributos.php +++ b/classesphp/classe_atributos.php @@ -438,7 +438,7 @@ class Atributos else{ $alias = $items; } - $shapes = retornaShapesSelecionados($this->layer,$this->arquivo,$this->mapa); + $shapes = retornaShapesSelecionados($this->layer,$this->arquivo,$this->mapa,true); $res_count = count($shapes); $resultadoFinal[] = array("totalSelecionados"=>$res_count,"itens"=>$items,"alias"=>$alias); $registros = array(); @@ -451,6 +451,11 @@ class Atributos } if ($tipolista == "selecionados"){ $chk = "CHECKED"; + //cria um novo array apenas para funcionar no contador + $s = array(); + foreach($shapes as $shape){ + $s[] = $shape; + } if ($fim != ""){ if (($res_count >= $fim) && ($fim < $res_count)){ $res_count = $fim; @@ -458,7 +463,7 @@ class Atributos } for ($i = $inicio; $i < $res_count; ++$i){ $valitem = array(); - $shape = $shapes[$i]; + $shape = $s[$i]; $indx = $shape->index; foreach ($items as $item){ $valori = trim($shape->values[$item]); @@ -483,12 +488,8 @@ class Atributos } if ($tipolista == "tudo"){ //ini_set('memory_limit', '500M'); - $shp_atual = array(); - for ($i = 0; $i < $res_count;++$i){ - $shp_atual[$i] = $shapes[$i];; - } + $shp_atual = $shapes; $chk = ""; - if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS){ $res_count = $this->layer->getNumresults(); $totalGeral = $res_count; diff --git a/classesphp/funcoes_gerais.php b/classesphp/funcoes_gerais.php index 3cc74c1..0d203de 100644 --- a/classesphp/funcoes_gerais.php +++ b/classesphp/funcoes_gerais.php @@ -2465,7 +2465,7 @@ function retornaShapesMapext($objLayer,$objMapa){ $objLayer->close(); return $shapes; } -function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ +function retornaShapesSelecionados($objLayer,$map_file,$objMapa,$indexado=false){ $shapes = array(); $qyfile = dirname($map_file)."/".$objLayer->name.".php"; @@ -2497,14 +2497,21 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ for ($i = 0; $i < $res_count; ++$i) { - if($versao == 6) - {$shape = $objLayer->getShape($objLayer->getResult($i));} + if($versao == 6){ + $shape = $objLayer->getShape($objLayer->getResult($i)); + $shp_index = $shape->index; + } else{ $result = $objLayer->getResult($i); $shp_index = $result->shapeindex; $shape = $objLayer->getfeature($shp_index,-1); } - $shapes[] = $shape; + if($indexado == true){ + $shapes[$shp_index] = $shape; + } + else{ + $shapes[] = $shape; + } } $fechou = $objLayer->close(); } @@ -2520,7 +2527,12 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ while ($shape = $objLayer->nextShape()) { if(in_array($shape->index,$listaDeIndices)){ - $shapes[] = $shape; + if($indexado == true){ + $shapes[$shape->index] = $shape; + } + else{ + $shapes[] = $shape; + } } } $objLayer->close(); -- libgit2 0.21.2