[Mapbender-commits] r3502 - in branches: . wfs11/conf wfs11/http/classes wfs11/http/javascripts wfs11/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jan 29 09:34:25 EST 2009


Author: christoph
Date: 2009-01-29 09:34:25 -0500 (Thu, 29 Jan 2009)
New Revision: 3502

Added:
   branches/wfs11/
   branches/wfs11/http/classes/class_ows.php
   branches/wfs11/http/classes/class_ows_factory.php
   branches/wfs11/http/classes/class_universal_wfs_factory.php
   branches/wfs11/http/classes/class_wfsToDb.php
   branches/wfs11/http/classes/class_wfs_1_0.php
   branches/wfs11/http/classes/class_wfs_1_0_factory.php
   branches/wfs11/http/classes/class_wfs_1_1.php
   branches/wfs11/http/classes/class_wfs_1_1_factory.php
   branches/wfs11/http/classes/class_wfs_deprecated.php
   branches/wfs11/http/classes/class_wfs_factory.php
   branches/wfs11/http/classes/class_wfs_featuretype.php
   branches/wfs11/http/javascripts/map_obj.js
Removed:
   branches/wfs11/http/javascripts/map_obj.js
Modified:
   branches/wfs11/conf/digitize_default.conf
   branches/wfs11/http/classes/class_gui.php
   branches/wfs11/http/classes/class_locale.php
   branches/wfs11/http/classes/class_mb_exception.php
   branches/wfs11/http/classes/class_wfs.php
   branches/wfs11/http/classes/class_wfs_conf.php
   branches/wfs11/http/javascripts/mod_digitize_tab.php
   branches/wfs11/http/php/mod_loadwfs.php
   branches/wfs11/http/php/mod_wfs_server.php
Log:


Copied: branches/wfs11 (from rev 3499, trunk/mapbender)

Modified: branches/wfs11/conf/digitize_default.conf
===================================================================
--- trunk/mapbender/conf/digitize_default.conf	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/conf/digitize_default.conf	2009-01-29 14:34:25 UTC (rev 3502)
@@ -10,9 +10,9 @@
 addButtonDig("setBasePoint", 1, "new_node_off.png", "", "", 112, 0);
 addButtonDig("delBasePoint", 1, "delete_node_off.png", "", "", 140, 0);
 addButtonDig("clear", 1, "del_off.png", "", "", 168, 0);
-addButtonDig("digitizeDifference", 0, "splitPolygon_off.png", "", "", 0, 28);
-addButtonDig("digitizeSplit", 0, "splitPolygon_off.png", "", "", 28, 28);
-addButtonDig("digitizeMerge", 0, "mergePolygons_off.png", "", "", 56, 28);
+addButtonDig("digitizeDifference", 1, "splitPolygon_off.png", "", "", 0, 28);
+addButtonDig("digitizeSplit", 1, "splitPolygon_off.png", "", "", 28, 28);
+addButtonDig("digitizeMerge", 1, "mergePolygons_off.png", "", "", 56, 28);
 
 //definition of directory of digitize buttons
 buttonDig_imgdir = "../img/button_digitize/";

Modified: branches/wfs11/http/classes/class_gui.php
===================================================================
--- trunk/mapbender/http/classes/class_gui.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/classes/class_gui.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -28,13 +28,31 @@
 	var $id;
 	var $elementArray = array();
 	
-	public function __construct ($id) {
-		if ($id) {
-			$this->id = $id;
-			$this->elementArray = $this->selectElements();
+	public function __construct () {
+		if (func_num_args() == 1) {
+			$id = func_get_arg(0);
+			if ($this->guiExists($id))	{
+				$this->id = $id;
+				$this->elementArray = $this->selectElements();
+			}
 		}
 	}
 
+	
+	public function addWfs ($aWfs) {
+		$sql ="INSERT INTO gui_wfs (fkey_gui_id, fkey_wfs_id)";
+		$sql .= "VALUES ($1, $2);";
+		$v = array($this->id, $aWfs->id);
+		$t = array("s", "i");
+		$res = db_prep_query($sql, $v, $t);
+
+		if (!$res) {
+			$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
+			return false;
+		}
+		return true;
+	}
+	
 	public function selectElements () {
 		$sql = "SELECT e_id FROM gui_element WHERE fkey_gui_id = $1 " . 
 				"ORDER BY e_pos";

Modified: branches/wfs11/http/classes/class_locale.php
===================================================================
--- trunk/mapbender/http/classes/class_locale.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/classes/class_locale.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -168,6 +168,18 @@
          * determines the available Locales on this system
          */
         function setSystemLocales() {
+                $this->systemLocales['pt_PT'] = array('linux' => 'pt_PT.utf8',
+                                        'windows' => 'Portuguese_Portugal.1252',
+                                        'bsd' => 'pt_PT',
+                                        'posix' => 'pt_PT');
+                $this->systemLocales['fr_FR'] = array('linux' => 'fr_FR.utf8',
+                                        'windows' => 'French_France.1252',
+                                        'bsd' => 'fr_FR',
+                                        'posix' => 'fr_FR');
+                $this->systemLocales['es_ES'] = array('linux' => 'es_ES.utf8',
+                                        'windows' => 'Spanish_Spain.1252',
+                                        'bsd' => 'es_ES',
+                                        'posix' => 'es_ES');
                 $this->systemLocales['it_IT'] = array(
 										'linux' => 'it_IT.utf8',
                                         'windows' => 'Italian_Italy.1252',

Modified: branches/wfs11/http/classes/class_mb_exception.php
===================================================================
--- trunk/mapbender/http/classes/class_mb_exception.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/classes/class_mb_exception.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -31,6 +31,9 @@
 	 * @param	string $message		message that is being logged
 	 */
 	public function __construct ($message) {
+		if ($message == Exception) {
+			return $this->mb_log("ERROR: " . $e->getMessage(), $this->level);
+		}
 		return $this->mb_log("ERROR: " . $message, $this->level);
 	}
 

Added: branches/wfs11/http/classes/class_ows.php
===================================================================
--- branches/wfs11/http/classes/class_ows.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_ows.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,48 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+
+/**
+ * An abstract class modelling an OGC web service (OWS), for example
+ * Web Map Service (WMS) or Web Feature Service (WFS).
+ */
+abstract class Ows {
+	var $id;
+	var $name;
+	var $title;
+	var $summary;
+	var $uploadUrl;
+	var $getCapabilities;
+	var $getCapabilitiesDoc;
+	var $fees;
+	var $accessconstraints;
+	var $individualName;
+	var $positionName;
+	var $providerName;
+	var $city;
+	var $deliveryPoint;
+	var $administrativeArea;
+	var $postalCode;
+	var $voice;
+	var $facsimile;
+	var $electronicMailAddress;
+	var $country;
+}
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_ows_factory.php
===================================================================
--- branches/wfs11/http/classes/class_ows_factory.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_ows_factory.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,121 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+
+/**
+ * This abstract class is the superclass of all factories
+ * creating OGC Web Services (OWS).
+ */
+abstract class OwsFactory {
+	
+	/**
+	 * Creates an OWS from an XML, presumably a capabilities document.
+	 * 
+	 * @return Ows
+	 * @param $xml String
+	 */
+	abstract public function createFromXml ($xml);
+
+	/**
+	 * Creates an OWS from the Mapbender database.
+	 * 
+	 * @return Ows
+	 * @param $id Integer The index in the database
+	 */
+	abstract public function createFromDb ($id);
+	
+	/**
+	 * Removes endlines and carriage returns from a string.
+	 * 
+	 * @return String
+	 * @param $string String
+	 */
+	final protected function stripEndlineAndCarriageReturn ($string) {
+		return preg_replace("/\n/", "", preg_replace("/\r/", " ", $string));
+	}
+	
+	/**
+	 * Creates a random id. The id contains non-numeric characters in 
+	 * order to distinguish it from a database id.
+	 * 
+	 * @return String
+	 */
+	final protected function createId () {
+		return "id_" . substr(md5(rand()),0,6);
+	}
+	
+	/**
+	 * Removes the namespace from a tag name.
+	 * 
+	 * Example: input is "topp:the_geom" will return "the_geom".
+	 * 
+	 * @return String
+	 * @param $s String
+	 */
+	final protected function sepNameSpace($s) {
+		$c = strpos($s, ":"); 
+		if ($c > 0) {
+			return substr($s, $c + 1);
+		}
+		return $s;
+	}
+
+	/**
+	 * Retrieves a document from a URL, presumably a capabilities document.
+	 * 
+	 * @return String
+	 * @param $url String
+	 */
+	final protected function getFromUrl ($url) {
+		$x = new connector($url);
+		$xml = $x->file;
+		if(!$xml){
+			throw new Exception("Unable to open document: " . $url);
+			return null;
+		}
+		return $xml;		
+	}
+
+	/**
+	 * Creates an OWS from an XML, presumably a capabilities document, 
+	 * which is retrieved from a URL.
+	 * 
+	 * @return Ows
+	 * @param $url String
+	 */
+	final public function createFromUrl ($url) {
+		try {
+			$xml = $this->getFromUrl($url);
+	
+			$myOws = $this->createFromXml($xml);
+			if ($myOws != null) {
+				$myOws->uploadUrl = $url;
+				return $myOws;
+			}		
+			return null;
+		}
+		catch (Exception $e) {
+			new mb_exception($e);
+			return null;
+		}
+		return null;
+	}
+}
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_universal_wfs_factory.php
===================================================================
--- branches/wfs11/http/classes/class_universal_wfs_factory.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_universal_wfs_factory.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,116 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_ows_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_1_0_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_1_1_factory.php");
+
+/**
+ * 
+ * @return 
+ * @param $xml String
+ */
+class UniversalWfsFactory extends WfsFactory {
+	
+	/**
+	 * Parses the capabilities document for the WFS 
+	 * version number and returns it.
+	 * 
+	 * @return String
+	 * @param $xml String
+	 */
+	private function getVersionFromXml ($xml) {
+
+		$admin = new administration();
+		$values = $admin->parseXml($xml);
+		
+		foreach ($values as $element) {
+			if($this->sepNameSpace(strtoupper($element[tag])) == "WFS_CAPABILITIES" && $element[type] == "open"){
+				return $element[attributes][version];
+			}
+		}
+		throw new Exception("WFS version could not be determined from XML.");
+	}
+
+	/**
+	 * Creates a WFS object by parsing its capabilities document. 
+	 * 
+	 * The WFS version is determined by parsing 
+	 * the capabilities document up-front.
+	 * 
+	 * @return Wfs
+	 * @param $xml String
+	 */
+	public function createFromXml ($xml) {
+		try {
+			$version = $this->getVersionFromXml($xml);
+
+			switch ($version) {
+				case "1.0.0":
+					$factory = new Wfs_1_0_Factory();
+					break;
+				case "1.1.0":
+					$factory = new Wfs_1_1_Factory();
+					break;
+				default:
+					throw new Exception("Unknown WFS version " . $version);
+					break;
+			}
+			return $factory->createFromXml($xml);
+		}
+		catch (Exception $e) {
+			new mb_exception($e);
+			return null;
+		}
+	}
+	
+	public function createFromDb ($id) {
+		try {
+			$sql = "SELECT wfs_version FROM wfs WHERE wfs_id = $1";
+			$v = array($id);
+			$t = array("i");
+			$res = db_prep_query($sql, $v, $t);
+			$row = db_fetch_array($res);
+			if ($row) {
+				$version = $row["wfs_version"];
+				
+				switch ($version) {
+					case "1.0.0":
+						$factory = new Wfs_1_0_Factory();
+						break;
+					case "1.1.0":
+						$factory = new Wfs_1_1_Factory();
+						break;
+					default:
+						throw new Exception("Unknown WFS version " . $version);
+						break;
+				}
+				return $factory->createFromDb($id);
+			}
+		}
+		catch (Exception $e) {
+			new mb_exception($e);
+			return null;
+		}
+	}
+}
+?>
\ No newline at end of file

Modified: branches/wfs11/http/classes/class_wfs.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/classes/class_wfs.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -17,795 +17,200 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-/**
-* class for wfs-objects
-*/
-
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
 require_once(dirname(__FILE__)."/class_connector.php");
-require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_ows.php");
+require_once(dirname(__FILE__)."/class_wfsToDb.php");
 
-class wfs {
-
-  var $wfs_id;
-  var $wfs_version;
-  var $wfs_name;
-  var $wfs_title;
-  var $wfs_abstract;
-  var $wfs_getcapabilities;
-  var $wfs_getcapabilities_doc; //new SB 2007-08-09
-  var $wfs_describefeaturetype;
-  var $wfs_describefeaturetype_namespace = array();
-  var $wfs_getfeature;
-  var $wfs_transaction;
-  var $wfs_upload_url; //new SB 2007-08-09
-
-  //new WFS 1.0.0 -- SB 2007-08-06
-
-  var $fees;
-  var $accessconstraints;
-  
-  var $wfs_featuretype = array();
- 
- 
-function wfs() {
-
-} 
-function createObjFromXML($url){
+/**
+ * An abstract Web Feature Service (WFS) class, modelling for example
+ * WFS 1.0.0 or WFS 1.1.0
+ */
+abstract class Wfs extends Ows {
+	var $describeFeatureType;
+	var $describeFeatureTypeNamespace;
+	var $getFeature;
+	var $transaction;
+	var $featureTypeArray = array();
 	
-	$x = new connector($url);
-	$data = $x->file;
-	#$data = implode("",file($url));
-	if(!$data){
-		echo "Unable to open document: ".$url;
-		die; 
+	/**
+	 * Returns the version of this WFS. Has to be implemented by the subclass.
+	 * @return String the version, for example "1.0.0"
+	 */
+	public function getVersion () {
+		return "";
 	}
 	
-	$values = null;
-	$tags = null;
-	$admin = new administration();
-	$this->wfs_getcapabilities_doc = $admin->char_encode($data);
-	$this->wfs_upload_url = $url;
+	public function addFeatureType ($aFeatureType) {
+		array_push($this->featureTypeArray, $aFeatureType);
+	}
 	
-	# for temporary wfs a id has to be created...
-	$this->wfs_id = "id_" . substr(md5(rand()),0,6);
-	$parser = xml_parser_create(CHARSET);
-	xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
-	xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
-	xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
-	xml_parse_into_struct($parser,$this->wfs_getcapabilities_doc,$values,$tags);
-	//xml_parse_into_struct($parser,$data,$values,$tags);
-	
-	xml_parser_free($parser);
+	// -----------------------------------------------------------------------
+	//
+	// Output formats
+	//
+	// -----------------------------------------------------------------------
 	
-	$section = false;
-	$request = false;
-	$featuretype_name = false;
- 	$featuretype_title = false;
- 	$featuretype_abstract = false;
- 	$featuretype_srs = false;
-	
-	foreach ($values as $element) {
-	
-		if(strtoupper($element[tag]) == "WFS_CAPABILITIES" && $element[type] == "open"){
-			$this->wfs_version = $element[attributes][version];
-		}
-		if(strtoupper($element[tag]) == "NAME"  && $element[level] == '3'){
-			$this->wfs_name = $element[value];
-		}
-		if(strtoupper($element[tag]) == "TITLE"  && $element[level] == '3'){
-			$this->wfs_title = $this->stripEndlineAndCarriageReturn($element[value]);
-		}
-		if(strtoupper($element[tag]) == "ABSTRACT" && $element[level] == '3'){
-			$this->wfs_abstract = $this->stripEndlineAndCarriageReturn($element[value]);
-		}
-		//new WFS 1.0.0 -- SB 2007-08-06
-		if(strtolower($element[tag]) == "fees"){
-			$this->fees = $element[value];
-		}
-		if(strtolower($element[tag]) == "accessconstraints"){
-			$this->accessconstraints = $element[value];
-		}
-		
-		/*capability section*/
-		
-		if($this->wfs_version == "1.0.0"){
-			
-			# getCapabilities
-			if(strtoupper($element[tag]) == "GETCAPABILITIES" && $element[type] == "open"){
-				$section = "getcapabilities";
-			}
-			if($section == "getcapabilities" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_getcapabilities = $element[attributes][onlineResource];
-			}
-			
-			# descriptFeatureType
-			if(strtoupper($element[tag]) == "DESCRIBEFEATURETYPE" && $element[type] == "open"){
-				$section = "describefeaturetype";
-				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
-				
-				
-			}
-			if($section == "describefeaturetype" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
-			}
-			
-			# getFeature
-			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "open"){
-				$section = "getfeature";
-			}
-			if($section == "getfeature" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_getfeature = $element[attributes][onlineResource];
-			}
-			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "close"){
-				$section = "";
-			}			
-			# transaction
-			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "open"){
-				$section = "transaction";
-			}
-			if($section == "transaction" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_transaction = $element[attributes][onlineResource];
-			}
-			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "close"){
-				$section = "";
-			}
-		} 
-		if(strtoupper($element[tag]) == "FEATURETYPE" && $element[type] == "open"){
-			$section = "featuretype";
-		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "NAME"){
-			$featuretype_name = $element[value];
-		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "TITLE"){
-			$featuretype_title = $this->stripEndlineAndCarriageReturn($element[value]);
-		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "ABSTRACT"){
-			$featuretype_abstract = $this->$element[value];
-		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "SRS"){
-			$featuretype_srs = $element[value];
-			$this->addFeaturetype($featuretype_name,$featuretype_title,$featuretype_abstract,$featuretype_srs,$this->wfs_describefeaturetype,$this->wfs_version);
-		}
-	}
-}
-function displayWFS(){
-	echo "id: " . $this->wfs_id . " <br>";
-	echo "version: " . $this->wfs_version . " <br>";
-	echo "name: " . $this->wfs_name . " <br>";
-	echo "title: " . $this->wfs_title . " <br>";
-	echo "abstract: " . $this->wfs_abstract . " <br>";
-	echo "capabilitiesrequest: " . $this->wfs_getcapabilities . " <br>";
-	echo "describefeaturetype: " . $this->wfs_describefeaturetype . " <br>";
-	echo "getfeature: " . $this->wfs_getfeature . " <br>";
-	echo "transaction: " . $this->wfs_transaction . " <br>";
-	for($i=0; $i<count($this->wfs_featuretype); $i++){
-		echo "<hr>";
-		echo "name: ". $this->wfs_featuretype[$i]->featuretype_name . "<br>";
-		echo "title: ". $this->wfs_featuretype[$i]->featuretype_title . "<br>";
-		echo "abstract: ". $this->wfs_featuretype[$i]->featuretype_abstract . "<br>";
-		echo "srs: ". $this->wfs_featuretype[$i]->featuretype_srs . "<br>";
-		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element);$j++){
-			echo " element: " . $this->wfs_featuretype[$i]->featuretype_element[$j]["name"] ." - ".$this->wfs_featuretype[$i]->featuretype_element[$j]["type"]."<br>";
-		}
-		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_namespace);$j++){
-			echo " namespace: " . $this->wfs_featuretype[$i]->featuretype_namespace[$j]["name"] ." - ".$this->wfs_featuretype[$i]->featuretype_namespace[$j]["value"]."<br>";
-		}
-	}
-} 
-function addFeaturetype($name,$title,$abstract,$srs,$url,$version){
-	$this->wfs_featuretype[count($this->wfs_featuretype)] = new featuretype($name,$title,$abstract,$srs,$url,$version);
-}
- function stripEndlineAndCarriageReturn($string) {
-	  	return preg_replace("/\n/", "", preg_replace("/\r/", " ", $string));
-	  }
-function createJsObjFromWFS($parent){
-	if(!$this->wfs_title || $this->wfs_title == ""){
-		echo "alert('Error: no valid capabilities-document !!');";
-		die; exit;
-	}
-		if($parent){
-			echo "parent.";
-		}
-		print("add_wfs('". 
-		$this->wfs_id ."','".
-		$this->wfs_version ."','".
-		$this->wfs_title ."','".
-		$this->wfs_abstract ."','". 
-		$this->wfs_getcapabilities ."','" .
-		$this->wfs_describefeaturetype ."');");
-		
+	/**
+	 * Compiles a string containing HTML formatted information about the WFS.
+	 * 
+	 * @return String 
+	 */
+	public function toHtml () {
+		$wfsString = "";
+		$wfsString .= "id: " . $this->id . " <br>";
+		$wfsString .= "version: " . $this->getVersion() . " <br>";
+		$wfsString .= "name: " . $this->name . " <br>";
+		$wfsString .= "title: " . $this->title . " <br>";
+		$wfsString .= "abstract: " . $this->summary . " <br>";
+		$wfsString .= "capabilitiesrequest: " . $this->getCapabilities . " <br>";
+		$wfsString .= "describefeaturetype: " . $this->describeFeatureType . " <br>";
+		$wfsString .= "getfeature: " . $this->getFeature . " <br>";
+		$wfsString .= "transaction: " . $this->transaction . " <br>";
 
-	for($i=0; $i<count($this->wfs_featuretype); $i++){
-		if($parent){
-			echo "parent.";
+		for ($i = 0; $i < count($this->featureTypeArray); $i++) {
+			$currentFeatureType = $this->featureTypeArray[$i];
+			$wfsString .= $currentFeatureType->toHtml();
 		}
-		print ("wfs_add_featuretype('". 
-			$this->wfs_featuretype[$i]->featuretype_name ."','". 
-			$this->wfs_featuretype[$i]->featuretype_title . "','".
-			$this->wfs_featuretype[$i]->featuretype_abstract . "','".  
-			$this->wfs_featuretype[$i]->featuretype_srs ."','". 
-			$this->wfs_featuretype[$i]->featuretype_geomtype ."');");
-		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element);$j++){
-			if($parent){
-			echo "parent.";
-			}
-			print("wfs_add_featuretype_element('".$this->wfs_featuretype[$i]->featuretype_element[$j]["name"]."', '".$this->wfs_featuretype[$i]->featuretype_element[$j]["type"]."', ".$j.", ".$i.");");
-		}
-		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_namespace);$j++){
-			if($parent){
-			echo "parent.";
-			}
-			print("wfs_add_featuretype_namespace('".$this->wfs_featuretype[$i]->featuretype_namespace[$j]["name"]."', '".$this->wfs_featuretype[$i]->featuretype_namespace[$j]["value"]."', ".$j.", ".$i.");");
-		}
+		return $wfsString;
 	}
-}
 
-/**
- * Inserts this WFS in the database
- */
-function insertWfs() {
-	global $DBSERVER,$DB,$OWNER,$PW;
-	$con = db_connect($DBSERVER,$OWNER,$PW);
-	db_select_db($DB,$con);
-
-	$sql = "INSERT INTO wfs (wfs_version, wfs_name, wfs_title, wfs_abstract, ";
-	$sql .= "wfs_getcapabilities, wfs_getcapabilities_doc, wfs_upload_url, ";
-	$sql .= "wfs_describefeaturetype, wfs_getfeature, wfs_transaction, fees, ";
-	$sql .= "accessconstraints, wfs_owner, wfs_timestamp) ";
-	$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)";
-
-	$v = array($this->wfs_version, $this->wfs_name, $this->wfs_title, 
-		$this->wfs_abstract, $this->wfs_getcapabilities, $this->wfs_getcapabilities_doc,
-		$this->wfs_upload_url, $this->wfs_describefeaturetype, $this->wfs_getfeature,
-		$this->wfs_transaction, $this->fees, $this->accessconstraints, 
-		$_SESSION["mb_user_id"], strtotime("now"));
-		
-	$t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 'i');
-
-	$res = db_prep_query($sql,$v,$t);
-
-	if(!$res){
-		db_rollback();
-		$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
-		return false;
+	/**
+	 * Can be switched to other output format if desired.
+	 * 
+	 * @return String
+	 */
+	public function __toString () {
+		return $this->toHtml();
 	}
-	$this->wfs_id = db_insert_id($con,'wfs','wfs_id');
-	return true;
-}
 
