title = $title; } public $title; } $locale = GetDefaultLocale(); $userInput = ""; $target = ""; $popup = 0; $layerName = ""; $mapName = ""; $sessionId = ""; $filter = ""; $resNames = array(); $resProps = array(); $matchLimit = ""; GetRequestParameters(); SetLocalizedFilesPath(GetLocalizationPath()); $searchError = GetLocalizedString("SEARCHERROR", $locale); try { $featureSrvc = $siteConnection->CreateService(MgServiceType::FeatureService); //Create a temporary map runtime object, locate the layer $map = new MgMap(); $map->Open($resourceService, $mapName); $layers = $map->GetLayers(); $layer = null; //fwrite($logHandle,"found layers:".$layers->GetCount()."\n"); for($i = 0; $i < $layers->GetCount(); $i++) { $layer = $layers->GetItem($i); //fwrite($logHandle,"found layer:".$layer->GetName()."\n"); 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); } //fwrite($logHandle,"filter before:".$filter."\n"); //substitute the input tag with the actual user input to make up the filter $filter = str_replace('$USER_VARIABLE', $userInput, $filter); //fwrite($logHandle,"filter after:".$filter."\n"); //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) { //fwrite($logHandle,"has result\n"); $colCount = $displayAll? $features->GetPropertyCount(): count($resProps); //output the beginning of the document (head section and beginning of body section) $templ = file_get_contents("./Search.templ"); $templ = Localize($templ, $locale, GetClientOS()); print sprintf($templ, $colCount, $target, $popup, $mapName); $classDef = $features->GetClassDefinition(); $idProps = $classDef->GetIdentityProperties(); $multiIds = $idProps->GetCount() > 1; $idPropNames = array(); $idPropTypes = array(); for($j = 0, $count = count($idProps); $j < $count; $j++) { $idProp = $idProps->GetItem($j); if($multiIds) array_push($idPropNames, $idProp->GetName()); else $idPropName = $idProp->GetName(); } //table headings echo "