[Mapbender-commits] r2871 - in branches/nimix_dev/http: classes javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Aug 18 12:15:57 EDT 2008


Author: nimix
Date: 2008-08-18 12:15:56 -0400 (Mon, 18 Aug 2008)
New Revision: 2871

Added:
   branches/nimix_dev/http/classes/class_wmc.php
   branches/nimix_dev/http/javascripts/mod_gazetteerSQL_client.php
   branches/nimix_dev/http/javascripts/mod_wfs_gazetteer_client.php
Log:
merge

Added: branches/nimix_dev/http/classes/class_wmc.php
===================================================================
--- branches/nimix_dev/http/classes/class_wmc.php	                        (rev 0)
+++ branches/nimix_dev/http/classes/class_wmc.php	2008-08-18 16:15:56 UTC (rev 2871)
@@ -0,0 +1,1075 @@
+<?php
+# $Id: class_wmc.php 2133 2008-02-20 16:07:05Z nimix $
+# http://www.mapbender.org/index.php/class_wmc.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__) . "/../classes/class_wms.php");
+require_once(dirname(__FILE__) . "/../classes/class_layer_monitor.php");
+require_once(dirname(__FILE__) . "/../classes/class_point.php");
+require_once(dirname(__FILE__) . "/../classes/class_bbox.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
+require_once(dirname(__FILE__) . "/../classes/class_map.php");
+require_once(dirname(__FILE__) . "/../classes/class_administration.php");
+require_once(dirname(__FILE__) . "/../classes/class_wmcToXml.php");
+
+/**
+ * Implementation of a Web Map Context Document, WMC 1.1.0
+ * 
+ * Use cases:
+ * 
+ * Instantiation (1) create a WMC object from a WMC XML document
+ * 		$myWmc = new wmc();
+ * 		$myWmc->createFromXml($xml);
+ * 
+ *    If you want to create a WMC object from a WMC in the database
+ *    	$xml = wmc::getDocument($wmcId);
+ * 		$myWmc = new wmc();
+ * 		$myWmc->createFromXml($xml);
+ *    
+ * 
+ * Instantiation (2) create a WMC from the client side
+ * 		$myWmc = new wmc();
+ * 		$myWmc->createFromJs($mapObject, $generalTitle, $extensionData);
+ * 	
+ * 	  	(creates a WMC from the JS data and then creates an object from that WMC)
+ * 
+ * Output (1) (do Instantiation first) Load a WMC into client
+ * 		This will return an array of JS statements
+ *  
+ * 		$myWmc->toJavaScript();
+ * 
+ * Output (2) (do Instantiation first) Merge with another WMC, then load
+ * 	
+ * 		$myWmc->merge($anotherWmcXml);
+ * 		$myWmc->toJavaScript();
+ * 
+ */
+class wmc {
+	/**
+	 * Representing the main map in a map application
+	 * @var Map
+	 */
+	var $mainMap;
+
+	/**
+	 * Representing an (optional) overview map in a map application
+	 * @var Map
+	 */
+	var $overviewMap;
+
+	/**
+	 * @var Array
+	 */
+	var $generalExtensionArray = array();
+
+	/**
+	 * The XML representation of this WMC.
+	 * @var String
+	 */
+	var $xml;
+	
+	// constants
+	var $monitoringIsOn = false;
+	var $saveWmcAsFile = true;
+	var $extensionNamespace = "mapbender";
+	var $extensionNamespaceUrl = "http://www.mapbender.org";
+		
+	// set in constructor
+	var $wmc_id;
+	var $userId;
+
+	// set during parsing
+	var $wmc_version;
+	var $wmc_name;
+	var $wmc_title;
+	var $wmc_abstract;
+	var $wmc_keyword = array();
+	var $wmc_contactposition;
+	var $wmc_contactvoicetelephone;
+	var $wmc_contactemail;
+	var $wmc_contactfacsimiletelephone;
+	var $wmc_contactperson;
+	var $wmc_contactorganization;
+	var $wmc_contactaddresstype;
+	var $wmc_contactaddress;
+	var $wmc_contactcity;
+	var $wmc_contactstateorprovince;
+	var $wmc_contactpostcode;
+	var $wmc_contactcountry;
+	var $wmc_logourl;
+	var $wmc_logourl_format;
+	var $wmc_logourl_type;
+	var $wmc_logourl_width;
+	var $wmc_logourl_height;
+	var $wmc_descriptionurl;
+	var $wmc_descriptionurl_format;
+	var $wmc_descriptionurl_type;
+
+	public function __construct () {
+		$this->userId = $_SESSION["mb_user_id"];
+		$this->wmc_id = time();
+	} 
+	
+	// ---------------------------------------------------------------------------
+	// INSTANTIATION
+	// ---------------------------------------------------------------------------
+
+	/**
+	 * Parses the XML string and instantiates the WMC object.
+	 * 
+	 * @param $xml String
+	 */
+	public function createFromXml ($xml) {
+		return $this->createObjFromWMC_xml($xml);
+	}
+
+	/**
+	 * Loads a WMC from the database.
+	 * 
+	 * @param integer $wmc_id the ID of the WMC document in the database table "mb_user_wmc"
+	 */
+	function createFromDb($wmcId){
+		$this->monitoringIsOn = true;
+		
+		$doc = wmc::getDocument($wmcId);
+		$this->createObjFromWMC_xml($doc);
+	}
+
+	public function createFromApplication ($appId) {
+		// get the map objects "overview" and "mapframe1"
+		$this->mainMap = map::selectMainMapByApplication($appId);
+		$this->overviewMap = map::selectOverviewMapByApplication($appId);
+		$this->createXml();
+		$this->saveAsFile();
+	}
+
+	/**
+	 * Creates a WMC object from a JS map object {@see map_obj.js}
+	 * 
+	 * @param object $mapObject a map object
+	 * @param integer $user_id the ID of the current user
+	 * @param string $generalTitle the desired title of the WMC
+	 * @param object $extensionData data exclusive to Mapbender, which will be 
+	 * 								mapped into the extension part of the WMC
+	 */
+	public function createFromJs($mapObject, $generalTitle, $extensionData) {
+	
+		if (count($mapObject) > 2) {
+			$e = new mb_exception("Save WMC only works for two concurrent map frames (overview plus main) at the moment.");
+		}
+		
+		// set extension data		
+		$this->generalExtensionArray = $extensionData;
+
+		// set title
+		$this->wmc_title = $generalTitle;
+		
+		// create the map objects
+		for ($i = 0; $i < count($mapObject); $i++) {
+			$currentMap = new Map();
+			$currentMap->createFromJs($mapObject[$i]);
+
+			if (isset($mapObject[$i]->isOverview)) {
+				$this->overviewMap = $currentMap;
+			}
+			else {
+				$this->mainMap = $currentMap;
+			}
+		}
+
+		
+		// create XML
+		$this->createXml();
+
+		$this->saveAsFile();
+		return true;
+	}
+	
+	// ---------------------------------------------------------------------------
+	// DATABASE FUNCTIONS
+	// ---------------------------------------------------------------------------
+
+	/**
+	 * Stores this WMC in the database. The WMC has to be instantiated first, see above.
+	 * 
+	 * @return mixed[] an assoc array with attributes "success" (boolean) and "message" (String).
+	 */
+	public function insert () {
+		$result = array();
+		if ($this->userId && $this->xml && $this->wmc_title) {
+			$sql = "INSERT INTO mb_user_wmc VALUES ($1, $2, $3, $4, $5)";
+			$v = array($this->wmc_id, $this->userId, $this->xml, $this->wmc_title, time());
+			$t = array("s", "i", "s", "s", "s");
+			
+			$res = db_prep_query($sql, $v, $t);
+			if (db_error()) {
+				$errMsg = "Error while saving WMC document '" . $this->wmc_title . "': " . db_error();
+				$result["success"] = false;
+				$result["message"] = $errMsg;
+				$e = new mb_exception("mod_insertWMCIntoDB: " . $errMsg);
+			}
+			else {
+				$result["success"] = true;
+				$msg = "WMC document '" . $this->wmc_title . "' has been saved.";
+				$result["message"] = $msg;
+				$e = new mb_notice("mod_insertWMCIntoDB: WMC  '" . $this->wmc_title . "' saved successfully.");
+			}
+		}
+		else {
+			$result["success"] = false;
+			$errMsg = "missing parameters (user_id: ".$this->userId.", title: " . $this->wmc_title . ")";
+			$result["message"] = $errMsg;
+			$e = new mb_exception("mod_insertWMCIntoDB: " . $errMsg .")");
+		}
+		return $result;
+	}
+	
+	/**
+	 * deletes a {@link http://www.mapbender.org/index.php/WMC WMC} 
+	 * entry specified by wmc_id and user_id
+	 *
+	 * @param	integer		the user_id
+	 * @param	string		the wmc_id
+	 * @return	boolean		Did the query run successful?
+	 */
+	public static function delete ($wmcId, $userId) {
+		if (!isset($userId) || $userId === null) {
+			$userId = $_SESSION["mb_user_id"];
+		}
+		
+		$sql = "DELETE FROM mb_user_wmc ";
+		$sql .= "WHERE fkey_user_id = $1 AND wmc_id = $2";
+		$v = array($userId, $wmcId);
+		$t = array('i', 's');
+		$res = db_prep_query($sql, $v, $t);
+		if ($res) {
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Returns a WMC document
+	 * @return String|boolean The document if it exists; else false
+	 * @param $id String the WMC id
+	 */
+	public static function getDocument ($id) {
+		$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = $1";
+		$v = array($id);
+		$t = array('s');
+		$res = db_prep_query($sql,$v,$t);
+		$row = db_fetch_array($res);
+		if ($row) {
+			return $row["wmc"];
+		}
+		return false;
+	}
+
+	// ---------------------------------------------------------------------------
+	// GETTER FUNCTIONS
+	// ---------------------------------------------------------------------------
+	
+	/**
+	 * @return string the title of the WMC.
+	 */
+	public function getTitle() {
+		return $this->wmc_title;
+	}
+
+	// ---------------------------------------------------------------------------
+	// OUTPUT FUNCTIONS
+	// ---------------------------------------------------------------------------
+	
+	/**
+	 * Wrapper function, returns XML at the moment
+	 * @return String
+	 */
+	public function __toString() {
+		return $this->toXml();
+	}
+
+	/**
+	 * Returns the XML document if available
+	 * 
+	 * @return String The XML document; if unavailable, null is returned.
+	 */
+	public function toXml () {
+		if (!$this->xml) {
+			$this->createXml();
+		}
+		return $this->xml;
+	}
+
+	/**
+	 * Returns an array of JavaScript statements
+	 * 
+	 * @return String[]
+	 */
+	public function toJavaScript () {
+/*
+		// counts how often a layer has been loaded
+		if ($this->monitoringIsOn) {
+			$monitor = new Layer_load_count();
+			for ($i = 0; $i < count($this->wmc_layer_id); $i++) {
+				$monitor->increment($this->wmc_layer_id[$i]);
+			}
+		}
+*/		
+		// will contain the JS code to create the maps
+		// representing the state stored in this WMC
+		$wmcJsArray = array();
+		
+		// set general extension data
+		if (count($this->generalExtensionArray) > 0) {
+			$json = new Mapbender_JSON();
+			array_push($wmcJsArray, "restoredWmcExtensionData = " . $json->encode($this->generalExtensionArray) . ";"); 
+		}
+		
+		// reset WMS data
+		array_push($wmcJsArray, "wms = [];");
+		array_push($wmcJsArray, "wms_layer_count = 0;");
+
+		// add WMS for main map frame
+		$wmsArray = $this->mainMap->getWmsArray();
+		// for all wms...
+		for ($i = 0; $i < count($wmsArray); $i++) {
+			// ..add wms and set properties
+			array_push($wmcJsArray, $wmsArray[$i]->createJsObjFromWMS_());
+		}
+
+		// delete existing map objects...
+		array_push($wmcJsArray, "mb_mapObj = [];");
+
+		// .. and add the overview map (if exists)
+		if ($this->overviewMap !== null) {
+			// find the WMS in the main map which is equal to the WMS
+			// in the overview map
+			$ovWmsArray = $this->overviewMap->getWmsArray();
+			$overviewWmsIndex = 0;
+			for ($i = 0; $i < count($ovWmsArray); $i++) {
+				for ($j = 0; $j < count($wmsArray); $j++) {
+					if ($ovWmsArray[$i]->equals($wmsArray[$j])) {
+						$overviewWmsIndex = $j;						
+						break;
+					}
+				}
+			}
+			$wmcJsArray = array_merge($wmcJsArray, $this->overviewMap->toJavaScript($overviewWmsIndex));
+
+		}
+
+		// .. and add main map ..
+		$wmcJsArray = array_merge($wmcJsArray, $this->mainMap->toJavaScript(null));
+
+		// Finally, request the maps
+		array_push($wmcJsArray, "setMapRequest('" . $this->mainMap->getFrameName() . "');");
+		if ($this->overviewMap !== null) {
+			array_push($wmcJsArray, "setMapRequest('" . $this->overviewMap->getFrameName() . "');");
+		}
+
+		array_push($wmcJsArray, "eventAfterLoadWMS.trigger();");
+		return $wmcJsArray;
+	}
+	
+	// ------------------------------------------------------------------------
+	// manipulation
+	// ------------------------------------------------------------------------
+	/**
+	 * Merges this WMC with another WMC.
+	 * The settings of the other WMC overwrite the settings of this WMC.
+	 * 
+	 * @return void
+	 * @param $xml2 Object
+	 */
+	public function merge ($xml2) {
+		$someWmc = new wmc();
+		$someWmc->createFromXml($xml2);
+
+		$this->mainMap->merge($someWmc->mainMap);
+		if (isset($this->overviewMap) && isset($someWmc->overviewMap)) {
+			$this->overviewMap->merge($someWmc->overviewMap);
+		}
+	}
+
+	/**
+	 * Appends the layers of another WMC to this WMC.
+	 * 
+	 * @return void
+	 * @param $xml2 Object
+	 */
+	public function append ($xml2) {
+		$someWmc = new wmc();
+		$someWmc->createFromXml($xml2);
+
+		$this->mainMap->append($someWmc->mainMap);
+		if (isset($this->overviewMap) && isset($someWmc->overviewMap)) {
+			// There is only one WMS in the overview map; merge, not append
+			$this->overviewMap->merge($someWmc->overviewMap);
+		}
+	}
+
+	/**
+	 * Adds a WMS to this WMC
+	 * 
+	 * @return 
+	 */
+	public function appendWmsArray ($wmsArray) {
+		return $this->mainMap->appendWmsArray($wmsArray);
+	}
+	
+	/**
+	 * Merges a WMS into this WMC
+	 * 
+	 * @return 
+	 */
+	public function mergeWmsArray ($wmsArray) {
+		$this->mainMap->mergeWmsArray($wmsArray);
+	}
+
+// ---------------------------------------------------------------------------
+// private functions
+// ---------------------------------------------------------------------------
+
+	/**
+	 * Loads a WMC from an actual WMC XML document.
+	 * Uses WMS class.
+	 * 
+	 * @param string $data the data from the XML file
+	 */
+	private function createObjFromWMC_xml($data){
+		// store xml 
+		$this->xml = $data;
+	
+		$values = administration::parseXml($data);
+
+		//
+		// Local variables that indicate which section of the WMC
+		// is currently parsed.
+		//
+		$extension = false;		$general = false;		$layerlist = false;
+		$layer = false;  		$formatlist = false;	$dataurl = false;
+		$metadataurl = false; 	$stylelist = false;
+
+		//
+		// reset WMC data
+		//
+		$this->mainMap = new Map();
+		$this->overviewMap = null;
+		$this->generalExtensionArray = array();
+		
+		$layerlistArray = array();
+		$layerlistArray["main"] = array();
+		$layerlistArray["overview"] = array();
+			 
+		foreach ($values as $element) {
+			$tag = strtoupper(administration::sepNameSpace($element[tag]));
+			$tagLowerCase = administration::sepNameSpace($element[tag]);
+			$type = $element[type];
+			$attributes = $element[attributes];
+			$value = mb_utf8_decode(html_entity_decode($element[value])); // TODO: not sure if utf decoding is necessary
+			
+			if ($tag == "VIEWCONTEXT" && $type == "open") {
+				$this->wmc_id = $attributes["id"];
+				$this->wmc_version = $attributes["version"];
+			}
+			if ($tag == "GENERAL" && $type == "open") {
+				$general = true;
+			}
+			if ($tag == "LAYERLIST" && $type == "open") {
+				$layerlist = true;
+			}
+			if ($general) {
+				if ($tag == "WINDOW") {
+					$this->mainMap->setWidth($attributes["width"]);
+					$this->mainMap->setHeight($attributes["height"]);
+				}
+				if ($tag == "BOUNDINGBOX") {
+					$bbox = new Mapbender_bbox($attributes["minx"], $attributes["miny"], $attributes["maxx"], $attributes["maxy"], $attributes["SRS"]);
+					$this->mainMap->setExtent($bbox);
+				}
+				if ($tag == "NAME") {
+					$this->wmc_name = $value;
+				}
+				if ($tag == "TITLE") {
+					$this->wmc_title = $value;
+				}
+				if ($tag == "ABSTRACT") {
+					$this->wmc_abstract = $value;
+				}
+				if ($tag == "CONTACTINFORMATION" && $type == "open") {
+					$contactinformation = true;
+				}
+				if ($contactinformation) {
+					if ($tag == "CONTACTPOSITION") {
+						$this->wmc_contactposition = $value;
+					}
+					if ($tag == "CONTACTVOICETELEPHONE") {
+						$this->wmc_contactvoicetelephone = $value;
+					}
+					if ($tag == "CONTACTFACSIMILETELEPHONE") {
+						$this->wmc_contactfacsimiletelephone = $value;
+					}
+					if ($tag == "CONTACTELECTRONICMAILADDRESS") {
+						$this->wmc_contactemail = $value;
+					}
+					if ($tag == "CONTACTPERSONPRIMARY" && $type == "open") {
+						$contactpersonprimary = true;
+					}
+					if ($contactpersonprimary) {
+						if ($tag == "CONTACTPERSON") {
+							$this->wmc_contactperson = $value;
+						}
+						if ($tag == "CONTACTORGANIZATION") {
+							$this->wmc_contactorganization = $value;;
+						}
+						if ($tag == "CONTACTPERSONPRIMARY" && $type == "close") {
+							$contactpersonprimary = false;
+						}
+					}
+					if ($tag == "CONTACTADDRESS" && $type == "open") {
+						$contactaddress = true;
+					}
+					if ($contactaddress) {
+						if ($tag == "ADDRESSTYPE") {
+							$this->wmc_contactaddresstype = $value;
+						}
+						if ($tag == "ADDRESS") {
+							$this->wmc_contactaddress = $value;
+						}
+						if ($tag == "CITY") {
+							$this->wmc_contactcity = $value;
+						}
+						if ($tag == "STATEORPROVINCE") {
+							$this->wmc_contactstateorprovince = $value;
+						}
+						if ($tag == "POSTCODE"){
+							$this->wmc_contactpostcode = $value;
+						}
+						if ($tag == "COUNTRY") {
+							$this->wmc_contactcountry = $value;
+						}
+						if ($tag == "CONTACTADDRESS" && $type == "close") {
+							$contactaddress = false;
+						}
+					}
+				}
+				if ($tag == "LOGOURL" && $type == "open") {
+						$logourl = true;
+						$this->wmc_logourl_width = $attributes["width"];
+						$this->wmc_logourl_height = $attributes["height"];
+						$this->wmc_logourl_format = $attributes["format"];
+				}
+				if ($logourl) {
+					if ($tag == "LOGOURL" && $type == "close") {
+						$logourl = false;
+					}
+					if ($tag == "ONLINERESOURCE") {
+						$this->wmc_logourl_type = $attributes["xlink:type"];
+						$this->wmc_logourl = $attributes["xlink:href"];
+					}
+				}
+				if ($tag == "DESCRIPTIONURL" && $type == "open") {
+						$descriptionurl = true;
+						$this->wmc_descriptionurl_format = $attributes["format"];
+				}
+				if ($descriptionurl) {
+					if ($tag == "DESCRIPTIONURL" && $type == "close"){
+						$descriptionurl = false;
+					}
+					if ($tag == "ONLINERESOURCE") {
+						$this->wmc_descriptionurl_type = $attributes["xlink:type"];
+						$this->wmc_descriptionurl = $attributes["xlink:href"];
+					}
+				}
+				if ($tag == "KEYWORDLIST" && $type == "open") {
+					$keywordlist = true;
+				}
+				if ($keywordlist) {
+					if ($tag == "KEYWORDLIST" && $type == "close") {
+						$keywordlist = false;
+						$cnt_keyword = -1;
+					}
+					if ($tag == "KEYWORD") {
+						$cnt_keyword++;
+						$this->wmc_keyword[$cnt_keyword] = $value;
+					}
+				}
+				if ($tag == "EXTENSION" && $type == "close") {
+					$generalExtension = false;
+					//
+					// After the general extension tag is closed,
+					// we have all necessary information to CREATE
+					// the map objects that are contained in this
+					// WMC.
+					//
+					$this->setMapData();
+				}
+				if ($generalExtension) {
+					$this->generalExtensionArray[$tag] = $value;
+				}
+				if ($tag == "EXTENSION" && $type == "open") {
+					$generalExtension = true;
+				}
+				if ($tag == "GENERAL" && $type == "close") {
+		   			$general = false;
+			 	}
+			}
+			if ($layerlist) {
+				if ($tag == "LAYERLIST" && $type == "close") {
+				   $layerlist = false;
+				}
+				if ($tag == "LAYER" && $type == "open") {
+					//
+					// The associative array currentLayer holds all 
+					// data of the currently processed layer.
+					// The data will be set in the classes' WMS
+					// object when the layer tag is closed.
+					//
+					$currentLayer = array();
+					
+					$currentLayer["queryable"] = $attributes["queryable"];
+					if ($attributes["hidden"] == "1") {
+						$currentLayer["visible"] = 0;
+					}
+					else {
+						$currentLayer["visible"] = 1;
+					}
+					$currentLayer["format"] = array();
+					$currentLayer["style"] = array();
+					$layer = true;
+				}
+				if ($layer) {
+					if ($tag == "LAYER" && $type == "close") {
+
+						//
+						// After a layer tag is closed,
+						// we have all necessary information to CREATE
+						// a layer object and append it to the WMS object
+						//
+						if ($currentLayer["extension"]["ISOVERVIEWLAYER"] == "1") {
+							array_push($layerlistArray["overview"], $currentLayer);		
+						}
+						else {
+							array_push($layerlistArray["main"], $currentLayer);											
+						}
+				 		$layer = false;
+					}
+					if ($formatlist) {
+						if ($tag == "FORMAT") {
+						 	array_push($currentLayer["format"], array("current" => $attributes["current"], "name" => $value));
+							if ($attributes["current"] == "1") {
+								$currentLayer["formatIndex"] = count($currentLayer["format"]) - 1;
+							}
+						 }
+						 if ($tag == "FORMATLIST" && $type == "close") {
+							 $formatlist = false;
+						 }
+					 }
+					 elseif ($metadataurl) {
+						if ($tag == "ONLINERESOURCE") {
+							$currentLayer["metadataurl"] = $attributes["xlink:href"];
+						}
+						if ($tag == "METADATAURL" && $type == "close") {
+							$metadataurl = false;
+						}
+					 }
+					 elseif ($dataurl) {
+						if ($tag == "ONLINERESOURCE") {
+						 	$currentLayer["dataurl"] = $attributes["xlink:href"];
+						}
+						 if ($tag == "DATAURL" && $type == "close") {
+							$dataurl = false;
+						 }
+					 }
+					 elseif ($stylelist) {
+						 if ($style) {
+							$index = count($currentLayer["style"]) - 1;
+							if ($tag == "STYLE" && $type == "close") {
+								$style = false;
+							}
+							if ($tag == "SLD" && $type == "open") {
+								$sld = true;
+							}
+							if ($sld) {
+								if ($tag == "SLD" && $type == "close") {
+									$sld = false;
+								}
+								if ($tag == "ONLINERESOURCE") {
+									$currentLayer["style"][$index]["sld_type"] = $attributes["xlink:type"];
+									$currentLayer["style"][$index]["sld_url"] = $attributes["xlink:href"];
+								}
+								if ($tag == "TITLE") {
+									$currentLayer["style"][$index]["sld_title"] = $value;
+								}
+							}
+							else {
+								if ($tag == "NAME"){
+									$currentLayer["style"][$index]["name"] = $value;
+								}
+								if ($tag == "TITLE") {
+									$currentLayer["style"][$index]["title"] = $value;
+								}
+								if ($legendurl) {
+									if ($tag == "LEGENDURL" && $type == "close") {
+										$legendurl = false;
+									}
+									if ($tag == "ONLINERESOURCE") {
+									 	$currentLayer["style"][$index]["legendurl_type"] = $attributes["xlink:type"];
+									 	$currentLayer["style"][$index]["legendurl"] = $attributes["xlink:href"];
+									}
+								}
+								if ($tag == "LEGENDURL" && $type == "open") {
+								 	$legendurl = true;
+								 	$currentLayer["style"][$index]["legendurl_width"] = $attributes["width"];
+								 	$currentLayer["style"][$index]["legendurl_height"] = $attributes["height"];
+								 	$currentLayer["style"][$index]["legendurl_format"] = $attributes["format"];
+								}
+							}
+						}
+						if ($tag == "STYLE" && $type == "open") {
+							$style = true;
+							array_push($currentLayer["style"], array("current" => $attributes["current"]));
+							if ($attributes["current"] == "1") {
+								$currentLayer["styleIndex"] = count($currentLayer["style"]) - 1;
+							}
+						}
+						if ($tag == "STYLELIST" && $type == "close") {
+							$stylelist = false;
+						}
+					}
+					else {
+						if ($tag == "SERVER" && $type == "open") {
+							 $server = true;
+							 $currentLayer["service"] = $attributes["service"];
+							 $currentLayer["version"] = $attributes["version"];
+							 $currentLayer["wms_title"] = $attributes["title"];
+						}
+						if ($server) {
+							if ($tag == "SERVER" && $type == "close") {
+						 		$server = false;
+						 	}
+							if ($tag == "ONLINERESOURCE") {
+						 		$currentLayer["url"] = $attributes["xlink:href"];
+							}
+						}
+						if ($tag == "NAME") {
+					 		$currentLayer["name"] = $value;
+						}
+						if ($tag == "TITLE") {
+					 		$currentLayer["title"] = $value;
+						}
+						if ($tag == "ABSTRACT") {
+					 		$currentLayer["abstract"] = $value;
+						}
+						if ($tag == "SRS") {
+							$currentLayer["epsg"] = explode(" ", $value);						 	
+						}
+						if ($tag == "EXTENSION" && $type == "close") {
+							$extension = false;
+						}
+						if ($extension == true){
+							if ($value !== "") {
+								if (isset($currentLayer["extension"][$tag])) {
+									if (!is_array($currentLayer["extension"][$tag])) {
+										$firstValue = $currentLayer["extension"][$tag];
+										$currentLayer["extension"][$tag] = array();
+										array_push($currentLayer["extension"][$tag], $firstValue);
+									}	
+									array_push($currentLayer["extension"][$tag], $value);
+								}
+								else {
+									$currentLayer["extension"][$tag] = $value;									
+								}
+							}
+						}
+						if ($tag == "EXTENSION" && $type == "open") {
+							$currentLayer["extension"] = array();
+							$extension = true;
+						}
+						if ($tag == "METADATAURL" && $type == "open") {
+							$metadataurl = true;
+						}
+						if ($tag == "DATAURL" && $type == "open") {
+							$dataurl = true;
+						}
+						if ($tag == "FORMATLIST" && $type == "open") {
+							$formatlist = true;
+						}
+						if ($tag == "STYLELIST" && $type == "open") {
+							$stylelist = true;
+						}
+					}
+				}
+			}
+		}
+		
+		// set WMS data
+		
+		$layerlistCompleteArray = array_merge($layerlistArray["main"], $layerlistArray["overview"]);
+		
+		for ($i = 0; $i < count($layerlistCompleteArray); $i++) {
+			$this->setLayerData($layerlistCompleteArray[$i]);
+		}
+
+		return true;
+	}
+
+	/**
+	 * Saves the current WMC in the log folder.
+	 * 
+	 * @return string the filename of the WMC document.
+	 */
+	private function saveAsFile() {
+		if ($this->saveWmcAsFile) {
+			$filename = "wmc_" . date("Y_m_d_H_i_s") . ".xml";
+			$logfile = "../tmp/" . $filename;
+			
+			if($h = fopen($logfile,"a")){
+				$content = $this->xml;
+				if(!fwrite($h,$content)){
+					$e = new mb_exception("class_wmc.php: failed to write wmc.");
+					return false;
+				}
+				fclose($h);
+			}
+			$e = new mb_notice("class_wmc: saving WMC as file " . $filename . "; You can turn this behaviour off in class_wmc.php");
+			return $filename;
+		}
+		return null;
+	}
+	
+	/**
+	 * Called during WMC parsing; sets the data of a single layer.
+	 * 
+	 * @return 
+	 * @param $currentLayer Array an associative array with layer data
+	 */
+	private function setLayerData ($currentLayer) {
+		$currentMap = $this->mainMap;
+		$currentMapIsOverview = false;
+
+		if ($currentLayer["extension"]["ISOVERVIEWLAYER"] == "1") {
+			$currentMap = $this->overviewMap;
+			$currentMapIsOverview = true;
+		}
+
+		$wmsArray = $currentMap->getWmsArray();
+
+		//
+		// check if current layer belongs to an existing WMS.
+		// If yes, store the index of this WMS in $wmsIndex.
+		// If not, set the value to null.
+		//
+		$wmsIndex = null;
+
+		// find last WMS with the same online resource
+		for ($i = count($wmsArray) - 1; $i >= 0; $i--) {
+			if (isset($currentLayer["url"]) && 
+				$currentLayer["url"] == $wmsArray[$i]->wms_getmap) {
+					$wmsIndex = $i;
+					break;
+			}
+		}
+
+		// Even if this WMS has been found before it could still
+		// be a duplicate! We would have to create a new WMS and 
+		// not append this layer to that WMS.
+		// For the overview layer we never add a new wms.
+		// check if this layer is an overview layer. If yes, skip this layer.
+		if ($wmsIndex !== null && !$currentMapIsOverview) {
+
+			// check if this WMS has a layer equal to the current layer.
+			// If yes, this is a new WMS. If not, append this layer
+			// to the existing WMS.
+			$matchingWmsLayerArray = $this->wmsArray[$wmsIndex]->objLayer;
+			
+			for ($i = 0; $i < count($matchingWmsLayerArray); $i++) {
+				if ($matchingWmsLayerArray[$i]->layer_name == $currentLayer["name"]) {
+
+					// by re-setting the index to null, a new WMS will be 
+					// added below.
+					$wmsIndex = null;
+					break;
+				}
+			}
+		}
+
+		// if yes, create a new WMS ...
+		if ($wmsIndex === null) {
+			$wmsIndex = 0;
+			$wms = new wms();
+
+			//
+			// set WMS data
+			//
+			$wms->wms_id = $currentLayer["extension"]["WMS_ID"]; // TO DO: how about WMS without ID?
+			$wms->wms_version = $currentLayer["version"];
+			$wms->wms_title = $currentLayer["wms_title"];
+			$wms->wms_abstract = $currentLayer["abstract"];
+			$wms->wms_getmap = $currentLayer["url"];
+			$wms->wms_getfeatureinfo = $currentLayer["url"]; // TODO : Add correct data
+			
+			$styleIndex = $currentLayer["styleIndex"];
+			$wms->wms_getlegendurl = $currentLayer["style"][$styleIndex]["legendurl"];
+
+			$wms->wms_filter = ""; // TODO : Add correct data
+
+			$formatIndex = $currentLayer["formatIndex"];
+			$wms->gui_wms_mapformat = $currentLayer["format"][$formatIndex]["name"];
+
+			$wms->gui_wms_featureinfoformat = "text/html"; // TODO : Add correct data
+			$wms->gui_wms_exceptionformat = "application/vnd.ogc.se_xml"; // TODO : Add correct data
+			$wms->gui_wms_epsg = $this->mainMap->getEpsg();
+			$wms->gui_wms_visible = 1; // TODO : Add correct data
+			$wms->gui_wms_opacity = 100; // TODO : Add correct data
+			$wms->gui_wms_sldurl = $currentLayer["style"][$styleIndex]["sld_url"];
+
+			$wms->gui_epsg = $currentLayer["epsg"];
+			//
+			// set data formats
+			//
+			for ($i = 0; $i < count($currentLayer["format"]); $i++) {
+				array_push($wms->data_type, "map");							
+				array_push($wms->data_format, $currentLayer["format"][$i]["name"]);							
+			}
+
+			// set root layer
+			$wms->addLayer(0, "");
+			$wms->objLayer[0]->layer_uid = $currentLayer["extension"]["WMS_LAYER_ID"];
+			$wms->objLayer[0]->layer_name = $currentLayer["extension"]["WMS_NAME"];
+			$wms->objLayer[0]->layer_title = $currentLayer["wms_title"];
+			$wms->objLayer[0]->layer_pos = 0;
+			$wms->objLayer[0]->layer_queryable = 0;
+			$wms->objLayer[0]->layer_minscale = 0;
+			$wms->objLayer[0]->layer_maxscale = 0;
+			$wms->objLayer[0]->gui_layer_wms_id = $currentLayer["extension"]["WMS_LAYER_ID"];
+			$wms->objLayer[0]->gui_layer_status = 1;
+			$wms->objLayer[0]->gui_layer_selectable = 1; 
+			$wms->objLayer[0]->gui_layer_visible = 1;
+			$wms->objLayer[0]->gui_layer_queryable = 0;
+			$wms->objLayer[0]->gui_layer_querylayer = 0;
+			$wms->objLayer[0]->gui_layer_minscale = 0;
+			$wms->objLayer[0]->gui_layer_maxscale = 0;
+
+			// layer epsg
+			if ($currentLayer["extension"]["EPSG"]) {
+				$layerEpsgArray = array();
+				$layerMinXArray = array();
+				$layerMinYArray = array();
+				$layerMaxXArray = array();
+				$layerMaxYArray = array();
+				if (!is_array($currentLayer["extension"]["EPSG"])) {
+					$layerEpsgArray[0] = $currentLayer["extension"]["EPSG"];
+					$layerMinXArray[0] = $currentLayer["extension"]["MINX"];
+					$layerMinYArray[0] = $currentLayer["extension"]["MINY"];
+					$layerMaxXArray[0] = $currentLayer["extension"]["MAXX"];
+					$layerMaxYArray[0] = $currentLayer["extension"]["MAXY"];
+				}
+				else {
+					$layerEpsgArray = $currentLayer["extension"]["EPSG"];
+					$layerMinXArray = $currentLayer["extension"]["MINX"];
+					$layerMinYArray = $currentLayer["extension"]["MINY"];
+					$layerMaxXArray = $currentLayer["extension"]["MAXX"];
+					$layerMaxYArray = $currentLayer["extension"]["MAXY"];
+				}
+	
+				for ($i=0; $i < count($layerEpsgArray); $i++) {
+					$currentLayerEpsg = array();
+					$currentLayerEpsg["epsg"] = $layerEpsgArray[$i];
+					$currentLayerEpsg["minx"] = floatval($layerMinXArray[$i]);
+					$currentLayerEpsg["miny"] = floatval($layerMinYArray[$i]); 
+					$currentLayerEpsg["maxx"] = floatval($layerMaxXArray[$i]);
+					$currentLayerEpsg["maxy"] = floatval($layerMaxYArray[$i]);
+					array_push($wms->objLayer[0]->layer_epsg, $currentLayerEpsg);
+				}
+			}			
+			// add WMS
+			array_push($wmsArray, $wms);
+
+			// the index of the WMS we just added
+			$wmsIndex = count($wmsArray) - 1;
+		}
+
+		// add layer to existing WMS ...
+		$currentWms = $wmsArray[$wmsIndex];
+		$currentWms->newLayer($currentLayer, null);
+		$currentMap->setWmsArray($wmsArray);
+		return true;
+	}
+	
+	/**
+	 * Called during WMC parsing; sets the maps within a WMC.
+	 * 
+	 * @return 
+	 */
+	private function setMapData () {
+		if ($this->generalExtensionArray["OV_WIDTH"] && 
+			$this->generalExtensionArray["OV_HEIGHT"] &&
+			$this->generalExtensionArray["OV_FRAMENAME"] &&
+			$this->generalExtensionArray["OV_MINX"] &&
+			$this->generalExtensionArray["OV_MINY"] &&
+			$this->generalExtensionArray["OV_MAXX"] &&
+			$this->generalExtensionArray["OV_MAXY"] &&
+			$this->generalExtensionArray["OV_SRS"]) {
+			
+			$this->overviewMap = new Map();
+			$this->overviewMap->setWidth($this->generalExtensionArray["OV_WIDTH"]);
+			$this->overviewMap->setHeight($this->generalExtensionArray["OV_HEIGHT"]);
+			$this->overviewMap->setFrameName($this->generalExtensionArray["OV_FRAMENAME"]);
+			$this->overviewMap->setIsOverview(true);
+
+			$bbox = new Mapbender_bbox($this->generalExtensionArray["OV_MINX"], $this->generalExtensionArray["OV_MINY"], $this->generalExtensionArray["OV_MAXX"], $this->generalExtensionArray["OV_MAXY"], $this->generalExtensionArray["OV_SRS"]);
+			$this->overviewMap->setExtent($bbox);
+		}
+		if ($this->generalExtensionArray["MAIN_FRAMENAME"]) {
+			$this->mainMap->setFrameName($this->generalExtensionArray["MAIN_FRAMENAME"]);
+		}
+		else {
+			$this->mainMap->setFrameName("mapframe1");
+		}
+		return true;
+	}
+
+	/**
+	 * Creates a WMC document (XML) from the current object
+	 * 
+	 * @return String XML
+	 */
+	private function createXml() {
+		$wmcToXml = new WmcToXml($this);
+		$this->xml = $wmcToXml->getXml();
+	}
+
+	
+} 
+
+/**
+ * @deprecated
+ */
+function mb_utf8_encode ($str) {
+//	if(CHARSET=="UTF-8") return utf8_encode($str);
+	return $str;
+}
+
+/**
+ * @deprecated
+ */
+function mb_utf8_decode ($str) {
+//	if(CHARSET=="UTF-8") return utf8_decode($str);
+	return $str;
+}
+?>

Added: branches/nimix_dev/http/javascripts/mod_gazetteerSQL_client.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_gazetteerSQL_client.php	                        (rev 0)
+++ branches/nimix_dev/http/javascripts/mod_gazetteerSQL_client.php	2008-08-18 16:15:56 UTC (rev 2871)
@@ -0,0 +1,391 @@
+<?php
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>">
+<title>Gazetteer</title>
+<?php
+include '../include/dyn_css.php';
+?>
+<script type="text/javascript">
+
+var targetFrameArray = [];
+<?php
+echo "var e_id = '". $e_id . "';";
+for ($i = 0; $i < count($e_target); $i++) {
+	echo "targetFrameArray.push('".$e_target[$i]."');";
+}
+?>
+<!--
+// --- begin: expected element vars ---
+// var scale 
+// var numberOfResults
+// var profile = "adresse" | "alk" | "alb" | "adresse2"
+
+if (typeof(scale) == 'undefined') {
+	var scale = 2000;
+	var e = new parent.Mb_warning("mod_gazetteerSQL: element var scale is missing.");
+}
+if (typeof(numberOfResults) == 'undefined') {
+	var numberOfResults = 0;
+	var e = new parent.Mb_warning("mod_gazetteerSQL: element var numberOfResults is missing.");
+}
+if (typeof(tooManyResultsString) == 'undefined') {
+	var tooManyResultsString = "Too many results. Please specify your query.";
+	var e = new parent.Mb_warning("mod_gazetteerSQL: element var tooManyResultsString is missing.");
+}
+if (typeof(profile) == 'undefined' || (profile != "alb" && profile != "alk" && profile != "adresse" && profile != "adresse2")) {
+	profile = "adresse"
+	var e = new parent.Mb_exception("mod_gazetteerSQL: element var profile is missing.");
+}
+
+// --- end: expected element vars ---
+
+
+var generalPreFunctions = [];
+var generalSubFunctions = [];
+var onloadSubFunctions = [];
+var communesSubFunctions = [];
+var streetSubFunctions = [];
+var numberSubFunctions = [];
+var districtSubFunctions = [];
+var parcelSubFunctions = [];
+var ownerSubFunctions = [];
+
+registerFunction(generalPreFunctions, "disableForm();");
+registerFunction(generalSubFunctions, "enableForm();");
+if (profile == "alb") {
+	registerFunction(onloadSubFunctions, "updateCommunes();");
+	registerFunction(communesSubFunctions, "updateOwner();");
+	registerFunction(ownerSubFunctions, "updateOwner();");
+}
+else if (profile == "alk") {
+	registerFunction(onloadSubFunctions, "updateCommunes();");
+	registerFunction(communesSubFunctions, "updateDistricts();");
+	registerFunction(parcelSubFunctions, "updateParcels();");
+}
+else if (profile == "adresse") {
+	registerFunction(onloadSubFunctions, "updateCommunes();");
+	registerFunction(communesSubFunctions, "updateStreets();");
+	registerFunction(streetSubFunctions, "updateNumbers();");
+}
+else if (profile == "adresse2") {
+	registerFunction(onloadSubFunctions, "updateStreets();");
+	registerFunction(streetSubFunctions, "updateNumbers();");
+}
+
+function executeFunctions(arrayOfFunctionStrings) {
+	for (var i = 0; i < arrayOfFunctionStrings.length; i++) {
+		eval(arrayOfFunctionStrings[i]);
+	}
+}
+
+function registerFunction(functionStringArray, functionString) {
+	functionStringArray.push(functionString);
+}
+
+function disableForm() {
+	document.getElementById('selectCommune').disabled = true;
+	document.getElementById('selectStreet').disabled = true;
+	document.getElementById('selectDistrict').disabled = true;
+	document.getElementById('inputParcel1').disabled = true;
+	document.getElementById('inputParcel2').disabled = true;
+	document.getElementById('inputParcelButton').disabled = true;
+	document.getElementById('inputOwner').disabled = true;
+	document.getElementById('inputOwnerButton').disabled = true;
+	document.getElementById("divResults").innerHTML = searchImage;
+}
+
+function enableForm() {
+	document.getElementById('selectCommune').removeAttribute("disabled");
+	document.getElementById('selectStreet').removeAttribute("disabled");
+	document.getElementById('selectDistrict').removeAttribute("disabled");
+	document.getElementById('inputParcel1').removeAttribute("disabled");
+	document.getElementById('inputParcel2').removeAttribute("disabled");
+	document.getElementById('inputParcelButton').removeAttribute("disabled");
+	document.getElementById('inputOwner').removeAttribute("disabled");
+	document.getElementById('inputOwnerButton').removeAttribute("disabled");
+	document.getElementById("divResults").innerHTML = "";
+}
+
+var highlight;
+var houseLocation;
+var parcelLocation;
+var searchImage = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
+var phpUrl = "../php/mod_gazetteerSQL_server.php";
+
+parent.mb_registerInitFunctions("window.frames['"+e_id+"'].initHighlight()");
+parent.mb_registerInitFunctions("window.frames['"+e_id+"'].executeFunctions(window.frames['"+e_id+"'].onloadSubFunctions)");
+
+
+// - BEGIN -------- HIGHLIGHTING AND ZOOMING ------------------------------------------
+
+function zoomToLocation(aPoint) {
+	parent.mb_repaintScale(targetFrameArray[0], aPoint.x, aPoint.y, scale)
+}
+
+function initHighlight() {
+	var generalHighlightZIndex = 100;
+	var generalHighlightLineWidth = 3;
+	var styleObj = {"position":"absolute", "top":"0px", "left":"0px", "z-index":generalHighlightZIndex};
+	highlight = new parent.Highlight(targetFrameArray, e_id, styleObj, generalHighlightLineWidth);
+}
+
+function zoomToHouseNumber(houseNumber) {
+	zoomToLocation(houseLocation[houseNumber]);
+	removeHighlight();
+	highlightHouseNumber(houseNumber);
+}
+
+function zoomToParcel(parcelId) {
+	zoomToLocation(parcelLocation[parcelId]);
+	removeHighlight();
+	highlightParcel(parcelId);
+}
+
+function highlightHouseNumber(houseNumber) {
+	var mG = new parent.MultiGeometry(parent.geomType.point);
+	mG.addGeometry();
+	mG.get(-1).addPoint(houseLocation[houseNumber]);
+	highlight.add(mG);
+	highlight.paint();
+}
+
+function highlightParcel(parcelId) {
+	var mG = new parent.MultiGeometry(parent.geomType.point);
+	mG.addGeometry();
+	mG.get(-1).addPoint(parcelLocation[parcelId]);
+	highlight.add(mG);
+	highlight.paint();
+}
+
+function removeHighlight() {
+	highlight.clean();
+}
+
+// - END -------- HIGHLIGHTING AND ZOOMING ------------------------------------------
+
+
+
+function removeChildNodes(node) {
+	while (node.childNodes.length > 0) {
+		var childNode = node.firstChild;
+		node.removeChild(childNode);
+	}
+}
+
+function getSize(result) {
+	if (typeof(result) == "array") {
+		return result.length;
+	}
+	else if (typeof(result) == "object") {
+		var c = 0;
+		for (var attr in result) {
+			c++;
+		}
+		return c;
+	}
+	return 1;
+}
+
+function updateCommunes() {
+	executeFunctions(generalPreFunctions);
+	parent.mb_ajax_json(phpUrl, {"command":"getCommunes"}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+
+		removeChildNodes(document.getElementById('selectCommune'));
+
+		for (var communeId in json.communes) {
+			if (typeof(json.communes[communeId]) != 'function') {
+				var currentNode = document.createElement("option");
+			
+				if (document.getElementById('selectCommune').childNodes.length == 0) {
+					currentNode.selected = "selected";
+				}
+				currentNode.value = communeId;
+				currentNode.innerHTML = json.communes[communeId];
+				document.getElementById('selectCommune').appendChild(currentNode);
+			}
+		}
+		executeFunctions(communesSubFunctions);
+	});
+}
+
+function updateStreets() {
+	executeFunctions(generalPreFunctions);
+	var communeId = document.getElementById('selectCommune').value;
+	
+	parent.mb_ajax_json(phpUrl, {"command":"getStreets", "communeId":communeId}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+
+		removeChildNodes(document.getElementById('selectStreet'));
+
+		for (var streetId in json.streets) {
+			if (typeof(json.streets[streetId]) != 'function') {
+				var currentNode = document.createElement("option");
+	
+				if (document.getElementById('selectStreet').childNodes.length == 0) {
+					currentNode.selected = "selected";
+				}
+				
+				currentNode.value = json.streets[streetId];
+				currentNode.innerHTML = json.streets[streetId];
+				document.getElementById('selectStreet').appendChild(currentNode);
+			}
+		}
+		executeFunctions(streetSubFunctions);
+	});
+}
+
+function updateDistricts() {
+	executeFunctions(generalPreFunctions);
+
+	var communeId = document.getElementById('selectCommune').value;
+	
+	parent.mb_ajax_json(phpUrl, {"command":"getDistricts", "communeId":communeId}, function (districtObject, status) {
+		executeFunctions(generalSubFunctions);
+
+		removeChildNodes(document.getElementById('selectDistrict'));
+
+		for (var districtId in districtObject.districts) {
+			if (typeof(districtObject.districts[districtId]) != 'function') {
+				var currentNode = document.createElement("option");
+	
+				currentNode.value = districtId;
+	
+				if (document.getElementById('selectDistrict').childNodes.length == 0) {
+					currentNode.selected = "selected";
+				}
+				
+				currentNode.value = districtObject.districts[districtId];
+				currentNode.innerHTML = districtObject.districts[districtId];
+				document.getElementById('selectDistrict').appendChild(currentNode);
+			}
+		}
+		executeFunctions(districtSubFunctions);
+	});
+}
+
+function updateNumbers() {
+	executeFunctions(generalPreFunctions);
+
+	var streetName = document.getElementById('selectStreet').value;
+	var communeId = document.getElementById('selectCommune').value;
+
+	parent.mb_ajax_json(phpUrl, {"command":"getNumbers", "communeId":communeId, "streetName":streetName, "numberOfResults":numberOfResults}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+		houseLocation = {};
+		var resultString = "";
+		if (getSize(json.houseNumbers) > 0) {
+			if (json.limited === true) {
+				resultString += tooManyResultsString;
+			}
+			for (var houseNumber in json.houseNumbers) {
+				if (typeof(json.houseNumbers[houseNumber]) != 'function') {
+					houseLocation[houseNumber] = new parent.Point(json.houseNumbers[houseNumber].x, json.houseNumbers[houseNumber].y);
+					resultString += "<b style=\"cursor:pointer\" onclick=\"zoomToHouseNumber('"+houseNumber+"')\" onmouseover=\"highlightHouseNumber('"+houseNumber+"')\" onmouseout=\"removeHighlight()\">"+houseNumber+"</b>&nbsp;&nbsp; ";
+				}
+			}
+		}
+		else {
+			resultString += noResultsString;
+		}
+		document.getElementById("divResults").innerHTML = resultString;
+		executeFunctions(numberSubFunctions);
+	});
+}
+
+function updateParcels() {
+	executeFunctions(generalPreFunctions);
+	
+	var districtId = document.getElementById('selectDistrict').value;
+	var inputParcel1 = document.getElementById('inputParcel1').value;
+	var inputParcel2 = document.getElementById('inputParcel2').value;
+
+
+	parent.mb_ajax_json(phpUrl, {"command":"getLandparcelsByDistrict", "districtId":districtId, "parcelNumber1":inputParcel1, "parcelNumber2":inputParcel2, "numberOfResults":numberOfResults}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+
+		parcelLocation = {};
+		var resultString = "";
+		if (getSize(json.landparcels) > 0) {
+			if (json.limited === true) {
+				resultString += tooManyResultsString;
+			}
+			resultString += "<ol>";
+			for (var parcelId in json.landparcels) {
+				if (typeof(json.landparcels[parcelId]) != 'function') {
+					parcelLocation[parcelId] = new parent.Point(json.landparcels[parcelId].x, json.landparcels[parcelId].y);
+					resultString += "<li style=\"cursor:pointer\" onclick=\"zoomToParcel('"+parcelId+"')\" onmouseover=\"highlightParcel('"+parcelId+"')\" onmouseout=\"removeHighlight()\">"+parcelId+"</li>";
+				}
+			}
+			resultString += "</ol>";
+		}
+		else {
+			resultString += noResultsString;
+		}
+		document.getElementById("divResults").innerHTML = resultString;
+		executeFunctions(numberSubFunctions);
+	});
+}
+
+function updateOwner() {
+	var ownerQueryString = document.getElementById('inputOwner').value;
+	var communeId = document.getElementById('selectCommune').value;
+
+	document.getElementById("divResults").innerHTML = "";
+	document.getElementById('selectCommune').removeAttribute("disabled");
+	document.getElementById('inputOwner').removeAttribute("disabled");
+	document.getElementById('inputOwnerButton').removeAttribute("disabled");
+	
+	if (ownerQueryString != "") {
+		executeFunctions(generalPreFunctions);
+		parent.mb_ajax_json(phpUrl, {"command":"getLandparcelsByOwner", "communeId":communeId, "ownerQueryString":ownerQueryString, "numberOfResults":numberOfResults}, function (json, status) {
+			executeFunctions(generalSubFunctions);
+
+			parcelLocation = {};
+			var resultString = "";
+			if (getSize(json.landparcels) > 0) {
+				if (json.limited === true) {
+					resultString += tooManyResultsString;
+				}
+				resultString += "<ol>";
+				for (var i=0; i < json.landparcels.length; i++) {
+					var parcelId = json.landparcels[i].landparcelId;
+					parcelLocation[parcelId] = new parent.Point(json.landparcels[i].x, json.landparcels[i].y);
+					resultString += "<li style=\"cursor:pointer\" onclick=\"zoomToParcel('"+parcelId+"')\" onmouseover=\"highlightParcel('"+parcelId+"')\" onmouseout=\"removeHighlight()\">"+json.landparcels[i].owner+ " (" + parcelId+")</li>";
+				}
+				resultString += "</ol>";
+			}
+			else {
+				resultString += noResultsString;
+			}
+			document.getElementById("divResults").innerHTML = resultString;
+			executeFunctions(numberSubFunctions);
+	
+		});
+	}
+}
+// -->
+</script>
+</head>
+<body>
+<form>
+<select class='selectCommune' id='selectCommune' onchange='executeFunctions(communesSubFunctions)'></select>
+<select class='selectStreet' id='selectStreet' onchange='executeFunctions(streetSubFunctions);' size=5 disabled></select>
+<select class='selectDistrict' id='selectDistrict' onchange='executeFunctions(districtSubFunctions);' size=5 disabled></select>
+<div id='divParcel' class='divParcel'>
+Flur: <input type='input' class='inputParcel1' id='inputParcel1' disabled></select>
+Flstz: <input type='input' class='inputParcel2' id='inputParcel2' disabled></select>
+<input type='button' id='inputParcelButton' value='?' onclick='executeFunctions(parcelSubFunctions);'>
+</div>
+<div id='divOwner' class='divOwner'>
+Eigent&uuml;mer: <input type='input' class='inputOwner' id='inputOwner' disabled></select>
+<input type='button' id='inputOwnerButton' value='?' onclick='executeFunctions(ownerSubFunctions);'>
+</div>
+</form>
+<div class='divResults' id='divResults'></div>
+</body>
+</html>
\ No newline at end of file