-function updateWfs() {
-	global $DBSERVER,$DB,$OWNER,$PW;
-	$con = db_connect($DBSERVER,$OWNER,$PW);
-	db_select_db($DB,$con);
+	/**
+	 * Creates a string of JavaScript code. This code will then 
+	 * create a WFS object on the client side.
+	 * 
+	 * @return String
+	 */
+	public function toJavaScript () {
+		$jsString = "";
 
-	$sql = "UPDATE wfs SET wfs_version = $1, wfs_name = $2, wfs_title = $3, ";
-	$sql .= "wfs_abstract = $4, wfs_getcapabilities = $5, wfs_getcapabilities_doc = $6, ";
-	$sql .= "wfs_upload_url = $7, wfs_describefeaturetype = $8, wfs_getfeature = $9, ";
-	$sql .= "wfs_transaction = $10, fees = $11, accessconstraints = $12, wfs_owner = $13, ";
-	$sql .= "wfs_timestamp = $14 ";
-	$sql .= "WHERE wfs_id = $15";
-	//echo $sql."<br />";
-	$v = array($this->wfs_version, $this->wfs_name, $this->wfs_title, $this->wfs_abstract,
-		$this->wfs_getcapabilities, $this->wfs_getcapabilities_doc, $this->wfs_upload_url,
-		$this->wfs_describefeaturetype, $this->wfs_getfeature, $this->wfs_transaction,
-		$this->fees, $this->accessconstraints, $_SESSION["mb_user_id"],strtotime("now"), 
-		$this->wfs_id);
-		
-	$t = array('s', 's', 's', 's', 's', 's', 's', 's' ,'s' ,'s' ,'s' ,'s' ,'i' ,'i' ,'i');
-	$res = db_prep_query($sql,$v,$t);
-	if(!$res){
-		db_rollback();
-		$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
-		return false;
-	}
-	return true;
-}
-/**
-* wfs2db
-*
-* this function saves the class information to the mapbender database 
-* @return boolean true if sucessful false otherwise
-*/
-function wfs2db($gui_id){
-	global $DBSERVER,$DB,$OWNER,$PW;
-	$con = db_connect($DBSERVER,$OWNER,$PW);
-	db_select_db($DB,$con);
-	
-	db_begin();
-	
-	// check if WFS already might exists (it might exist when wfs_id is numeric)
-	$wfs_exists = is_numeric($this->wfs_id);
-
-	// if it might exist, update it
-	if ($wfs_exists) {
-		// but check first if it really exists in the database
-		$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
-		$v = array($this->wfs_id);
-		$t = array("i");
-		$res = db_prep_query($sql, $v, $t);	
-		if($res){
-			$this->updateWfs();
+		$parent = "";
+		if (func_num_args() == 1 && func_get_arg(0) == true) {
+			$parent = "parent.";
 		}
-		// if not, insert as new WFS
-		else {
-			$this->insertWfs();
-		}
-	}
-	// if it does not exist, insert as new WFS
-	else {
-		$this->insertWfs();
-	}
-
-	# delete featuretypes from DB that does not exist and find the ids
-	$sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1;";
-	$v = array($this->wfs_id);
-	$t = array("i");
-	$res_ft = db_prep_query($sql, $v, $t);
-	$cnt = 0;
-	while(db_fetch_row($res_ft)){
-		$found = false;
-		for($i=0; $i<count($this->wfs_featuretype); $i++){
-			if($this->wfs_featuretype[$i]->featuretype_name == db_result($res_ft, $cnt, "featuretype_name")){
-				$this->wfs_featuretype[$i]->featuretype_id = db_result($res_ft, $cnt, "featuretype_id");
-				$found = true;
-				break;
-			}
-		}
 		
-		if(!$found){
-			$sql = "DELETE FROM wfs_featuretype WHERE featuretype_id = $1 AND fkey_wfs_id = $2";
-			$v = array(db_result($res_ft, $cnt, "featuretype_id"), $this->wfs_id);
-			$t = array('i','i');
-			//echo $sql."<br />";
-			$res = db_prep_query($sql,$v,$t);
-			if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
+		if(!$this->title || $this->title == ""){
+			$e = new mb_exception("Error: no valid capabilities-document !!");
+			return null;
 		}
-		$cnt++;
-	}
+
+		$jsString .= $parent . "add_wfs('". 
+			$this->id ."','".
+			$this->getVersion() ."','".
+			$this->title ."','".
+			$this->summary ."','". 
+			$this->getCapabilities ."','" .
+			$this->describeFeatureType .
+			"');";
+			
 	
-	
-	# TABLE wfs_featuretype
-	
-	for($i=0; $i<count($this->wfs_featuretype); $i++){
-		if(!$this->wfs_featuretype[$i]->featuretype_id){
-			$sql = "INSERT INTO wfs_featuretype(fkey_wfs_id, featuretype_name, featuretype_title, featuretype_abstract, featuretype_srs) ";
-			$sql .= "VALUES($1,$2,$3,$4,$5)";
-			$v = array($this->wfs_id,$this->wfs_featuretype[$i]->featuretype_name,$this->wfs_featuretype[$i]->featuretype_title,$this->wfs_featuretype[$i]->featuretype_abstract,$this->wfs_featuretype[$i]->featuretype_srs);
-			$t = array('i','s','s','s','s');
-			//echo $sql."<br />";
-			$res = db_prep_query($sql,$v,$t);
-			if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
+		for ($i = 0; $i < count($this->featureTypeArray); $i++) {
+			$currentFeatureType = $this->featureTypeArray[$i];
 			
-			# save the id of each featuretype: 
-			$this->wfs_featuretype[$i]->featuretype_id = db_insert_id($con,'wfs_featuretype','featuretype_id');
-		}
-		else{
-			$sql = "UPDATE wfs_featuretype SET ";
-			$sql .= "featuretype_title = $1,";
-			$sql .= "featuretype_abstract = $2,";
-			$sql .= "featuretype_srs = $3 ";
-			$sql .= "WHERE featuretype_id = $4";
-			$v = array($this->wfs_featuretype[$i]->featuretype_title,$this->wfs_featuretype[$i]->featuretype_abstract,$this->wfs_featuretype[$i]->featuretype_srs,$this->wfs_featuretype[$i]->featuretype_id);
-			$t = array('s','s','s','i');
-			//echo $sql."<br />";
-			$res = db_prep_query($sql,$v,$t);
-			if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
-		}
-		
-		//delete featuretype elements from db and find the ids
-		$sql = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1;";
-		$v = array($this->wfs_featuretype[$i]->featuretype_id);
-		$t = array("i");
-		$res_el = db_prep_query($sql, $v, $t);
-		$cnt = 0;
-		while(db_fetch_row($res_el)){
-			$found = false;
-			for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element); $j++){
-				if($this->wfs_featuretype[$i]->featuretype_element[$j]["name"] == db_result($res_el, $cnt, "element_name")){
-					$this->wfs_featuretype[$i]->featuretype_element[$j]["id"] = db_result($res_el, $cnt, "element_id");
-					$found = true;
-					break;
-				}
-			}
-			
-			if(!$found){
-				$sql = "DELETE FROM wfs_element WHERE element_id = $1 AND fkey_featuretype_id = $2";
-				$v = array(db_result($res_el, $cnt, "element_id"), $this->wfs_featuretype[$i]->featuretype_id);
-				$t = array('i','i');
-				//echo $sql."<br />";
-				$res = db_prep_query($sql,$v,$t);
-				if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
-			}
-			$cnt++;
-		}
-
-
-		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element);$j++){
-			if(!$this->wfs_featuretype[$i]->featuretype_element[$j]["id"]){
-				$sql = "INSERT INTO wfs_element(fkey_featuretype_id, element_name,element_type) ";
-				$sql .= "VALUES($1, $2, $3);";
+			$jsString .= $parent . "wfs_add_featuretype('". 
+				$currentFeatureType->name ."','". 
+				$currentFeatureType->title . "','".
+				$currentFeatureType->summary . "','".  
+				$currentFeatureType->srs ."','". 
+				$currentFeatureType->geomtype .
+				"');";
 				
-				$v = array($this->wfs_featuretype[$i]->featuretype_id, $this->wfs_featuretype[$i]->featuretype_element[$j]["name"], $this->wfs_featuretype[$i]->featuretype_element[$j]["type"]);
-				$t = array("s", "s", "s");
-				$res = db_prep_query($sql, $v, $t);
-				if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
-			}
-			else{
-				$sql = "UPDATE wfs_element SET element_type = $1 ";
-				$sql .= "WHERE element_id = $2 AND ";
-				$sql .= "fkey_featuretype_id = $3;";
-				$v = array($this->wfs_featuretype[$i]->featuretype_element[$j]["type"], $this->wfs_featuretype[$i]->featuretype_element[$j]["id"], $this->wfs_featuretype[$i]->featuretype_id);
-				$t = array("s", "i", "i");
-				$res = db_prep_query($sql, $v, $t);
-				if (!$res) {
-					db_rollback();
-					$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
-					return;
-				}
-			}
-		}
-
-		$sql = "DELETE FROM wfs_featuretype_namespace WHERE ";
-		$sql .= "fkey_wfs_id = $1 AND fkey_featuretype_id = $2";
-		$v = array($this->wfs_id, $this->wfs_featuretype[$i]->featuretype_id);
-		$t = array("i", "i");
-		$res = db_prep_query($sql, $v, $t);
-		if (!$res) {
-			db_rollback();
-			$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
-			return;
-		}
+			for ($j = 0; $j < count($currentFeatureType->elementArray); $j++) {
+				$currentElement = $currentFeatureType->elementArray[$j];
 				
-		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_namespace);$j++){
-			$sql = "INSERT INTO wfs_featuretype_namespace ";
-			$sql .= "(fkey_wfs_id, fkey_featuretype_id, namespace, namespace_location) ";
-			$sql .= "VALUES ($1, $2, $3, $4);"; 
-
-			$v = array($this->wfs_id, $this->wfs_featuretype[$i]->featuretype_id, $this->wfs_featuretype[$i]->featuretype_namespace[$j]["name"], $this->wfs_featuretype[$i]->featuretype_namespace[$j]["value"]);
-			$t = array("s", "s", "s", "s");
-			$res = db_prep_query($sql, $v, $t);
-
-			if (!$res) {
-				db_rollback();
-				$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
-				return;
+				$jsString .= $parent . "wfs_add_featuretype_element('" . 
+					$currentElement->name . "', '" . 
+					$currentElement->type . "', " .
+					$j . ", " . 
+					$i . 
+					");";
 			}
-		}
-	}
-	
-	# TABLE gui_wfs
-	
-	if($gui_id){
-		$sql ="INSERT INTO gui_wfs (fkey_gui_id, fkey_wfs_id)";
-		$sql .= "VALUES($1, $2);";
-		$v = array($gui_id, $this->wfs_id);
-		$t = array("s", "i");
-		$res = db_prep_query($sql, $v, $t);
-
-		if (!$res) {
-			db_rollback();
-			$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
-			return;
-		}
-	}
-	
-	//echo "Successfully saved!<br />";
-	db_commit();
-	
-	return true;
-}
-/**
-* updateObjFromXML
-*
-* this function regets the information from the xml (update)
-* @return boolean true if successful, false otherwise
-*/
-function updateObjFromXML($url){
-	$x = new connector($url);
-	$data = $x->file;
-	#$data = implode("",file($url));
-	if(!$data){
-		$e = new mb_exception("Unable to open document: ".$url);
-		return false; 
-	}
-	
-	$values = null;
-	$tags = null;
-	$admin = new administration();
-	$this->wfs_getcapabilities_doc = $admin->char_encode($data);
-	$this->wfs_featuretype = array();
-	$this->wfs_upload_url = $url;
-	
-	# for temporary wfs a id has to be created...
-	//$this->wfs_id = "id_" . substr(md5(rand()),0,6);
-	$parser = xml_parser_create(CHARSET);
-	xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
-	xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
-	xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
-	xml_parse_into_struct($parser,$this->wfs_getcapabilities_doc,$values,$tags);
-	//xml_parse_into_struct($parser,$data,$values,$tags);
-	
-	xml_parser_free($parser);
-	
-	$section = false;
-	$request = false;
-	$featuretype_name = false;
- 	$featuretype_title = false;
- 	$featuretype_abstract = false;
- 	$featuretype_srs = false;
-	
-	foreach ($values as $element) {
-	
-		if(strtoupper($element[tag]) == "WFS_CAPABILITIES" && $element[type] == "open"){
-			$this->wfs_version = $element[attributes][version];
-		}
-		if(strtoupper($element[tag]) == "NAME"  && $element[level] == '3'){
-			$this->wfs_name = $element[value];
-		}
-/*		if(strtoupper($element[tag]) == "TITLE"  && $element[level] == '3'){
-			$this->wfs_title = $this->stripEndlineAndCarriageReturn($element[value]);
-		}
-		if(strtoupper($element[tag]) == "ABSTRACT" && $element[level] == '3'){
-			$this->wfs_abstract = $this->stripEndlineAndCarriageReturn($element[value]);
-		}
-		//new WFS 1.0.0 -- SB 2007-08-06
-		if(strtolower($element[tag]) == "fees"){
-			$this->fees = $element[value];
-		}
-		if(strtolower($element[tag]) == "accessconstraints"){
-			$this->accessconstraints = $element[value];
-		}
-*/		
-		/*capability section*/
-		
-		if($this->wfs_version == "1.0.0"){
 			
-			# getCapabilities
-			if(strtoupper($element[tag]) == "GETCAPABILITIES" && $element[type] == "open"){
-				$section = "getcapabilities";
-			}
-			if($section == "getcapabilities" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_getcapabilities = $element[attributes][onlineResource];
-			}
-			
-			# descriptFeatureType
-			if(strtoupper($element[tag]) == "DESCRIBEFEATURETYPE" && $element[type] == "open"){
-				$section = "describefeaturetype";
-				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
+			for ($j = 0; $j < count($currentFeatureType->namespaceArray); $j++) {
+				$currentNamespace = $currentFeatureType->namespaceArray[$j];
 				
-				
+				$jsString .= $parent . "wfs_add_featuretype_namespace('" . 
+					$currentNamespace->name . "', '" . 
+					$currentNamespace->value . "', " . 
+					$j . ", " . 
+					$i . 
+					");";
 			}
-			if($section == "describefeaturetype" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
-			}
 			
-			# getFeature
-			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "open"){
-				$section = "getfeature";
-			}
-			if($section == "getfeature" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_getfeature = $element[attributes][onlineResource];
-			}
-			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "close"){
-				$section = "";
-			}			
-			# transaction
-			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "open"){
-				$section = "transaction";
-			}
-			if($section == "transaction" && strtoupper($element[tag]) == "POST"){
-				$this->wfs_transaction = $element[attributes][onlineResource];
-			}
-			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "close"){
-				$section = "";
-			}
-		} 
-		if(strtoupper($element[tag]) == "FEATURETYPE" && $element[type] == "open"){
-			$section = "featuretype";
 		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "NAME"){
-			$featuretype_name = $element[value];
-		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "TITLE"){
-			$featuretype_title = $this->stripEndlineAndCarriageReturn($element[value]);
-		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "ABSTRACT"){
-			$featuretype_abstract = $this->$element[value];
-		}
-		if($section == "featuretype" && strtoupper($element[tag]) == "SRS"){
-			$featuretype_srs = $element[value];
-			$this->addFeaturetype($featuretype_name,$featuretype_title,$featuretype_abstract,$featuretype_srs,$this->wfs_describefeaturetype,$this->wfs_version);
-		}
+		return $jsString;
 	}
-	return true;
-}
 
-/**
-* creatObjfromDB
-*
-* this function fills the object with wfs information from db
-* 
-* @param int the id of wfs to get the information from
-*/ 
-function createObjFromDB($wfs_id){
-	global $DBSERVER,$DB,$OWNER,$PW;
-	$con = db_connect($DBSERVER,$OWNER,$PW);
-	db_select_db($DB,$con);
+	/**
+	 * For backwards compatibility only. Echoes a string directly.
+	 * 
+	 * @deprecated
+	 * @return 
+	 * @param $parent Boolean
+	 */
+	public function createJsObjFromWFS($parent){
+		echo $this->toJavaScript($parent);
+	}
 
-	$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
-	$v = array($wfs_id);
-	$t = array("i");
-	$res = db_prep_query($sql, $v, $t);
-	$cnt = 0;
-	while(db_fetch_row($res)){
-		$this->wfs_id = db_result($res, $cnt, "wfs_id");
-		$this->wfs_version = db_result($res, $cnt, "wfs_version");
-		$this->wfs_name = db_result($res, $cnt, "wfs_name");
-		$this->wfs_title = db_result($res, $cnt, "wfs_title");
-		$this->wfs_abstract = db_result($res, $cnt, "wfs_abstract");
-		$this->wfs_getcapabilities = db_result($res, $cnt, "wfs_getcapabilities");
-		$this->wfs_getcapabilities_doc = db_result($res, $cnt, "wfs_getcapabilities_doc");
-		$this->wfs_upload_url = db_result($res, $cnt, "wfs_upload_url");
-		$this->wfs_describefeaturetype = db_result($res, $cnt, "wfs_describefeaturetype");
-		$this->wfs_getfeature = db_result($res, $cnt, "wfs_getfeature");
-		$this->wfs_transaction = db_result($res, $cnt, "wfs_transaction");
-		$this->fees = db_result($res, $cnt, "fees");
-		$this->accessconstraints = db_result($res, $cnt, "accessconstraints");
-		$this->wfs_owner = db_result($res, $cnt, "wfs_owner");
-		$this->wfs_timestamp = db_result($res, $cnt, "wfs_timestamp");
-		
-		$sql_fe = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 ORDER BY featuretype_id";
-		$v = array($this->wfs_id);
-		$t = array("i");
-		$res_fe = db_prep_query($sql_fe, $v, $t);
-		$cnt_fe = 0;
-		while(db_fetch_row($res_fe)){
-			$c = count($this->wfs_featuretype);
-//			$this->wfs_featuretype[$c]->featuretype_id = db_result($res_fe, $cnt_fe, "featuretype_id");
-			$this->wfs_featuretype[$c]->featuretype_name = db_result($res_fe, $cnt_fe, "featuretype_name");
-			$this->wfs_featuretype[$c]->featuretype_title = db_result($res_fe, $cnt_fe, "featuretype_title");
-			$this->wfs_featuretype[$c]->featuretype_abstract = db_result($res_fe, $cnt_fe, "featuretype_abstract");
-			$this->wfs_featuretype[$c]->featuretype_srs = db_result($res_fe, $cnt_fe, "featuretype_srs");
-			
-			$sql_el = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1 ORDER BY element_id";
-			$v = array(db_result($res_fe, $cnt_fe, "featuretype_id"));
-			$t = array("i");
-			$res_el = db_prep_query($sql_el, $v, $t);
-			$cnt_el = 0;
-			while(db_fetch_row($res_el)){
-				$z = count($this->wfs_featuretype[$c]->featuretype_element);
-				$this->wfs_featuretype[$c]->featuretype_element[$z]["name"] = db_result($res_el, $cnt_el, "element_name");
-				$this->wfs_featuretype[$c]->featuretype_element[$z]["type"] = db_result($res_el, $cnt_el, "element_type");
-				$cnt_el++;
-			}
-			$sql_ns = "SELECT * FROM wfs_featuretype_namespace WHERE fkey_featuretype_id = $1 ORDER BY namespace";
-			$v = array(db_result($res_fe, $cnt_fe, "featuretype_id"));
-			$t = array("i");
-			$res_ns = db_prep_query($sql_ns, $v, $t);
-			$cnt_ns = 0;
-			while(db_fetch_row($res_ns)){
-				$z = count($this->wfs_featuretype[$c]->featuretype_namespace);
-				$this->wfs_featuretype[$c]->featuretype_namespace[$z]["name"] = db_result($res_ns, $cnt_ns, "namespace");
-				$this->wfs_featuretype[$c]->featuretype_namespace[$z]["value"] = db_result($res_ns, $cnt_ns, "namespace_location");
-				$cnt_ns++;
-			}
-			$cnt_fe++;
-		}
-		$cnt++;
-    }
-}
-/** end createObjfromDB **/
+	// -----------------------------------------------------------------------
+	//
+	// Database interface
+	//
+	// -----------------------------------------------------------------------
+	
+	/**
+	 * Database wrapper function
+	 * 
+	 * @return Boolean
+	 */
+	public function insertOrUpdate () {
+		return WfsToDb::insertOrUpdate($this);
+	}
 
-	public function getallwfs($userid){
-		$this->wfs_id = array();
-		$this->wfs_name = array();
-		$this->wfs_title = array();
-		$this->wfs_abstract = array();
-		
-		global $DBSERVER,$DB,$OWNER,$PW;
-		$con = db_connect($DBSERVER,$OWNER,$PW);
-		db_select_db($DB,$con);
-		if($userid){
-		 	$sql = "SELECT * FROM wfs WHERE wfs_owner = $1";
-			$v = array($userid);
-			$t = array('i');
-			$res = db_prep_query($sql,$v,$t);
-		}
-		else{
-		 	$sql = "SELECT * FROM wfs";
-			$res = db_query($sql);
-		}
-		
-		$cnt = 0;
-		while ($row = db_fetch_array($res)){
-			$this->wfs_version[$cnt] = $row["wfs_version"];
-			$this->wfs_id[$cnt] = $row["wfs_id"];
-			$this->wfs_name[$cnt] = $row["wfs_name"];
-			$this->wfs_title[$cnt] = $row["wfs_title"];
-			$this->wfs_abstract[$cnt] = $row["wfs_abstract"];
-			$this->wfs_getcapabilities[$cnt] = $row["wfs_getcapabilities"];
-			$this->wfs_describefeaturetype[$cnt] = $row["wfs_describefeaturetype"];
-			$this->wfs_getfeature[$cnt] = $row["wfs_getfeature"];
-			$cnt++;
-		}	
+	/**
+	 * Database wrapper function
+	 * 
+	 * @return Boolean
+	 */
+	public function insert () {
+		return WfsToDb::insert($this);
 	}
-}
 
