0)) { $buffer = 0; } # Turn the highlight string into a boolean $highlight = strtolower($highlight); if($highlight == 'on' or $highlight == 'true') { $highlight = true; } else { $highlight = false; } $map = ms_newMapObj($mapfile) or appError('Could not open "'.$mapfile.'!"'); $layers = explode(',', $layers); $found = false; $ext = 0; $minx = 0; $miny = 0; $maxx = 0; $maxy = 0; $foundOnLayer = ''; for($l = 0; $l < $map->numlayers and !$found; $l++) { $lay = $map->getLayer($l); $inCGI = false; for($cgi = 0; $cgi < count($layers); $cgi++) { if($lay->name == $layers[$cgi]) { $inCGI = true; } } if($lay->status == MS_DEFAULT or $inCGI == true) { $queryTemplate = $lay->getMetaData("ITEMQUERY_TEMPLATE"); $queryHeader = $lay->getMetaData("ITEMQUERY_HEADER"); $queryFooter = $lay->getMetaData("ITEMQUERY_FOOTER"); if($queryTemplate != "") { $lay->set('template', $queryTemplate); } else { $lay->set('template', 'dummy.html'); } $lay->set('header', $queryHeader); $lay->set('footer', $queryFooter); $result = $lay->queryByAttributes($item, $string, MS_SINGLE); if($result == MS_SUCCESS) { $lay->open(); $res = $lay->getResult(0); $sh = $lay->getFeature($res->shapeindex, $res->tileindex); $minx = $sh->bounds->minx - $buffer; $miny = $sh->bounds->miny - $buffer; $maxx = $sh->bounds->maxx + $buffer; $maxy = $sh->bounds->maxy + $buffer; $lay->close(); $found = true; $foundOnLayer = $lay->name; } } } $template = $map->processQueryTemplate(array(), array()); $replaceArr = array(); $replaceArr['[MAPFILE]'] = $mapfile; $replaceArr['[map]'] = $mapfile; $replaceArr['[QSTRING]'] = $string; $replaceArr['[QITEM]'] = $item; if(!$found) { if(isset($ZOOMTO_EMPTY_PAGE)) { $contents = file_get_contents($ZOOMTO_EMPTY_PAGE); foreach($replaceArr as $key=>$value) { $contents = str_replace($key, $value, $contents); } print $contents; } else { $errorStr = sprintf("Cound not find results.
Mapfile: %s
Layers (Non-Default): %s
Query Item: %s
Query String: %s", $mapfile, $_REQUEST['layers'], $item, $string); appError($errorStr); } } else { if($mode == 'bounds-only') { header("Content-type: text/plain"); printf("%0.3f,%0.3f,%0.3f,%0.3f", $minx, $miny, $maxx, $maxy); } else if($mode == 'xml') { header("Content-type: text/xml"); #print ""; print ""; printf("%0.3f,%0.3f,%0.3f,%0.3f", $minx, $miny, $maxx, $maxy); printf("", 'Highlight'); printf("%s", $mapfile); printf("", $foundOnLayer); printf(""); printf("", $item); printf("", $string); printf(""); print ""; #print ""; } else { header("Content-type: text/html"); print ''; print "\n"; print "\n"; printf("%0.3f,%0.3f,%0.3f,%0.3f", $minx, $miny, $maxx, $maxy); if($highlight) { printf("", 'Highlight'); printf("%s", $mapfile); printf("", $foundOnLayer); printf(""); printf("", $item); printf("", $string); printf(""); } print "\n"; print "\n"; print ""; print "$value) { $template = str_replace($key, $value, $template); } print $template; print "]]>"; print ""; print ""; } } ?>