Added: branches/nimix_dev/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_wfs_gazetteer_client.php	                        (rev 0)
+++ branches/nimix_dev/http/javascripts/mod_wfs_gazetteer_client.php	2008-08-18 16:15:56 UTC (rev 2871)
@@ -0,0 +1,1280 @@
+<?php 
+# $Id: mod_wfs_gazetteer_client.php 2331 2008-04-02 08:09:18Z nimix $
+# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
+# http://www.mapbender.org/index.php/WFS_gazetteer
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+$gui_id = $_SESSION["mb_user_gui"];
+
+$target = $_REQUEST["e_target"];
+$isLoaded = $_REQUEST["isLoaded"];
+
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset='<?php echo CHARSET;?>'">	
+<title>mod_wfs_gazetteer</title>
+
+<?php
+include '../include/dyn_css.php';
+?>
+<script type="text/javascript">
+<?php 
+	include '../include/dyn_js.php';
+	include '../include/dyn_php.php';
+	include(dirname(__FILE__) . "/../../conf/" . $wfs_spatial_request_conf_filename);
+
+	echo "var targetString = '" . $target . "';";
+	echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
+	echo "var e_id_css = '" . $e_id_css . "';";
+?>
+
+// Element var maxHighlightedPoints
+try{
+	if (maxHighlightedPoints){
+		maxHighlightedPoints = Number(maxHighlightedPoints);
+
+		if (isNaN(maxHighlightedPoints)) {
+//			var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints must be a number.");
+		}
+	}
+}
+catch(e){
+	maxHighlightedPoints = 0;
+//	var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints is not set, see 'edit element vars'.");
+}
+// Element var showResultInPopup
+try {if(showResultInPopup){}}catch(e) {showResultInPopup = 1;}
+
+//element var openLinkFromSearch for opening attribute link directly onclick of searchResult entry
+try{
+	if (openLinkFromSearch){}
+}
+catch(e){
+	openLinkFromSearch =0;
+}
+
+var targetArray = targetString.split(",");
+var global_wfsConfObj;
+var global_selectedWfsConfId;
+var point_px = 10;
+var resultGeom = null;
+var cw_fillcolor = "#cc33cc";
+var frameName = e_id_css;
+var inputNotEnough = [];
+
+//start button management spatialRequest ////////
+var button_point = "point";
+var button_polygon = "polygon";
+var button_rectangle = "rectangle";
+var button_extent = "extent";
+var mb_wfs_tolerance = 8;
+
+var activeButton = null;
+var mod_wfs_spatialRequest_geometry = null;
+var mod_wfs_spatialRequest_frameName = "";
+var mod_wfs_spatialRequest_epsg;
+var mod_wfs_spatialRequest_width;
+var mod_wfs_spatialRequest_height;
+
+/**
+ * This Geometry contains the geometry of the optinal spatial constraint
+ */
+var spatialRequestGeom = null;
+
+/**
+ * Something like box, polygon, point, extent
+ */
+var spatialRequestType = null;
+
+/**
+ * This Geometry contains the result from the WFS request
+ */
+var geomArray;
+
+var buttonWfs_id = [];
+var buttonWfs_on = [];
+var buttonWfs_src = [];
+var buttonWfs_title_off = [];
+var buttonWfs_title_on = [];
+var buttonWfs_x = [];
+var buttonWfs_y = [];
+
+function addButtonWfs(id, isOn, src, title, x, y) {
+	buttonWfs_id.push(id);
+	buttonWfs_on.push(isOn);
+	buttonWfs_src.push(src);
+	buttonWfs_title_off.push(title);
+	buttonWfs_title_on.push(title);
+	buttonWfs_x.push(x);
+	buttonWfs_y.push(y);
+}
+// end of button management spatialRequest ///////////
+
+parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initModWfsGazetteer()");
+parent.mb_registerInitFunctions("window.frames['"+this.name+"'].init_wfsSpatialRequest()");
+
+function init_wfsSpatialRequest() {
+	//parent.mb_ajax_json("../php/mod_wfsSpatialRequest_messages.php", function(obj, status) {
+	//	msgObj = obj;
+		buttonWfs_id = [];
+		buttonWfs_on = [];
+		buttonWfs_src = [];
+		buttonWfs_title_off = [];
+		buttonWfs_title_on = [];
+		buttonWfs_x = [];
+		buttonWfs_y = [];
+		addButtonWfs("rectangle", buttonRectangle.status, buttonRectangle.img, buttonRectangle.title, buttonRectangle.x, buttonRectangle.y);
+		addButtonWfs("polygon", buttonPolygon.status, buttonPolygon.img, buttonPolygon.title, buttonPolygon.x, buttonPolygon.y);
+		addButtonWfs("point", buttonPoint.status, buttonPoint.img, buttonPoint.title, buttonPoint.x, buttonPoint.y);
+		addButtonWfs("extent", buttonExtent.status, buttonExtent.img, buttonExtent.title, buttonExtent.x, buttonExtent.y);
+		displayButtons();
+	//});
+}
+
+function wfsInitFunction (j) {
+	var functionCall = "parent.mb_regButton_frame('initWfsButton', '"+frameName+"', "+j+")";
+	var x = new Function ("", functionCall); 
+	x();
+} 
+
+function initWfsButton(ind, pos) {
+	parent.mb_button[ind] = document.getElementById(buttonWfs_id[pos]);
+	parent.mb_button[ind].img_over = buttonWfs_imgdir + buttonWfs_src[pos].replace(/_off/,"_over");
+	parent.mb_button[ind].img_on = buttonWfs_imgdir + buttonWfs_src[pos].replace(/_off/,"_on");
+	parent.mb_button[ind].img_off = buttonWfs_imgdir + buttonWfs_src[pos];
+	parent.mb_button[ind].img_out = buttonWfs_imgdir + buttonWfs_src[pos];
+	parent.mb_button[ind].status = 0;
+	parent.mb_button[ind].elName = buttonWfs_id[pos];
+	parent.mb_button[ind].frameName = frameName;
+	parent.mb_button[ind].go = new Function ("requestGeometryHighlight.clean(); wfsEnable(parent.mb_button["+ind+"], " + pos + ")");
+	parent.mb_button[ind].stop = new Function ("wfsDisable(parent.mb_button["+ind+"], " + pos + ")");
+	var ind = parent.getMapObjIndexByName("mapframe1");
+	mod_wfs_spatialRequest_width = parent.mb_mapObj[ind].width;
+	mod_wfs_spatialRequest_height = parent.mb_mapObj[ind].height;
+	mod_wfs_spatialRequest_epsg = parent.mb_mapObj[ind].epsg;
+	parent.mb_registerPanSubElement("measuring");
+}	
+
+function displayButtons() {
+	for (var i = 0 ; i < buttonWfs_id.length ; i ++) {
+		if (parseInt(buttonWfs_on[i])==1) {
+			var currentImg = document.createElement("img");
+			currentImg.id = buttonWfs_id[i];
+			currentImg.name = buttonWfs_id[i];
+			currentImg.title = buttonWfs_title_off[i];
+			currentImg.src = buttonWfs_imgdir+buttonWfs_src[i];
+			currentImg.style.marginRight = "5px";
+			currentImg.onmouseover = new Function("wfsInitFunction("+i+")");
+			
+			document.getElementById("displaySpatialButtons").appendChild(currentImg);
+		}
+	}
+}
+
+function disableButtons() {
+	removeChildNodes(document.getElementById("displaySpatialButtons"));
+}
+
+function wfsEnable(obj) {
+   	var el = parent.window.frames["mapframe1"].document;
+   	el.onmouseover = null;
+   	el.onmousedown = null;
+   	el.onmouseup = null;
+   	el.onmousemove = null;
+   	
+	if (obj.id == button_point) {
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	if (obj.id == button_polygon) {
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	else if (obj.id == button_rectangle){
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	else if (obj.id == button_extent){
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	callRequestGeometryConstructor(obj.id,"mapframe1");
+}
+
+function callRequestGeometryConstructor(selectedType,target){
+		if(document.getElementById("res")){
+			document.getElementById("res").innerHTML ="";
+			spatialRequestGeom = null;
+		}
+		if(document.getElementById("spatialResHint")){
+			document.getElementById("spatialResHint").innerHTML = "";
+		}
+		spatialRequestType = selectedType;
+		var geometryConstructor = new parent.RequestGeometryConstructor(target);
+		geometryConstructor.getGeometry(selectedType,function(target,queryGeom){
+			if(queryGeom !=''){
+				var spatialRes = document.createElement("span");
+				spatialRes.id = "spatialResHint";
+				spatialRes.name = "spatialResHint";
+				document.getElementById("displaySpatialButtons").appendChild(spatialRes);
+				document.getElementById("spatialResHint").innerHTML = spatialRequestIsSetMessage;
+				spatialRequestGeom = queryGeom;
+			}
+			parent.mb_disableThisButton(selectedType);
+			
+			// spatialRequestGeom is a Geometry, but for the highlight
+			// a MultiGeometry is needed.
+			var multiGeom;
+			// a line represents a bbox...but highlight must be a polyon
+			// (extent or box selection)
+			if (spatialRequestGeom.geomType == parent.geomType.line) {
+				multiGeom = new parent.MultiGeometry(parent.geomType.polygon);
+				newGeom = new parent.Geometry(parent.geomType.polygon);
+				var p1 = spatialRequestGeom.get(0);
+				var p2 = spatialRequestGeom.get(1);
+				newGeom.addPoint(p1);
+				newGeom.addPointByCoordinates(p1.x, p2.y);
+				newGeom.addPoint(p2);
+				newGeom.addPointByCoordinates(p2.x, p1.y);
+				newGeom.close();
+				multiGeom.add(newGeom);
+			}
+			// standard case
+			// (polygon and point selection)
+			else {
+				multiGeom = new parent.MultiGeometry(spatialRequestGeom.geomType);
+				multiGeom.add(spatialRequestGeom);
+			}
+			
+			// add highlight of geometry
+			requestGeometryHighlight.add(multiGeom);
+			requestGeometryHighlight.paint();
+		
+		});
+}
+
+function wfsDisable(obj) {
+	var el = parent.window.frames["mapframe1"].document; 
+	el.onmousedown = null;
+	el.ondblclick = null;
+	el.onmousemove = null;
+	parent.writeTag("mapframe1","measure_display","");
+	parent.writeTag("mapframe1","measure_sub","");
+	activeButton = null;
+}
+
+function openwindow(url) {
+	window1 = window.open(url, "Information", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
+	window1.focus();
+}
+//----------------------------------------------------------------------------------
+
+function appendWfsConf(newWfsConfIdString) {
+	// merge with existing wfs conf ids
+	if (wfsConfIdString !== "") {
+		if (newWfsConfIdString !== "") {
+			wfsConfIdString += "," + newWfsConfIdString;
+
+			// rebuild form
+			initModWfsGazetteer();
+		}
+	}
+	else {
+		wfsConfIdString = newWfsConfIdString;
+
+		// rebuild form
+		initModWfsGazetteer();
+	}
+	
+}
+
+function removeChildNodes(node) {
+	while (node.childNodes.length > 0) {
+	  var childNode = node.firstChild;
+		node.removeChild(childNode);
+	}
+}
+
+/**
+ * removes whitespaces and endlines before and after a string
+ *
+ */ 
+function trimString (str) {
+	return str.replace(/^\s+|\s+|\n+$/g, '');
+}
+
+function appendStyles() {
+	var styleObj;
+	var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
+	if (parent.ie) {
+		var styleSheetObj=document.createStyleSheet();
+		styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+		styleObj.setAttribute("type","text/css");
+		ruleArray = rule.split("}");
+		for (var i=0; i < ruleArray.length - 1; i++) {
+			var currentRule = trimString(ruleArray[i]);
+			var nameValueArray = currentRule.split("{");
+			var name = nameValueArray[0];
+			var value = nameValueArray[1];
+			styleSheetObj.addRule(name,value);
+		}
+	}
+	else {
+		styleObj=document.createElement("style");
+		styleObj.setAttribute("type","text/css");
+		document.getElementsByTagName("head")[0].appendChild(styleObj);
+		styleObj.appendChild(document.createTextNode(rule+"\n"));		
+	}
+}
+
+//----------------------------------------------------------------------------------
+
+
+function initModWfsGazetteer() {
+	// empty nodes
+	var nodesToEmpty = ["selectWfsConfForm", "wfsForm", "res", "wfsInfo"];
+	while (nodesToEmpty.length > 0) {
+		var currentId = nodesToEmpty.pop();
+		var currentNode = document.getElementById(currentId);
+		removeChildNodes(currentNode);
+	}
+	document.getElementById("wfsGeomType").style.visibility = "hidden";
+	document.getElementById("wfsRemove").style.visibility = "hidden";
+		
+	geomArray = new parent.GeometryArray();
+
+	parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConf",wfsConfIdString:wfsConfIdString}, function(json, status) {
+		global_wfsConfObj = json;
+		var wfsCount = 0;
+		for (var wfsConfId in global_wfsConfObj) {
+			global_selectedWfsConfId = wfsConfId; 
+			if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
+				wfsCount++;
+			}
+		}
+		if (wfsCount === 0) {
+			var e = new parent.Mb_exception("no wfs conf id available.");
+		}
+		else if (wfsCount === 1) {
+			appendStyles();
+			appendWfsForm();
+			setWfsInfo();	
+		}
+		else {
+			appendWfsConfSelectBox();
+			setWfsInfo();	
+		}
+		parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
+	});
+	
+	// creates a Highlight object for the request geometry
+	var styleProperties = {"position":"absolute", "top":"0px", "left":"0px", "z-index":100};
+	requestGeometryHighlight = new parent.Highlight(targetArray, "requestGeometryHighlight", styleProperties, 2);
+	parent.mb_registerSubFunctions("window.frames['" + frameName +"'].requestGeometryHighlight.paint()");
+	
+}
+
+function setWfsInfo() {
+	var bulbNode = document.getElementById("wfsInfo"); 	
+
+	// append bulb image
+	removeChildNodes(bulbNode);
+	var imgNode = document.createElement("img");
+	imgNode.id = "wfsInfoImg";
+	//imgNode.src = "../img/button_digitize/geomInfo.png";
+	imgNode.src = "../img/tree_new/info.png";
+	imgNode.border = 0;
+	bulbNode.appendChild(imgNode);
+	bulbNode.href = "javascript:openwindow('../php/mod_featuretypeMetadata.php?wfs_conf_id=" + global_selectedWfsConfId.toString() + "');";
+	bulbNode.style.visibility = "visible";
+	
+	// set wfsGeomType image
+	var wfsGeomTypeNode = document.getElementById("wfsGeomType");
+	var wfsGeomType = "";
+	for (var i=0; i < global_wfsConfObj[global_selectedWfsConfId].element.length; i++) {
+		if (parseInt(global_wfsConfObj[global_selectedWfsConfId].element[i].f_geom)) {
+			wfsGeomType = global_wfsConfObj[global_selectedWfsConfId].element[i].element_type;
+		}
+	}
+	if (wfsGeomType.match(/Point/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/point.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else if (wfsGeomType.match(/Line/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/line.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else if (wfsGeomType.match(/Polygon/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/polygon.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else {
+		var e = new parent.Mb_exception("WFS gazetteer: geometry type unknown.");
+	}
+	
+	// set image: remove this WFS
+	var wfsRemoveNode = document.getElementById("wfsRemove");
+	//wfsRemoveNode.src = "../img/button_digitize/geomRemove.png";
+	wfsRemoveNode.src = "../img/tree_new/delete_wms.png";
+	wfsRemoveNode.style.visibility = 'visible';
+	// Internet explorer
+	if (parent.ie) {
+		wfsRemoveNode.onclick = function() {
+			var x = new Function ("", "delete global_wfsConfObj[global_selectedWfsConfId];setWfsConfIdString();initModWfsGazetteer();parent.mb_setWmcExtensionData({'wfsConfIdString':wfsConfIdString});"); 
+			x(); 
+		};
+	}
+	// Firefox
+	else {
+		wfsRemoveNode.onclick = function () {
+			delete global_wfsConfObj[global_selectedWfsConfId];
+			setWfsConfIdString();
+			initModWfsGazetteer();			
+			parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
+		}
+	}  
+}
+
+function setWfsConfIdString() {
+	var str = [];
+	for (var wfsConfId in global_wfsConfObj) {
+		global_selectedWfsConfId = wfsConfId; 
+		if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
+			str.push(wfsConfId);
+		}
+	}
+	wfsConfIdString = str.join(",");
+}
+
+function appendWfsConfSelectBox() {
+	var selectNode = document.createElement("select");
+	selectNode.name = "wfs_conf_sel";
+	var wfsFormNode = document.getElementById("selectWfsConfForm");
+	if (parent.ie) {
+		selectNode.onchange = function() {
+		global_selectedWfsConfId = this.value;
+     	if(typeof(resultGeometryPopup)!="undefined"){
+	 		resultGeometryPopup.destroy();
+	 	}
+	 	if(typeof(wfsPopup)!="undefined"){
+	 		wfsPopup.destroy();
+	 	}
+    	setWfsInfo();
+		appendStyles();
+		appendWfsForm();
+		};
+	}
+	else{
+	   selectNode.setAttribute("onchange", "if(typeof(resultGeometryPopup)!='undefined'){resultGeometryPopup.destroy();}if(typeof(wfsPopup)!='undefined'){wfsPopup.destroy();};global_selectedWfsConfId = this.value;setWfsInfo();appendStyles();appendWfsForm();");
+	}
+	var isSelected = false;
+	for (var wfsConfId in global_wfsConfObj) {
+		var optionNode = document.createElement("option");
+		
+		optionNode.value = wfsConfId;
+		optionNode.innerHTML = global_wfsConfObj[wfsConfId].g_label;
+
+		if (!isSelected) {
+			optionNode.selected = true;
+			isSelected = true;
+			global_selectedWfsConfId = wfsConfId;
+		}
+		selectNode.appendChild(optionNode);
+	}
+
+	var form = document.getElementById('selectWfsConfForm');
+	form.appendChild(selectNode);
+	
+	appendStyles();
+	appendWfsForm();
+}
+
+function appendWfsForm() {
+	var form = document.getElementById("wfsForm");
+	removeChildNodes(form);
+	var resultDiv = document.getElementById("res");
+	removeChildNodes(resultDiv);
+	
+	var divContainer = document.createElement("div");
+	divContainer.className = global_wfsConfObj[global_selectedWfsConfId].g_label_id;
+	
+	divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
+	
+	form.appendChild(divContainer);
+
+	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
+
+	for (var i = 0; i < wfsConfElementArray.length; i++){
+		if (parseInt(wfsConfElementArray[i].f_search)) {
+			var spanNode = document.createElement("span");
+			spanNode.setAttribute("id", wfsConfElementArray[i].element_name+"Span");
+			spanNode.className = wfsConfElementArray[i].f_label_id;
+			spanNode.innerHTML = wfsConfElementArray[i].f_label;
+			if(wfsConfElementArray[i].f_form_element_html.match(/\<select/)){
+				var inputNode = document.createElement("span");
+				inputNode.id = wfsConfElementArray[i].element_name+"Select";
+				inputNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+			}
+			else if(wfsConfElementArray[i].f_form_element_html.match(/checkbox/)){
+				var inputNode = document.createElement("span");
+				inputNode.id = wfsConfElementArray[i].element_name+"Checkbox";
+				inputNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+			}
+			else{ 
+				var inputNode = document.createElement("input");
+				inputNode.type = "text";
+				inputNode.className = wfsConfElementArray[i].f_style_id;
+				inputNode.id = wfsConfElementArray[i].element_name;
+				if(wfsConfElementArray[i].f_form_element_html.match(/datepicker/)){
+					inputNode.readOnly=true;
+					inputNode.style.backgroundColor = "#D3D3D3";
+					inputNode.title = "Use datepicker for selection of date";
+				}
+			}
+			form.appendChild(spanNode);
+			form.appendChild(inputNode);
+			
+			//build imgNode for datepicker image
+			if(wfsConfElementArray[i].f_form_element_html.match(/datepicker/)){
+				var imgNode = document.createElement("span");
+				imgNode.id = wfsConfElementArray[i].element_name+"Img";
+				imgNode.title = "Click here to open datepicker";
+				imgNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+				form.appendChild(imgNode);
+			}
+			form.appendChild(document.createElement("br"));
+		}
+	}
+	var submitButton = document.createElement("input");
+	submitButton.type = "submit";
+	submitButton.id = "submitButton";
+	submitButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
+	submitButton.value = global_wfsConfObj[global_selectedWfsConfId].g_button;
+	
+	form.appendChild(submitButton);
+	
+	var delFilterButton = document.createElement("input");
+	delFilterButton.type = "button";
+	delFilterButton.style.marginLeft = "5px";
+	delFilterButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
+	delFilterButton.value = clearFilterButtonLabel;
+	// Internet explorer
+	if (parent.ie) {$_REQUEST['pdfPathString']
+		delFilterButton.onclick = function() {
+			var x = new Function ("", "clearFilter();"); 
+			x(); 
+		};
+	}
+	// Firefox
+	else {
+		delFilterButton.onclick = function () {
+			clearFilter();
+		}
+	}  
+	form.appendChild(delFilterButton);
+	
+	checkSrs();
+}
+
+function checkSrs(){
+	//check SRS
+	var ind = parent.getMapObjIndexByName("mapframe1");
+	var submit = document.getElementById("submitButton");
+	if(global_wfsConfObj[global_selectedWfsConfId].featuretype_srs.toUpperCase()!=parent.mb_mapObj[ind].getSRS().toUpperCase()){
+		var msg = "Different EPSG of map and wfs featuretype, no spatial request possible!\n";
+		msg += parent.mb_mapObj[ind].getSRS()+" und "+global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
+		alert(msg);
+			
+		//disable Submit Button
+		if(submit)submit.disabled = true;
+	}
+	else{
+		//disable Submit Button
+		if(submit)submit.disabled = false;
+	}
+}
+
+function clearFilter(){
+	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
+	for (var i = 0; i < wfsConfElementArray.length; i++){
+		if (parseInt(wfsConfElementArray[i].f_search)) {
+			if(wfsConfElementArray[i].f_form_element_html.match(/checkbox/)){
+				var elementArray = document.getElementsByName(wfsConfElementArray[i].element_name);
+				for (var j = 0; j < elementArray.length; j++){ 
+					elementArray[j].checked = "";
+				}
+				document.getElementById('checkAll').checked = "";
+			}
+			else{
+				document.getElementById(wfsConfElementArray[i].element_name).value = "";	
+			}
+		}	
+	}
+	
+	//remove geometry from spatialrequest, remove drawn rectangle or polygon and hint
+	spatialRequestGeom = null;
+	requestGeometryHighlight.clean();
+	requestGeometryHighlight.paint();
+	if(document.getElementById('spatialResHint')){
+ 		document.getElementById("spatialResHint").innerHTML = "";
+ 	}
+		
+	//remove result popup
+	if(typeof(resultGeometryPopup)!="undefined"){
+ 		resultGeometryPopup.destroy();
+ 	}
+ 	//remove detail popup
+ 	if(typeof(wfsPopup)!="undefined"){
+ 		wfsPopup.destroy();
+ 	}
+	
+ 	if(document.getElementById('spatialResHint')){
+ 		document.getElementById("spatialResHint").innerHTML = "";
+ 	}
+ 	document.getElementById("res").innerHTML = "";
+}
+
+function getNumberOfFilterParameters(){
+	var cnt = 0;
+	var el = global_wfsConfObj[global_selectedWfsConfId].element;
+	inputNotEnough = [];
+	for (var i = 0; i < el.length; i++){
+	
+		if( el[i]['f_search'] == 1){
+			if(el[i]['f_form_element_html'].match(/\<select/)){
+				var elementValue = document.getElementById(el[i]['element_name']).options[document.getElementById(el[i]['element_name']).selectedIndex].value;
+    		}
+    		else if(el[i]['f_form_element_html'].match(/checkbox/)){
+				var elementArray = document.getElementsByName(el[i]['element_name']);
+				var selectedVal = [];
+				for (var j = 0; j < elementArray.length; j++){ 
+					if (elementArray[j].checked == true){ 
+						selectedVal.push(elementArray[j].value);
+					}
+				}
+				var elementValue = selectedVal.join(",");
+			}
+			else{
+				var elementValue = document.getElementById(el[i]['element_name']).value;
+			}
+	
+			if (elementValue != '') {
+				cnt++;
+			}
+			if(elementValue.length < el[i]['f_min_input']){
+				inputNotEnough.push(el[i]['element_name']+"("+el[i]['f_min_input']+")");
+			}
+		}
+	}
+	
+	if(inputNotEnough.length>0){
+		alert("Mandatory fields: "+inputNotEnough.join(', '));
+		return false;
+	}
+	
+//	if(spatialRequestGeom == null){
+//		alert("Bitte räumliche Eingrenzung vornehmen.");
+//		return false;
+//	}
+	
+	return cnt;
+}
+function validate(){
+	if(geomArray.count()>0){
+ 		geomArray.empty();
+ 	}
+ 	if(typeof(resultGeometryPopup)!="undefined"){
+ 		resultGeometryPopup.destroy();
+ 	}
+ 	if(typeof(wfsPopup)!="undefined"){
+ 		wfsPopup.destroy();
+ 	}
+	global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
+
+	var filterParameterCount = getNumberOfFilterParameters();
+	
+	if(filterParameterCount == 0 && spatialRequestGeom == null){
+	//if(filterParameterCount == 0){
+		//alert("Please specify at least one filter attribute.");
+		return false;
+	}
+	else{
+		if(inputNotEnough.length==0){
+			var andConditions = "";
+			
+			var el = global_wfsConfObj[global_selectedWfsConfId].element;
+			var srs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
+		
+			for (var i = 0; i < el.length; i++) {
+				if (el[i]['f_search'] == 1){
+					if(el[i]['f_form_element_html'].match(/\<select/)){
+						var elementValue = document.getElementById(el[i]['element_name']).options[document.getElementById(el[i]['element_name']).selectedIndex].value;
+	    			}
+	    			else if(el[i]['f_form_element_html'].match(/checkbox/)){
+						var elementArray = document.getElementsByName(el[i]['element_name']);
+						var selectedVal = [];
+						for (var j = 0; j < elementArray.length; j++){ 
+							if (elementArray[j].checked == true){ 
+								selectedVal.push(elementArray[j].value);
+							}
+						}
+						var elementValue = selectedVal.join(",");
+					}
+					else{
+						var elementValue = document.getElementById(el[i]['element_name']).value;
+					}
+				}
+				
+				if (el[i]['f_search'] == 1 && elementValue != '') {
+					var a = new Array();
+					a = elementValue.split(",");
+					var orConditions = "";
+					for (var j=0; j < a.length; j++) {
+						if(el[i]['f_operator']=='bothside'){
+							orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>*";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "*</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsLike>";
+					}
+						else if(el[i]['f_operator']=='rightside'){
+							orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "*</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsLike>";
+						}
+						else if(el[i]['f_operator']=='greater_than'){
+							orConditions += "<ogc:PropertyIsGreaterThan>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsGreaterThan>";
+						}
+						else if(el[i]['f_operator']=='less_than'){
+							orConditions += "<ogc:PropertyIsLessThan>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsLessThan>";
+						}
+						else if(el[i]['f_operator']=='less_equal_than'){
+							orConditions += "<ogc:PropertyIsLessThanOrEqualTo>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsLessThanOrEqualTo>";
+						}
+						else if(el[i]['f_operator']=='greater_equal_than'){
+							orConditions += "<ogc:PropertyIsGreaterThanOrEqualTo>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsGreaterThanOrEqualTo>";
+						}
+						else if(el[i]['f_operator']=='equal'){
+							orConditions += "<ogc:PropertyIsEqualTo>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsEqualTo>";
+						}
+						else{
+							orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:Literal>*";
+							if(el[i]['f_toupper'] == 1){
+								orConditions += a[j].toUpperCase();
+							}
+							else{
+								orConditions += a[j];
+							}
+							orConditions += "*</ogc:Literal>";
+							orConditions += "</ogc:PropertyIsLike>";
+						}
+					}
+					if(a.length > 1){
+						andConditions += "<Or>" + orConditions + "</Or>";
+					}
+					else {
+						andConditions += orConditions;
+					}
+				}
+			}
+			
+			if(spatialRequestGeom!=null){
+				if(spatialRequestGeom.geomType == "polygon"){
+					if(buttonPolygon.filteroption=='within'){	
+						andConditions += "<Within><ogc:PropertyName>";
+						for (var j=0; j < el.length; j++) {
+							if(el[j]['f_geom']==1){
+								var elementName = el[j]['element_name'];
+								andConditions += el[j]['element_name'];
+							}
+						}
+						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+						andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+						for(var k=0; k<spatialRequestGeom.count(); k++){
+							if(k>0)	andConditions += " ";
+							andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+						}
+						andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+						andConditions += "</gml:Polygon></Within>";
+					}
+					else if(buttonPolygon.filteroption=='intersects'){
+						andConditions += "<Intersects><ogc:PropertyName>";
+						for (var j=0; j < el.length; j++) {
+							if(el[j]['f_geom']==1){
+								var elementName = el[j]['element_name'];
+								andConditions += el[j]['element_name'];
+							}
+						}
+						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+						andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
+						for(var k=0; k<spatialRequestGeom.count(); k++){
+							if(k>0)	andConditions += " ";
+							andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+						}
+						andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+						andConditions += "</gml:Polygon></Intersects>";
+					}
+				}	
+				else if(spatialRequestGeom.geomType == "line"){
+					var rectangle = [];
+					rectangle = spatialRequestGeom.getBBox();
+					
+					if(buttonRectangle.filteroption=='within'){	
+						andConditions += "<Within><ogc:PropertyName>";
+						for (var j=0; j < el.length; j++) {
+							if(el[j]['f_geom']==1){
+								var elementName = el[j]['element_name'];
+								andConditions += el[j]['element_name'];
+							}
+						}
+						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+						andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+						andConditions += rectangle[0].x+","+rectangle[0].y;
+						andConditions += " ";
+						andConditions += rectangle[0].x+","+rectangle[1].y;
+						andConditions += " ";
+						andConditions += rectangle[1].x+","+rectangle[1].y;
+						andConditions += " ";
+						andConditions += rectangle[1].x+","+rectangle[0].y;
+						andConditions += " ";
+						andConditions += rectangle[0].x+","+rectangle[0].y;
+						andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+						andConditions += "</gml:Polygon></Within>";
+					}
+					else if(buttonRectangle.filteroption=='intersects'){
+						andConditions += "<Intersects><ogc:PropertyName>";
+						for (var j=0; j < el.length; j++) {
+							if(el[j]['f_geom']==1){
+								var elementName = el[j]['element_name'];
+								andConditions += el[j]['element_name'];
+							}
+						}
+						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+						andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
+						andConditions += rectangle[0].x+","+rectangle[0].y;
+						andConditions += " ";
+						andConditions += rectangle[0].x+","+rectangle[1].y;
+						andConditions += " ";
+						andConditions += rectangle[1].x+","+rectangle[1].y;
+						andConditions += " ";
+						andConditions += rectangle[1].x+","+rectangle[0].y;
+						andConditions += " ";
+						andConditions += rectangle[0].x+","+rectangle[0].y;
+						andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+						andConditions += "</gml:Polygon></Intersects>";
+					}			
+				}
+				else if(spatialRequestGeom.geomType == "point"){
+					var tmp = spatialRequestGeom.get(0);
+					var mapPos = parent.makeRealWorld2mapPos("mapframe1",tmp.x, tmp.y);
+					var buffer = mb_wfs_tolerance/2;
+					var mapPosXAddPix = mapPos[0] + buffer; 
+					var mapPosYAddPix = mapPos[1] +buffer;
+					var mapPosXRemovePix = mapPos[0] - buffer;
+					var mapPosYRemovePix = mapPos[1] - buffer;
+					var realWorld1 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+					var realWorld2 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+					var realWorld3 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+					var realWorld4 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+					andConditions += "<Intersects><ogc:PropertyName>";
+					for (var j=0; j < el.length; j++) {
+						if(el[j]['f_geom']==1){
+							var elementName = el[j]['element_name'];
+							andConditions += el[j]['element_name'];
+						}
+					}
+					andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
+					andConditions += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] +  " ";
+					andConditions += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1]; 
+					andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
+				}
+				//andConditions += "<ogc:Not><ogc:PropertyIsNull>";
+	            //andConditions += "<ogc:PropertyName>" + elementName + "</ogc:PropertyName>";
+	       		//andConditions += "</ogc:PropertyIsNull></ogc:Not>";
+			}
+			
+			var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
+			u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
+			u += "&filter=";
+	
+			if (filterParameterCount > 1 || spatialRequestGeom != null) {
+				andConditions = "<And>" + andConditions + "</And>";
+			}
+	
+			var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
+	
+			document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
+			var parameters = {command:"getSearchResults", "wfs_conf_id":global_selectedWfsConfId, "frame":this.name, "url":u, "filter":filter, "backlink":""};
+			parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {
+				document.getElementById("res").innerHTML = "<table><tr><td>Arranging search results...</td></tr></table>";
+				
+				if(status=='success'){
+					for (var i=0; i < parent.wms.length; i++) {
+						for (var j=0; j < parent.wms[i].objLayer.length; j++) {
+							var currentLayer = parent.wms[i].objLayer[j];
+							var wms_id = parent.wms[i].wms_id; 
+							if (currentLayer.gui_layer_wfs_featuretype == global_selectedWfsConfId) {
+								var layer_name = currentLayer.layer_name; 
+								parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1); 
+								parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);					
+							}
+						}
+					}
+					var geoObj = eval('(' + jsCode + ')');	
+		       		if (jsCode) {
+			        	if (typeof(geoObj) == 'object') {
+			        		geomArray.importGeoJSON(geoObj);
+			        		document.getElementById("res").innerHTML = '';
+							displayResult(geomArray);
+						}
+						else {
+							document.getElementById("res").innerHTML = '';
+							displayResult();
+						}
+					}
+		       		else {
+						document.getElementById("res").innerHTML = '';
+						alert("No results.");
+					}
+		       	}
+			});
+		}
+		else{
+			return false;
+		}
+	}	
+	//spatialRequestGeom = null;
+	return false;
+}
+
+function displayResult(geom){
+	geomArray = geom;
+	if(geomArray!=null && geomArray.count()>0){
+		var contentHtml = createListOfGeometries();
+	}
+	else{
+		var contentHtml = "No results.";
+	}
+	
+	if(showResultInPopup==1){
+		if (typeof(resultGeometryPopup) == "undefined") {
+			resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
+		}
+		else {
+			resultGeometryPopup.destroy();
+			resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
+		}
+		resultGeometryPopup.show();
+	
+	}
+	else{
+		document.getElementById("res").innerHTML = contentHtml;
+	}
+	
+} 
+
+function createListOfGeometries(){
+	if(showResultInPopup==1){
+		var domPath = "window.frames['"+frameName+"'].";
+	}
+	else{
+		var domPath = "";
+	}
+	var listOfGeom = "<form name='resultListForm'><table style='background-color:#EEEEEE;'>\n";
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var labelArray = [];
+	if (geomArray.count() > 0) {
+				
+		if(showResultInPopup==1){
+			listOfGeom += "<tr>";
+			var labelObj = getListTitle();
+			for (var k = 1 ; k < labelObj.length; k ++) {
+				listOfGeom += "<td>";
+				listOfGeom += labelObj[k];
+				listOfGeom += "</td>";
+			}
+			listOfGeom += "</tr>";
+		}
+						
+		for (var i = 0 ; i < geomArray.count(); i ++) {
+			if (geomArray.get(i).get(-1).isComplete()) {
+				listOfGeom += "<tr>\n";
+				var resultElObj = getListValues(geomArray.get(i));
+				for (var l = 1 ; l < resultElObj.length; l ++) {
+					if(resultElObj[l]!=''){
+						listOfGeom += "<td style='cursor:pointer;\n";
+						if(showResultInPopup==1){
+							if ((i % 2) === 0) {
+								listOfGeom += "color:blue'";
+							}
+							else {
+								listOfGeom += "color:red'";
+							}
+						}
+						else{
+							if ((i % 2) === 0) {
+								listOfGeom += "' class='even'";
+							}
+							else {
+								listOfGeom += "' class='uneven'";
+							}
+						}
+						listOfGeom += " onmouseover=\""+domPath+"setResult('over',"+i+")\" ";
+						listOfGeom += " onmouseout=\""+domPath+"setResult('out',"+i+")\" ";
+						listOfGeom += " onclick=\""+domPath+"setResult('click',"+i+"); "+domPath+"showWfs("+i+");\" ";
+						listOfGeom += ">"+ resultElObj[l] +"</td>";
+					}
+				}	
+				listOfGeom += "\t</tr>\n"; 
+			}
+		}
+	}
+	listOfGeom += "</table></form>\n";
+	return listOfGeom; 
+}
+
+function getListTitle(){
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var labelArray = [];
+	for (var j = 0 ; j < wfsConf.element.length ; j++) {
+		if(wfsConf.element[j].f_show == 1 && wfsConf.element[j].f_label!=''){
+			var labelPos = wfsConf.element[j].f_respos;
+			labelArray[labelPos] = wfsConf.element[j].f_label;
+		}
+	}
+	return labelArray;
+}
+		
+function getListValues(geom){
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var resultArray = [];
+	for (var i = 0 ; i < wfsConf.element.length ; i++) {
+		if (wfsConf.element[i].f_show == 1 && geom.e.getElementValueByName(wfsConf.element[i].element_name) !=false) {
+			var pos = wfsConf.element[i].f_respos;
+			if(pos>0){
+				resultArray[pos] = geom.e.getElementValueByName(wfsConf.element[i].element_name);
+			}
+		}
+	}
+	return resultArray;
+}
+
+function showWfs(geometryIndex) {
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var wfsElement = geomArray.get(geometryIndex).e;
+	var showDetailsObj = [];
+	var details = 0;
+	for (var i = 0 ; i <wfsConf.element.length; i ++) {
+		if(wfsConf.element[i].f_show_detail == 1 && wfsElement.getElementValueByName(wfsConf.element[i].element_name)!=''){
+			var elPos = wfsConf.element[i].f_detailpos;
+			if(elPos>0){
+				var currentObj = {};
+//				showDetailsObj[elPos] = {};
+				currentObj.elPos = elPos;
+				currentObj.data = {};
+				//var elementVal = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+				//showDetailsObj[elPos][wfsConf.element[i].f_label] = elementVal;
+				if(wfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
+					var newPath = wfsElement.getElementValueByName(wfsConf.element[i].element_name).replace(/%computername%/,"Rechnername");
+					var setUrl = wfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+newPath+"' target='_blank'");
+					if(setUrl.match(/><\/a>/)){
+						var newLink	=	setUrl.replace(/><\/a>/, ">"+wfsElement.getElementValueByName(wfsConf.element[i].element_name)+"</a>");
+					}
+					else{
+						var newLink = setUrl;
+					}
+					if(openLinkFromSearch=='1'){
+						window.open(elementVal, elementVal,"width=500, height=400,left=100,top=100,scrollbars=yes");
+					}
+//					showDetailsObj[elPos][wfsConf.element[i].f_label] =  newLink;
+					currentObj.data[wfsConf.element[i].f_label] = newLink;
+				}
+				else{
+//					showDetailsObj[elPos][wfsConf.element[i].f_label] = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+					currentObj.data[wfsConf.element[i].f_label] = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+				}
+				showDetailsObj.push(currentObj);
+			}
+			details = 1;
+		}
+		else{
+			details = 0;
+		}
+	}
+	var resultHtml = "";
+	resultHtml += "<table style='background-color:#EEEEEE;'>\n";
+//	for (var elPos in showDetailsObj) {
+
+	showDetailsObj.sort(showDetailObjSort);
+	for (var i=0; i < showDetailsObj.length; i++) {
+//		var currentDetail = showDetailsObj[elPos];
+		var currentDetail = showDetailsObj[i].data;
+		for(var key in currentDetail){
+			var currentDetailName = key;
+			var currentDetailValue = currentDetail[key];
+			resultHtml +="<tr><td>\n"; 
+			resultHtml += currentDetailName;
+			resultHtml +="</td>\n"; 
+			resultHtml += "<td>\n";
+			resultHtml += currentDetailValue;
+			resultHtml += "</td></tr>\n";
+		}
+	}
+	if(details != 1){
+		resultHtml +="<tr><td>No detail information</td></tr>\n";
+	}
+	resultHtml += "</table>\n";
+	if(showResultInPopup==1){
+		if (typeof(wfsPopup) == "undefined") {
+			wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
+		}
+		else {
+			wfsPopup.destroy();
+			wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
+		}
+		wfsPopup.show();
+	}
+}
+
+function showDetailObjSort (a, b) {
+	return (parseInt(a.elPos) - parseInt(b.elPos));
+}
+
+/*
+* event -> {over || out || click}
+* geom -> commaseparated coordinates x1,y1,x2,y2 ...
+*/
+function setResult(event, index){
+	var currentGeom = geomArray.get(index);
+	if (maxHighlightedPoints > 0 && currentGeom.getTotalPointCount() > maxHighlightedPoints) {
+		currentGeom = currentGeom.getBBox4();
+	}
+	if (event == "over") {
+		global_resultHighlight.add(currentGeom, cw_fillcolor);
+		global_resultHighlight.paint();
+	}
+	else if (event == "out"){
+		global_resultHighlight.del(currentGeom, cw_fillcolor);
+		global_resultHighlight.paint();
+	}
+	else if (event == "click"){
+		global_resultHighlight.del(currentGeom, cw_fillcolor);
+		var bbox = currentGeom.getBBox();
+		var bufferFloat = parseFloat(global_wfsConfObj[global_selectedWfsConfId].g_buffer);
+		var buffer = new parent.Point(bufferFloat,bufferFloat);
+		bbox[0] = bbox[0].minus(buffer);
+		bbox[1] = bbox[1].plus(buffer);
+		parent.mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
+		parent.zoom(targetArray[0], 'true', 1.0);
+		global_resultHighlight.add(currentGeom, cw_fillcolor);
+		global_resultHighlight.paint();
+	}
+	global_resultHighlight.paint();
+	return true;
+}
+function callPick(obj){
+	dTarget = obj;
+	var dp = window.open('../tools/datepicker/datepicker.php?m=Jan_Feb_Mar_Apr_May_June_July_Aug_Sept_Oct_Nov_Dec&d=Mon_Tue_Wed_Thu_Fri_Sat_Sun&t=today','dp','left=200,top=200,width=230,height=210,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0');
+	dp.focus();
+	return false;
+}
+
+</script>
+</head>
+<body leftmargin='0' topmargin='10'  bgcolor='#ffffff'>
+<form name='selectWfsConfForm' id='selectWfsConfForm'></form>
+<div name='displaySpatialButtons' id='displaySpatialButtons' style='width:180px'></div>
+<a name='wfsInfo' id='wfsInfo'></a>
+<img src = "" name='wfsRemove' id='wfsRemove'>
+<img src = "" name='wfsGeomType' id='wfsGeomType'>
+<form name='wfsForm' id='wfsForm' onsubmit='return validate()'></form>
+<div name='res' id='res' style='width:180px'></div>
+</body>
+</html>



More information about the Mapbender_commits mailing list