-
-class featuretype extends wfs{
-	var $featuretype_element = array();	
-	var $featuretype_namespace = array();	
+	/**
+	 * Database wrapper function
+	 * 
+	 * @return Boolean
+	 */
+	public function update () {
+		return WfsToDb::update($this);
+	}
 	
-	function featuretype($name,$title,$abstract,$srs,$url,$version){
+	/**
+	 * Database wrapper function
+	 * 
+	 * @return Boolean
+	 */
+	public function delete () {
+		return WfsToDb::delete($this);
+	}
 
-		$url .= "&SERVICE=WFS&VERSION=".$version."&REQUEST=DescribeFeatureType&TYPENAME=".$name;
-		
-		$this->featuretype_name = $name;
-		$this->featuretype_title = $title;
-		$this->featuretype_abstract = $abstract;
-		$this->featuretype_srs = $srs;
-		
-		$y = new connector($url);
-		$data = $y->file;
-				
-		#$data = implode("",file($url));
-		$parser = xml_parser_create();
-		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
-		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
-		xml_parse_into_struct($parser,$data,$values,$tags);
-		xml_parser_free($parser);
-		
-		foreach ($values as $element) {	
-			if($this->sepNameSpace($element[tag]) == "schema" && $element[type] == "open"){
-				$section = "namespace";
-//				echo "namespace<br>";
-			}
-			
-			if($section == "namespace"){		
-				while (list($k, $val) = each ($element[attributes])) {
-   					if (substr($k, 0, 5) == "xmlns") {
-						$cnt = count($this->featuretype_namespace);
-						$match = false;
-						for ($i = 0 ; $i < $cnt && $match == false ; $i++) {
-							if ($this->sepNameSpace($k) == $this->featuretype_namespace[$i]["name"] && $val == $this->featuretype_namespace[$i]["value"]) {
-								$match = true;
-							}
-						}
-						if ($match == false) {
-							$this->featuretype_namespace[$cnt]["name"] = $this->sepNameSpace($k);
-							$this->featuretype_namespace[$cnt]["value"] = $val;
-//							echo "namespace: " . $this->sepNameSpace($k) . " -> " . $val . "<br>";
-						}
-   					}
-				}
-			}
-			if($this->sepNameSpace($element[tag]) == "complexType" && $element[type] == "open"){
-				$section = "";
-			}
-			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "open"){
-				$section = "complexcontent";
-//				echo "complexcontent<br>";
-			}
-			if($section == "complexcontent" && $this->sepNameSpace($element[tag]) == "element" && $element[attributes][name]){
-				$cnt = count($this->featuretype_element);
-				$this->featuretype_element[$cnt]["name"] = $element[attributes]["name"];
-				$this->featuretype_element[$cnt]["type"] = $this->sepNameSpace($element[attributes]["type"]);
-//				echo "element: ".$this->featuretype_element[$cnt]["name"]."<br>";
-			}
-			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "close"){
-				$section = "";
-			}
-		}
+	/**
+	 * Database wrapper function
+	 * 
+	 * @return Boolean
+	 */
+	public function exists () {
+		return WfsToDb::exists($this);
 	}
-	function sepNameSpace($s){
-		$c = strpos($s,":"); 
-		if($c>0){
-			return substr($s,$c+1);
-		}
-		else{
-			return $s;
-		}		
-	}
 }
 ?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_wfsToDb.php
===================================================================
--- branches/wfs11/http/classes/class_wfsToDb.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfsToDb.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,489 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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.
+
+/**
+* class for wfs-objects
+*/
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_wfs.php");
+
+class WfsToDb {
+
+	/**
+	 * Inserts a new or updates an existing WFS. Replaces the old wfs2db function.
+	 * 
+	 * @return Boolean
+	 * @param $aWfs Wfs
+	 */
+	public function insertOrUpdate ($aWfs) {
+		if (WfsToDb::exists($aWfs)) {
+			return WfsToDb::update($aWfs);
+		}
+		return WfsToDb::insert($aWfs);
+	}
+	
+	/**
+	 * Inserts a new WFS into the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfs Wfs
+	 */
+	public static function insert ($aWfs) {
+		db_begin();
+
+		$sql = "INSERT INTO wfs (wfs_version, wfs_name, wfs_title, wfs_abstract, ";
+		$sql .= "wfs_getcapabilities, wfs_getcapabilities_doc, wfs_upload_url, ";
+		$sql .= "wfs_describefeaturetype, wfs_getfeature, wfs_transaction, fees, ";
+		$sql .= "accessconstraints, wfs_owner, wfs_timestamp) ";
+		$sql .= "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)";
+	
+		$v = array(
+			$aWfs->version, 
+			$aWfs->name, 
+			$aWfs->title, 
+			$aWfs->summary, 
+			$aWfs->getCapabilities, 
+			$aWfs->getCapabilitiesDoc,
+			$aWfs->uploadUrl, 
+			$aWfs->describeFeatureType, 
+			$aWfs->getFeature,
+			$aWfs->transaction, 
+			$aWfs->fees, 
+			$aWfs->accessconstraints, 
+			$_SESSION["mb_user_id"], 
+			strtotime("now")
+		);
+			
+		$t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 'i');
+	
+		$res = db_prep_query($sql, $v, $t);
+	
+		if (!$res) {
+			$e = new mb_exception("Error while inserting WFS into database.");
+			return false;
+		}
+
+		// set the WFS id
+		$aWfs->id = db_insert_id($con, 'wfs', 'wfs_id');
+		
+		// Insert the feature types
+		for ($i = 0; $i < count($aWfs->featureTypeArray); $i++) {
+			$currentFeatureType = $aWfs->featureTypeArray[$i];
+			if (!WfsToDb::insertFeatureType($currentFeatureType)) {
+				db_rollback();
+				return false;
+			}
+		}
+		db_commit();
+		return true;		
+	}
+	
+	/**
+	 * Updates an existing WFS in the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfs Wfs
+	 */
+	public static function update ($aWfs) {
+		db_begin();
+		
+		// update WFS
+		$sql = "UPDATE wfs SET wfs_version = $1, wfs_name = $2, wfs_title = $3, ";
+		$sql .= "wfs_abstract = $4, wfs_getcapabilities = $5, wfs_getcapabilities_doc = $6, ";
+		$sql .= "wfs_upload_url = $7, wfs_describefeaturetype = $8, wfs_getfeature = $9, ";
+		$sql .= "wfs_transaction = $10, fees = $11, accessconstraints = $12, wfs_owner = $13, ";
+		$sql .= "wfs_timestamp = $14 ";
+		$sql .= "WHERE wfs_id = $15";
+
+		$v = array(
+			$aWfs->version, 
+			$aWfs->name, 
+			$aWfs->title, 
+			$aWfs->summary,
+			$aWfs->getCapabilities, 
+			$aWfs->getCapabilitiesDoc, 
+			$aWfs->uploadUrl,
+			$aWfs->describeFeatureType, 
+			$aWfs->getFeature, 
+			$aWfs->transaction,
+			$aWfs->fees, 
+			$aWfs->accessconstraints, 
+			$_SESSION["mb_user_id"],
+			strtotime("now"), 
+			$aWfs->id
+		);
+			
+		$t = array('s', 's', 's', 's', 's', 's', 's', 's' ,'s' ,'s' ,'s' ,'s' ,'i' ,'i' ,'i');
+		$res = db_prep_query($sql, $v, $t);
+		if (!$res) {
+			$e = new mb_exception("Error while updating WFS in database.");
+			db_rollback();
+			return false;
+		}
+		
+		// update existing WFS feature types
+		$featureTypeNameArray = array();
+		for ($i = 0; $i < count($aWfs->featureTypeArray); $i++) {
+			$currentFeatureType = $aWfs->featureTypeArray[$i];
+			array_push($featureTypeNameArray, $currentFeatureType);
+			if (!WfsToDb::updateFeatureType($currentFeatureType)) {
+				db_rollback();
+				return false;
+			}
+		}		
+		
+		// delete obsolete WFS feature types
+		$v = array($aWfs->id);
+		$t = array("i");
+		$sql = "DELETE FROM wfs_featuretype WHERE wfs_id = $1 AND featuretype_name NOT IN (";
+		for ($i = 0; $i < count($featureTypeNameArray); $i++) {
+			if ($i > 0) {
+				$sql .= ", ";
+			}
+			$sql .= "$" . ($i+1);
+			array_push($v, $featureTypeNameArray);
+			array_push($t, "s");
+		}
+		$res = db_prep_query($sql,$v,$t);
+		if (!$res) {
+			$e = new mb_exception("Error while deleting obsolete WFS feature types in database.");
+			db_rollback();
+			return false;
+		}
+		db_commit();
+		return true;		
+	}
+	
+	
+	/**
+	 * Checks if a WFS exists in the database. 
+	 * 
+	 * @return Boolean
+	 * @param $aWfs Wfs
+	 */
+	public static function exists ($aWfs) {
+		// temporary WFS do not have a numeric ID
+		if (!is_numeric($aWfs->id)) {
+			return false;
+		}
+
+		// if ID is numeric, check if it exists in the database
+		$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
+		$v = array($aWfs->id);
+		$t = array("i");
+		$res = db_prep_query($sql, $v, $t);	
+		if ($row = db_fetch_array($res)) {
+			return true;
+		}
+		return false;
+	}
+	
+	/**
+	 * Delete a WFS from the database. Also sets the WFS object to null.
+	 * 
+	 * @return Boolean
+	 * @param $aWfs Wfs
+	 */
+	public static function delete ($aWfs) {
+		$sql = "DELETE FROM wfs WHERE wfs_id = $1";
+		$v = array($aWfs->id);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		if ($res) {
+			$aWfs = null;
+			return true;
+		}
+		return false;
+	}
+	
+
+
+	//-----------------------------------------------------------------------	
+	//
+	// PRIVATE
+	//
+	//-----------------------------------------------------------------------	
+	
+	private static function insertFeatureTypeNamespace ($aWfsId, $aWfsFeatureTypeId, $aWfsFeatureTypeNamespace) {
+		$sql = "INSERT INTO wfs_featuretype_namespace (fkey_wfs_id, " . 
+				"fkey_featuretype_id, namespace, namespace_location) " . 
+				"VALUES ($1, $2, $3, $4);"; 
+
+		$v = array(
+			$aWfsId, 
+			$aWfsFeatureTypeId, 
+			$aWfsFeatureTypeNamespace->name, 
+			$aWfsFeatureTypeNamespace->value
+		);
+		$t = array("s", "s", "s", "s");
+		$res = db_prep_query($sql, $v, $t);
+
+		if (!$res) {
+			$e = new mb_exception("Error while inserting WFS feature type namespace into the database.");
+			return false;
+		}
+		return true;
+	}
+	
+	/**
+	 * Inserts a new WFS feature type element into the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureTypeId Integer
+	 * @param $aWfsFeatureTypeElement Object
+	 */
+	private static function insertFeatureTypeElement ($aWfsFeatureTypeId, $aWfsFeatureTypeElement) {
+		$sql = "INSERT INTO wfs_element (fkey_featuretype_id, element_name, " . 
+				"element_type) VALUES ($1, $2, $3)";
+		
+		$v = array(
+			$aWfsFeatureTypeId, 
+			$aWfsFeatureTypeElement->name, 
+			$aWfsFeatureTypeElement->type
+		);
+		$t = array("i", "s", "s");
+		
+		$res = db_prep_query($sql, $v, $t);
+		
+		if (!$res) {
+			$e = new mb_exception("Error while inserting WFS feature type element into the database.");
+			return false;
+		}
+		
+		// set the WFS feature type element ID
+		$aWfsFeatureTypeElement->id = db_insert_id("", "wfs_element", "element_id");
+		
+		return true;
+	}
+
+	/**
+	 * Updates an existing WFS feature type element in the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureTypeId Integer
+	 * @param $aWfsFeatureTypeElement Object
+	 */
+	private static function updateFeatureTypeElement ($aWfsFeatureTypeId, $aWfsFeatureTypeElement) {
+		$sql = "UPDATE wfs_element SET element_type = $1 " . 
+				"WHERE element_id = $2 AND fkey_featuretype_id = $3";
+
+		$v = array(
+			$aWfsFeatureTypeElement->type, 
+			$aWfsFeatureTypeElement->id, 
+			$aWfsFeatureTypeId
+		);
+		$t = array("s", "i", "i");
+
+		$res = db_prep_query($sql, $v, $t);
+
+		if (!$res) {
+			$e = new mb_exception("Error while updating WFS feature type element in the database.");
+			return false;
+		}
+		
+		return true;
+	}
+
+	/**
+	 * Inserts a new WFS feature type into the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureType WfsFeatureType
+	 */
+	private static function insertFeatureType ($aWfsFeatureType) {
+		$sql = "INSERT INTO wfs_featuretype (fkey_wfs_id, featuretype_name, " . 
+				"featuretype_title, featuretype_abstract, featuretype_srs) " . 
+				"VALUES($1, $2, $3, $4, $5)";
+
+		$v = array(
+			$aWfsFeatureType->wfs->id,
+			$aWfsFeatureType->name,
+			$aWfsFeatureType->title,
+			$aWfsFeatureType->summary,
+			$aWfsFeatureType->srs
+		);
+		$t = array('i','s','s','s','s');
+
+		$res = db_prep_query($sql,$v,$t);
+		if (!$res) {
+			$e = new mb_exception("Error while inserting WFS feature type into database.");
+			return false;	
+		}
+
+		// save the id of each featuretype
+		$aWfsFeatureType->id = db_insert_id("", "wfs_featuretype", "featuretype_id");
+
+		// insert feature type elements
+		for ($i = 0; $i < count($aWfsFeatureType->elementArray); $i++) {
+			$element = $aWfsFeatureType->elementArray[$i];
+			if (!WfsToDb::insertFeatureTypeElement($aWfsFeatureType->id, $element)) {
+				return false;	
+			}
+		}
+		
+		// insert feature type namespaces
+		for ($i = 0; $i < count($aWfsFeatureType->namespaceArray); $i++) {
+			$namespace = $aWfsFeatureType->namespaceArray[$i];
+			if (!WfsToDb::insertFeatureTypeNamespace($aWfsFeatureType->wfs->id, $aWfsFeatureType->id, $namespace)) {
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	/**
+	 * Updates an existing WFS feature type in the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureType WfsFeatureType
+	 */
+	private static function updateFeatureType ($aWfsFeatureType) {
+
+		$sql = "UPDATE wfs_featuretype SET ";
+		$sql .= "featuretype_title = $1,";
+		$sql .= "featuretype_abstract = $2,";
+		$sql .= "featuretype_srs = $3 ";
+		$sql .= "WHERE featuretype_id = $4";
+		$v = array(
+			$aWfsFeatureType->title,
+			$aWfsFeatureType->summary,
+			$aWfsFeatureType->srs,
+			$aWfsFeatureType->id
+		);
+		$t = array('s','s','s','i');
+
+		$res = db_prep_query($sql,$v,$t);
+		if (!$res ) {
+			$e = new mb_exception("Error while updating WFS feature type in database.");
+			return false;
+		}
+		
+		// update existing WFS feature type elements
+		$featureTypeElementNameArray = array();
+		for ($i = 0; $i < count($aWfsFeatureType->elementArray); $i++) {
+			$currentElement = $aWfsFeatureType->elementArray[$i];
+			array_push($featureTypeElementNameArray, $currentElement);
+			if (!WfsToDb::updateFeatureTypeElement($currentElement)) {
+				return false;
+			}
+		}		
+		
+		// delete obsolete WFS feature type elements
+		$v = array($aWfs->id);
+		$t = array("i");
+		$sql = "DELETE FROM wfs_element WHERE fkey_featuretype_id = $1 AND element_name NOT IN (";
+		for ($i = 0; $i < count($featureTypeElementNameArray); $i++) {
+			if ($i > 0) {
+				$sql .= ", ";
+			}
+			$sql .= "$" . ($i+1);
+			array_push($v, $featureTypeElementNameArray);
+			array_push($t, "s");
+		}
+		$res = db_prep_query($sql,$v,$t);
+		if (!$res) {
+			$e = new mb_exception("Error while deleting obsolete WFS feature type element in database.");
+			return false;
+		}
+
+		// delete all namespaces of this WFS feature type
+		$sql = "DELETE FROM wfs_featuretype_namespace WHERE ";
+		$sql .= "fkey_wfs_id = $1 AND fkey_featuretype_id = $2";
+		$v = array(
+			$aWfsFeatureType->wfs->id, 
+			$aWfsFeatureType->id
+		);
+		$t = array("i", "i");
+		$res = db_prep_query($sql, $v, $t);
+		if (!$res) {
+			$e = new mb_exception("Error while deleting WFS feature type namespaces from the database.");
+			return false;
+		}		
+		
+		// insert feature type namespaces
+		for ($i = 0; $i < count($aWfsFeatureType->namespaceArray); $i++) {
+			$namespace = $aWfsFeatureType->namespaceArray[$i];
+			if (!WfsToDb::insertFeatureTypeNamespace ($aWfsFeatureType->wfs->id, $aWfsFeatureType->id, $namespace)) {
+				$e = new mb_exception("Error while inserting WFS feature type namespaces into the database.");
+				return false;
+			}
+		}		
+		return true;		
+	}
+	
+	/**
+	 * Deletes an existing WFS feature type from the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureType WfsFeatureType
+	 */
+	private static function deleteFeatureType ($aWfsFeatureType) {
+		$sql = "DELETE FROM wfs_featuretype WHERE featuretype_id = $1 AND fkey_wfs_id = $2";
+		$v = array($aWfsFeatureType->id, $aWfsFeatureType->wfs->id);
+		$t = array('i', 'i');
+
+		$res = db_prep_query($sql, $v, $t);
+		if (!$res) {
+			$e = new mb_exception("Error while deleting WFS feature type from database.");
+			return false;
+		}
+		return true;
+	}
+	
+	/**
+	 * Checks if a featuretype exists in the database. It selects the rows
+	 * that match the WFS id and the featuretype name.
+	 * 
+	 * If the featuretype is found the featuretype id is returned.
+	 * 
+	 * @return Integer
+	 * @param $aWfsFeatureType WfsFeatureType
+	 */
+	private static function getFeatureTypeId ($aWfsFeatureType) {
+		$sql = "SELECT featuretype_id FROM wfs_featuretype WHERE " . 
+			"fkey_wfs_id = $1 AND featuretype_name = $2";
+		$v = array(
+			$aWfsFeatureType->wfs->id,
+			$aWfsFeatureType->name,
+		);
+		$t = array("i", "s");
+		$res = db_prep_query($sql, $v, $t);
+		if ($row = db_fetch_array($res)) {
+			return $row["featuretype_id"];
+		}
+		return null;
+	}
+	
+	/**
+	 * Checks if a featuretype exists in the database. 
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureType WfsFeatureType
+	 */
+	private static function featureTypeExists ($aWfsFeatureType) {
+		if (WfsToDb::getFeatureTypeId($aWfsFeatureType) !== null) {
+			return true;
+		}
+		return false;
+	}
+}
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_wfs_1_0.php
===================================================================
--- branches/wfs11/http/classes/class_wfs_1_0.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfs_1_0.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,33 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_wfs.php");
+
+class Wfs_1_0 extends Wfs {
+	const VERSION = "1.0.0";
+	
+	public function getVersion () {
+		return "1.0.0";
+	}
+}
+
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_wfs_1_0_factory.php
===================================================================
--- branches/wfs11/http/classes/class_wfs_1_0_factory.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfs_1_0_factory.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,198 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_1_0.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_featuretype.php");
+require_once(dirname(__FILE__)."/../classes/class_connector.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
+/**
+ * Creates WFS 1.0 objects from a capabilities documents.
+ * 
+ * @return Wfs_1_0
+ */
+class Wfs_1_0_Factory extends WfsFactory {
+
+	private function createFeatureTypeFromXml ($xml, $myWfs) {
+		$newFeatureType = new Wfs_1_0_FeatureType($myWfs);
+
+		$admin = new administration();
+		$values = $admin->parseXml($xml);
+
+		foreach ($values as $element) {	
+			if ($this->sepNameSpace($element[tag]) == "schema" && $element[type] == "open") {
+				$section = "namespace";
+			}
+			
+			if ($section == "namespace" && is_array($element[attributes])) {	
+					
+				while (list($k, $val) = each ($element[attributes])) {
+   					if (substr($k, 0, 5) == "xmlns") {
+   						$key = $this->sepNameSpace($k);
+						$newFeatureType->addNamespace($key, $val);
+   					}
+				}
+			}
+			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "open"){
+				$section = "complexcontent";
+			}
+			if($section == "complexcontent" && $this->sepNameSpace($element[tag]) == "element" && $element[attributes][name]){
+				$newFeatureType->addElement(
+					$element[attributes]["name"], 
+					$this->sepNameSpace($element[attributes]["type"])
+				);				
+			}
+			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "close"){
+				$section = "";
+			}
+		}	
+		return $newFeatureType;	
+	}
+
+	private function createFeatureTypeFromUrl ($url, $aWfs) {
+		$xml = $this->getFromUrl($url);
+		return $this->createFeatureTypeFromXml ($xml, $aWfs);
+	}
+
+	/**
+	 * Creates WFS 1.0 objects from a capabilities documents.
+	 * 
+	 * @return Wfs_1_0
+	 * @param $xml String
+	 */
+	public function createFromXml ($xml) {
+		try {
+			
+			$myWfs = new Wfs_1_0();
+		
+			$admin = new administration();
+			$values = $admin->parseXml($xml);
+			
+			$myWfs->getCapabilitiesDoc = $admin->char_encode($xml);
+			$myWfs->id = $this->createId();
+		
+			foreach ($values as $element) {
+				$tag = strtoupper($element[tag]);
+
+				if($tag == "WFS_CAPABILITIES" && $element[type] == "open"){
+					$myWfs->version = $element[attributes][version];
+					if ($myWfs->version !== "1.0.0") {
+						throw new Exception("Not a WFS 1.0.0 capabilities document.");
+					}
+				}
+				if($tag == "NAME"  && $element[level] == '3'){
+					$myWfs->name = $element[value];
+				}
+				if($tag == "TITLE"  && $element[level] == '3'){
+					$myWfs->title = $this->stripEndlineAndCarriageReturn($element[value]);
+				}
+				if($tag == "ABSTRACT" && $element[level] == '3'){
+					$myWfs->summary = $this->stripEndlineAndCarriageReturn($element[value]);
+				}
+				if($tag == "FEES"){
+					$myWfs->fees = $element[value];
+				}
+				if($tag == "ACCESSCONSTRAINTS"){
+					$myWfs->accessconstraints = $element[value];
+				}
+				
+				# getCapabilities
+				if($tag == "GETCAPABILITIES" && $element[type] == "open"){
+					$section = "getcapabilities";
+				}
+				if($section == "getcapabilities" && $tag == "POST"){
+					$myWfs->getCapabilities = $element[attributes][onlineResource];
+				}
+				
+				# descriptFeatureType
+				if($tag == "DESCRIBEFEATURETYPE" && $element[type] == "open"){
+					$section = "describefeaturetype";
+					$myWfs->describeFeatureType = $element[attributes][onlineResource];
+					
+					
+				}
+				if($section == "describefeaturetype" && $tag == "POST"){
+					$myWfs->describeFeatureType = $element[attributes][onlineResource];
+				}
+				
+				# getFeature
+				if($tag == "GETFEATURE" && $element[type] == "open"){
+					$section = "getfeature";
+				}
+				if($section == "getfeature" && $tag == "POST"){
+					$myWfs->getFeature = $element[attributes][onlineResource];
+				}
+				if($tag == "GETFEATURE" && $element[type] == "close"){
+					$section = "";
+				}			
+				# transaction
+				if($tag == "TRANSACTION" && $element[type] == "open"){
+					$section = "transaction";
+				}
+				if($section == "transaction" && $tag == "POST"){
+					$myWfs->transaction = $element[attributes][onlineResource];
+				}
+				if($tag == "TRANSACTION" && $element[type] == "close"){
+					$section = "";
+				}
+				if($tag == "FEATURETYPE" && $element[type] == "open"){
+					$section = "featuretype";
+				}
+				if($section == "featuretype" && $tag == "NAME"){
+					$featuretype_name = $element[value];
+				}
+				if($section == "featuretype" && $tag == "TITLE"){
+					$featuretype_title = $this->stripEndlineAndCarriageReturn($element[value]);
+				}
+				if($section == "featuretype" && $tag == "ABSTRACT"){
+					$featuretype_abstract = $element[value];
+				}
+				if($section == "featuretype" && $tag == "SRS"){
+					$featuretype_srs = $element[value];
+
+					$describeFeatureTypeUrl = $myWfs->describeFeatureType . "&SERVICE=WFS&VERSION=" . 
+							$myWfs->version . "&REQUEST=DescribeFeatureType&TYPENAME=" . $this->sepNameSpace($featuretype_name);
+
+					$currentFeatureType = $this->createFeatureTypeFromUrl($describeFeatureTypeUrl, $myWfs);
+					if ($currentFeatureType !== null) {
+						$currentFeatureType->name = $this->sepNameSpace($featuretype_name);
+						$currentFeatureType->title = $featuretype_title;
+						$currentFeatureType->summary = $featuretype_abstract;
+						$currentFeatureType->srs = $featuretype_srs;
+
+						$myWfs->addFeatureType($currentFeatureType);
+					}
+				}
+			}
+			return $myWfs;
+		}
+		catch (Exception $e) {
+			$e = new mb_exception($e);
+			return null;
+		}
+	}
+	
+	public function createFromDb ($id) {
+		$myWfs = new Wfs_1_0();
+		return parent::createFromDb($id, $myWfs);
+	}
+}
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_wfs_1_1.php
===================================================================
--- branches/wfs11/http/classes/class_wfs_1_1.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfs_1_1.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,33 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_wfs.php");
+
+class Wfs_1_1 extends Wfs {
+	const VERSION = "1.1.0";
+	
+	public function getVersion () {
+		return "1.1.0";
+	}
+}
+
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_wfs_1_1_factory.php
===================================================================
--- branches/wfs11/http/classes/class_wfs_1_1_factory.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfs_1_1_factory.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,199 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_1_1.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_featuretype.php");
+require_once(dirname(__FILE__)."/../classes/class_connector.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
+/**
+ * Creates WFS 1.1 objects from a capabilities documents.
+ * 
+ * @return Wfs_1_1
+ */
+class Wfs_1_1_Factory extends WfsFactory {
+
+	private function createFeatureTypeFromXml ($xml, $myWfs) {
+		$newFeatureType = new Wfs_1_1_FeatureType($myWfs);
+
+		$admin = new administration();
+		$values = $admin->parseXml($xml);
+
+		foreach ($values as $element) {	
+			if ($this->sepNameSpace($element[tag]) == "schema" && $element[type] == "open") {
+				$section = "namespace";
+			}
+			
+			if ($section == "namespace" && is_array($element[attributes])) {	
+					
+				while (list($k, $val) = each ($element[attributes])) {
+   					if (substr($k, 0, 5) == "xmlns") {
+   						$key = $this->sepNameSpace($k);
+						$newFeatureType->addNamespace($key, $val);
+   					}
+				}
+			}
+			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "open"){
+				$section = "complexcontent";
+			}
+			if($section == "complexcontent" && $this->sepNameSpace($element[tag]) == "element" && $element[attributes][name]){
+				$newFeatureType->addElement(
+					$element[attributes]["name"], 
+					$this->sepNameSpace($element[attributes]["type"])
+				);				
+			}
+			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "close"){
+				$section = "";
+			}
+		}	
+		return $newFeatureType;	
+	}
+
+	private function createFeatureTypeFromUrl ($url, $aWfs) {
+		$xml = $this->getFromUrl($url);
+		return $this->createFeatureTypeFromXml ($xml, $aWfs);
+	}
+
+	/**
+	 * Creates WFS 1.0 objects from a capabilities documents.
+	 * 
+	 * @return Wfs_1_1
+	 * @param $xml String
+	 */
+	public function createFromXml ($xml) {
+		try {
+			
+			$myWfs = new Wfs_1_1();
+		
+			$admin = new administration();
+			$values = $admin->parseXml($xml);
+			
+			$myWfs->getCapabilitiesDoc = $admin->char_encode($xml);
+			$myWfs->id = $this->createId();
+		
+			foreach ($values as $element) {
+				$tag = $this->sepNameSpace(strtoupper($element[tag]));
+			
+				if($tag == "WFS_CAPABILITIES" && $element[type] == "open"){
+					$myWfs->version = $element[attributes][version];
+					if ($myWfs->version !== "1.1.0") {
+						throw new Exception("Not a WFS 1.1.0 capabilities document.");
+					}
+				}
+				if($tag == "NAME"  && $element[level] == '3'){
+					$myWfs->name = $element[value];
+				}
+				if($tag == "TITLE"  && $element[level] == '3'){
+					$myWfs->title = $this->stripEndlineAndCarriageReturn($element[value]);
+				}
+				if($tag == "ABSTRACT" && $element[level] == '3'){
+					$myWfs->summary = $this->stripEndlineAndCarriageReturn($element[value]);
+				}
+				if($tag == "FEES"){
+					$myWfs->fees = $element[value];
+				}
+				if($tag == "ACCESSCONSTRAINTS"){
+					$myWfs->accessconstraints = $element[value];
+				}
+				
+				if($tag == "OPERATION" && $element[type] == "open"){
+					switch ($element[attributes][name]) {
+						case "GetCapabilities" :
+							$section = "getcapabilities";
+							break;
+						case "DescribeFeatureType" :
+							$section = "describefeaturetype";
+							break;
+						case "GetFeature" :
+							$section = "getfeature";
+							break;
+						case "Transaction" :
+							$section = "transaction";
+							break;
+					}
+				}
+				# getCapabilities
+				if($section == "getcapabilities" && $tag == "POST"){
+					$myWfs->getCapabilities = html_entity_decode($element[attributes]["xlink:href"]);
+				}
+			
+				# descriptFeatureType
+				if($section == "describefeaturetype" && $tag == "POST"){
+					$myWfs->describeFeatureType = html_entity_decode($element[attributes]["xlink:href"]);
+				}
+				
+				# getFeature
+				if($section == "getfeature" && $tag == "POST"){
+					$myWfs->getFeature = html_entity_decode($element[attributes]["xlink:href"]);
+				}
+
+				# transaction
+				if($section == "transaction" && $tag == "POST"){
+					$myWfs->transaction = html_entity_decode($element[attributes]["xlink:href"]);
+				}
+
+				if($tag == "OPERATION" && $element[type] == "close"){
+					$section = "";	
+				}
+
+				if($tag == "FEATURETYPE" && $element[type] == "open"){
+					$section = "featuretype";
+				}
+				if($section == "featuretype" && $tag == "NAME"){
+					$featuretype_name = $element[value];
+				}
+				if($section == "featuretype" && $tag == "TITLE"){
+					$featuretype_title = $this->stripEndlineAndCarriageReturn($element[value]);
+				}
+				if($section == "featuretype" && $tag == "ABSTRACT"){
+					$featuretype_abstract = $element[value];
+				}
+				if($section == "featuretype" && $tag == "DEFAULTSRS"){
+					$featuretype_srs = $element[value];
+
+					$describeFeatureTypeUrl = $myWfs->describeFeatureType . "&SERVICE=WFS&VERSION=" . 
+							$myWfs->version . "&REQUEST=DescribeFeatureType&TYPENAME=" . $this->sepNameSpace($featuretype_name);
+
+					$currentFeatureType = $this->createFeatureTypeFromUrl($describeFeatureTypeUrl, $myWfs);
+					if ($currentFeatureType !== null) {
+						$currentFeatureType->name = $this->sepNameSpace($featuretype_name);
+						$currentFeatureType->title = $featuretype_title;
+						$currentFeatureType->summary = $featuretype_abstract;
+						$currentFeatureType->srs = $featuretype_srs;
+
+						$myWfs->addFeatureType($currentFeatureType);
+					}
+				}
+			}
+			return $myWfs;
+		}
+		catch (Exception $e) {
+			$e = new mb_exception($e);
+			return null;
+		}
+	}
+	
+	public function createFromDb ($id) {
+		$myWfs = new Wfs_1_1();
+		return parent::createFromDb($id, $myWfs);
+	}
+}
+?>
\ No newline at end of file

