title = $title; } public $title; } $locale = ""; $userInput = ""; $target = ""; $popup = 0; $layerName = ""; $mapName = ""; $sessionId = ""; $filter = ""; $resNames = array(); $resProps = array(); $matchLimit = ""; GetRequestParameters(); SetLocalizedFilesPath(GetLocalizationPath()); $searchError = GetLocalizedString("SEARCHERROR", $locale); try { InitializeWebTier(); $cred = new MgUserInformation($sessionId); //connect to the site and get a feature service and a resource service instances $site = new MgSiteConnection(); $site->Open($cred); $featureSrvc = $site->CreateService(MgServiceType::FeatureService); $resourceSrvc = $site->CreateService(MgServiceType::ResourceService); //Create a temporary map runtime object, locate the layer $map = new MgMap(); $map->Open($resourceSrvc, $mapName); $layers = $map->GetLayers(); $layer = null; for($i = 0; $i < $layers->GetCount(); $i++) { $layer = $layers->GetItem($i); if($layer->GetName() == $layerName) break; } if($layer == null) { trigger_error(FormatMessage("SEARCHLAYERNOTFOUND", $locale, $locale, array($layerName))); } //unescape strings // if(ini_get("magic_quotes_sybase") == "1") { $matchLabel = str_replace("''", "'", $matchLabel); $filter = str_replace("''", "'", $filter); } else if(get_magic_quotes_gpc() == "1") { //Unescape single quotes $filter = str_replace("\\'", "'", $filter); //Unescape double quotes $filter = str_replace('\\"', '"', $filter); //remove additional backslash $filter = str_replace("\\", "", $filter); } //substitute the input tag with the actual user input to make up the filter $filter = str_replace('$USER_VARIABLE', $userInput, $filter); //parse the match label string, which defines what columns to be displayed $displayAll = (count($resProps) == 0); //query the features $opts = new MgFeatureQueryOptions(); $opts->SetFilter($filter); $featureClassName = $layer->GetFeatureClassName(); $srcId = new MgResourceIdentifier($layer->GetFeatureSourceId()); $features = $featureSrvc->SelectFeatures($srcId, $featureClassName, $opts); $hasResult = $features->ReadNext(); if($hasResult) { $colCount = $displayAll? $features->GetPropertyCount(): count($resProps); //output the beginning of the document (head section and beginning of body section) $templ = file_get_contents("../viewerfiles/search.templ"); $templ = Localize($templ, $locale, GetClientOS()); print sprintf($templ, $colCount, $target, $popup); $classDef = $features->GetClassDefinition(); $idProps = $classDef->GetIdentityProperties(); $idPropNames = array(); for($j = 0; $j < $idProps->GetCount(); $j++) { $idProp = $idProps->GetItem($j); array_push($idPropNames, $idProp->GetName()); } //table headings echo "