Modified: branches/wfs11/http/classes/class_wfs_conf.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_conf.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/classes/class_wfs_conf.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -69,7 +69,7 @@
 					$idArray = array_intersect($idArray, $user->getWfsConfByPermission());
 				}
 
-				return $this->getWfsConfFromDbByArray($idArray);
+				return $this->getWfsConfFromDb($idArray);
 			}
 			// parameter is invalid
 			else {

Added: branches/wfs11/http/classes/class_wfs_deprecated.php
===================================================================
--- branches/wfs11/http/classes/class_wfs_deprecated.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfs_deprecated.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,830 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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.
+
+/**
+* class for wfs-objects
+*/
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_ows.php");
+
+abstract class Wfs extends Ows {
+}
+
+class wfs {
+
+  var $wfs_id;
+  var $wfs_version;
+  var $wfs_name;
+  var $wfs_title;
+  var $wfs_abstract;
+  var $wfs_getcapabilities;
+  var $wfs_getcapabilities_doc; //new SB 2007-08-09
+  var $wfs_describefeaturetype;
+  var $wfs_describefeaturetype_namespace = array();
+  var $wfs_getfeature;
+  var $wfs_transaction;
+  var $wfs_upload_url; //new SB 2007-08-09
+
+  //new WFS 1.0.0 -- SB 2007-08-06
+
+  var $fees;
+  var $accessconstraints;
+  
+  var $wfs_featuretype = array();
+ 
+ 
+function wfs() {
+
+} 
+/*
+function createObjFromXML($url){
+	
+	$x = new connector($url);
+	$data = $x->file;
+	#$data = implode("",file($url));
+	if(!$data){
+		echo "Unable to open document: ".$url;
+		die; 
+	}
+	
+	$values = null;
+	$tags = null;
+	$admin = new administration();
+	$this->wfs_getcapabilities_doc = $admin->char_encode($data);
+	$this->wfs_upload_url = $url;
+	
+	# for temporary wfs a id has to be created...
+	$this->wfs_id = "id_" . substr(md5(rand()),0,6);
+	$parser = xml_parser_create(CHARSET);
+	xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+	xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+	xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
+	xml_parse_into_struct($parser,$this->wfs_getcapabilities_doc,$values,$tags);
+	//xml_parse_into_struct($parser,$data,$values,$tags);
+	
+	xml_parser_free($parser);
+	
+	$section = false;
+	$request = false;
+	$featuretype_name = false;
+ 	$featuretype_title = false;
+ 	$featuretype_abstract = false;
+ 	$featuretype_srs = false;
+	
+	foreach ($values as $element) {
+	
+		if(strtoupper($element[tag]) == "WFS_CAPABILITIES" && $element[type] == "open"){
+			$this->wfs_version = $element[attributes][version];
+		}
+		if(strtoupper($element[tag]) == "NAME"  && $element[level] == '3'){
+			$this->wfs_name = $element[value];
+		}
+		if(strtoupper($element[tag]) == "TITLE"  && $element[level] == '3'){
+			$this->wfs_title = $this->stripEndlineAndCarriageReturn($element[value]);
+		}
+		if(strtoupper($element[tag]) == "ABSTRACT" && $element[level] == '3'){
+			$this->wfs_abstract = $this->stripEndlineAndCarriageReturn($element[value]);
+		}
+		//new WFS 1.0.0 -- SB 2007-08-06
+		if(strtolower($element[tag]) == "fees"){
+			$this->fees = $element[value];
+		}
+		if(strtolower($element[tag]) == "accessconstraints"){
+			$this->accessconstraints = $element[value];
+		}
+		
+		
+		if($this->wfs_version == "1.0.0"){
+			
+			# getCapabilities
+			if(strtoupper($element[tag]) == "GETCAPABILITIES" && $element[type] == "open"){
+				$section = "getcapabilities";
+			}
+			if($section == "getcapabilities" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_getcapabilities = $element[attributes][onlineResource];
+			}
+			
+			# descriptFeatureType
+			if(strtoupper($element[tag]) == "DESCRIBEFEATURETYPE" && $element[type] == "open"){
+				$section = "describefeaturetype";
+				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
+				
+				
+			}
+			if($section == "describefeaturetype" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
+			}
+			
+			# getFeature
+			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "open"){
+				$section = "getfeature";
+			}
+			if($section == "getfeature" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_getfeature = $element[attributes][onlineResource];
+			}
+			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "close"){
+				$section = "";
+			}			
+			# transaction
+			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "open"){
+				$section = "transaction";
+			}
+			if($section == "transaction" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_transaction = $element[attributes][onlineResource];
+			}
+			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "close"){
+				$section = "";
+			}
+		} 
+		if(strtoupper($element[tag]) == "FEATURETYPE" && $element[type] == "open"){
+			$section = "featuretype";
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "NAME"){
+			$featuretype_name = $element[value];
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "TITLE"){
+			$featuretype_title = $this->stripEndlineAndCarriageReturn($element[value]);
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "ABSTRACT"){
+			$featuretype_abstract = $this->$element[value];
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "SRS"){
+			$featuretype_srs = $element[value];
+			$this->addFeaturetype($featuretype_name,$featuretype_title,$featuretype_abstract,$featuretype_srs,$this->wfs_describefeaturetype,$this->wfs_version);
+		}
+	}
+}
+*/
+/*
+
+function displayWFS(){
+	echo "id: " . $this->wfs_id . " <br>";
+	echo "version: " . $this->wfs_version . " <br>";
+	echo "name: " . $this->wfs_name . " <br>";
+	echo "title: " . $this->wfs_title . " <br>";
+	echo "abstract: " . $this->wfs_abstract . " <br>";
+	echo "capabilitiesrequest: " . $this->wfs_getcapabilities . " <br>";
+	echo "describefeaturetype: " . $this->wfs_describefeaturetype . " <br>";
+	echo "getfeature: " . $this->wfs_getfeature . " <br>";
+	echo "transaction: " . $this->wfs_transaction . " <br>";
+	for($i=0; $i<count($this->wfs_featuretype); $i++){
+		echo "<hr>";
+		echo "name: ". $this->wfs_featuretype[$i]->featuretype_name . "<br>";
+		echo "title: ". $this->wfs_featuretype[$i]->featuretype_title . "<br>";
+		echo "abstract: ". $this->wfs_featuretype[$i]->featuretype_abstract . "<br>";
+		echo "srs: ". $this->wfs_featuretype[$i]->featuretype_srs . "<br>";
+		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element);$j++){
+			echo " element: " . $this->wfs_featuretype[$i]->featuretype_element[$j]["name"] ." - ".$this->wfs_featuretype[$i]->featuretype_element[$j]["type"]."<br>";
+		}
+		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_namespace);$j++){
+			echo " namespace: " . $this->wfs_featuretype[$i]->featuretype_namespace[$j]["name"] ." - ".$this->wfs_featuretype[$i]->featuretype_namespace[$j]["value"]."<br>";
+		}
+	}
+} 
+*/
+/*
+function addFeaturetype($name,$title,$abstract,$srs,$url,$version){
+	$this->wfs_featuretype[count($this->wfs_featuretype)] = new featuretype($name,$title,$abstract,$srs,$url,$version);
+}
+*/
+/*
+ function stripEndlineAndCarriageReturn($string) {
+	  	return preg_replace("/\n/", "", preg_replace("/\r/", " ", $string));
+	  }
+	 */
+	/*
+function createJsObjFromWFS($parent){
+	if(!$this->wfs_title || $this->wfs_title == ""){
+		echo "alert('Error: no valid capabilities-document !!');";
+		die; exit;
+	}
+		if($parent){
+			echo "parent.";
+		}
+		print("add_wfs('". 
+		$this->wfs_id ."','".
+		$this->wfs_version ."','".
+		$this->wfs_title ."','".
+		$this->wfs_abstract ."','". 
+		$this->wfs_getcapabilities ."','" .
+		$this->wfs_describefeaturetype ."');");
+		
+
+	for($i=0; $i<count($this->wfs_featuretype); $i++){
+		if($parent){
+			echo "parent.";
+		}
+		print ("wfs_add_featuretype('". 
+			$this->wfs_featuretype[$i]->featuretype_name ."','". 
+			$this->wfs_featuretype[$i]->featuretype_title . "','".
+			$this->wfs_featuretype[$i]->featuretype_abstract . "','".  
+			$this->wfs_featuretype[$i]->featuretype_srs ."','". 
+			$this->wfs_featuretype[$i]->featuretype_geomtype ."');");
+		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element);$j++){
+			if($parent){
+			echo "parent.";
+			}
+			print("wfs_add_featuretype_element('".$this->wfs_featuretype[$i]->featuretype_element[$j]["name"]."', '".$this->wfs_featuretype[$i]->featuretype_element[$j]["type"]."', ".$j.", ".$i.");");
+		}
+		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_namespace);$j++){
+			if($parent){
+			echo "parent.";
+			}
+			print("wfs_add_featuretype_namespace('".$this->wfs_featuretype[$i]->featuretype_namespace[$j]["name"]."', '".$this->wfs_featuretype[$i]->featuretype_namespace[$j]["value"]."', ".$j.", ".$i.");");
+		}
+	}
+}
+*/
+/**
+ * Inserts this WFS in the database
+ */
+/*
+function insertWfs() {
+	global $DBSERVER,$DB,$OWNER,$PW;
+	$con = db_connect($DBSERVER,$OWNER,$PW);
+	db_select_db($DB,$con);
+
+	$sql = "INSERT INTO wfs (wfs_version, wfs_name, wfs_title, wfs_abstract, ";
+	$sql .= "wfs_getcapabilities, wfs_getcapabilities_doc, wfs_upload_url, ";
+	$sql .= "wfs_describefeaturetype, wfs_getfeature, wfs_transaction, fees, ";
+	$sql .= "accessconstraints, wfs_owner, wfs_timestamp) ";
+	$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)";
+
+	$v = array($this->wfs_version, $this->wfs_name, $this->wfs_title, 
+		$this->wfs_abstract, $this->wfs_getcapabilities, $this->wfs_getcapabilities_doc,
+		$this->wfs_upload_url, $this->wfs_describefeaturetype, $this->wfs_getfeature,
+		$this->wfs_transaction, $this->fees, $this->accessconstraints, 
+		$_SESSION["mb_user_id"], strtotime("now"));
+		
+	$t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 'i');
+
+	$res = db_prep_query($sql,$v,$t);
+
+	if(!$res){
+		db_rollback();
+		$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
+		return false;
+	}
+	$this->wfs_id = db_insert_id($con,'wfs','wfs_id');
+	return true;
+}
+*/
+/*
+function updateWfs() {
+	global $DBSERVER,$DB,$OWNER,$PW;
+	$con = db_connect($DBSERVER,$OWNER,$PW);
+	db_select_db($DB,$con);
+
+	$sql = "UPDATE wfs SET wfs_version = $1, wfs_name = $2, wfs_title = $3, ";
+	$sql .= "wfs_abstract = $4, wfs_getcapabilities = $5, wfs_getcapabilities_doc = $6, ";
+	$sql .= "wfs_upload_url = $7, wfs_describefeaturetype = $8, wfs_getfeature = $9, ";
+	$sql .= "wfs_transaction = $10, fees = $11, accessconstraints = $12, wfs_owner = $13, ";
+	$sql .= "wfs_timestamp = $14 ";
+	$sql .= "WHERE wfs_id = $15";
+	//echo $sql."<br />";
+	$v = array($this->wfs_version, $this->wfs_name, $this->wfs_title, $this->wfs_abstract,
+		$this->wfs_getcapabilities, $this->wfs_getcapabilities_doc, $this->wfs_upload_url,
+		$this->wfs_describefeaturetype, $this->wfs_getfeature, $this->wfs_transaction,
+		$this->fees, $this->accessconstraints, $_SESSION["mb_user_id"],strtotime("now"), 
+		$this->wfs_id);
+		
+	$t = array('s', 's', 's', 's', 's', 's', 's', 's' ,'s' ,'s' ,'s' ,'s' ,'i' ,'i' ,'i');
+	$res = db_prep_query($sql,$v,$t);
+	if(!$res){
+		db_rollback();
+		$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
+		return false;
+	}
+	return true;
+}
+*/
+/**
+* wfs2db
+*
+* this function saves the class information to the mapbender database 
+* @return boolean true if sucessful false otherwise
+*/
+
+
+/*
+function wfs2db($gui_id){
+	global $DBSERVER,$DB,$OWNER,$PW;
+	$con = db_connect($DBSERVER,$OWNER,$PW);
+	db_select_db($DB,$con);
+	
+	db_begin();
+	
+	// check if WFS already might exists (it might exist when wfs_id is numeric)
+	$wfs_exists = is_numeric($this->wfs_id);
+
+	// if it might exist, update it
+	if ($wfs_exists) {
+		// but check first if it really exists in the database
+		$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
+		$v = array($this->wfs_id);
+		$t = array("i");
+		$res = db_prep_query($sql, $v, $t);	
+		if($res){
+			$this->updateWfs();
+		}
+		// if not, insert as new WFS
+		else {
+			$this->insertWfs();
+		}
+	}
+	// if it does not exist, insert as new WFS
+	else {
+		$this->insertWfs();
+	}
+
+	# delete featuretypes from DB that does not exist and find the ids
+	$sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1;";
+	$v = array($this->wfs_id);
+	$t = array("i");
+	$res_ft = db_prep_query($sql, $v, $t);
+	$cnt = 0;
+	while(db_fetch_row($res_ft)){
+		$found = false;
+		for($i=0; $i<count($this->wfs_featuretype); $i++){
+			if($this->wfs_featuretype[$i]->featuretype_name == db_result($res_ft, $cnt, "featuretype_name")){
+				$this->wfs_featuretype[$i]->featuretype_id = db_result($res_ft, $cnt, "featuretype_id");
+				$found = true;
+				break;
+			}
+		}
+		
+		if(!$found){
+			$sql = "DELETE FROM wfs_featuretype WHERE featuretype_id = $1 AND fkey_wfs_id = $2";
+			$v = array(db_result($res_ft, $cnt, "featuretype_id"), $this->wfs_id);
+			$t = array('i','i');
+			//echo $sql."<br />";
+			$res = db_prep_query($sql,$v,$t);
+			if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
+		}
+		$cnt++;
+	}
+	# TABLE wfs_featuretype
+	
+	for($i=0; $i<count($this->wfs_featuretype); $i++){
+		if(!$this->wfs_featuretype[$i]->featuretype_id){
+			$sql = "INSERT INTO wfs_featuretype(fkey_wfs_id, featuretype_name, featuretype_title, featuretype_abstract, featuretype_srs) ";
+			$sql .= "VALUES($1,$2,$3,$4,$5)";
+			$v = array($this->wfs_id,$this->wfs_featuretype[$i]->featuretype_name,$this->wfs_featuretype[$i]->featuretype_title,$this->wfs_featuretype[$i]->featuretype_abstract,$this->wfs_featuretype[$i]->featuretype_srs);
+			$t = array('i','s','s','s','s');
+			//echo $sql."<br />";
+			$res = db_prep_query($sql,$v,$t);
+			if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
+			
+			# save the id of each featuretype: 
+			$this->wfs_featuretype[$i]->featuretype_id = db_insert_id($con,'wfs_featuretype','featuretype_id');
+		}
+		else{
+			$sql = "UPDATE wfs_featuretype SET ";
+			$sql .= "featuretype_title = $1,";
+			$sql .= "featuretype_abstract = $2,";
+			$sql .= "featuretype_srs = $3 ";
+			$sql .= "WHERE featuretype_id = $4";
+			$v = array($this->wfs_featuretype[$i]->featuretype_title,$this->wfs_featuretype[$i]->featuretype_abstract,$this->wfs_featuretype[$i]->featuretype_srs,$this->wfs_featuretype[$i]->featuretype_id);
+			$t = array('s','s','s','i');
+			//echo $sql."<br />";
+			$res = db_prep_query($sql,$v,$t);
+			if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
+		}
+		//delete featuretype elements from db and find the ids
+		$sql = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1;";
+		$v = array($this->wfs_featuretype[$i]->featuretype_id);
+		$t = array("i");
+		$res_el = db_prep_query($sql, $v, $t);
+		$cnt = 0;
+		while(db_fetch_row($res_el)){
+			$found = false;
+			for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element); $j++){
+				if($this->wfs_featuretype[$i]->featuretype_element[$j]["name"] == db_result($res_el, $cnt, "element_name")){
+					$this->wfs_featuretype[$i]->featuretype_element[$j]["id"] = db_result($res_el, $cnt, "element_id");
+					$found = true;
+					break;
+				}
+			}
+			
+			if(!$found){
+				$sql = "DELETE FROM wfs_element WHERE element_id = $1 AND fkey_featuretype_id = $2";
+				$v = array(db_result($res_el, $cnt, "element_id"), $this->wfs_featuretype[$i]->featuretype_id);
+				$t = array('i','i');
+				//echo $sql."<br />";
+				$res = db_prep_query($sql,$v,$t);
+				if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
+			}
+			$cnt++;
+		}
+
+		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_element);$j++){
+			if(!$this->wfs_featuretype[$i]->featuretype_element[$j]["id"]){
+				$sql = "INSERT INTO wfs_element(fkey_featuretype_id, element_name,element_type) ";
+				$sql .= "VALUES($1, $2, $3);";
+				
+				$v = array($this->wfs_featuretype[$i]->featuretype_id, $this->wfs_featuretype[$i]->featuretype_element[$j]["name"], $this->wfs_featuretype[$i]->featuretype_element[$j]["type"]);
+				$t = array("s", "s", "s");
+				$res = db_prep_query($sql, $v, $t);
+				if(!$res){db_rollback();$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");return;}
+			}
+			else{
+				$sql = "UPDATE wfs_element SET element_type = $1 ";
+				$sql .= "WHERE element_id = $2 AND ";
+				$sql .= "fkey_featuretype_id = $3;";
+				$v = array($this->wfs_featuretype[$i]->featuretype_element[$j]["type"], $this->wfs_featuretype[$i]->featuretype_element[$j]["id"], $this->wfs_featuretype[$i]->featuretype_id);
+				$t = array("s", "i", "i");
+				$res = db_prep_query($sql, $v, $t);
+				if (!$res) {
+					db_rollback();
+					$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
+					return;
+				}
+			}
+		}
+
+		$sql = "DELETE FROM wfs_featuretype_namespace WHERE ";
+		$sql .= "fkey_wfs_id = $1 AND fkey_featuretype_id = $2";
+		$v = array($this->wfs_id, $this->wfs_featuretype[$i]->featuretype_id);
+		$t = array("i", "i");
+		$res = db_prep_query($sql, $v, $t);
+		if (!$res) {
+			db_rollback();
+			$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
+			return;
+		}
+				
+		for($j=0; $j<count($this->wfs_featuretype[$i]->featuretype_namespace);$j++){
+			$sql = "INSERT INTO wfs_featuretype_namespace ";
+			$sql .= "(fkey_wfs_id, fkey_featuretype_id, namespace, namespace_location) ";
+			$sql .= "VALUES ($1, $2, $3, $4);"; 
+
+			$v = array($this->wfs_id, $this->wfs_featuretype[$i]->featuretype_id, $this->wfs_featuretype[$i]->featuretype_namespace[$j]["name"], $this->wfs_featuretype[$i]->featuretype_namespace[$j]["value"]);
+			$t = array("s", "s", "s", "s");
+			$res = db_prep_query($sql, $v, $t);
+
+			if (!$res) {
+				db_rollback();
+				$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
+				return;
+			}
+		}
+	}
+	
+	# TABLE gui_wfs
+	/*
+	if($gui_id){
+		$sql ="INSERT INTO gui_wfs (fkey_gui_id, fkey_wfs_id)";
+		$sql .= "VALUES($1, $2);";
+		$v = array($gui_id, $this->wfs_id);
+		$t = array("s", "i");
+		$res = db_prep_query($sql, $v, $t);
+
+		if (!$res) {
+			db_rollback();
+			$e = new mb_exception("Error while saving WFS to DB. Rollback performed.");
+			return;
+		}
+	}
+	//echo "Successfully saved!<br />";
+	db_commit();
+	
+	return true;
+}
+*/
+
+/**
+* updateObjFromXML
+*
+* this function regets the information from the xml (update)
+* @return boolean true if successful, false otherwise
+*/
+function updateObjFromXML($url){
+	$x = new connector($url);
+	$data = $x->file;
+	#$data = implode("",file($url));
+	if(!$data){
+		$e = new mb_exception("Unable to open document: ".$url);
+		return false; 
+	}
+	
+	$values = null;
+	$tags = null;
+	$admin = new administration();
+	$this->wfs_getcapabilities_doc = $admin->char_encode($data);
+	$this->wfs_featuretype = array();
+	$this->wfs_upload_url = $url;
+	
+	# for temporary wfs a id has to be created...
+	//$this->wfs_id = "id_" . substr(md5(rand()),0,6);
+	$parser = xml_parser_create(CHARSET);
+	xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+	xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+	xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
+	xml_parse_into_struct($parser,$this->wfs_getcapabilities_doc,$values,$tags);
+	//xml_parse_into_struct($parser,$data,$values,$tags);
+	
+	xml_parser_free($parser);
+	
+	$section = false;
+	$request = false;
+	$featuretype_name = false;
+ 	$featuretype_title = false;
+ 	$featuretype_abstract = false;
+ 	$featuretype_srs = false;
+	
+	foreach ($values as $element) {
+	
+		if(strtoupper($element[tag]) == "WFS_CAPABILITIES" && $element[type] == "open"){
+			$this->wfs_version = $element[attributes][version];
+		}
+		if(strtoupper($element[tag]) == "NAME"  && $element[level] == '3'){
+			$this->wfs_name = $element[value];
+		}
+/*		if(strtoupper($element[tag]) == "TITLE"  && $element[level] == '3'){
+			$this->wfs_title = $this->stripEndlineAndCarriageReturn($element[value]);
+		}
+		if(strtoupper($element[tag]) == "ABSTRACT" && $element[level] == '3'){
+			$this->wfs_abstract = $this->stripEndlineAndCarriageReturn($element[value]);
+		}
+		//new WFS 1.0.0 -- SB 2007-08-06
+		if(strtolower($element[tag]) == "fees"){
+			$this->fees = $element[value];
+		}
+		if(strtolower($element[tag]) == "accessconstraints"){
+			$this->accessconstraints = $element[value];
+		}
+*/		
+		/*capability section*/
+		
+		if($this->wfs_version == "1.0.0"){
+			
+			# getCapabilities
+			if(strtoupper($element[tag]) == "GETCAPABILITIES" && $element[type] == "open"){
+				$section = "getcapabilities";
+			}
+			if($section == "getcapabilities" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_getcapabilities = $element[attributes][onlineResource];
+			}
+			
+			# descriptFeatureType
+			if(strtoupper($element[tag]) == "DESCRIBEFEATURETYPE" && $element[type] == "open"){
+				$section = "describefeaturetype";
+				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
+				
+				
+			}
+			if($section == "describefeaturetype" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_describefeaturetype = $element[attributes][onlineResource];
+			}
+			
+			# getFeature
+			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "open"){
+				$section = "getfeature";
+			}
+			if($section == "getfeature" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_getfeature = $element[attributes][onlineResource];
+			}
+			if(strtoupper($element[tag]) == "GETFEATURE" && $element[type] == "close"){
+				$section = "";
+			}			
+			# transaction
+			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "open"){
+				$section = "transaction";
+			}
+			if($section == "transaction" && strtoupper($element[tag]) == "POST"){
+				$this->wfs_transaction = $element[attributes][onlineResource];
+			}
+			if(strtoupper($element[tag]) == "TRANSACTION" && $element[type] == "close"){
+				$section = "";
+			}
+		} 
+		if(strtoupper($element[tag]) == "FEATURETYPE" && $element[type] == "open"){
+			$section = "featuretype";
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "NAME"){
+			$featuretype_name = $element[value];
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "TITLE"){
+			$featuretype_title = $this->stripEndlineAndCarriageReturn($element[value]);
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "ABSTRACT"){
+			$featuretype_abstract = $this->$element[value];
+		}
+		if($section == "featuretype" && strtoupper($element[tag]) == "SRS"){
+			$featuretype_srs = $element[value];
+			$this->addFeaturetype($featuretype_name,$featuretype_title,$featuretype_abstract,$featuretype_srs,$this->wfs_describefeaturetype,$this->wfs_version);
+		}
+	}
+	return true;
+}
+
+/**
+* creatObjfromDB
+*
+* this function fills the object with wfs information from db
+* 
+* @param int the id of wfs to get the information from
+*/ 
+/*
+function createObjFromDB($wfs_id){
+	global $DBSERVER,$DB,$OWNER,$PW;
+	$con = db_connect($DBSERVER,$OWNER,$PW);
+	db_select_db($DB,$con);
+
+	$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
+	$v = array($wfs_id);
+	$t = array("i");
+	$res = db_prep_query($sql, $v, $t);
+	$cnt = 0;
+	while(db_fetch_row($res)){
+		$this->wfs_id = db_result($res, $cnt, "wfs_id");
+		$this->wfs_version = db_result($res, $cnt, "wfs_version");
+		$this->wfs_name = db_result($res, $cnt, "wfs_name");
+		$this->wfs_title = db_result($res, $cnt, "wfs_title");
+		$this->wfs_abstract = db_result($res, $cnt, "wfs_abstract");
+		$this->wfs_getcapabilities = db_result($res, $cnt, "wfs_getcapabilities");
+		$this->wfs_getcapabilities_doc = db_result($res, $cnt, "wfs_getcapabilities_doc");
+		$this->wfs_upload_url = db_result($res, $cnt, "wfs_upload_url");
+		$this->wfs_describefeaturetype = db_result($res, $cnt, "wfs_describefeaturetype");
+		$this->wfs_getfeature = db_result($res, $cnt, "wfs_getfeature");
+		$this->wfs_transaction = db_result($res, $cnt, "wfs_transaction");
+		$this->fees = db_result($res, $cnt, "fees");
+		$this->accessconstraints = db_result($res, $cnt, "accessconstraints");
+		$this->wfs_owner = db_result($res, $cnt, "wfs_owner");
+		$this->wfs_timestamp = db_result($res, $cnt, "wfs_timestamp");
+		
+		$sql_fe = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 ORDER BY featuretype_id";
+		$v = array($this->wfs_id);
+		$t = array("i");
+		$res_fe = db_prep_query($sql_fe, $v, $t);
+		$cnt_fe = 0;
+		while(db_fetch_row($res_fe)){
+			$c = count($this->wfs_featuretype);
+//			$this->wfs_featuretype[$c]->featuretype_id = db_result($res_fe, $cnt_fe, "featuretype_id");
+			$this->wfs_featuretype[$c]->featuretype_name = db_result($res_fe, $cnt_fe, "featuretype_name");
+			$this->wfs_featuretype[$c]->featuretype_title = db_result($res_fe, $cnt_fe, "featuretype_title");
+			$this->wfs_featuretype[$c]->featuretype_abstract = db_result($res_fe, $cnt_fe, "featuretype_abstract");
+			$this->wfs_featuretype[$c]->featuretype_srs = db_result($res_fe, $cnt_fe, "featuretype_srs");
+			
+			$sql_el = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1 ORDER BY element_id";
+			$v = array(db_result($res_fe, $cnt_fe, "featuretype_id"));
+			$t = array("i");
+			$res_el = db_prep_query($sql_el, $v, $t);
+			$cnt_el = 0;
+			while(db_fetch_row($res_el)){
+				$z = count($this->wfs_featuretype[$c]->featuretype_element);
+				$this->wfs_featuretype[$c]->featuretype_element[$z]["name"] = db_result($res_el, $cnt_el, "element_name");
+				$this->wfs_featuretype[$c]->featuretype_element[$z]["type"] = db_result($res_el, $cnt_el, "element_type");
+				$cnt_el++;
+			}
+			$sql_ns = "SELECT * FROM wfs_featuretype_namespace WHERE fkey_featuretype_id = $1 ORDER BY namespace";
+			$v = array(db_result($res_fe, $cnt_fe, "featuretype_id"));
+			$t = array("i");
+			$res_ns = db_prep_query($sql_ns, $v, $t);
+			$cnt_ns = 0;
+			while(db_fetch_row($res_ns)){
+				$z = count($this->wfs_featuretype[$c]->featuretype_namespace);
+				$this->wfs_featuretype[$c]->featuretype_namespace[$z]["name"] = db_result($res_ns, $cnt_ns, "namespace");
+				$this->wfs_featuretype[$c]->featuretype_namespace[$z]["value"] = db_result($res_ns, $cnt_ns, "namespace_location");
+				$cnt_ns++;
+			}
+			$cnt_fe++;
+		}
+		$cnt++;
+    }
+}
+*/
+/** end createObjfromDB **/
+
+	public function getallwfs($userid){
+		$this->wfs_id = array();
+		$this->wfs_name = array();
+		$this->wfs_title = array();
+		$this->wfs_abstract = array();
+		
+		global $DBSERVER,$DB,$OWNER,$PW;
+		$con = db_connect($DBSERVER,$OWNER,$PW);
+		db_select_db($DB,$con);
+		if($userid){
+		 	$sql = "SELECT * FROM wfs WHERE wfs_owner = $1";
+			$v = array($userid);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+		}
+		else{
+		 	$sql = "SELECT * FROM wfs";
+			$res = db_query($sql);
+		}
+		
+		$cnt = 0;
+		while ($row = db_fetch_array($res)){
+			$this->wfs_version[$cnt] = $row["wfs_version"];
+			$this->wfs_id[$cnt] = $row["wfs_id"];
+			$this->wfs_name[$cnt] = $row["wfs_name"];
+			$this->wfs_title[$cnt] = $row["wfs_title"];
+			$this->wfs_abstract[$cnt] = $row["wfs_abstract"];
+			$this->wfs_getcapabilities[$cnt] = $row["wfs_getcapabilities"];
+			$this->wfs_describefeaturetype[$cnt] = $row["wfs_describefeaturetype"];
+			$this->wfs_getfeature[$cnt] = $row["wfs_getfeature"];
+			$cnt++;
+		}	
+	}
+}
+
+/*
+class featuretype extends wfs{
+	var $featuretype_element = array();	
+	var $featuretype_namespace = array();	
+	
+	function featuretype($name,$title,$abstract,$srs,$url,$version){
+
+		$url .= "&SERVICE=WFS&VERSION=".$version."&REQUEST=DescribeFeatureType&TYPENAME=".$name;
+		
+		$this->featuretype_name = $name;
+		$this->featuretype_title = $title;
+		$this->featuretype_abstract = $abstract;
+		$this->featuretype_srs = $srs;
+		
+		$y = new connector($url);
+		$data = $y->file;
+				
+		#$data = implode("",file($url));
+		$parser = xml_parser_create();
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+		xml_parse_into_struct($parser,$data,$values,$tags);
+		xml_parser_free($parser);
+		
+		foreach ($values as $element) {	
+			if($this->sepNameSpace($element[tag]) == "schema" && $element[type] == "open"){
+				$section = "namespace";
+//				echo "namespace<br>";
+			}
+			
+			if($section == "namespace"){		
+				while (list($k, $val) = each ($element[attributes])) {
+   					if (substr($k, 0, 5) == "xmlns") {
+						$cnt = count($this->featuretype_namespace);
+						$match = false;
+						for ($i = 0 ; $i < $cnt && $match == false ; $i++) {
+							if ($this->sepNameSpace($k) == $this->featuretype_namespace[$i]["name"] && $val == $this->featuretype_namespace[$i]["value"]) {
+								$match = true;
+							}
+						}
+						if ($match == false) {
+							$this->featuretype_namespace[$cnt]["name"] = $this->sepNameSpace($k);
+							$this->featuretype_namespace[$cnt]["value"] = $val;
+//							echo "namespace: " . $this->sepNameSpace($k) . " -> " . $val . "<br>";
+						}
+   					}
+				}
+			}
+			if($this->sepNameSpace($element[tag]) == "complexType" && $element[type] == "open"){
+				$section = "";
+			}
+			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "open"){
+				$section = "complexcontent";
+//				echo "complexcontent<br>";
+			}
+			if($section == "complexcontent" && $this->sepNameSpace($element[tag]) == "element" && $element[attributes][name]){
+				$cnt = count($this->featuretype_element);
+				$this->featuretype_element[$cnt]["name"] = $element[attributes]["name"];
+				$this->featuretype_element[$cnt]["type"] = $this->sepNameSpace($element[attributes]["type"]);
+//				echo "element: ".$this->featuretype_element[$cnt]["name"]."<br>";
+			}
+			if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "close"){
+				$section = "";
+			}
+		}
+	}
+	function sepNameSpace($s){
+		$c = strpos($s,":"); 
+		if($c>0){
+			return substr($s,$c+1);
+		}
+		else{
+			return $s;
+		}		
+	}
+}
+*/
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_wfs_factory.php
===================================================================
--- branches/wfs11/http/classes/class_wfs_factory.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfs_factory.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,133 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_ows_factory.php");
+
+/**
+ * 
+ * @return 
+ * @param $xml String
+ */
+abstract class WfsFactory extends OwsFactory {
+	
+	/**
+	 * Parses the capabilities document for the WFS 
+	 * version number and returns it.
+	 * 
+	 * @return String
+	 * @param $xml String
+	 */
+	private function getVersionFromXml ($xml) {
+
+		$admin = new administration();
+		$values = $admin->parseXml($xml);
+		
+		foreach ($values as $element) {
+			if(strtoupper($element[tag]) == "WFS_CAPABILITIES" && $element[type] == "open"){
+				return $element[attributes][version];
+			}
+		}
+		throw new Exception("WFS version could not be determined from XML.");
+	}
+	
+	/**
+	 * Retrieves the data of a WFS from the database and initiates the object.
+	 * 
+	 * @return 
+	 * @param $id Integer
+	 * @param $aWfs Wfs is being created by the subclass
+	 */
+	public function createFromDb ($id) {
+		if (func_num_args() == 2) {
+			$aWfs = func_get_arg(1);
+		}
+		else {
+			return null;
+		}
+
+		$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
+		$v = array($id);
+		$t = array("i");
+		$res = db_prep_query($sql, $v, $t);
+		$cnt = 0;
+		while(db_fetch_row($res)){
+			$aWfs->id = db_result($res, $cnt, "wfs_id");
+			$aWfs->name = db_result($res, $cnt, "wfs_name");
+			$aWfs->title = db_result($res, $cnt, "wfs_title");
+			$aWfs->summary = db_result($res, $cnt, "wfs_abstract");
+			$aWfs->getCapabilities = db_result($res, $cnt, "wfs_getcapabilities");
+			$aWfs->getCapabilitiesDoc = db_result($res, $cnt, "wfs_getcapabilities_doc");
+			$aWfs->uploadUrl = db_result($res, $cnt, "wfs_upload_url");
+			$aWfs->describeFeatureType = db_result($res, $cnt, "wfs_describefeaturetype");
+			$aWfs->getFeature = db_result($res, $cnt, "wfs_getfeature");
+			$aWfs->transaction = db_result($res, $cnt, "wfs_transaction");
+			$aWfs->fees = db_result($res, $cnt, "fees");
+			$aWfs->accessconstraints = db_result($res, $cnt, "accessconstraints");
+			$aWfs->owner = db_result($res, $cnt, "wfs_owner");
+			$aWfs->timestamp = db_result($res, $cnt, "wfs_timestamp");
+			
+			$sql_fe = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 ORDER BY featuretype_id";
+			$v = array($aWfs->id);
+			$t = array("i");
+			$res_fe = db_prep_query($sql_fe, $v, $t);
+			$cnt_fe = 0;
+			
+			while(db_fetch_row($res_fe)){
+				$c = count($aWfs->wfs_featuretype);
+				$aWfs->featureTypeArray[$c]->id = db_result($res_fe, $cnt_fe, "featuretype_id");
+				$aWfs->featureTypeArray[$c]->name = db_result($res_fe, $cnt_fe, "featuretype_name");
+				$aWfs->featureTypeArray[$c]->title = db_result($res_fe, $cnt_fe, "featuretype_title");
+				$aWfs->featureTypeArray[$c]->summary = db_result($res_fe, $cnt_fe, "featuretype_abstract");
+				$aWfs->featureTypeArray[$c]->srs = db_result($res_fe, $cnt_fe, "featuretype_srs");
+				
+				$sql_el = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1 ORDER BY element_id";
+				$v = array(db_result($res_fe, $cnt_fe, "featuretype_id"));
+				$t = array("i");
+				$res_el = db_prep_query($sql_el, $v, $t);
+				$cnt_el = 0;
+				while(db_fetch_row($res_el)){
+					$z = count($aWfs->featureTypeArray[$c]->elementArray);
+					$aWfs->featureTypeArray[$c]->elementArray[$z] = new stdClass();
+					$aWfs->featureTypeArray[$c]->elementArray[$z]->id = db_result($res_el, $cnt_el, "element_id");
+					$aWfs->featureTypeArray[$c]->elementArray[$z]->name = db_result($res_el, $cnt_el, "element_name");
+					$aWfs->featureTypeArray[$c]->elementArray[$z]->type = db_result($res_el, $cnt_el, "element_type");
+					$cnt_el++;
+				}
+				$sql_ns = "SELECT * FROM featureTypeArray_namespace WHERE fkey_featuretype_id = $1 ORDER BY namespace";
+				$v = array(db_result($res_fe, $cnt_fe, "featuretype_id"));
+				$t = array("i");
+				$res_ns = db_prep_query($sql_ns, $v, $t);
+				$cnt_ns = 0;
+				while(db_fetch_row($res_ns)){
+					$z = count($aWfs->featureTypeArray[$c]->namespaceArray);
+					$aWfs->featureTypeArray[$c]->namespaceArray[$z] = new stdClass();
+					$aWfs->featureTypeArray[$c]->namespaceArray[$z]->name = db_result($res_ns, $cnt_ns, "namespace");
+					$aWfs->featureTypeArray[$c]->namespaceArray[$z]->value = db_result($res_ns, $cnt_ns, "namespace_location");
+					$cnt_ns++;
+				}
+				$cnt_fe++;
+			}
+			$cnt++;
+	    }	
+		return $aWfs;	
+	}
+}
+?>
\ No newline at end of file

Added: branches/wfs11/http/classes/class_wfs_featuretype.php
===================================================================
--- branches/wfs11/http/classes/class_wfs_featuretype.php	                        (rev 0)
+++ branches/wfs11/http/classes/class_wfs_featuretype.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,115 @@
+<?php
+# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
+# http://www.mapbender.org/index.php/class_wfs.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__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/class_wfs.php");
+
+abstract class WfsFeatureType {
+	var $id;
+	var $name;
+	var $title;
+	var $summary;
+	var $srs;
+	var $wfs;
+	var $namespaceArray = array();
+	var $elementArray = array();
+
+	private function hasNamespace ($key, $value) {
+		for ($i = 0; $i < count($this->namespaceArray); $i++) {
+			if ($this->namespaceArray[$i]->name == $key && 
+				$this->namespaceArray[$i]->value == $value) 
+			{
+				return true;
+			}
+		}
+		return false;
+	}
+
+	public function addNamespace ($key, $value) {
+		if ($this->hasNamespace($key, $value)) {
+			return $this;
+		}
+		
+		$newNamespace = new stdClass();
+		$newNamespace->name = $key;
+		$newNamespace->value = $value;
+
+		array_push($this->namespaceArray, $newNamespace);
+
+		return $this;
+	}
+
+	public function addElement ($name, $type) {
+		$newElement = new stdClass();
+		$newElement->id = null;
+		$newElement->name = $name;
+		$newElement->type = $type;
+
+		array_push($this->elementArray, $newElement);
+
+		return $this;
+	}
+
+	public function toHtml () {
+		
+		$wfsString .= "<hr>";
+		$wfsString .= "name: ". $this->name . "<br>";
+		$wfsString .= "title: ". $this->title . "<br>";
+		$wfsString .= "abstract: ". $this->summary . "<br>";
+		$wfsString .= "srs: ". $this->srs . "<br>";
+
+		for ($j = 0; $j < count($this->elementArray); $j++) {
+			$currentElement = $this->elementArray[$j];
+			$wfsString .= " element: " . $currentElement->name . 
+							" - " . $currentElement->type . "<br>";
+		}
+
+		for ($j = 0; $j < count($this->namespaceArray); $j++) {
+			$currentNamespace = $this->namespaceArray[$j];
+			$wfsString .= " namespace: " . $currentNamespace->name . 
+							" - " . $currentNamespace->value . "<br>";
+		}
+		return $wfsString;
+	}
+
+	public function __toString () {
+		return $this->toHtml();
+	}
+}
+
+/**
+ * This class will be implemented only if needed
+ */
+class Wfs_1_0_FeatureType extends WfsFeatureType {
+	public function __construct ($aWfs) {
+		$this->wfs = $aWfs;
+	}
+}
+
+/**
+ * This class will be implemented only if needed
+ */
+class Wfs_1_1_FeatureType extends WfsFeatureType {
+	public function __construct ($aWfs) {
+		$this->wfs = $aWfs;
+	}
+}
+?>
\ No newline at end of file

Deleted: branches/wfs11/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/javascripts/map_obj.js	2009-01-29 14:34:25 UTC (rev 3502)
@@ -1,889 +0,0 @@
-/* 
-* $Id: map_obj.js 2517 2008-06-19 16:40:00Z christoph $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
-var mb_mapObj = [];
-
-function mb_mapObj_const(frameName, elementName, width, height, wms_index){
-
-	/**
-	 * set the extent of the wms
-	 */
-	this.setExtent = function(minx, miny, maxx, maxy){
-		this.extent = String(minx) + "," + String(miny) + "," + String(maxx) + "," + String(maxy);
-	};
-	
-	/**
-	 * get the width of the mapObj
-	 *
-	 * @member mb_mapObj_const
-	 * @return width of the mapObj
-	 * @type integer
-	 */
-	this.getWidth = function(){
-		return parseInt(this.width, 10);
-	};
-	
-	/**
-	 * set the width of the mapObj
-	 *
-	 * @param {integer} widht the width of the mapObj
-	 */
-	this.setWidth = function(width){
-		this.width = parseInt(width, 10);
-
-		//apply new width
-		if(this.frameName){
-			document.getElementById(this.frameName).style.width = this.width;
-		}
-		var domElement = this.getDomElement();
-		domElement.style.width = this.width;
-	};
-	
-	/**
-	 * get the height of the mapObj
-	 *
-	 * @member mb_mapObj_const
-	 * @return width of the mapObj
-	 * @type integer
-	 */
-	this.getHeight = function(){
-		return parseInt(this.height, 10);
-	};
-	
-	this.getDomElement = function(){
-		if(this.frameName){
-			return window.frames[this.frameName].document.getElementById(this.elementName);
-		}
-		return document.getElementById(this.elementName);
-	}
-	
-	/**
-	 * set the height of the mapObj
-	 *
-	 * @param {integer} height the height of the mapObj
-	 */
-	this.setHeight = function(height){
-		this.height = parseInt(height, 10);
-		//apply new height
-		if(this.frameName){
-			document.getElementById(this.frameName).style.height = this.height;
-		}
-		var domElement = this.getDomElement();
-		domElement.style.width = this.width;
-	};
-	
-	/**
-	 * converts the extent of the mapobject so that the maximum	extent will be displayed
-	 */
-	this.calculateExtent = function(ext){
-		var relation_px_x = this.getWidth() / this.getHeight();
-		var relation_px_y = this.getHeight() / this.getWidth();
-		var relation_bbox_x = ext.extentx / ext.extenty;
-		if (relation_bbox_x <= relation_px_x) {
-			ext.minx = ext.centerx - relation_px_x * ext.extenty / 2;
-			ext.maxx = ext.centerx + relation_px_x * ext.extenty / 2;
-		}
-		if (relation_bbox_x > relation_px_x) {
-			ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
-			ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
-		}
-		this.setExtent(ext.minx, ext.miny, ext.maxx, ext.maxy);
-		return ext;
-	};
-	
-	this.width = width;
-	this.height = height;
-	this.frameName = frameName;
-	this.type = (frameName !== "") ? "IFRAME" : "DIV";
-	this.elementName = elementName;
-	this.layers = [];
-	this.styles = [];
-	this.querylayers = [];
-	this.geom = "";
-	this.gml = "";
-	this.wms = [];
-	
-	// 
-	// Add pointers to WMS objects which are in this map.
-	// If wms_index is set (=map is overview), only this 
-	// WMS is being pointed to.
-	//
-	var index = 0;
-	for (var i = 0; i < wms.length; i++) {
-		var isValidWms = (wms_index === null) || (wms_index == i);
-		if (isValidWms) {
-			this.wms[index] = wms[i];
-			this.wms[index].mapURL = false;
-			index++;
-		}
-	}
-	
-	//
-	// set list of visible layers, active querylayers 
-	// and styles for each WMS in this map
-	//
-	var cnt_layers;
-	var cnt_querylayers;
-	var styles;
-	var layers;
-	var querylayers = "";
-	for (i = 0; i < this.wms.length; i++) {
-		cnt_layers = 0;
-		cnt_querylayers = 0;
-		styles = "";
-		layers = "";
-		querylayers = "";
-		
-		for (var ii = 0; ii < this.wms[i].objLayer.length; ii++) {
-			// layer is visible and not root layer
-			if (this.wms[i].objLayer[ii].gui_layer_visible == 1 && ii > 0) {
-				if (cnt_layers > 0) {
-					layers += ",";
-					styles += ",";
-				}
-				layers += wms[i].objLayer[ii].layer_name;
-				styles += "";
-				cnt_layers++;
-			}
-			// layer is queryable and not root layer
-			if (this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii > 0) {
-				if (cnt_querylayers > 0) {
-					querylayers += ",";
-				}
-				querylayers += wms[i].objLayer[ii].layer_name;
-				cnt_querylayers++;
-			}
-		}
-		this.layers[i] = layers;
-		this.styles[i] = styles;
-		this.querylayers[i] = querylayers;
-	}
-	
-	this.epsg = wms[0].gui_wms_epsg;
-	var bbox_minx, bbox_miny, bbox_maxx, bbox_maxy;
-	
-	for (var i = 0; i < wms[0].gui_epsg.length; i++) {
-		if (this.epsg == wms[0].gui_epsg[i]) {
-			bbox_minx = parseFloat(wms[0].gui_minx[i]);
-			bbox_miny = parseFloat(wms[0].gui_miny[i]);
-			bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
-			bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
-		}
-	}
-	var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
-	
-	this.calculateExtent(wmsExtent);
-
-	this.mapURL = [];
-	var domElement = this.getDomElement();
-	domElement.style.width = this.width;
-	domElement.style.height = this.height;   
-   
-	
-	/**
-	 * get the extent of the mapObj
-	 *
-	 * @member mb_mapObj_const
-	 * @return extent of the mapObj as commaseparated minx,minx,maxx,maxy
-	 * @type string
-	 */
-	this.getExtent = function(){
-		return this.extent;
-	};
-	
-	/**
-	 * get the extent as minx, maxx, miny, maxy
-	 *
-	 * @return extent and additional informations of the mapObj
-	 * @type Object
-	 */
-	this.getExtentInfos = function(){
-		var c = this.getExtent().split(",");
-		var ext = new Extent(c[0], c[1], c[2], c[3]);
-		return ext;
-	};
-	
-	/**
-	 * Sets the list of layers, styles and querylayers for a specified WMS
-	 */
-	this.restateLayers = function(wms_id){
-		for (var i = 0; i < this.wms.length; i++) {
-			if (this.wms[i].wms_id == wms_id) {
-				var currentWms = this.wms[i];
-				var cnt_layers = 0;
-				var cnt_querylayers = 0;
-				var layers = "";
-				var styles = "";
-				var querylayers = "";
-				for (var ii = 0; ii < currentWms.objLayer.length; ii++) {
-					var currentLayer = currentWms.objLayer[ii];
-					if (currentLayer.gui_layer_visible == 1 && !currentLayer.has_childs) {
-						if (cnt_layers > 0) {
-							layers += ",";
-							styles += ",";
-						}
-						layers += currentLayer.layer_name;
-						styles += "";
-						cnt_layers++;
-					}
-					if (currentLayer.gui_layer_querylayer == 1 && !currentLayer.has_childs) {
-						if (cnt_querylayers > 0) {
-							querylayers += ",";
-						}
-						querylayers += currentLayer.layer_name;
-						cnt_querylayers++;
-					}
-				}
-				this.layers[i] = layers;
-				this.querylayers[i] = querylayers;
-				this.styles[i] = styles;
-			}
-		}
-//		this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
-	};
-	
-	/**
-	 * 
-	 * @param {Object} direction
-	 */
-	this.pan = function (direction) {
-		var arrayBBox = this.extent.split(",");
-		var minx = parseFloat(arrayBBox[0]);
-		var miny = parseFloat(arrayBBox[1]);
-		var maxx = parseFloat(arrayBBox[2]);
-		var maxy = parseFloat(arrayBBox[3]);
-		var xtentx = maxx - minx;
-		var xtenty =  maxy - miny;
-		var factor = 0.5;
-		
-		switch (direction) {
-			case "NW" :
-				minx -= (xtentx * factor); 
-				maxx -= (xtentx * factor); 
-				miny += (xtenty * factor); 
-				maxy += (xtenty * factor);
-				break;
-			case "N" :
-				miny += (xtenty * factor); 
-				maxy += (xtenty * factor);
-				break;
-			case "NE" :
-				minx += (xtentx * factor); 
-				maxx += (xtentx * factor); 
-				miny += (xtenty * factor); 
-				maxy += (xtenty * factor);
-				break;
-			case "E" :
-				minx += (xtentx * factor); 
-				maxx += (xtentx * factor);
-				break;
-			case "SE" :
-				minx += (xtentx * factor); 
-				maxx += (xtentx * factor); 
-				miny -= (xtenty * factor); 
-				maxy -= (xtenty * factor);				
-				break;
-			case "S" :
-				miny -= (xtenty * factor); 
-				maxy -= (xtenty * factor);
-				break;
-			case "SW" :
-				minx -= (xtentx * factor); 
-				maxx -= (xtentx * factor); 
-				miny -= (xtenty * factor); 
-				maxy -= (xtenty * factor);
-				break;
-			case "W" :
-				minx -= (xtentx * factor); 
-				maxx -= (xtentx * factor);
-				break;
-		}
-		this.extent = minx + "," + miny + "," + maxx + "," + maxy;
-		this.setMapRequest();
-		
-	};
-	
-	this.zoomFull = function () {
-		
-		for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
-			if (this.epsg == this.wms[0].gui_epsg[i]) {
-				var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
-				var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
-				var bbox_maxx = parseFloat(this.wms[0].gui_maxx[i]);
-				var bbox_maxy = parseFloat(this.wms[0].gui_maxy[i]);
-				var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
-				var newExtent = this.calculateExtent(wmsExtent);
-				this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
-			}
-		}
-	};
-	
-	/**
-	 * zoom the map with a zoomfactor and optional to x,y coords
-	 *
-	 * @param {boolean} in_ in = true, out = false
-	 * @param {float} factor the zoomfactor 1 equals 100%
-	 * @param {float} x center to x-position
-	 * @param {float} y center to y-position
-	 */
-	this.zoom = function(in_, factor, x, y){
-		factor = parseFloat(factor);
-		if (!in_) {
-			factor = 1 / factor;
-		}
-		
-		var extent = this.getExtentInfos();
-		var distx = extent.maxx - extent.minx;
-		var disty = extent.maxy - extent.miny;
-		
-		
-		if (x && y) {
-			var centerx = parseFloat(x);
-			var centery = parseFloat(y);
-		}
-		else {
-			var centerx = extent.minx + distx / 2;
-			var centery = extent.miny + disty / 2;
-		}
-		
-		var new_distx = distx / factor;
-		var new_disty = disty / factor;
-		var minx = centerx - new_distx / 2;
-		var miny = centery - new_disty / 2;
-		var maxx = centerx + new_distx / 2;
-		var maxy = centery + new_disty / 2;
-		this.setExtent(minx, miny, maxx, maxy);
-
-		this.setMapRequest();
-	};
-	
-	var performUnknownCalculation = function (value) {
-		return Math.pow(10,(
-			Math.round(
-				Math.log(value)/
-				Math.log(10)
-			)
-		));
-	};
-	
-	this.convertPixelToReal = function (aPoint) {
-		var arrayBBox = this.extent.split(",");
-		var minX = parseFloat(arrayBBox[0]);
-		var minY = parseFloat(arrayBBox[1]);
-		var maxX = parseFloat(arrayBBox[2]);
-		var maxY = parseFloat(arrayBBox[3]);
-		var xtentx = maxX - minX;
-		var xtenty = maxY - minY;
-		var deltaX = xtentx/this.width;
-		var deltaY = xtenty/this.height;
-		var roundx, roundy;
-
-		if(deltaX > 0){
-			roundx = 1/performUnknownCalculation(deltaX);
-		}
-		else{
-			roundx = performUnknownCalculation(deltaX);
-		}
-		if(deltaY > 0){
-			roundy = 1/performUnknownCalculation(deltaY);
-		}
-		else{
-			roundy =  performUnknownCalculation(deltaY);
-		}	
-		var posX = parseFloat(minX + (aPoint.x / this.width) * xtentx);
-		var posY = parseFloat(maxY - (aPoint.y / this.height) * xtenty);
-		posX = Math.round(posX * roundx) / roundx;
-		posY = Math.round(posY * roundy) / roundy;
-		return new Point(posX, posY);
-	};
-	
-	/**
-	 * Convert real world coordinates to pixel coordinates
-	 */
-	this.convertRealToPixel = function (aPoint) {
-		var arrayBBox = this.extent.split(",");
-		var minX = parseFloat(arrayBBox[0]);
-		var minY = parseFloat(arrayBBox[1]);
-		var maxX = parseFloat(arrayBBox[2]);
-		var maxY = parseFloat(arrayBBox[3]);
-		return new Point(
-			Math.round((aPoint.x - minX) * this.width /(maxX - minX)), 
-			Math.round((maxY - aPoint.y) * this.height/(maxY - minY))
-		);
-	};
-	
-	/**
-	 * get the srs of the mapObj
-	 *
-	 * @return srs as epsg:number
-	 * @type string
-	 */
-	this.getSRS = function(){
-		return this.epsg;
-	};
-	
-	/**
-	 * get all mapRequests
-	 *
-	 * @return array of mapRequests of this map object
-	 * @type string[]
-	 */
-	this.getMapRequests = function(){
-		var allRequests = [];
-		//loop through all wms to get the mapRequests
-		for (var i = 0; i < this.wms.length; i++) {
-			var currentRequest = this.wms[i].getMapRequest(this);
-			if (currentRequest) {
-				allRequests.push(currentRequest);
-			}
-		}
-		if (allRequests.length > 0) {
-			return allRequests;
-		}
-		return false;
-	};
-	
-	/**
-	 * Return the map URL of the WMS at index i
-	 * @param {Object} currentWmsIndex
-	 */
-	this.getMapUrl = function(ii){
-		var currentWms = this.wms[ii];
-		var validLayers = currentWms.getLayers(this);
-		if(validLayers.length === 0) {
-			return false;
-		}
-		var layerNames = validLayers.join(",");
-		
-		url = currentWms.wms_getmap;
-		url += mb_getConjunctionCharacter(currentWms.wms_getmap);
-		
-		if (currentWms.wms_version == "1.0.0") {
-			url += "WMTVER=" + currentWms.wms_version + "&REQUEST=map&";
-		}
-		else {
-			url += "VERSION=" + currentWms.wms_version + "&REQUEST=GetMap&SERVICE=WMS&";
-		}
-		
-		url += "LAYERS=" + layerNames + "&";
-		url += "STYLES=";
-		var layer = layerNames.split(",");
-		for (var j = 0; j < layer.length; j++) {
-			if (j > 0) {
-				url += ",";
-			}
-			if (currentWms.getCurrentStyleByLayerName(layer[j]) !== false) {
-				url += currentWms.getCurrentStyleByLayerName(layer[j]);
-			}
-		}
-		url += "&";
-		url += "SRS=" + this.epsg + "&";
-		url += "BBOX=" + this.extent + "&";
-		url += "WIDTH=" + this.width + "&";
-		url += "HEIGHT=" + this.height + "&";
-		url += "FORMAT=" + currentWms.gui_wms_mapformat + "&";
-		url += "BGCOLOR=0xffffff&";
-		
-		if (currentWms.gui_wms_mapformat.search(/gif/i) > -1 ||
-		currentWms.gui_wms_mapformat.search(/png/i) > -1) {
-			url += "TRANSPARENT=TRUE&";
-		}
-		
-		url += "EXCEPTIONS=" + currentWms.gui_wms_exceptionformat + "&";
-		
-		// add vendor-specific
-		for (var v = 0; v < mb_vendorSpecific.length; v++) {
-			var vendorSpecificString = eval(mb_vendorSpecific[v]);
-			// if eval doesn't evaluate a function, the result is undefined.
-			// Sometimes it is necessary not to evaluate a function, for
-			// example if you want to change a variable from the current
-			// scope (see mod_addSLD.php) 
-			if (typeof(vendorSpecificString) != "undefined") {
-				url += vendorSpecificString + "&";
-			}
-		}
-		// add Filter
-		if (currentWms.wms_filter !== "") {
-			url += "&SLD=" + currentWms.wms_filter + "?id=" + mb_styleID + "&";
-		}
-		// add sld
-		if (currentWms.gui_wms_sldurl !== "") {
-			url += "&SLD=" + escape(currentWms.gui_wms_sldurl) + "&";
-		}
-		return url;
-	}
-	
-	/**
-	 * get all featureInfoRequests
-	 *
-	 * @member mb_mapObj_const
-	 * @param float x the x-value of the click position in pixel
-	 * @param float y the y-value of the click position in pixel
-	 * @return array of all featureInfoRequests of this map object
-	 * @type string[]
-	 */
-	this.getFeatureInfoRequests = function(clickPoint){
-		var allRequests = [];
-		//loop through all wms to get the FeatureInfoRequests
-		for (var i = 0; i < this.wms.length; i++) {
-			var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
-			if (currentRequest) {
-				allRequests.push(currentRequest);
-			}
-		}
-		if (allRequests.length > 0) {
-			return allRequests;
-		}
-		return false;
-	};
-	
-	/**
-	 * calculation of the mapscale
-	 *
-	 * @member mb_mapObj_const
-	 * @return scale
-	 * @type integer
-	 */
-	this.getScale = function(){
-		var scale;
-		var bbox = this.extent.split(",");
-		var xtenty;
-		if (this.epsg == "EPSG:4326") {
-			var pxLenx = (parseFloat(bbox[2]) - parseFloat(bbox[0])) / this.width;
-			var pxLeny = (parseFloat(bbox[3]) - parseFloat(bbox[1])) / this.height;
-			var lat_from = ((parseFloat(bbox[3]) - parseFloat(bbox[1]) / 2) * Math.PI) / 180;
-			var lat_to = ((parseFloat(bbox[3]) - parseFloat(bbox[1]) / 2 + pxLeny) * Math.PI) / 180;
-			var lon_from = ((parseFloat(bbox[2]) - parseFloat(bbox[0]) / 2) * Math.PI) / 180;
-			var lon_to = ((parseFloat(bbox[2]) - parseFloat(bbox[0]) / 2 + pxLeny) * Math.PI) / 180;
-			var dist = 6371229 * Math.acos(Math.sin(lat_from) * Math.sin(lat_to) + Math.cos(lat_from) * Math.cos(lat_to) * Math.cos(lon_from - lon_to));
-			scale = (dist / Math.SQRT2) * (mb_resolution * 100);
-		}
-		else {
-			xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
-			scale = (xtenty / this.height) * (mb_resolution * 100);
-		}
-		return parseInt(Math.round(scale));
-	};
-	
-	/**
-	 *
-	 */
-	this.checkScale = function(wmsIndex){
-		var thisLayer = this.layers[wmsIndex].split(",");
-		var thisScale = this.getScale();
-		var str_layer = "";
-		var cnt_layer = 0;
-		for (var i = 0; i < this.wms[wmsIndex].objLayer.length; i++) {
-			var currentLayer = this.wms[wmsIndex].objLayer[i];
-			var myLayername = currentLayer.layer_name;
-			
-			var myMinscale = currentLayer.gui_layer_minscale;
-			var myMaxscale = currentLayer.gui_layer_maxscale;
-			
-			for (var ii = 0; ii < thisLayer.length; ii++) {
-				if (thisLayer[ii] == myLayername && !currentLayer.has_childs) {
-					if (myMinscale !== 0 && thisScale < myMinscale) {
-						continue;
-					}
-					if (myMaxscale !== 0 && thisScale > myMaxscale) {
-						continue;
-					}
-					if (cnt_layer > 0) {
-						str_layer += ",";
-					}
-					str_layer += thisLayer[ii];
-					cnt_layer++;
-				}
-			}
-		}
-		var str_layerstyles = [];
-		str_layerstyles[0] = str_layer;
-		return str_layerstyles;
-		
-	};
-	
-	this.repaintScale = function(x, y, scale){
-		if (x === null && y === null) {
-			var arrayBBox = this.extent.split(",");
-			x = parseFloat(arrayBBox[0]) +
-			((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0])) /
-			2);
-			y = parseFloat(arrayBBox[1]) +
-			((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1])) /
-			2);
-		}
-		var minx = parseFloat(x) - (this.width / (mb_resolution * 100 * 2) * scale);
-		var miny = parseFloat(y) - (this.height / (mb_resolution * 100 * 2) * scale);
-		var maxx = parseFloat(x) + (this.width / (mb_resolution * 100 * 2) * scale);
-		var maxy = parseFloat(y) + (this.height / (mb_resolution * 100 * 2) * scale);
-		this.repaint(new Point(minx, miny), new Point(maxx, maxy));
-	};
-	
-	this.repaint = function(min, max){
-		this.extent = min.x + "," + min.y + "," + max.x + "," + max.y;
-		this.setMapRequest();
-	};
-	
-	this.setSingleMapRequest = function (wms_id) {
-		eventBeforeMapRequest.trigger({frameName:this.frameName});
-	
-		var ts = mb_timestamp();	
-	
-		for (var ii = 0; ii < this.wms.length; ii++){ 
-			var currentWms = this.wms[ii];
-			if (currentWms.wms_id != wms_id) {
-				continue;
-			}
-			var newMapRequest = getLayerHtmlCode(ii);
-
-			if (mb_log) {
-				var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
-			}
-			var myDivId = this.elementName + "_div_" + ii;          
-			writeTag(this.frameName, myDivId, newMapRequest);
-			var myMapId = this.elementName + "_map_" + ii;
-			eventAfterMapRequest.trigger({"frameName":this.elementName, "myMapId":myMapId});
-			return true;
-		}  
-		return false; 
-			
-	};
-	
-	this.mb_setFutureObj = function(mod_back_cnt){
-		var cnt = this.mb_MapFutureObj.length;
-		this.mb_MapFutureObj[cnt] = {};
-		this.mb_MapFutureObj[cnt].reqCnt = mod_back_cnt;
-		this.mb_MapFutureObj[cnt].width = this.width;
-		this.mb_MapFutureObj[cnt].height = this.height;
-		this.mb_MapFutureObj[cnt].epsg = this.epsg;
-		this.mb_MapFutureObj[cnt].extent = this.extent;
-		this.mb_MapFutureObj[cnt].layers = [];
-		
-		for(var i=0; i<this.layers.length;i++){
-			this.mb_MapFutureObj[cnt].layers[i] = this.layers[i];
-		}
-
-		this.mb_MapFutureObj[cnt].styles = [];
-
-		for(var i=0; i < this.styles.length;i++){
-			this.mb_MapFutureObj[cnt].styles[i] = this.styles[i];
-		}
-
-		this.mb_MapFutureObj[cnt].querylayers = [];
-
-		for(var i=0; i < this.querylayers.length; i++) {
-			this.mb_MapFutureObj[cnt].querylayers[i] = this.querylayers[i];
-		}
-	}
-	
-	this.setMapRequest = function(){
-		var functionName = 'setMapRequest';
-		
-		var ret = eventBeforeMapRequest.trigger({
-				frameName: this.frameName
-			}, "AND");
-		if (ret === false) {
-			return true;
-		}
-		var ts = mb_timestamp();
-		var myMapId = [];
-		
-		var newMapRequest = "";
-		
-		for (var ii = 0; ii < this.wms.length; ii++) {
-			var currentWms = this.wms[ii];
-		
-			if (!(currentWms.gui_wms_visible > 0)) {
-				continue;
-			}
-			myMapId.push(this.elementName + "_map_" + ii);
-			
-			newMapRequest += getLayerHtmlCode(ii);
-			
-		}
-		writeTag(this.frameName, this.elementName+"_maps", newMapRequest);
-
-		eventAfterMapRequest.trigger({
-			"frameName": this.elementName,
-			"myMapId": myMapId.join(",")
-		});
-	};
-
-	var that = this;
-
-	var getLayerHtmlCode = function (ii) {
-		var currentWms = that.wms[ii];
-	
-		var myDivId = that.elementName + "_div_" + ii;          
-		var myMapId = that.elementName + "_map_" + ii;
-
-		//disable Layer which are out of scale
-		var validLayers = that.checkScale(ii);
-		var layerNames = validLayers.toString();
-	
-		var newMapURL = false;
-		var opacityString = "";
-		
-		if (that.layers[ii] !== "" && layerNames !== ''){
-			// get map URL
-			newMapURL = that.getMapUrl(ii);
-	
-			var currentOpacity = currentWms.gui_wms_mapopacity;
-			if (currentOpacity != 1) {
-				opacityString += "opacity:" + currentOpacity + "; ";
-				opacityString += "Filter: Alpha(Opacity=" + currentOpacity*100 + "); ";
-				opacityString += "-moz-opacity:" + currentOpacity + " ; ";
-				opacityString += "-khtml-opacity:" + currentOpacity;
-			}
-		}
-	
-		var imageString = "";
-		if (newMapURL) {
-			imageString = "<img id='"+myMapId+"' name='mapimage' ";
-			imageString += "src='" + newMapURL + "' ";
-			imageString += "width='"+that.width+"' ";
-			imageString += "height='"+that.height+"' ";
-			imageString += "border='0'>";	
-		}
-	
-		var newMapRequest = "<div id='"+myDivId+"' ";
-		newMapRequest += "style=\"position:absolute; top:0px; left:0px; ";
-		newMapRequest += "z-index:" + ii + ";" + opacityString + "\">";
-		newMapRequest += imageString;
-		newMapRequest += "</div>";   
-	
-		that.mapURL[ii]= newMapURL;	
-		currentWms.mapURL = newMapURL;
-	
-		if (mb_log && currentWms.mapURL) {
-			var tmp = eval(mb_log + "('" +newMapURL + "','" + ts + "')");
-		}
-	
-		return newMapRequest;
-	}
-	
-	this.getWmsIdByTitle = function (title) {
-		for (var i=0; i < this.wms.length; i++) {
-			if (this.wms[i].wms_title == title) {
-				return this.wms[i].wms_id;
-			}
-		}
-		return null;
-	};
-
-	this.getWmsIndexById = function (wms_id) {
-		for (var i=0; i< this.wms.length; i++){
-			if(this.wms[i].wms_id == wms_id){
-				return i;
-			}
-		}
-		return null;
-	};
-
-	this.removeWms = function (wmsIndex) {
-		var wms_ID = null;
-		var i;
-		var new_wmsarray = [];
-		var new_layerarray = [];
-		var new_querylayerarray = [];
-		var new_stylesarray = [];
-		var new_mapURLarray = [];
-		
-		for	(i = 0; i < this.wms.length; i++) {
-			if (i != wmsIndex) {
-				new_wmsarray.push(this.wms[i]);
-				new_layerarray.push(this.layers[i]);
-				new_querylayerarray.push(this.querylayers[i]);
-				new_stylesarray.push(this.styles[i]);
-				new_mapURLarray.push(this.mapURL[i]);
-			}
-			else {
-				wms_ID = this.wms[i].wms_id;
-			}
-		}
-		this.wms = new_wmsarray; 
-		this.layers = new_layerarray; 
-		this.querylayers = new_querylayerarray; 
-		this.styles = new_stylesarray; 
-		this.mapURL = new_mapURLarray;
-	
-		var another_new_wmsarray = [];
-
-		for	(i = 0; i < window.wms.length; i++) {
-			if (window.wms[i].wms_id != wms_ID) {
-				another_new_wmsarray.push(window.wms[i]); 
-			}
-		}
-		window.wms = another_new_wmsarray; 
-	};
-	
-	/**
-	 * move a wms or layer 
-	 *
-	 * @param int wms_id id of wms to move
-	 * @param int layer_id id of layer to move
-	 * @return true of successful
-	 * @type boolean
-	 */
-	this.move = function(wms_id, layer_id, moveUp){
-		var i,j;
-		for(i=0;i<this.wms.length;i++){
-			if (wms_id == this.wms[i].wms_id) {
-				break;
-			}
-		}
-		
-		//check if only one wms is affected?
-		if (layer_id && layer_id != this.wms[i].objLayer[0].layer_id) {
-			return this.wms[i].moveLayer(layer_id, moveUp);
-		}
-		
-		//else swap wms
-		j = i + (moveUp?-1:1);
-		if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length)) {
-			return false;
-		}
-		
-		upper = this.wms[i];
-		this.wms[i] = this.wms[j];
-		this.wms[j] = upper;
-		var upperLayers = this.layers[i];
-		var upperStyles = this.styles[i];
-		var upperQuerylayers = this.querylayers[i];
-		this.layers[i] = this.layers[j];
-		this.styles[i] = this.styles[j];
-		this.querylayers[i] = this.querylayers[j];
-		this.layers[j] = upperLayers;
-		this.styles[j] = upperStyles;
-		this.querylayers[j] = upperQuerylayers;
-		
-		return true;
-	};
-	
-	this.getMousePos = function(e){
-		if(ie){
-			if(this.frameName){
-				clickX = window.frames[fName].event.clientX;
-				clickY = window.frames[fName].event.clientY;
-			}
-			else{
-				clickX = event.clientX;
-				clickY = event.clientY;
-			}
-		}
-		else{
-			clickX = e.pageX;
-			clickY = e.pageY;
-		}
-		
-		//remove divtag offset
-		clickX -= parseInt(this.getDomElement().style.left);
-		clickY -= parseInt(this.getDomElement().style.top);
-		
-		return new Point(clickX, clickY);
-	}
-
-	eventAfterMapObjectConstruction.trigger();
-}

Copied: branches/wfs11/http/javascripts/map_obj.js (from rev 3501, trunk/mapbender/http/javascripts/map_obj.js)
===================================================================
--- branches/wfs11/http/javascripts/map_obj.js	                        (rev 0)
+++ branches/wfs11/http/javascripts/map_obj.js	2009-01-29 14:34:25 UTC (rev 3502)
@@ -0,0 +1,889 @@
+/* 
+* $Id: map_obj.js 2517 2008-06-19 16:40:00Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+var mb_mapObj = [];
+
+function mb_mapObj_const(frameName, elementName, width, height, wms_index){
+
+	/**
+	 * set the extent of the wms
+	 */
+	this.setExtent = function(minx, miny, maxx, maxy){
+		this.extent = String(minx) + "," + String(miny) + "," + String(maxx) + "," + String(maxy);
+	};
+	
+	/**
+	 * get the width of the mapObj
+	 *
+	 * @member mb_mapObj_const
+	 * @return width of the mapObj
+	 * @type integer
+	 */
+	this.getWidth = function(){
+		return parseInt(this.width, 10);
+	};
+	
+	/**
+	 * set the width of the mapObj
+	 *
+	 * @param {integer} widht the width of the mapObj
+	 */
+	this.setWidth = function(width){
+		this.width = parseInt(width, 10);
+
+		//apply new width
+		if(this.frameName){
+			document.getElementById(this.frameName).style.width = this.width;
+		}
+		var domElement = this.getDomElement();
+		domElement.style.width = this.width;
+	};
+	
+	/**
+	 * get the height of the mapObj
+	 *
+	 * @member mb_mapObj_const
+	 * @return width of the mapObj
+	 * @type integer
+	 */
+	this.getHeight = function(){
+		return parseInt(this.height, 10);
+	};
+	
+	this.getDomElement = function(){
+		if(this.frameName){
+			return window.frames[this.frameName].document.getElementById(this.elementName);
+		}
+		return document.getElementById(this.elementName);
+	}
+	
+	/**
+	 * set the height of the mapObj
+	 *
+	 * @param {integer} height the height of the mapObj
+	 */
+	this.setHeight = function(height){
+		this.height = parseInt(height, 10);
+		//apply new height
+		if(this.frameName){
+			document.getElementById(this.frameName).style.height = this.height;
+		}
+		var domElement = this.getDomElement();
+		domElement.style.height = this.height;
+	};
+	
+	/**
+	 * converts the extent of the mapobject so that the maximum	extent will be displayed
+	 */
+	this.calculateExtent = function(ext){
+		var relation_px_x = this.getWidth() / this.getHeight();
+		var relation_px_y = this.getHeight() / this.getWidth();
+		var relation_bbox_x = ext.extentx / ext.extenty;
+		if (relation_bbox_x <= relation_px_x) {
+			ext.minx = ext.centerx - relation_px_x * ext.extenty / 2;
+			ext.maxx = ext.centerx + relation_px_x * ext.extenty / 2;
+		}
+		if (relation_bbox_x > relation_px_x) {
+			ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
+			ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
+		}
+		this.setExtent(ext.minx, ext.miny, ext.maxx, ext.maxy);
+		return ext;
+	};
+	
+	this.width = width;
+	this.height = height;
+	this.frameName = frameName;
+	this.type = (frameName !== "") ? "IFRAME" : "DIV";
+	this.elementName = elementName;
+	this.layers = [];
+	this.styles = [];
+	this.querylayers = [];
+	this.geom = "";
+	this.gml = "";
+	this.wms = [];
+	
+	// 
+	// Add pointers to WMS objects which are in this map.
+	// If wms_index is set (=map is overview), only this 
+	// WMS is being pointed to.
+	//
+	var index = 0;
+	for (var i = 0; i < wms.length; i++) {
+		var isValidWms = (wms_index === null) || (wms_index == i);
+		if (isValidWms) {
+			this.wms[index] = wms[i];
+			this.wms[index].mapURL = false;
+			index++;
+		}
+	}
+	
+	//
+	// set list of visible layers, active querylayers 
+	// and styles for each WMS in this map
+	//
+	var cnt_layers;
+	var cnt_querylayers;
+	var styles;
+	var layers;
+	var querylayers = "";
+	for (i = 0; i < this.wms.length; i++) {
+		cnt_layers = 0;
+		cnt_querylayers = 0;
+		styles = "";
+		layers = "";
+		querylayers = "";
+		
+		for (var ii = 0; ii < this.wms[i].objLayer.length; ii++) {
+			// layer is visible and not root layer
+			if (this.wms[i].objLayer[ii].gui_layer_visible == 1 && ii > 0) {
+				if (cnt_layers > 0) {
+					layers += ",";
+					styles += ",";
+				}
+				layers += wms[i].objLayer[ii].layer_name;
+				styles += "";
+				cnt_layers++;
+			}
+			// layer is queryable and not root layer
+			if (this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii > 0) {
+				if (cnt_querylayers > 0) {
+					querylayers += ",";
+				}
+				querylayers += wms[i].objLayer[ii].layer_name;
+				cnt_querylayers++;
+			}
+		}
+		this.layers[i] = layers;
+		this.styles[i] = styles;
+		this.querylayers[i] = querylayers;
+	}
+	
+	this.epsg = wms[0].gui_wms_epsg;
+	var bbox_minx, bbox_miny, bbox_maxx, bbox_maxy;
+	
+	for (var i = 0; i < wms[0].gui_epsg.length; i++) {
+		if (this.epsg == wms[0].gui_epsg[i]) {
+			bbox_minx = parseFloat(wms[0].gui_minx[i]);
+			bbox_miny = parseFloat(wms[0].gui_miny[i]);
+			bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
+			bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
+		}
+	}
+	var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+	
+	this.calculateExtent(wmsExtent);
+
+	this.mapURL = [];
+	var domElement = this.getDomElement();
+	domElement.style.width = this.width;
+	domElement.style.height = this.height;   
+   
+	
+	/**
+	 * get the extent of the mapObj
+	 *
+	 * @member mb_mapObj_const
+	 * @return extent of the mapObj as commaseparated minx,minx,maxx,maxy
+	 * @type string
+	 */
+	this.getExtent = function(){
+		return this.extent;
+	};
+	
+	/**
+	 * get the extent as minx, maxx, miny, maxy
+	 *
+	 * @return extent and additional informations of the mapObj
+	 * @type Object
+	 */
+	this.getExtentInfos = function(){
+		var c = this.getExtent().split(",");
+		var ext = new Extent(c[0], c[1], c[2], c[3]);
+		return ext;
+	};
+	
+	/**
+	 * Sets the list of layers, styles and querylayers for a specified WMS
+	 */
+	this.restateLayers = function(wms_id){
+		for (var i = 0; i < this.wms.length; i++) {
+			if (this.wms[i].wms_id == wms_id) {
+				var currentWms = this.wms[i];
+				var cnt_layers = 0;
+				var cnt_querylayers = 0;
+				var layers = "";
+				var styles = "";
+				var querylayers = "";
+				for (var ii = 0; ii < currentWms.objLayer.length; ii++) {
+					var currentLayer = currentWms.objLayer[ii];
+					if (currentLayer.gui_layer_visible == 1 && !currentLayer.has_childs) {
+						if (cnt_layers > 0) {
+							layers += ",";
+							styles += ",";
+						}
+						layers += currentLayer.layer_name;
+						styles += "";
+						cnt_layers++;
+					}
+					if (currentLayer.gui_layer_querylayer == 1 && !currentLayer.has_childs) {
+						if (cnt_querylayers > 0) {
+							querylayers += ",";
+						}
+						querylayers += currentLayer.layer_name;
+						cnt_querylayers++;
+					}
+				}
+				this.layers[i] = layers;
+				this.querylayers[i] = querylayers;
+				this.styles[i] = styles;
+			}
+		}
+//		this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
+	};
+	
+	/**
+	 * 
+	 * @param {Object} direction
+	 */
+	this.pan = function (direction) {
+		var arrayBBox = this.extent.split(",");
+		var minx = parseFloat(arrayBBox[0]);
+		var miny = parseFloat(arrayBBox[1]);
+		var maxx = parseFloat(arrayBBox[2]);
+		var maxy = parseFloat(arrayBBox[3]);
+		var xtentx = maxx - minx;
+		var xtenty =  maxy - miny;
+		var factor = 0.5;
+		
+		switch (direction) {
+			case "NW" :
+				minx -= (xtentx * factor); 
+				maxx -= (xtentx * factor); 
+				miny += (xtenty * factor); 
+				maxy += (xtenty * factor);
+				break;
+			case "N" :
+				miny += (xtenty * factor); 
+				maxy += (xtenty * factor);
+				break;
+			case "NE" :
+				minx += (xtentx * factor); 
+				maxx += (xtentx * factor); 
+				miny += (xtenty * factor); 
+				maxy += (xtenty * factor);
+				break;
+			case "E" :
+				minx += (xtentx * factor); 
+				maxx += (xtentx * factor);
+				break;
+			case "SE" :
+				minx += (xtentx * factor); 
+				maxx += (xtentx * factor); 
+				miny -= (xtenty * factor); 
+				maxy -= (xtenty * factor);				
+				break;
+			case "S" :
+				miny -= (xtenty * factor); 
+				maxy -= (xtenty * factor);
+				break;
+			case "SW" :
+				minx -= (xtentx * factor); 
+				maxx -= (xtentx * factor); 
+				miny -= (xtenty * factor); 
+				maxy -= (xtenty * factor);
+				break;
+			case "W" :
+				minx -= (xtentx * factor); 
+				maxx -= (xtentx * factor);
+				break;
+		}
+		this.extent = minx + "," + miny + "," + maxx + "," + maxy;
+		this.setMapRequest();
+		
+	};
+	
+	this.zoomFull = function () {
+		
+		for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
+			if (this.epsg == this.wms[0].gui_epsg[i]) {
+				var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
+				var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
+				var bbox_maxx = parseFloat(this.wms[0].gui_maxx[i]);
+				var bbox_maxy = parseFloat(this.wms[0].gui_maxy[i]);
+				var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+				var newExtent = this.calculateExtent(wmsExtent);
+				this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
+			}
+		}
+	};
+	
+	/**
+	 * zoom the map with a zoomfactor and optional to x,y coords
+	 *
+	 * @param {boolean} in_ in = true, out = false
+	 * @param {float} factor the zoomfactor 1 equals 100%
+	 * @param {float} x center to x-position
+	 * @param {float} y center to y-position
+	 */
+	this.zoom = function(in_, factor, x, y){
+		factor = parseFloat(factor);
+		if (!in_) {
+			factor = 1 / factor;
+		}
+		
+		var extent = this.getExtentInfos();
+		var distx = extent.maxx - extent.minx;
+		var disty = extent.maxy - extent.miny;
+		
+		
+		if (x && y) {
+			var centerx = parseFloat(x);
+			var centery = parseFloat(y);
+		}
+		else {
+			var centerx = extent.minx + distx / 2;
+			var centery = extent.miny + disty / 2;
+		}
+		
+		var new_distx = distx / factor;
+		var new_disty = disty / factor;
+		var minx = centerx - new_distx / 2;
+		var miny = centery - new_disty / 2;
+		var maxx = centerx + new_distx / 2;
+		var maxy = centery + new_disty / 2;
+		this.setExtent(minx, miny, maxx, maxy);
+
+		this.setMapRequest();
+	};
+	
+	var performUnknownCalculation = function (value) {
+		return Math.pow(10,(
+			Math.round(
+				Math.log(value)/
+				Math.log(10)
+			)
+		));
+	};
+	
+	this.convertPixelToReal = function (aPoint) {
+		var arrayBBox = this.extent.split(",");
+		var minX = parseFloat(arrayBBox[0]);
+		var minY = parseFloat(arrayBBox[1]);
+		var maxX = parseFloat(arrayBBox[2]);
+		var maxY = parseFloat(arrayBBox[3]);
+		var xtentx = maxX - minX;
+		var xtenty = maxY - minY;
+		var deltaX = xtentx/this.width;
+		var deltaY = xtenty/this.height;
+		var roundx, roundy;
+
+		if(deltaX > 0){
+			roundx = 1/performUnknownCalculation(deltaX);
+		}
+		else{
+			roundx = performUnknownCalculation(deltaX);
+		}
+		if(deltaY > 0){
+			roundy = 1/performUnknownCalculation(deltaY);
+		}
+		else{
+			roundy =  performUnknownCalculation(deltaY);
+		}	
+		var posX = parseFloat(minX + (aPoint.x / this.width) * xtentx);
+		var posY = parseFloat(maxY - (aPoint.y / this.height) * xtenty);
+		posX = Math.round(posX * roundx) / roundx;
+		posY = Math.round(posY * roundy) / roundy;
+		return new Point(posX, posY);
+	};
+	
+	/**
+	 * Convert real world coordinates to pixel coordinates
+	 */
+	this.convertRealToPixel = function (aPoint) {
+		var arrayBBox = this.extent.split(",");
+		var minX = parseFloat(arrayBBox[0]);
+		var minY = parseFloat(arrayBBox[1]);
+		var maxX = parseFloat(arrayBBox[2]);
+		var maxY = parseFloat(arrayBBox[3]);
+		return new Point(
+			Math.round((aPoint.x - minX) * this.width /(maxX - minX)), 
+			Math.round((maxY - aPoint.y) * this.height/(maxY - minY))
+		);
+	};
+	
+	/**
+	 * get the srs of the mapObj
+	 *
+	 * @return srs as epsg:number
+	 * @type string
+	 */
+	this.getSRS = function(){
+		return this.epsg;
+	};
+	
+	/**
+	 * get all mapRequests
+	 *
+	 * @return array of mapRequests of this map object
+	 * @type string[]
+	 */
+	this.getMapRequests = function(){
+		var allRequests = [];
+		//loop through all wms to get the mapRequests
+		for (var i = 0; i < this.wms.length; i++) {
+			var currentRequest = this.wms[i].getMapRequest(this);
+			if (currentRequest) {
+				allRequests.push(currentRequest);
+			}
+		}
+		if (allRequests.length > 0) {
+			return allRequests;
+		}
+		return false;
+	};
+	
+	/**
+	 * Return the map URL of the WMS at index i
+	 * @param {Object} currentWmsIndex
+	 */
+	this.getMapUrl = function(ii){
+		var currentWms = this.wms[ii];
+		var validLayers = currentWms.getLayers(this);
+		if(validLayers.length === 0) {
+			return false;
+		}
+		var layerNames = validLayers.join(",");
+		
+		url = currentWms.wms_getmap;
+		url += mb_getConjunctionCharacter(currentWms.wms_getmap);
+		
+		if (currentWms.wms_version == "1.0.0") {
+			url += "WMTVER=" + currentWms.wms_version + "&REQUEST=map&";
+		}
+		else {
+			url += "VERSION=" + currentWms.wms_version + "&REQUEST=GetMap&SERVICE=WMS&";
+		}
+		
+		url += "LAYERS=" + layerNames + "&";
+		url += "STYLES=";
+		var layer = layerNames.split(",");
+		for (var j = 0; j < layer.length; j++) {
+			if (j > 0) {
+				url += ",";
+			}
+			if (currentWms.getCurrentStyleByLayerName(layer[j]) !== false) {
+				url += currentWms.getCurrentStyleByLayerName(layer[j]);
+			}
+		}
+		url += "&";
+		url += "SRS=" + this.epsg + "&";
+		url += "BBOX=" + this.extent + "&";
+		url += "WIDTH=" + this.width + "&";
+		url += "HEIGHT=" + this.height + "&";
+		url += "FORMAT=" + currentWms.gui_wms_mapformat + "&";
+		url += "BGCOLOR=0xffffff&";
+		
+		if (currentWms.gui_wms_mapformat.search(/gif/i) > -1 ||
+		currentWms.gui_wms_mapformat.search(/png/i) > -1) {
+			url += "TRANSPARENT=TRUE&";
+		}
+		
+		url += "EXCEPTIONS=" + currentWms.gui_wms_exceptionformat + "&";
+		
+		// add vendor-specific
+		for (var v = 0; v < mb_vendorSpecific.length; v++) {
+			var vendorSpecificString = eval(mb_vendorSpecific[v]);
+			// if eval doesn't evaluate a function, the result is undefined.
+			// Sometimes it is necessary not to evaluate a function, for
+			// example if you want to change a variable from the current
+			// scope (see mod_addSLD.php) 
+			if (typeof(vendorSpecificString) != "undefined") {
+				url += vendorSpecificString + "&";
+			}
+		}
+		// add Filter
+		if (currentWms.wms_filter !== "") {
+			url += "&SLD=" + currentWms.wms_filter + "?id=" + mb_styleID + "&";
+		}
+		// add sld
+		if (currentWms.gui_wms_sldurl !== "") {
+			url += "&SLD=" + escape(currentWms.gui_wms_sldurl) + "&";
+		}
+		return url;
+	}
+	
+	/**
+	 * get all featureInfoRequests
+	 *
+	 * @member mb_mapObj_const
+	 * @param float x the x-value of the click position in pixel
+	 * @param float y the y-value of the click position in pixel
+	 * @return array of all featureInfoRequests of this map object
+	 * @type string[]
+	 */
+	this.getFeatureInfoRequests = function(clickPoint){
+		var allRequests = [];
+		//loop through all wms to get the FeatureInfoRequests
+		for (var i = 0; i < this.wms.length; i++) {
+			var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
+			if (currentRequest) {
+				allRequests.push(currentRequest);
+			}
+		}
+		if (allRequests.length > 0) {
+			return allRequests;
+		}
+		return false;
+	};
+	
+	/**
+	 * calculation of the mapscale
+	 *
+	 * @member mb_mapObj_const
+	 * @return scale
+	 * @type integer
+	 */
+	this.getScale = function(){
+		var scale;
+		var bbox = this.extent.split(",");
+		var xtenty;
+		if (this.epsg == "EPSG:4326") {
+			var pxLenx = (parseFloat(bbox[2]) - parseFloat(bbox[0])) / this.width;
+			var pxLeny = (parseFloat(bbox[3]) - parseFloat(bbox[1])) / this.height;
+			var lat_from = ((parseFloat(bbox[3]) - parseFloat(bbox[1]) / 2) * Math.PI) / 180;
+			var lat_to = ((parseFloat(bbox[3]) - parseFloat(bbox[1]) / 2 + pxLeny) * Math.PI) / 180;
+			var lon_from = ((parseFloat(bbox[2]) - parseFloat(bbox[0]) / 2) * Math.PI) / 180;
+			var lon_to = ((parseFloat(bbox[2]) - parseFloat(bbox[0]) / 2 + pxLeny) * Math.PI) / 180;
+			var dist = 6371229 * Math.acos(Math.sin(lat_from) * Math.sin(lat_to) + Math.cos(lat_from) * Math.cos(lat_to) * Math.cos(lon_from - lon_to));
+			scale = (dist / Math.SQRT2) * (mb_resolution * 100);
+		}
+		else {
+			xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
+			scale = (xtenty / this.height) * (mb_resolution * 100);
+		}
+		return parseInt(Math.round(scale));
+	};
+	
+	/**
+	 *
+	 */
+	this.checkScale = function(wmsIndex){
+		var thisLayer = this.layers[wmsIndex].split(",");
+		var thisScale = this.getScale();
+		var str_layer = "";
+		var cnt_layer = 0;
+		for (var i = 0; i < this.wms[wmsIndex].objLayer.length; i++) {
+			var currentLayer = this.wms[wmsIndex].objLayer[i];
+			var myLayername = currentLayer.layer_name;
+			
+			var myMinscale = currentLayer.gui_layer_minscale;
+			var myMaxscale = currentLayer.gui_layer_maxscale;
+			
+			for (var ii = 0; ii < thisLayer.length; ii++) {
+				if (thisLayer[ii] == myLayername && !currentLayer.has_childs) {
+					if (myMinscale !== 0 && thisScale < myMinscale) {
+						continue;
+					}
+					if (myMaxscale !== 0 && thisScale > myMaxscale) {
+						continue;
+					}
+					if (cnt_layer > 0) {
+						str_layer += ",";
+					}
+					str_layer += thisLayer[ii];
+					cnt_layer++;
+				}
+			}
+		}
+		var str_layerstyles = [];
+		str_layerstyles[0] = str_layer;
+		return str_layerstyles;
+		
+	};
+	
+	this.repaintScale = function(x, y, scale){
+		if (x === null && y === null) {
+			var arrayBBox = this.extent.split(",");
+			x = parseFloat(arrayBBox[0]) +
+			((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0])) /
+			2);
+			y = parseFloat(arrayBBox[1]) +
+			((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1])) /
+			2);
+		}
+		var minx = parseFloat(x) - (this.width / (mb_resolution * 100 * 2) * scale);
+		var miny = parseFloat(y) - (this.height / (mb_resolution * 100 * 2) * scale);
+		var maxx = parseFloat(x) + (this.width / (mb_resolution * 100 * 2) * scale);
+		var maxy = parseFloat(y) + (this.height / (mb_resolution * 100 * 2) * scale);
+		this.repaint(new Point(minx, miny), new Point(maxx, maxy));
+	};
+	
+	this.repaint = function(min, max){
+		this.extent = min.x + "," + min.y + "," + max.x + "," + max.y;
+		this.setMapRequest();
+	};
+	
+	this.setSingleMapRequest = function (wms_id) {
+		eventBeforeMapRequest.trigger({frameName:this.frameName});
+	
+		var ts = mb_timestamp();	
+	
+		for (var ii = 0; ii < this.wms.length; ii++){ 
+			var currentWms = this.wms[ii];
+			if (currentWms.wms_id != wms_id) {
+				continue;
+			}
+			var newMapRequest = getLayerHtmlCode(ii);
+
+			if (mb_log) {
+				var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
+			}
+			var myDivId = this.elementName + "_div_" + ii;          
+			writeTag(this.frameName, myDivId, newMapRequest);
+			var myMapId = this.elementName + "_map_" + ii;
+			eventAfterMapRequest.trigger({"frameName":this.elementName, "myMapId":myMapId});
+			return true;
+		}  
+		return false; 
+			
+	};
+	
+	this.mb_setFutureObj = function(mod_back_cnt){
+		var cnt = this.mb_MapFutureObj.length;
+		this.mb_MapFutureObj[cnt] = {};
+		this.mb_MapFutureObj[cnt].reqCnt = mod_back_cnt;
+		this.mb_MapFutureObj[cnt].width = this.width;
+		this.mb_MapFutureObj[cnt].height = this.height;
+		this.mb_MapFutureObj[cnt].epsg = this.epsg;
+		this.mb_MapFutureObj[cnt].extent = this.extent;
+		this.mb_MapFutureObj[cnt].layers = [];
+		
+		for(var i=0; i<this.layers.length;i++){
+			this.mb_MapFutureObj[cnt].layers[i] = this.layers[i];
+		}
+
+		this.mb_MapFutureObj[cnt].styles = [];
+
+		for(var i=0; i < this.styles.length;i++){
+			this.mb_MapFutureObj[cnt].styles[i] = this.styles[i];
+		}
+
+		this.mb_MapFutureObj[cnt].querylayers = [];
+
+		for(var i=0; i < this.querylayers.length; i++) {
+			this.mb_MapFutureObj[cnt].querylayers[i] = this.querylayers[i];
+		}
+	}
+	
+	this.setMapRequest = function(){
+		var functionName = 'setMapRequest';
+		
+		var ret = eventBeforeMapRequest.trigger({
+				frameName: this.frameName
+			}, "AND");
+		if (ret === false) {
+			return true;
+		}
+		var ts = mb_timestamp();
+		var myMapId = [];
+		
+		var newMapRequest = "";
+		
+		for (var ii = 0; ii < this.wms.length; ii++) {
+			var currentWms = this.wms[ii];
+		
+			if (!(currentWms.gui_wms_visible > 0)) {
+				continue;
+			}
+			myMapId.push(this.elementName + "_map_" + ii);
+			
+			newMapRequest += getLayerHtmlCode(ii);
+			
+		}
+		writeTag(this.frameName, this.elementName+"_maps", newMapRequest);
+
+		eventAfterMapRequest.trigger({
+			"frameName": this.elementName,
+			"myMapId": myMapId.join(",")
+		});
+	};
+
+	var that = this;
+
+	var getLayerHtmlCode = function (ii) {
+		var currentWms = that.wms[ii];
+	
+		var myDivId = that.elementName + "_div_" + ii;          
+		var myMapId = that.elementName + "_map_" + ii;
+
+		//disable Layer which are out of scale
+		var validLayers = that.checkScale(ii);
+		var layerNames = validLayers.toString();
+	
+		var newMapURL = false;
+		var opacityString = "";
+		
+		if (that.layers[ii] !== "" && layerNames !== ''){
+			// get map URL
+			newMapURL = that.getMapUrl(ii);
+	
+			var currentOpacity = currentWms.gui_wms_mapopacity;
+			if (currentOpacity != 1) {
+				opacityString += "opacity:" + currentOpacity + "; ";
+				opacityString += "Filter: Alpha(Opacity=" + currentOpacity*100 + "); ";
+				opacityString += "-moz-opacity:" + currentOpacity + " ; ";
+				opacityString += "-khtml-opacity:" + currentOpacity;
+			}
+		}
+	
+		var imageString = "";
+		if (newMapURL) {
+			imageString = "<img id='"+myMapId+"' name='mapimage' ";
+			imageString += "src='" + newMapURL + "' ";
+			imageString += "width='"+that.width+"' ";
+			imageString += "height='"+that.height+"' ";
+			imageString += "border='0'>";	
+		}
+	
+		var newMapRequest = "<div id='"+myDivId+"' ";
+		newMapRequest += "style=\"position:absolute; top:0px; left:0px; ";
+		newMapRequest += "z-index:" + ii + ";" + opacityString + "\">";
+		newMapRequest += imageString;
+		newMapRequest += "</div>";   
+	
+		that.mapURL[ii]= newMapURL;	
+		currentWms.mapURL = newMapURL;
+	
+		if (mb_log && currentWms.mapURL) {
+			var tmp = eval(mb_log + "('" +newMapURL + "','" + ts + "')");
+		}
+	
+		return newMapRequest;
+	}
+	
+	this.getWmsIdByTitle = function (title) {
+		for (var i=0; i < this.wms.length; i++) {
+			if (this.wms[i].wms_title == title) {
+				return this.wms[i].wms_id;
+			}
+		}
+		return null;
+	};
+
+	this.getWmsIndexById = function (wms_id) {
+		for (var i=0; i< this.wms.length; i++){
+			if(this.wms[i].wms_id == wms_id){
+				return i;
+			}
+		}
+		return null;
+	};
+
+	this.removeWms = function (wmsIndex) {
+		var wms_ID = null;
+		var i;
+		var new_wmsarray = [];
+		var new_layerarray = [];
+		var new_querylayerarray = [];
+		var new_stylesarray = [];
+		var new_mapURLarray = [];
+		
+		for	(i = 0; i < this.wms.length; i++) {
+			if (i != wmsIndex) {
+				new_wmsarray.push(this.wms[i]);
+				new_layerarray.push(this.layers[i]);
+				new_querylayerarray.push(this.querylayers[i]);
+				new_stylesarray.push(this.styles[i]);
+				new_mapURLarray.push(this.mapURL[i]);
+			}
+			else {
+				wms_ID = this.wms[i].wms_id;
+			}
+		}
+		this.wms = new_wmsarray; 
+		this.layers = new_layerarray; 
+		this.querylayers = new_querylayerarray; 
+		this.styles = new_stylesarray; 
+		this.mapURL = new_mapURLarray;
+	
+		var another_new_wmsarray = [];
+
+		for	(i = 0; i < window.wms.length; i++) {
+			if (window.wms[i].wms_id != wms_ID) {
+				another_new_wmsarray.push(window.wms[i]); 
+			}
+		}
+		window.wms = another_new_wmsarray; 
+	};
+	
+	/**
+	 * move a wms or layer 
+	 *
+	 * @param int wms_id id of wms to move
+	 * @param int layer_id id of layer to move
+	 * @return true of successful
+	 * @type boolean
+	 */
+	this.move = function(wms_id, layer_id, moveUp){
+		var i,j;
+		for(i=0;i<this.wms.length;i++){
+			if (wms_id == this.wms[i].wms_id) {
+				break;
+			}
+		}
+		
+		//check if only one wms is affected?
+		if (layer_id && layer_id != this.wms[i].objLayer[0].layer_id) {
+			return this.wms[i].moveLayer(layer_id, moveUp);
+		}
+		
+		//else swap wms
+		j = i + (moveUp?-1:1);
+		if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length)) {
+			return false;
+		}
+		
+		upper = this.wms[i];
+		this.wms[i] = this.wms[j];
+		this.wms[j] = upper;
+		var upperLayers = this.layers[i];
+		var upperStyles = this.styles[i];
+		var upperQuerylayers = this.querylayers[i];
+		this.layers[i] = this.layers[j];
+		this.styles[i] = this.styles[j];
+		this.querylayers[i] = this.querylayers[j];
+		this.layers[j] = upperLayers;
+		this.styles[j] = upperStyles;
+		this.querylayers[j] = upperQuerylayers;
+		
+		return true;
+	};
+	
+	this.getMousePos = function(e){
+		if(ie){
+			if(this.frameName){
+				clickX = window.frames[fName].event.clientX;
+				clickY = window.frames[fName].event.clientY;
+			}
+			else{
+				clickX = event.clientX;
+				clickY = event.clientY;
+			}
+		}
+		else{
+			clickX = e.pageX;
+			clickY = e.pageY;
+		}
+		
+		//remove divtag offset
+		clickX -= parseInt(this.getDomElement().style.left);
+		clickY -= parseInt(this.getDomElement().style.top);
+		
+		return new Point(clickX, clickY);
+	}
+
+	eventAfterMapObjectConstruction.trigger();
+}

Modified: branches/wfs11/http/javascripts/mod_digitize_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/javascripts/mod_digitize_tab.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -902,6 +902,9 @@
 					d.get(-1).wfs_conf = wfsConfId;
 					d.get(-1).e = wfsProperties;
 				}
+				// remove the original and the temporary polygon
+				d.del(0);
+				d.del(0);
 				parent.mb_disableThisButton(button_difference);
 			});
 		}
@@ -1204,7 +1207,7 @@
 				}
 					
 				// button: remove geometry from database
-				if (isValidWfsConfIndex(wfsConf, d.get(i).wfs_conf)) {
+				if (d.get(i).e.getElementValueByName('fid')) {
 					listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_removeDb_src+"' title='"+msgObj.buttonDig_removeDb_title+"' onclick=\"var deltrans = confirm('"+msgObj.messageConfirmDeleteGeomFromDb+"');if (deltrans) dbGeom('delete', "+i+")\">";
 				}
 				listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+"));' ";
@@ -1692,7 +1695,12 @@
 			for (var i=0; i<myform.length; i++){
 				if (myform.elements[i].id == "fid") {
 					fid = myform.elements[i].value;
-					d.get(m).e.setElement('fid', fid);
+					if (fid == "false") {
+						fid = false;
+					}
+					else {
+						d.get(m).e.setElement('fid', fid);
+					}
 				}
 				else if (myform.elements[i].type == 'text' ){
 					if (myform.elements[i].id) {
@@ -1730,23 +1738,24 @@
 }
 
 function wfsSubWrite(m, type, status, response, fid) {
-	if (type == 'save' && fid) {
-		d.get(m).e.setElement("fid", fid);
-	}
-	if (type == 'delete') {
-		parent.mb_disableThisButton(mod_digitizeEvent);
-		d.del(m);
-	}
-	parent.mb_execWfsWriteSubFunctions();
-	executeDigitizeSubFunctions();
-	
 	if (status == "success" && response == "success") {
+		if (type == 'save' && fid) {
+			d.get(m).e.setElement("fid", fid);
+		}
+		if (type == 'delete') {
+			parent.mb_disableThisButton(mod_digitizeEvent);
+			d.del(m);
+		}
+		
 		var wfsWriteMessage = msgObj.messageSuccessWfsWrite;
 	}
 	else {
 		var wfsWriteMessage = msgObj.messageErrorWfsWrite;
 	} 
 
+	parent.mb_execWfsWriteSubFunctions();
+	executeDigitizeSubFunctions();
+
 	if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
 		wfsWindow.alert(wfsWriteMessage);
 		window.setTimeout("wfsWindow.close()",0);

Modified: branches/wfs11/http/php/mod_loadwfs.php
===================================================================
--- trunk/mapbender/http/php/mod_loadwfs.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/php/mod_loadwfs.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -19,15 +19,31 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/mb_validateInput.php");
-require_once(dirname(__FILE__)."/../classes/class_wfs.php"); 
+require_once(dirname(__FILE__)."/../classes/class_universal_wfs_factory.php"); 
+require_once(dirname(__FILE__)."/../classes/class_gui.php"); 
 
 echo "file: ".$_REQUEST["xml_file"];
 echo "<br>-------------------------------<br>";
 
 $guiList = mb_validateInput($_REQUEST["guiList"]);
-$xml = mb_validateInput($_REQUEST["xml_file"]);
-$mywms = new wfs();
-$mywms->createObjFromXML($xml);      
-$mywms->wfs2db($guiList);
-$mywms->displayWFS();
+$url = mb_validateInput($_REQUEST["xml_file"]);
+
+
+$myWfsFactory = new UniversalWfsFactory();
+$myWfs = $myWfsFactory->createFromUrl($url);      
+
+$myWfs->insertOrUpdate();
+
+// link WFS to GUIs in $guiList
+$guiArray = explode(",", $guiList);
+foreach ($guiArray as $appName) {
+	$currentApp = new gui($appName);	
+	$currentApp->addWfs($myWfs);
+}
+
+echo $myWfs;
+
+print_r($myWfs);die;
+
+
 ?>
\ No newline at end of file

Modified: branches/wfs11/http/php/mod_wfs_server.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_server.php	2009-01-29 11:13:02 UTC (rev 3499)
+++ branches/wfs11/http/php/mod_wfs_server.php	2009-01-29 14:34:25 UTC (rev 3502)
@@ -3,6 +3,7 @@
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
 require_once(dirname(__FILE__)."/../classes/class_wfs.php");
 require_once(dirname(__FILE__) . "/../classes/class_json.php");
+require_once(dirname(__FILE__) . "/../classes/class_universal_wfs_factory.php");
 
 $json = new Mapbender_JSON();
 $obj = $json->decode(stripslashes($_REQUEST['obj']));
@@ -251,11 +252,17 @@
  */
 function deleteWfs($obj){
 	//$obj->success = false;
-	$sql = "DELETE FROM wfs WHERE wfs_id = $1";
-	$v = array($obj->wfs);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$obj->success = true;
+	$id = $obj->wfs;
+	
+	$wfsFactory = new UniversalWfsFactory();
+	$myWfs = $wfsFactory->createFromDb($id);
+	if ($myWfs->delete()) {
+		$obj->success = true;
+	}
+	else {
+		$obj->success = false;
+	}
+	
 	return true;
 }
 



More information about the Mapbender_commits mailing list