[Mapbender-commits] r1941 - tags/2.4.4/resources

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Dec 21 11:10:40 EST 2007


Author: christoph
Date: 2007-12-21 11:10:40 -0500 (Fri, 21 Dec 2007)
New Revision: 1941

Added:
   tags/2.4.4/resources/update_mapbender_2.4.3_to_2.4.4.diff
Log:
diff to 2.4.3

Added: tags/2.4.4/resources/update_mapbender_2.4.3_to_2.4.4.diff
===================================================================
--- tags/2.4.4/resources/update_mapbender_2.4.3_to_2.4.4.diff	                        (rev 0)
+++ tags/2.4.4/resources/update_mapbender_2.4.3_to_2.4.4.diff	2007-12-21 16:10:40 UTC (rev 1941)
@@ -0,0 +1,2876 @@
+Index: Changes.txt
+===================================================================
+--- Changes.txt	(revision 1939)
++++ Changes.txt	(working copy)
+@@ -4,6 +4,11 @@
+ 
+ ------------------------
+ 
++Changelog 2.4.4
++
++see http://www.mapbender.org/index.php/Template:Changelog_2.4.4
++
++
+ Changelog 2.4.3
+ 
+ see http://www.mapbender.org/index.php/Template:Changelog_2.4.3
+Index: http/classes/class_bbox.php
+===================================================================
+--- http/classes/class_bbox.php	(revision 0)
++++ http/classes/class_bbox.php	(revision 0)
+@@ -0,0 +1,285 @@
++<?php
++# $Id: class_bbox.php 1740 2007-10-26 10:12:53Z christoph $
++# http://www.mapbender.org/index.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__)."/../../conf/mapbender.conf");
++require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
++$con = db_connect(DBSERVER,OWNER,PW);
++db_select_db(DB,$con);
++
++/**
++ * A Mapbender_point is a 2-dimensional point with an EPSG. 
++ */
++class Mapbender_point {
++	var $x;
++	var $y;
++	var $epsg;
++	
++	/**
++	 * @constructor
++	 */
++	function __construct($x, $y, $epsg) {
++		if (!$x || !$y || !$epsg) {
++			$e = new mb_exception("Mapbender_point: constructor: some parameters are not set (set (x: ".$x.", y: ".$y.", epsg:".$epsg.")!");
++		}
++		$this->x = $x;
++		$this->y = $y;
++		$this->epsg = $epsg;
++	}
++	
++	/**
++	 * computes a new point with the minimal coordinates of this point and $point
++	 */
++	static function min ($point1, $point2) {
++		if ($point1->epsg == $point2->epsg) {
++			if ($point1->isWestOf($point2)) {
++				$minx = $point1->x;
++			}
++			else {
++				$minx = $point2->x;
++			}
++			if ($point1->isSouthOf($point2)) {
++				$miny = $point1->y;
++			}
++			else {
++				$miny = $point2->y;
++			}
++			return new Mapbender_point($minx, $miny, $point1->epsg);
++		}
++		else {
++			$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
++		}
++	}
++	
++	/**
++	 * computes a new point with the maximal coordinates of this point and $point
++	 */
++	static function max ($point1, $point2) {
++		if ($point1->epsg == $point2->epsg) {
++			if ($point1->isWestOf($point2)) {
++				$maxx = $point2->x;
++			}
++			else {
++				$maxx = $point1->x;
++			}
++			if ($point1->isSouthOf($point2)) {
++				$maxy = $point2->y;
++			}
++			else {
++				$maxy = $point1->y;
++			}
++			return new Mapbender_point($maxx, $maxy, $point1->epsg);
++		}
++		else {
++			$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
++		}
++	}
++	
++	function isWestOf($point) {
++		if ($this->x < $point->x) {
++			return true;
++		}
++	}
++
++	function isSouthOf($point) {
++		if ($this->y < $point->y) {
++			return true;
++		}
++	}
++	
++	/**
++	 * Addition
++	 * 
++	 * @param anotherPoint another Mapbender_point
++	 */
++	function plus ($anotherPoint) {
++		return new Mapbender_point($this->x + $anotherPoint->x, $this->y + $anotherPoint->y, $this->epsg);
++	}
++
++	/**
++	 * Subtraction
++	 * 
++	 * @param anotherPoint another Mapbender_point
++	 */
++	function minus ($anotherPoint) {
++		return $this->plus($anotherPoint->times(-1));
++	}
++	
++	/**
++	 * Scalar multiplication
++	 * 
++	 * @param aFloat a floating point number
++	 */
++	function times ($aFloat) {
++		return new Mapbender_point($this->x * $aFloat, $this->y * $aFloat, $this->epsg);
++	}
++
++	/**
++	 * transforms this point to another EPSG
++	 */
++	function transform($toEpsg) {
++		if(SYS_DBTYPE=='pgsql'){
++			$currentEpsg = preg_replace("/EPSG:/", "", $this->epsg);
++			$targetEpsg = preg_replace("/EPSG:/", "", $toEpsg);
++			$sql = "SELECT X(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as x, ";
++			$sql .= "Y(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as y";
++			$res = db_query($sql);
++			$point = new Mapbender_point(db_result($res,0,"x"), db_result($res,0,"y"), $toEpsg);
++			$this->x = $point->x;
++			$this->y = $point->y;
++			$this->epsg = $point->epsg;
++		}
++		else {
++			$e = new mb_exception("transformCoordinates needs PostgreSQL");
++		}
++	}
++	
++	function __toString() {
++		return (string) "(" . $this->x . "," . $this->y . "," . $this->epsg . ")";
++	}
++}
++
++/**
++ * A bounding box consisting of an lower left and an upper right point, and an EPSG.
++ */
++class Mapbender_bbox {
++	var $min;
++	var $max;
++	var $epsg;
++	
++	/**
++	 * @constructor
++	 */
++	function __construct($param0, $param1, $param2, $param3, $param4) {
++		// params are point, point, epsg
++		if (is_a($param0, "Mapbender_point") && is_a($param1, "Mapbender_point") && !$param3 && !$param4) {
++			$e = new mb_notice("Mapbender_bbox: constructor: point1, point2, epsg");
++			$min = $param0; // is a Mapbender_point
++			$max = $param1; // is a Mapbender_point
++			$epsg = $param2; // is an EPSG code like "EPSG:4326"
++			
++			if ($min->isWestOf($max) && $min->isSouthOf($max)) {
++				if ($min->epsg == $max->epsg && $min->epsg == $epsg) {
++					$this->min = $min;
++					$this->max = $max;
++					$this->epsg = $epsg;
++				}
++				else {
++					$e = new mb_exception("Mapbender_bbox: constructor: EPSG mismatch!");
++				}
++			}
++			else {
++				$e = new mb_exception("Mapbender_bbox: constructor: min (".$this->min.") is not southwest of max (".$this->max.")!");
++			}
++		}
++		// params are x1, y1, x2, xy, epsg
++		else {
++			$e = new mb_notice("Mapbender_bbox: constructor: x1, y1, x2, y2, epsg");
++			$min = new Mapbender_point($param0, $param1, $param4);
++			$max = new Mapbender_point($param2, $param3, $param4);
++			$epsg = $param4; // is an EPSG code like "EPSG:4326"
++			
++			if ($min->isWestOf($max) && $min->isSouthOf($max)) {
++				if ($min->epsg == $max->epsg && $min->epsg == $epsg) {
++					$this->min = $min;
++					$this->max = $max;
++					$this->epsg = $epsg;
++				}
++				else {
++					$e = new mb_exception("Mapbender_bbox: constructor: EPSG mismatch!");
++				}
++			}
++			else {
++				$e = new mb_exception("Mapbender_bbox: constructor: min (".$this->min.") is not southwest of max (".$this->max.")!");
++			}
++			
++		}
++	}
++	
++	/**
++	 * Computes a new bounding box, bbox1 UNION bbox2
++	 */
++	static function union ($bboxArray) {
++		if (count($bboxArray) == 1) {
++			return array_pop($bboxArray);
++		}
++		elseif (count($bboxArray) >= 2) {
++			
++			$bbox1 = array_pop($bboxArray);
++			$bbox2 = Mapbender_bbox::union($bboxArray);
++
++			if (!($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
++				$e = new mb_exception("Mapbender_bbox: union: both parameters invalid!");
++				return null;
++			}
++			elseif (!($bbox1 != null && $bbox1->isValid()) && ($bbox2 != null && $bbox2->isValid())) {
++				$e = new mb_exception("Mapbender_bbox: union: first parameter invalid!");
++				return $bbox2;
++			}
++			elseif (($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
++				$e = new mb_exception("Mapbender_bbox: union: second parameter invalid!");
++				return $bbox1;
++			}
++			else {
++				if ($bbox1->epsg == $bbox2->epsg) {
++					$e = new mb_notice("Mapbender_bbox: union: bbox1 is: " . $bbox1);
++					$e = new mb_notice("Mapbender_bbox: union: bbox2 is: " . $bbox2);
++					$e = new mb_notice("Mapbender_bbox: union: merging bbox1 and bbox2...");
++					return new Mapbender_bbox(Mapbender_point::min($bbox1->min, $bbox2->min), Mapbender_point::max($bbox1->max, $bbox2->max), $bbox1->epsg);
++				}
++				else {
++					$e = new mb_exception("Mapbender_bbox: cannot process union with different EPSG codes");
++				}
++			}
++		}
++		else {
++			$e = new mb_exception("Mapbender_bbox: Invalid parameter (Not an array)!");
++		}
++		return null;
++	}
++	
++	/**
++	 * transforms this bbox in another EPSG
++	 * @param toEpsg transform the bbox to this EPSG code, example: "EPSG:4326" 
++	 */
++	function transform($toEpsg) {
++		if ($this->isValid()) {
++			$this->epsg = $toEpsg;
++			$this->min->transform($toEpsg);
++			$this->max->transform($toEpsg);
++			return true;
++		}
++		return false;
++	}
++
++	/**
++	 * checks if lower left and upper right coordinate are set, as well as EPSG
++	 */
++	function isValid() {
++		if ($this->min != null && $this->max != null && $this->epsg != null) {
++			return true;
++		}
++		$e = new mb_exception("Mapbender_bbox: this is not a valid bbox!");
++		return false;
++	}
++	
++	function __toString() {
++		return (string) "[" . $this->min . $this->max . " " . $this->epsg . "]"; 
++	}
++}
++?>
+\ No newline at end of file
+Index: http/classes/class_gui.php
+===================================================================
+--- http/classes/class_gui.php	(revision 1939)
++++ http/classes/class_gui.php	(working copy)
+@@ -183,7 +183,7 @@
+ 				$error = true;
+ 			}
+ 
+-			$sql = "INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) SELECT '" . $newGuiName . "', e_id, e_pos, e_public, e_comment, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url FROM gui_element WHERE fkey_gui_id = '" . $guiList . "';";
++			$sql = "INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) SELECT '" . $newGuiName . "', e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url FROM gui_element WHERE fkey_gui_id = '" . $guiList . "';";
+ 			$res = db_query($sql);
+ 			if (!$res) {
+ 				$report .= "<br><br>" . $sql . "<br><br>" . db_error() . "<br>";
+@@ -204,14 +204,15 @@
+ 				$error = true;
+ 			}
+ 
+-			$sql = "INSERT INTO gui_mb_group (fkey_gui_id, fkey_mb_group_id, mb_group_type) SELECT '" . $newGuiName . "', fkey_mb_group_id, mb_group_type FROM gui_mb_group WHERE fkey_gui_id = '" . $guiList . "';";
+-			$res = db_query($sql);
+-			if (!$res) {
+-				$report .= "<br><br>" . $sql . "<br><br>" . db_error() . "<br>";
+-				$error = true;
+-			}
++			if ($withUsers == true) {
++				/* group of original gui is copied as well */
++				$sql = "INSERT INTO gui_mb_group (fkey_gui_id, fkey_mb_group_id, mb_group_type) SELECT '" . $newGuiName . "', fkey_mb_group_id, mb_group_type FROM gui_mb_group WHERE fkey_gui_id = '" . $guiList . "';";
++				$res = db_query($sql);
++				if (!$res) {
++					$report .= "<br><br>" . $sql . "<br><br>" . db_error() . "<br>";
++					$error = true;
++				}
+ 
+-			if ($withUsers == true) {
+ 				/* users of original gui are copied as well */
+ 				$sql = "INSERT INTO gui_mb_user (fkey_gui_id, fkey_mb_user_id, mb_user_type) SELECT '" . $newGuiName . "', fkey_mb_user_id, mb_user_type FROM gui_mb_user WHERE fkey_gui_id = '" . $guiList . "';";
+ 				$res = db_query($sql);
+Index: http/classes/class_mb_exception.php
+===================================================================
+--- http/classes/class_mb_exception.php	(revision 1939)
++++ http/classes/class_mb_exception.php	(working copy)
+@@ -29,6 +29,8 @@
+ 	var $mb_log_level = LOG_LEVEL;	
+ 	var $dir = "../../log/";
+ 	var $filename_prefix = "mb_error_";
++	var $result = false;
++	var $message = "";
+ 
+ 	function indexOf($level, $levelArray) {
+ 		$index = false;
+@@ -57,11 +59,31 @@
+ 				if($h = fopen($logfile,"a")){
+ 					$content = date("Y.m.d, H:i:s") . "," . $n .chr(13).chr(10);
+ 					if(!fwrite($h,$content)){
+-						#exit;
++						$this->result = false;
++						$this->message = "Unable to write " . $logfile;
++						return false;
+ 					}
+ 					fclose($h);
++					$this->result = true;
++					$this->message = "Successful.";
++					return true;
++				}
++				else {
++					$this->result = false;
++					$this->message = "Unable to open or generate " . $logfile;
++					return false;
+ 				}
+ 			}
++			else {
++				$this->result = false;
++				$this->message = "Directory " . $this->dir . " is not valid.";
++				return false;
++			}
++		}
++		else {
++			$this->result = false;
++			$this->message = "Log level '" . $level . "' is not valid or logging is disabled in mapbender.conf.";
++			return false; 
+ 		}
+ 	}
+ }
+@@ -70,7 +92,7 @@
+ 	var $level = "notice";
+ 	
+ 	function mb_notice($message) {
+-		$this->mb_log($message, $this->level);
++		return $this->mb_log("Notice: " . $message, $this->level);
+ 	}
+ }
+ 
+@@ -78,7 +100,7 @@
+ 	var $level = "warning";
+ 	
+ 	function mb_warning($message) {
+-		$this->mb_log($message, $this->level);
++		return $this->mb_log("Warning: " . $message, $this->level);
+ 	}
+ }
+ 
+@@ -86,7 +108,7 @@
+ 	var $level = "error";
+ 	
+ 	function mb_exception($message) {
+-		$this->mb_log($message, $this->level);
++		return $this->mb_log("ERROR: " . $message, $this->level);
+ 	}
+ }
+ ?>
+\ No newline at end of file
+Index: http/classes/class_wmc.php
+===================================================================
+--- http/classes/class_wmc.php	(revision 1939)
++++ http/classes/class_wmc.php	(working copy)
+@@ -1,5 +1,5 @@
+ <?php
+-# $Id: class_wmc.php 645 2006-12-08 12:58:39Z christoph $
++# $Id: class_wmc.php 1233 2007-10-19 14:28:21Z baudson $
+ # http://www.mapbender.org/index.php/class_wmc.php
+ # Copyright (C) 2002 CCGIS 
+ #
+@@ -16,12 +16,23 @@
+ # 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("../../conf/mapbender.conf");
+ require_once("../classes/class_wms.php");
+ require_once("../classes/class_mb_exception.php");
+-require_once("../classes/class_administration.php");
++require_once("../classes/class_bbox.php");
++require_once("../extensions/JSON.php");
++
++$con = db_connect(DBSERVER,OWNER,PW);
++db_select_db(DB,$con);
+ 
++function mb_utf8_encode ($str) {
++	if(CHARSET=="UTF-8") return utf8_encode($str);
++	return $str;
++}
++function mb_utf8_decode ($str) {
++	if(CHARSET=="UTF-8") return utf8_decode($str);
++	return $str;
++}
+ function sepNameSpace($s){
+ 	$c = strpos($s,":"); 
+ 	if($c>0)return substr($s,$c+1);
+@@ -29,218 +40,744 @@
+ }
+ class wmc {
+ 
+-		var $wmc_id;
+-		var $wmc_version;
+-		var $wmc_windowWidth;
+-		var $wmc_windowHeight;
+-		var $wmc_bBox_SRS;
+-		var $wmc_bBox_minx;
+-		var $wmc_bBox_maxx;
+-		var $wmc_bBox_miny;
+-		var $wmc_bBox_maxy;
+-		var $wmc_name;
+-		var $wmc_title;
+-		var $wmc_abstract;
+-		var $wmc_logourl;
+-		var $wmc_logourl_format;
+-		var $wmc_logourl_type;
+-		var $wmc_logourl_width;
+-		var $wmc_logourl_height;
+-		var $wmc_descriptionurl;
+-		var $wmc_descriptionurl_format;
+-		var $wmc_descriptionurl_type;
+-		var $wmc_keyword = array();
+-		var $wmc_contactposition;
+-		var $wmc_contactvoicetelephone;
+-		var $wmc_contactemail;
+-		var $wmc_contactfacsimiletelephone;
+-		var $wmc_contactperson;
+-		var $wmc_contactorganization;
+-		var $wmc_contactaddresstype;
+-		var $wmc_contactaddress;
+-		var $wmc_contactcity;
+-		var $wmc_contactstateorprovince;
+-		var $wmc_contactpostcode;
+-		var $wmc_contactcountry;
+-					
+-		var $wmc_wms_title = array();
+-		var $wmc_layer_queryable = array();
+-		var $wmc_layer_querylayer = array();
+-		var $wmc_layer_hidden = array();
+-		var $wmc_wms_id = array();
+-		var $wmc_wms_service = array();
+-		var $wmc_wms_version = array();
+-		var $wmc_layer_id = array();
+-		var $wmc_layer_title = array();
+-		var $wmc_layer_name = array();
+-		var $wmc_layer_abstract = array();
+-		var $wmc_layer_srs = array();
+-		var $wmc_wms_serviceURL = array();
+-		var $wmc_layer_format_current = array();
+-		var $wmc_layer_dataurl = array();
+-		var $wmc_layer_metadataurl = array();
+-		var $wmc_layer_minscale = array();
+-		var $wmc_layer_maxscale = array();
+-		var $wmc_layer_format = array();
+-		var $wmc_layer_style_current = array();
+-		var $wmc_layer_style_name = array();
+-		var $wmc_layer_style_title = array();
+-		var $wmc_layer_style_legendurl = array();
+-		var $wmc_layer_style_legendurl_width = array();
+-		var $wmc_layer_style_legendurl_height = array();
+-		var $wmc_layer_style_legendurl_format = array();
+-		var $wmc_layer_style_legendurl_type = array();
+-		var $wmc_layer_style_sld_url = array();
+-		var $wmc_layer_style_sld_type = array();
+-		var $wmc_layer_style_sld_title = array();
+-		var $wmc_wms_count = 0;
++	var $xml;
++	
++	var $wmc_id;
++	var $wmc_version;
++	var $wmc_windowWidth;
++	var $wmc_windowHeight;
++	var $wmc_bBox_SRS;
++	var $wmc_bBox_minx;
++	var $wmc_bBox_maxx;
++	var $wmc_bBox_miny;
++	var $wmc_bBox_maxy;
++	var $wmc_name;
++	var $wmc_title;
++	var $wmc_abstract;
++	var $wmc_general_extension = array();
++	var $wmc_logourl;
++	var $wmc_logourl_format;
++	var $wmc_logourl_type;
++	var $wmc_logourl_width;
++	var $wmc_logourl_height;
++	var $wmc_descriptionurl;
++	var $wmc_descriptionurl_format;
++	var $wmc_descriptionurl_type;
++	var $wmc_keyword = array();
++	var $wmc_contactposition;
++	var $wmc_contactvoicetelephone;
++	var $wmc_contactemail;
++	var $wmc_contactfacsimiletelephone;
++	var $wmc_contactperson;
++	var $wmc_contactorganization;
++	var $wmc_contactaddresstype;
++	var $wmc_contactaddress;
++	var $wmc_contactcity;
++	var $wmc_contactstateorprovince;
++	var $wmc_contactpostcode;
++	var $wmc_contactcountry;
++				
++				
++	var $wmc_wms_title = array();
++	var $wmc_layer_queryable = array();
++	var $wmc_layer_hidden = array();
++	var $wmc_wms_id = array();
++	var $wmc_wms_service = array();
++	var $wmc_wms_version = array();
++	var $wmc_wms_layer_id = array();
++	var $wmc_layer_wfs_featuretype = array();
++	var $wmc_layer_id = array();
++	var $wmc_layer_pos = array();
++	var $wmc_layer_parent = array();
++	var $wmc_layer_querylayer = array();
++	var $wmc_layer_title = array();
++	var $wmc_layer_name = array();
++	var $wmc_layer_abstract = array();
++	var $wmc_layer_srs = array();
++	var $wmc_wms_serviceURL = array();
++	var $wmc_layer_format_current = array();
++	var $wmc_layer_dataurl = array();
++	var $wmc_layer_metadataurl = array();
++	var $wmc_layer_minscale = array();
++	var $wmc_layer_maxscale = array();
++	var $wmc_gui_layer_minscale = array();
++	var $wmc_gui_layer_maxscale = array();
++	var $wmc_layer_format = array();
++	var $wmc_layer_style_current = array();
++	var $wmc_layer_style_name = array();
++	var $wmc_layer_style_title = array();
++	var $wmc_layer_style_legendurl = array();
++	var $wmc_layer_style_legendurl_width = array();
++	var $wmc_layer_style_legendurl_height = array();
++	var $wmc_layer_style_legendurl_format = array();
++	var $wmc_layer_style_legendurl_type = array();
++	var $wmc_layer_style_sld_url = array();
++	var $wmc_layer_style_sld_type = array();
++	var $wmc_layer_style_sld_title = array();
++	
++	var $wmc_wms_count = 0;
+ 			
+-	function wmc() {	
+-	} 
++	/*	
++	 	var $data_type = array(); 
++		var $data_format = array();
++		
++		var $objLayer = array(); 
++		  
++		var $gui_wms_mapformat;
++		var $gui_wms_featureinfoformat;
++		var $gui_wms_exceptionformat;
++		var $gui_wms_epsg;
++		  
++		var $default_epsg = 0;
++  */
++	var $monitoringIsOn = false;
++  		
++function wmc() {
++} 
++
++function saveAsFile() {
++	$filename = "wmc_" . date("Y_m_d_H_i_s") . ".log";
++	$logfile = "../../log/" . $filename;
+ 	
+-	function getTitle() {
+-		return $this->wmc_title;
++	if($h = fopen($logfile,"a")){
++		$content = $this->xml;
++		if(!fwrite($h,$content)){
++			$e = new mb_exception("class_wmc.php: failed to write wmc.");
++			return false;
++		}
++		fclose($h);
+ 	}
++	return $filename;
++}
++
++function getTitle() {
++	return $this->wmc_title;
++}
++
++function getNumberOfWms () {
++	return $this->wmc_wms_count;
++}
++
++function createWMCFromObj($mapObject, $user_id, $generalTitle, $extensionData) {
++	$this->wmc_id = $user_id . '_' . time();
+ 	
+-	function getNumberOfWms () {
+-		return $this->wmc_wms_count;
+-	}
+-
+-	function createObjFromWMC_id($wmc_id){
+-		
+-		$con = db_connect(DBSERVER,OWNER,PW);
+-		db_select_db(DB, $con);
++	$generalWidth = $mapObject->width;
++	$generalHeight = $mapObject->height;
++	$generalBboxSrs = $mapObject->epsg;
++	
++	$arrayBBox = explode(",", $mapObject->extent);
++	$generalBboxMinx = floatval($arrayBBox[0]);
++	$generalBboxMiny = floatval($arrayBBox[1]);
++	$generalBboxMaxx = floatval($arrayBBox[2]);
++	$generalBboxMaxy = floatval($arrayBBox[3]);
++	
++	$generalName = "Mapbender WMC"; // TO do : insert proper data
++	$generalKeywords = array("Mapbender", "WMC"); // TO do : insert proper data
++	$generalAbstract = ""; // TO do : insert proper data
++	$generalLogoUrl = ""; // TO do : insert proper data
++	$generalLogoUrlWidth = ""; // TO do : insert proper data
++	$generalLogoUrlHeight = ""; // TO do : insert proper data
++	$generalLogoUrlFormat = ""; // TO do : insert proper data
++	$generalDescriptionUrl = ""; // TO do : insert proper data
++	$generalContactPerson = "";
++	$generalContactOrganization = "";
++	$generalContactPosition = "";
++	$generalContactAddressType = "";
++	$generalContactAddress = "";
++	$generalContactCity = "";
++	$generalContactStateOrProvince = "";
++	$generalContactPostCode = "";
++	$generalContactCountry = "";
++	$generalContactVoiceTelephone = "";
++	$generalContactFacsimileTelephone = "";
++	$generalContactElectronicMailAddress = "";
++			
++	$extension_namespace = "mapbender";
++	
++	// LayerList variables
++	$layerHidden = "";
++	$layerQueryable = "";
++	$layerAbstract = "";
++	$layerName = "";
++	$layerSrs = "";
++	$layerDataUrl = "";
++	$layerMetadataUrl = "";
++	$layerFormat = "";
++	$layerFormat_current = "";
++	$layerStyle_current = "";
++	$layerStyle_name = "";
++	$layerStyle_title = "";
++	$layerStyle_legendURL = "";
++	$layerStyle_legendURL_width = "";
++	$layerStyle_legendURL_height = "";
++	$layerStyle_legendURL_format = "";		
++	
++	// generate XML
++	$doc = new DOMDocument("1.0", CHARSET);
++	$doc->preserveWhiteSpace = false;
++	
++	// ViewContext
++	$e_view_context = $doc->createElementNS("http://www.opengis.net/context", "ViewContext");
++	
++	
++	$e_view_context->setAttribute("version", "1.0.0");
++	$e_view_context->setAttribute("id", $this->wmc_id);
++	$e_view_context->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
++	$e_view_context->setAttribute("xmlns:mapbender", "http://www.mapbender.org");
++	$e_view_context->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
++	$e_view_context->setAttribute("xsi:SchemaLocation", "http://schemas.opengis.net/context/1.0.0/context.xsd");
++	
++		// General
++		$e_general = $doc->createElement("General");
++	
++			$e_window = $doc->createElement("Window");
++			if (!empty($generalWidth) && !empty($generalHeight)) {
++				$e_window->setAttribute("width", $generalWidth);
++				$e_window->setAttribute("height", $generalHeight);
++			}
++			$e_general->appendChild($e_window);
++			
++			$e_bbox = $doc->createElement("BoundingBox");
++			$e_bbox->setAttribute("SRS", $generalBboxSrs);
++			$e_bbox->setAttribute("minx", $generalBboxMinx);
++			$e_bbox->setAttribute("miny", $generalBboxMiny);
++			$e_bbox->setAttribute("maxx", $generalBboxMaxx);
++			$e_bbox->setAttribute("maxy", $generalBboxMaxy);
++			$e_general->appendChild($e_bbox);
++			
++			$e_name = $doc->createElement("Name", $generalName);
++			$e_general->appendChild($e_name);
++			
++			$e_title = $doc->createElement("Title", $generalTitle);
++			$e_general->appendChild($e_title);
++			
++			$e_keyword_list = $doc->createElement("KeywordList");
++			for ($i=0; $i < count($generalKeywords); $i++) {
++				$e_keyword = $doc->createElement("Keyword", $generalKeywords[$i]);
++				$e_keyword_list->appendChild($e_keyword);
++			}
++			$e_general->appendChild($e_keyword_list);
++			
++			if ($generalAbstract){
++				$e_abstract = $doc->createElement("Abstract", $generalAbstract);
++				$e_general->appendChild($e_abstract);
++			}
++			
++			if ($generalLogoUrlWidth && $generalLogoUrlHeight && $generalLogoUrlFormat && $generalLogoUrl){
++				$e_logo_url = $doc->createElement("LogoURL");
++				$e_logo_url->setAttribute("width", $generalLogoUrlWidth);
++				$e_logo_url->setAttribute("height", $generalLogoUrlHeight);
++				$e_logo_url->setAttribute("format", $generalLogoUrlFormat);
++			
++				$e_logo_url_or = $doc->createElement("OnlineResource");
++				$e_logo_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
++				$e_logo_url_or->setAttribute("xlink:type", "simple");
++				$e_logo_url_or->setAttribute("xlink:href", $generalLogoUrl);
++				$e_logo_url->appendChild($e_logo_url_or);
++	
++				$e_general->appendChild($e_logo_url);
++			}
++				
++			if ($generalDescriptionUrl){
++				$e_description_url = $doc->createElement("DescriptionURL");
++	
++				$e_description_url_or = $doc->createElement("OnlineResource");
++				$e_description_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
++				$e_description_url_or->setAttribute("xlink:type", "simple");
++				$e_description_url_or->setAttribute("xlink:href", $generalDescriptionUrl);
++				$e_description_url->appendChild($e_description_url_or);
++	
++				$e_general->appendChild($e_description_url);
++			}
++			
++			if ($generalContactElectronicMailAddress || $generalContactOrganization ||
++				$generalContactPerson || $generalContactPosition || $generalContactAddressType ||
++				$generalContactAddress || $generalContactCity || $generalContactStateOrProvince ||
++				$generalContactPostCode || $generalContactCountry || $generalContactVoiceTelephone ||
++				$generalContactFacsimileTelephone || $generalContactElectronicMailAddress) {
++			
++				$e_contact = $doc->createElement("ContactInformation");
++			
++				if ($generalContactPerson || $generalContactOrganization){
++					$e_contact_person_primary = $doc->createElement("ContactPersonPrimary");
++			
++					if ($generalContactPerson){
++						$e_contact_person = $doc->createElement("ContactPerson", $generalContactPerson);
++						$e_contact_person_primary->appendChild($e_contact_person);
++					}
++					if ($generalContactOrganization){
++						$e_contact_organization = $doc->createElement("ContactOrganization", $generalContactOrganization);
++						$e_contact_person_primary->appendChild($e_contact_organization);
++					}
++					$e_contact->appendChild($e_contact_person_primary);
++				}
++			
++				if ($generalContactPosition){
++					$e_contact_position = $doc->createElement("ContactPosition", $generalContactPosition);
++					$e_contact->appendChild($e_contact_position);
++				}
++			
++				if ($generalContactAddressType || $generalContactAddress || 
++					$generalContactCity || $generalContactStateOrProvince ||
++					$generalContactPostCode || $generalContactCountry) {
++			
++					$e_contact_address = $doc->createElement("ContactAddress");
++			
++					if ($generalContactAddressType){
++						$e_address_type = $doc->createElement("AddressType", $generalContactAddressType);
++						$e_contact_address->appendChild($e_address_type);
++					}
++					if ($generalContactAddress){
++						$e_address = $doc->createElement("Address", $generalContactAddress);
++						$e_contact_address->appendChild($e_address);
++					}
++					if ($generalContactCity){
++						$e_city = $doc->createElement("City", $generalContactCity);
++						$e_contact_address->appendChild($e_city);
++					}
++					if ($generalContactStateOrProvince){
++						$e_state = $doc->createElement("StateOrProvince", $generalContactStateOrProvince);
++						$e_contact_address->appendChild($e_state);
++					}
++					if ($generalContactPostCode){
++						$e_postcode = $doc->createElement("PostCode", $generalContactPostCode);
++						$e_contact_address->appendChild($e_postcode);
++					}
++					if ($generalContactCountry){
++						$e_country = $doc->createElement("Country", $generalContactCountry);
++						$e_contact_address->appendChild($e_country);
++					}
++					$e_contact->appendChild($e_contact_address);
++				}
++				
++				if ($generalContactVoiceTelephone){
++					$e_voice_telephone = $doc->createElement("ContactVoiceTelephone", $generalContactVoiceTelephone);
++					$e_contact->appendChild($e_voice_telephone);
++				}
++				if ($generalContactFacsimileTelephone){
++					$e_facsimile_telephone = $doc->createElement("ContactFacsimileTelephone", $generalContactFacsimileTelephone);
++					$e_contact->appendChild($e_facsimile_telephone);
++				}
++				if ($generalContactElectronicMailAddress){
++					$e_email = $doc->createElement("ContactElectronicMailAddress", $generalContactElectronicMailAddress);
++					$e_contact->appendChild($e_email);
++				}
++				$e_general->appendChild($e_contact);
++			}
++			
++			
++			if (count($extensionData) > 0) {
++				//$e = new mb_exception("writing wmc...");
++				$e_extensionGeneral = $doc->createElement("Extension");
++				
++				foreach ($extensionData as $keyExtensionData => $valueExtensionData) {
++					$e_currentExtensionTag = $doc->createElement($extension_namespace.":".$keyExtensionData, $valueExtensionData);
++					$e_extensionGeneral->appendChild($e_currentExtensionTag);
++				}
++				$e_general->appendChild($e_extensionGeneral);
++			}
++		$e_view_context->appendChild($e_general);
++	
++	
++		// LayerList
++		$e_layer_list = $doc->createElement("LayerList");
++	
++		for ($i=0; $i < count($mapObject->wms); $i++){
++			$wmsId = $mapObject->wms[$i]->wms_id;
++			$wms_epsg = array();
++			$wms_epsg[0] = $mapObject->epsg;
+ 		
+-		$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = $1";
+-		$v = array($wmc_id);
+-		$t = array("s");
+-		$res = db_prep_query($sql, $v, $t);
+-		$wmc = db_fetch_array($res);
+-		$this->createObjFromWMC_xml($wmc[0]);
++			if ($mapObject->wms[$i]->gui_wms_epsg != $mapObject->epsg){
++				$wms_epsg[1] = $mapObject->wms[$i]->gui_wms_epsg;
++			}
+ 	
+-	}
++			for ($q = 0; $q < count($mapObject->wms[$i]->gui_epsg); $q++){
++				$isInArray = false;
++				
++				for ($r=0 ; $r < count($wms_epsg); $r++){
++					if ($wms_epsg[$r] == $mapObject->wms[$i]->gui_epsg[$q]){
++						$isInArray = true;
++					}
++				}
++				if ($isInArray == false){
++					array_push($wms_epsg, $mapObject->wms[$i]->gui_epsg[$q]);
++				}
++			}
++			for ($j = 0; $j < count($mapObject->wms[$i]->objLayer); $j++){
++				if ($mapObject->wms[$i]->objLayer[$j]->layer_parent != ''){
++					if ($mapObject->wms[$i]->objLayer[$j]->gui_layer_visible == "1"){
++						$layerHidden = 0;
++					}
++					else{
++						$layerHidden = 1;
++					}
++					$layerQueryable = $mapObject->wms[$i]->objLayer[$j]->layer_queryable;
++					$layerQuerylayer = $mapObject->wms[$i]->objLayer[$j]->gui_layer_querylayer;
++					$layerId = $mapObject->wms[$i]->objLayer[$j]->layer_uid;
++					$layerName = $mapObject->wms[$i]->objLayer[$j]->layer_name;
++					$layerTitle = $mapObject->wms[$i]->objLayer[$j]->layer_title;
++					$layerAbstract = $mapObject->wms[$i]->wms_abstract; //To Do: insert actual abstract
++					$layerDataUrl = $mapObject->wms[$i]->objLayer[$j]->layer_dataurl_href; 
++					$layerMetadataUrl = $mapObject->wms[$i]->objLayer[$j]->layer_metadataurl;
++					$layerMinscale = $mapObject->wms[$i]->objLayer[$j]->layer_minscale; 
++					$layerMaxscale = $mapObject->wms[$i]->objLayer[$j]->layer_maxscale; 
++					$guiLayerMinscale = $mapObject->wms[$i]->objLayer[$j]->gui_layer_minscale; 
++					$guiLayerMaxscale = $mapObject->wms[$i]->objLayer[$j]->gui_layer_maxscale; 
++					$wmsVersion = $mapObject->wms[$i]->wms_version;
++					$wmsTitle = $mapObject->wms[$i]->wms_title;
++					$wmsLayerId = $mapObject->wms[$i]->objLayer[0]->layer_uid;
++					$wmsOnlineResource = $mapObject->wms[$i]->wms_getmap;
++					$layerPos = $mapObject->wms[$i]->objLayer[$j]->layer_pos;
++					$layerParent = $mapObject->wms[$i]->objLayer[$j]->layer_parent;
++					$queryLayer = $mapObject->wms[$i]->objLayer[$j]->gui_layer_querylayer;
++					$wfsFeatureType = $mapObject->wms[$i]->objLayer[$j]->gui_layer_wfs_featuretype;
++					
++					$e_layer = $doc->createElement("Layer");
++					$e_layer->setAttribute("queryable", $layerQueryable);
++					$e_layer->setAttribute("hidden", $layerHidden);
++		
++						$e_service = $doc->createElement("Server");
++						$e_service->setAttribute("service", "OGC:WMS");
++						$e_service->setAttribute("version", $wmsVersion);
++						$e_service->setAttribute("title", $wmsTitle);
++		
++						$e_service_or = $doc->createElement("OnlineResource");
++						$e_service_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
++						$e_service_or->setAttribute("xlink:type", "simple");
++						$e_service_or->setAttribute("xlink:href", $wmsOnlineResource);
++						
++						$e_service->appendChild($e_service_or);
++						$e_layer->appendChild($e_service);
++		
++						$e_layer_name = $doc->createElement("Name", $layerName);
++						$e_layer->appendChild($e_layer_name);
++		
++						$e_layer_title = $doc->createElement("Title", $layerTitle);
++						$e_layer->appendChild($e_layer_title);
++		
++						if ($layerAbstract){
++							$e_layer_abstract = $doc->createElement("Abstract", $layerAbstract);
++							$e_layer->appendChild($e_layer_abstract);
++						}
++		
++						$e_layer_srs = $doc->createElement("SRS", implode(" ", $wms_epsg));
++						$e_layer->appendChild($e_layer_name);
++		
++						if ($layerDataUrl){
++							$e_layer_data_url = $doc->createElement("DataURL");
++			
++							$e_layer_data_url_or = $doc->createElement("OnlineResource");
++							$e_layer_data_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
++							$e_layer_data_url_or->setAttribute("xlink:type", "simple");
++							$e_layer_data_url_or->setAttribute("xlink:href", $layerDataUrl);
++							
++							$e_layer_data_url->appendChild($e_layer_data_url_or);
++							$e_layer->appendChild($e_layer_data_url);
++						}
++		
++						if ($layerMetadataUrl){
++							$e_layer_metadata_url = $doc->createElement("MetadataURL");
++			
++							$e_layer_metadata_url_or = $doc->createElement("OnlineResource");
++							$e_layer_metadata_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
++							$e_layer_metadata_url_or->setAttribute("xlink:type", "simple");
++							$e_layer_metadata_url_or->setAttribute("xlink:href", $layerMetadataUrl);
++							
++							$e_layer_metadata_url->appendChild($e_layer_metadata_url_or);
++							$e_layer->appendChild($e_layer_metadata_url);
++						}
++		
++						$e_extension = $doc->createElement("Extension");
++		
++						$e_scalehint = $doc->createElement($extension_namespace.":ScaleHint");
++						$e_scalehint->setAttribute("min", $layerMinscale);
++						$e_scalehint->setAttribute("max", $layerMaxscale);
++						$e_extension->appendChild($e_scalehint);
++						
++						$e_gui_scalehint = $doc->createElement($extension_namespace.":guiScaleHint");
++						$e_gui_scalehint->setAttribute("min", $guiLayerMinscale);
++						$e_gui_scalehint->setAttribute("max", $guiLayerMaxscale);
++						$e_extension->appendChild($e_gui_scalehint);
++						
++						$e_layer_id = $doc->createElement($extension_namespace.":layer_id", $layerId);
++						$e_extension->appendChild($e_layer_id);
++						
++						$e_wms_layer_id = $doc->createElement($extension_namespace.":wms_layer_id", $wmsLayerId);
++						$e_extension->appendChild($e_wms_layer_id);
++						
++						$e_layer_pos = $doc->createElement($extension_namespace.":layer_pos", $layerPos);
++						$e_extension->appendChild($e_layer_pos);
++		
++						$e_layer_parent = $doc->createElement($extension_namespace.":layer_parent", $layerParent);
++						$e_extension->appendChild($e_layer_parent);
++		
++						$e_wms_id = $doc->createElement($extension_namespace.":wms_id", $wmsId);
++						$e_extension->appendChild($e_wms_id);
++		
++						$e_querylayer = $doc->createElement($extension_namespace.":querylayer", $layerQuerylayer);
++						$e_extension->appendChild($e_querylayer);
++						
++						if ($wfsFeatureType) {
++							$e_wfsFeatureType = $doc->createElement($extension_namespace.":wfsFeatureType", $wfsFeatureType);
++							$e_extension->appendChild($e_wfsFeatureType);
++						}
+ 
+-	function createObjFromWMC_xml($data){
+-		$values = NULL;
+-		$tags = NULL;
+-		$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,$data,$values,$tags);
+-		$code = xml_get_error_code ($parser);
+-		if ($code) {
+-			$line = xml_get_current_line_number($parser); 
+-			$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
+-			return false;
+-		}
+-		xml_parser_free($parser);
++						$e_layer->appendChild($e_extension);
++		
++						//layerFormat
++						$e_layer_format = $doc->createElement("FormatList");
++		
++						$data_format_current = false;
++		
++						for ($k = 0; $k < count($mapObject->wms[$i]->data_format); $k++){
++		
++							if ($mapObject->wms[$i]->data_type[$k] == "map") {
++								$layerFormat = $mapObject->wms[$i]->data_format[$k];
++				
++								$e_format = $doc->createElement("Format", $layerFormat);
++		
++								if ($data_format_current == false && ( 
++										($mapObject->wms[$i]->data_format[$k] == $mapObject->wms[$i]->gui_wms_mapformat) ||
++										($k == (count($mapObject->wms[$i]->data_format)-1))
++								)){
++		
++									$e_format->setAttribute("current", "1");
++									$data_format_current = true;
++								}
++								$e_layer_format->appendChild($e_format);
++							}
++						}
++						$e_layer->appendChild($e_layer_format);
++		
++		
++						// LayerStyle
++						$e_layer_stylelist = $doc->createElement("StyleList");
++			
++						for ($k = 0; $k < count($mapObject->wms[$i]->objLayer[$j]->layer_style); $k++){
++		
++							if ($k == 0){
++								$layerStyle_current = 1; // To do: insert proper data
++							}
++							else{
++								$layerStyle_current = 0; // To do: insert proper data
++							}
+ 		
+-		$section = NULL;
+-		$format = NULL;
+-		$cnt_format = 0;
+-		$parent = array();
+-		$myParent = array();
+-		$cnt_layer = -1;
+-		$request = NULL; 
+-		$layer_style = array();
+-		$cnt_style = -1;
+-		$extension = false;
++							$e_layer_style = $doc->createElement("Style");
+ 		
+-		$general = false;
+-		$layerlist = false;
+-		$layer = false;
+-		$formatlist = false;
+-		$metadataurl = false;
+-		$dataurl = false;
+-		$stylelist = false;
++							$layerStyleSLD = "";
+ 		
+-		foreach ($values as $element) {
+-			if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "open"){
+-					$this->wmc_id = $element[attributes]["id"];
+-					$this->wmc_version = $element[attributes]["version"];
++							if ($layerStyleSLD){
++								$layerStyleSLDUrl = ""; // To Do: Insert Proper Data
++								
++								$e_layer_style_or = $doc->createElement("OnlineResource");
++								$e_layer_style_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
++								$e_layer_style_or->setAttribute("xlink:type", "simple");
++								$e_layer_style_or->setAttribute("xlink:href", $layerStyleSLDUrl);
++								$e_layer_style->appendChild($e_layer_style_or);
++							}
++							else{
++								//TODO: determine correct layer style entries
++								$layerStyle_name = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->name;
++								$layerStyle_title = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->title;
++								$layerStyle_legendUrl = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->legendurl;
++								$layerStyle_legendUrl_width = ""; // To Do: add proper data
++								$layerStyle_legendUrl_height = ""; // To Do: add proper data
++								$layerStyle_legendUrl_format = ""; // To Do: add proper data
++		
++								if ($layerStyle_current == 1){
++									$e_layer_style->setAttribute("current", "1");
++								}
++	
++								$e_layer_style_name = $doc->createElement("Name", $layerStyle_name);
++								$e_layer_style->appendChild($e_layer_style_name);
++	
++								$e_layer_style_title = $doc->createElement("Title", $layerStyle_title);
++								$e_layer_style->appendChild($e_layer_style_title);
++								
++								
++								$e_layer_style_legendurl = $doc->createElement("LegendUrl");
++								$e_layer_style_legendurl->setAttribute("width", $layerStyle_legendUrl_width);
++								$e_layer_style_legendurl->setAttribute("height", $layerStyle_legendUrl_height);
++								$e_layer_style_legendurl->setAttribute("format", $layerStyle_legendUrl_format);
++	
++								$e_layer_style_legendurl_or = $doc->createElement("OnlineResource");
++								$e_layer_style_legendurl_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
++								$e_layer_style_legendurl_or->setAttribute("xlink:type", "simple");
++								$e_layer_style_legendurl_or->setAttribute("xlink:href", $layerStyle_legendUrl);
++								$e_layer_style_legendurl->appendChild($e_layer_style_legendurl_or);
++								$e_layer_style->appendChild($e_layer_style_legendurl);
++							}
++							$e_layer_stylelist->appendChild($e_layer_style);
++						}	
++						$e_layer->appendChild($e_layer_stylelist);
++						
++					$e_layer_list->appendChild($e_layer);
++				}
+ 			}
+-			if(strtoupper($element[tag]) == "GENERAL" && $element[type] == "open"){
+-			   $general = true;
+-			}
+-			if(strtoupper($element[tag]) == "LAYERLIST" && $element[type] == "open"){
+-			   $layerlist = true;
+-			}
+-			if ($general) {
++		}
++		$e_view_context->appendChild($e_layer_list);
++	
++	
++	$doc->appendChild($e_view_context);
++	$this->xml = $doc->saveXML();
++	
++	// for debugging: saving WMC as file
++	// (comment when no longer needed)
++	$filename = $this->saveAsFile();
++	if ($filename) {
++		$e = new mb_notice("class_wmc: saving WMC as file " . $filename);
++	}
++}
++
++function createObjFromWMC_id($wmc_id){
++	
++	global $DBSERVER,$DB,$OWNER,$PW;
++	$con = db_connect($DBSERVER,$OWNER,$PW);
++	db_select_db(DB, $con);
++	
++	$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = '" . $wmc_id . "'";
++	$res = db_query($sql);
++	$wmc = db_fetch_row($res);
++	$this->createObjFromWMC_xml($wmc[0]);
++	$this->monitoringIsOn = true;
++
++}
++function createObjFromWMC_xml($data){
++#	$data = str_replace("&#38;", "&amp;", $data);
++
++	// store xml 
++	$this->xml = $data;
++
++	// for debugging: saving WMC as file
++	// (comment when no longer needed)
++	$filename = $this->saveAsFile();
++	if ($filename) {
++		$e = new mb_notice("class_wmc: saving WMC as file " . $filename);
++	}
++
++
++
++	$values = NULL;
++	$tags = NULL;
++	$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,$data,$values,$tags);
++	$code = xml_get_error_code ($parser);
++	if ($code) {
++		$line = xml_get_current_line_number($parser); 
++		$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
++		return false;
++	}
++	xml_parser_free($parser);
++	
++	$section = NULL;
++	$format = NULL;
++	$cnt_format = 0;
++	$parent = array();
++	$myParent = array();
++	$cnt_layer = -1;
++	$request = NULL; 
++	$layer_style = array();
++	$extension = false;
++	
++	$general = false;
++	$layerlist = false;
++	$layer = false;
++	$formatlist = false;
++	$dataurl = false;
++	$metadataurl = false; 
++	$stylelist = false;
++	$cnt_style = -1;
++		 
++	foreach ($values as $element) {
++					$verbose .= ".";
++		if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "open"){
++				$this->wmc_id = $element[attributes]["id"];
++				$this->wmc_version = $element[attributes]["version"];
++		}
++		if(strtoupper($element[tag]) == "GENERAL" && $element[type] == "open"){
++		   $general = true;
++		}
++		if(strtoupper($element[tag]) == "LAYERLIST" && $element[type] == "open"){
++		   $layerlist = true;
++		}
++		if ($general) {
+ 				if(strtoupper($element[tag]) == "WINDOW"){
+-					$this->wmc_windowWidth = $element[attributes]["width"];
+-					$this->wmc_windowHeight = $element[attributes]["height"];
++						$this->wmc_windowWidth = $element[attributes]["width"];
++						$this->wmc_windowHeight = $element[attributes]["height"];
+ 				}
+ 				if(strtoupper($element[tag]) == "BOUNDINGBOX"){
+-					$this->wmc_bBox_SRS = $element[attributes]["SRS"];
+-					$this->wmc_bBox_minx = $element[attributes]["minx"];
+-					$this->wmc_bBox_miny = $element[attributes]["miny"];
+-					$this->wmc_bBox_maxx = $element[attributes]["maxx"];
+-					$this->wmc_bBox_maxy = $element[attributes]["maxy"];
++						$this->wmc_bBox_SRS = $element[attributes]["SRS"];
++						$this->wmc_bBox_minx = $element[attributes]["minx"];
++						$this->wmc_bBox_miny = $element[attributes]["miny"];
++						$this->wmc_bBox_maxx = $element[attributes]["maxx"];
++						$this->wmc_bBox_maxy = $element[attributes]["maxy"];
+ 				}
+ 				if(strtoupper($element[tag]) == "NAME"){
+-					$this->wmc_name = $element[value];
++						$this->wmc_name = mb_utf8_decode(html_entity_decode($element[value]));
+ 				}
+ 				if(strtoupper($element[tag]) == "TITLE"){
+-					$this->wmc_title = $element[value];
++						$this->wmc_title = mb_utf8_decode(html_entity_decode($element[value]));
+ 				}
+ 				if(strtoupper($element[tag]) == "ABSTRACT"){
+-					$this->wmc_abstract = $element[value];
++						$this->wmc_abstract = mb_utf8_decode(html_entity_decode($element[value]));
+ 				}
+ 				if(strtoupper($element[tag]) == "CONTACTINFORMATION" && $element['type'] == "open"){
+-					$contactinformation = true;
++						$contactinformation = true;
+ 				}
+ 				if ($contactinformation) {
+ 					if(strtoupper($element[tag]) == "CONTACTPOSITION"){
+-						$this->wmc_contactposition = $element[value];
++							$this->wmc_contactposition = mb_utf8_decode(html_entity_decode($element[value]));
+ 					}
+ 					if(strtoupper($element[tag]) == "CONTACTVOICETELEPHONE"){
+-						$this->wmc_contactvoicetelephone = $element[value];
++							$this->wmc_contactvoicetelephone = $element[value];
+ 					}
+ 					if(strtoupper($element[tag]) == "CONTACTFACSIMILETELEPHONE"){
+-						$this->wmc_contactfacsimiletelephone = $element[value];
++							$this->wmc_contactfacsimiletelephone = $element[value];
+ 					}
+ 					if(strtoupper($element[tag]) == "CONTACTELECTRONICMAILADDRESS"){
+-						$this->wmc_contactemail = $element[value];
++							$this->wmc_contactemail = mb_utf8_decode(html_entity_decode($element[value]));
+ 					}
+ 					if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "open"){
+-						$contactpersonprimary = true;
++							$contactpersonprimary = true;
+ 					}
+ 					if ($contactpersonprimary) {
+ 						if(strtoupper($element[tag]) == "CONTACTPERSON"){
+-							$this->wmc_contactperson = $element[value];
++								$this->wmc_contactperson = mb_utf8_decode(html_entity_decode($element[value]));
+ 						}
+ 						if(strtoupper($element[tag]) == "CONTACTORGANIZATION"){
+-							$this->wmc_contactorganization = $element[value];
++								$this->wmc_contactorganization = mb_utf8_decode(html_entity_decode($element[value]));
+ 						}
+ 						if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "close"){
+-							$contactpersonprimary = false;
++								$contactpersonprimary = false;
+ 						}
+ 					}
+ 					if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "open"){
+-						$contactaddress = true;
++							$contactaddress = true;
+ 					}
+ 					if ($contactaddress) {
+ 						if(strtoupper($element[tag]) == "ADDRESSTYPE"){
+-							$this->wmc_contactaddresstype = $element[value];
++								$this->wmc_contactaddresstype = mb_utf8_decode(html_entity_decode($element[value]));
+ 						}
+ 						if(strtoupper($element[tag]) == "ADDRESS"){
+-							$this->wmc_contactaddress = $element[value];
++								$this->wmc_contactaddress = mb_utf8_decode(html_entity_decode($element[value]));
+ 						}
+ 						if(strtoupper($element[tag]) == "CITY"){
+-							$this->wmc_contactcity = $element[value];
++								$this->wmc_contactcity = mb_utf8_decode(html_entity_decode($element[value]));
+ 						}
+ 						if(strtoupper($element[tag]) == "STATEORPROVINCE"){
+-							$this->wmc_contactstateorprovince = $element[value];
++								$this->wmc_contactstateorprovince = mb_utf8_decode(html_entity_decode($element[value]));
+ 						}
+ 						if(strtoupper($element[tag]) == "POSTCODE"){
+-							$this->wmc_contactpostcode = $element[value];
++								$this->wmc_contactpostcode = $element[value];
+ 						}
+ 						if(strtoupper($element[tag]) == "COUNTRY"){
+-							$this->wmc_contactcountry = $element[value];
++								$this->wmc_contactcountry = mb_utf8_decode(html_entity_decode($element[value]));
+ 						}
+ 						if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "close"){
+-							$contactaddress = false;
++								$contactaddress = false;
+ 						}
+ 					}
+ 				}
+@@ -245,14 +782,14 @@
+ 					}
+ 				}
+ 				if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "open"){
+-					$logourl = true;
+-					$this->wmc_logourl_width = $element[attributes]["width"];
+-					$this->wmc_logourl_height = $element[attributes]["height"];
+-					$this->wmc_logourl_format = $element[attributes]["format"];
++						$logourl = true;
++						$this->wmc_logourl_width = $element[attributes]["width"];
++						$this->wmc_logourl_height = $element[attributes]["height"];
++						$this->wmc_logourl_format = $element[attributes]["format"];
+ 				}
+ 				if ($logourl) {
+ 					if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "close"){
+-						$logourl = false;
++							$logourl = false;
+ 					}
+ 					if(strtoupper($element[tag]) == "ONLINERESOURCE"){
+ 						$this->wmc_logourl_type = $element[attributes]["xlink:type"];
+@@ -260,12 +797,12 @@
+ 					}
+ 				}
+ 				if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "open"){
+-					$descriptionurl = true;
+-					$this->wmc_descriptionurl_format = $element[attributes]["format"];
++						$descriptionurl = true;
++						$this->wmc_descriptionurl_format = $element[attributes]["format"];
+ 				}
+ 				if ($descriptionurl) {
+ 					if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "close"){
+-						$descriptionurl = false;
++							$descriptionurl = false;
+ 					}
+ 					if(strtoupper($element[tag]) == "ONLINERESOURCE"){
+ 						$this->wmc_descriptionurl_type = $element[attributes]["xlink:type"];
+@@ -273,24 +810,35 @@
+ 					}
+ 				}
+ 				if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "open"){
+-					$keywordlist = true;
++						$keywordlist = true;
+ 				}
+ 				if ($keywordlist) {
+ 					if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "close"){
+-						$keywordlist = false;
+-						$cnt_keyword = -1;
++							$keywordlist = false;
++							$cnt_keyword = -1;
+ 					}
+ 					if(strtoupper($element[tag]) == "KEYWORD"){
+ 						$cnt_keyword++;
+-						$this->wmc_keyword[$cnt_keyword] = $element[value];
++						$this->wmc_keyword[$cnt_keyword] = mb_utf8_decode(html_entity_decode($element[value]));
+ 					}
+ 				}
+ 						
++				if(strtoupper($element[tag]) == "EXTENSION" && $element['type'] == "close"){
++					$generalExtension = false;
++				}
++				if ($generalExtension) {
++					$this->wmc_general_extension[sepNameSpace($element[tag])] = $element[value];
++//					$e = new mb_exception("WMC: " . $element[tag] . ": " . $element[value]);
++				}
++				if(strtoupper($element[tag]) == "EXTENSION" && $element['type'] == "open"){
++					$generalExtension = true;
++				}
++
+ 				if(strtoupper($element[tag]) == "GENERAL" && $element['type'] == "close"){
+ 		   			$general = false;
+ 			 	}
+-			}
+-			if ($layerlist) {
++		}
++		if ($layerlist) {
+ 				if(strtoupper($element[tag]) == "LAYERLIST" && $element['type'] == "close"){
+ 				   $layerlist = false;
+ 				}
+@@ -302,9 +850,9 @@
+       		 		 $cnt_epsg = 0;
+ 				}
+ 				if ($layer) {
+-					if(strtoupper($element[tag]) == "LAYER" && $element[type] == "close"){
+-						$layer = false;
+-					}
++					 if(strtoupper($element[tag]) == "LAYER" && $element[type] == "close"){
++					 		$layer = false;
++					 }
+ 					 if ($formatlist) {
+ 						 if(strtoupper($element[tag]) == "FORMAT"){
+ 						 	$cnt_format++;
+@@ -317,10 +865,10 @@
+ 					 }
+ 					 elseif ($metadataurl) {
+ 						 if(strtoupper($element[tag]) == "ONLINERESOURCE"){
+-							$this->wmc_layer_metadataurl[$cnt_layer] = $element[attributes]["xlink:href"];
++						 	$this->wmc_layer_metadataurl[$cnt_layer] = $element[attributes]["xlink:href"];
+ 						 }
+ 						 if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "close"){
+-							$metadataurl = false;
++							 $metadataurl = false;
+ 						 }
+ 					 }
+ 					 elseif ($dataurl) {
+@@ -353,7 +901,7 @@
+ 								 	$this->wmc_layer_style_sld_url[$cnt_layer][$cnt_style] = $element[attributes]["xlink:href"];
+ 								 }
+ 								 if(strtoupper($element[tag]) == "TITLE"){
+-								 	$this->wmc_layer_style_sld_title[$cnt_layer][$cnt_style] = $element[value];
++								 	$this->wmc_layer_style_sld_title[$cnt_layer][$cnt_style] = mb_utf8_decode(html_entity_decode($element[value]));
+ 								 }
+ 							 }
+ 							 else {
+@@ -358,7 +906,7 @@
+ 							 }
+ 							 else {
+ 								 if(strtoupper($element[tag]) == "NAME"){
+-								 	$this->wmc_layer_style_name[$cnt_layer][$cnt_style] = $element[value];
++								 	$this->wmc_layer_style_name[$cnt_layer][$cnt_style] = mb_utf8_decode(html_entity_decode($element[value]));
+ 								 }
+ 								 if(strtoupper($element[tag]) == "TITLE"){
+ 								 	$this->wmc_layer_style_title[$cnt_layer][$cnt_style] = $element[value];
+@@ -389,7 +937,7 @@
+ 						 	 $server = true;
+ 						 	 $this->wmc_wms_service[$cnt_layer] = $element[attributes]["service"];
+ 						 	 $this->wmc_wms_version[$cnt_layer] = $element[attributes]["version"];
+-						 	 $this->wmc_wms_title[$cnt_layer] = $element[attributes]["title"];
++						 	 $this->wmc_wms_title[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[attributes]["title"]));
+ 						 }
+ 						 if ($server) {
+ 							 if(strtoupper($element[tag]) == "SERVER" && $element[type] == "close"){
+@@ -400,13 +948,13 @@
+ 							 }
+ 						 }
+ 						 if(strtoupper($element[tag]) == "NAME"){
+-					 		 $this->wmc_layer_name[$cnt_layer] = $element[value];
++					 		 $this->wmc_layer_name[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
+ 						 }
+ 						 if(strtoupper($element[tag]) == "TITLE"){
+-					 		 $this->wmc_layer_title[$cnt_layer] = $element[value];
++					 		 $this->wmc_layer_title[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
+ 						 }
+ 						 if(strtoupper($element[tag]) == "ABSTRACT"){
+-					 		 $this->wmc_layer_abstract[$cnt_layer] = $element[value];
++					 		 $this->wmc_layer_abstract[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
+ 						 }
+ 						 if(strtoupper($element[tag]) == "SRS"){
+ 							 $epsgArray = explode(" ", $element[value]);						 	
+@@ -426,11 +974,21 @@
+ 					 		 $this->wmc_layer_minscale[$cnt_layer] = $element[attributes]["min"];
+ 					 		 $this->wmc_layer_maxscale[$cnt_layer] = $element[attributes]["max"];
+ 						 }
++						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "GUISCALEHINT"){
++					 		 $this->wmc_gui_layer_minscale[$cnt_layer] = $element[attributes]["min"];
++					 		 $this->wmc_gui_layer_maxscale[$cnt_layer] = $element[attributes]["max"];
++						 }
+ 						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_ID"){
+ 					 		 $this->wmc_layer_id[$cnt_layer] = $element[value];
+ 						 }
+-						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WMS_ID"){
+-					 		 $this->wmc_wms_id[$cnt_layer] = $element[value];
++						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WMS_LAYER_ID"){
++					 		 $this->wmc_wms_layer_id[$cnt_layer] = $element[value];
++						 }
++						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_POS"){
++					 		 $this->wmc_layer_pos[$cnt_layer] = $element[value];
++						 }
++						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_PARENT"){
++					 		 $this->wmc_layer_parent[$cnt_layer] = $element[value];
+ 						 }
+ 						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "QUERYLAYER"){
+ 					 		 $this->wmc_layer_querylayer[$cnt_layer] = $element[value];
+@@ -435,17 +993,23 @@
+ 						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "QUERYLAYER"){
+ 					 		 $this->wmc_layer_querylayer[$cnt_layer] = $element[value];
+ 						 }
+-						 if(strtoupper(sepNameSpace($element[tag])) == "METADATAURL" && $element[type] == "open"){
++						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WMS_ID"){
++					 		 $this->wmc_wms_id[$cnt_layer] = $element[value];
++						 }
++						 if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WFSFEATURETYPE"){
++					 		 $this->wmc_layer_wfs_featuretype[$cnt_layer] = $element[value];
++						 }
++						 if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "open"){
+ 							 $metadataurl = true;
+ 						 }
+-						 if(strtoupper(sepNameSpace($element[tag])) == "DATAURL" && $element[type] == "open"){
++						 if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "open"){
+ 							 $dataurl = true;
+ 						 }
+-						 if(strtoupper(sepNameSpace($element[tag])) == "FORMATLIST" && $element[type] == "open"){
++						 if(strtoupper($element[tag]) == "FORMATLIST" && $element[type] == "open"){
+ 							 $formatlist = true;
+ 							 $cnt_format = -1;
+ 						 }
+-						 if(strtoupper(sepNameSpace($element[tag])) == "STYLELIST" && $element[type] == "open"){
++						 if(strtoupper($element[tag]) == "STYLELIST" && $element[type] == "open"){
+ 							 $stylelist = true;
+ 							 $cnt_style = -1;
+ 						 }
+@@ -454,9 +1018,22 @@
+ 			}
+ 		}
+ 		return true;
++	  //return $verbose;
+ 	}
+ 
+ 	function createJsObjFromWMC($target, $mapObj, $action){
++		
++		/*
++		 * counts how often a layer has been loaded
++		 */
++		/*
++		if ($this->monitoringIsOn) {
++			$monitor = new Layer_load_count();
++			for ($i = 0; $i < count($this->wmc_layer_id); $i++) {
++				$monitor->increment($this->wmc_layer_id[$i]);
++			}
++		}
++		*/
+ 		$wmc_string = "";
+ 		$validActions = array("load", "merge", "append");
+ 		if (!in_array($action, $validActions)) {
+@@ -463,6 +1040,13 @@
+ 			$wmc_string .= "alert('invalid action: ".$action."');";			
+ 		}
+ 		else {
++			
++			// general extension
++			if (count($this->wmc_general_extension) > 0) {
++				$json = new Services_JSON();
++				$wmc_string .= $target . "restoredWmcExtensionData = " . $json->encode($this->wmc_general_extension) . ";\n"; 
++			}
++			
+ 			$wmc_string .= "var index = " . $target . "getMapObjIndexByName('" . $mapObj . "');\n";
+ 			if ($action == "load") {
+ 				// delete all previous wms
+@@ -513,7 +1097,8 @@
+ 						}
+ 					}
+ 					// add wms
+-					$wmc_string .= "\t" . $target . "add_wms('','".
++					$wmc_string .= "\t" . $target . "add_wms('".
++						$this->wmc_wms_id[$i]."','".
+ 						$this->wmc_wms_version[$i] ."','".
+ 						$this->wmc_wms_title[$i] ."','".
+ 						$this->wmc_layer_abstract[$i] ."','".
+@@ -557,7 +1142,10 @@
+ 									$wmc_string .= "if (!wms_exists) {\n\t";
+ 								} 
+ 								// add parent layer
+-								$wmc_string .= $target . "wms_add_layer('','".$this->wmc_layer_id[$i]."','','". $this->wmc_wms_title[$i] ."','','0','0','0','0','','".$this->wmc_wms_id[$i]."','1','1','1','0','0','0','0');\n";
++								$wmc_string .= $target . "wms_add_layer('','".
++									$this->wmc_wms_layer_id[$i]."','','". 
++									$this->wmc_wms_title[$i] ."','','0','0','0','0','','".
++									$this->wmc_wms_id[$i]."','1','', '1','1','0','0','0','0','');\n";
+ 								if ($action == "merge") {
+ 									$wmc_string .= "}\n";
+ 								} 
+@@ -577,15 +1165,21 @@
+ 								$wmc_string .= "\t\t\tcurrent_layer_index = m;\n";
+ 								$wmc_string .= "\t\t}\n";
+ 								$wmc_string .= "\t}\n"; 
+-		
++
++								if ($this->wmc_layer_querylayer[$ii]!="") {
++									$querylayer_yn = $this->wmc_layer_querylayer[$ii];
++								}
++								else {
++									$querylayer_yn = $this->wmc_layer_queryable[$ii];
++								}			
+ 								$wmc_string .= "\tif (layer_exists) {\n";
+ 								// check if the visibility or the queryability are different to the existing layer
+ 								$wmc_string .= "\t\tif (" . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible != '" . intval(!$this->wmc_layer_hidden[$ii]) . "'";
+-								$wmc_string .= " || " . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer != '" . $this->wmc_layer_queryable[$ii] . "') {\n";
++								$wmc_string .= " || " . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer != '" . $querylayer_yn . "') {\n";
+ 		
+ 								// if yes, update the visibility and queryability
+ 								$wmc_string .= "\t\t\t" . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible = " . intval(!$this->wmc_layer_hidden[$ii]) . ";\n"; 
+-								$wmc_string .= "\t\t\t" . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer = " . $this->wmc_layer_queryable[$ii] . ";\n"; 
++								$wmc_string .= "\t\t\t" . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer = " . $querylayer_yn . ";\n"; 
+ 								$wmc_string .= "\t\t}\n";
+ 								$wmc_string .= "\t}\n"; 
+ 								$wmc_string .= "}\n"; 
+@@ -593,7 +1187,8 @@
+ 							} 
+ 
+ 							// add layer
+-							$wmc_string .= "\t" . $target . "wms_add_layer('0','". 
++							$wmc_string .= "\t" . $target . "wms_add_layer('".
++								($this->wmc_layer_parent[$ii]!=""?$this->wmc_layer_parent[$ii]:"0") . "','". 
+ 								$this->wmc_layer_id[$ii] . "','". 
+ 								$this->wmc_layer_name[$ii] . "','". 
+ 								$this->wmc_layer_title[$ii] ."','". 
+@@ -598,7 +1193,7 @@
+ 								$this->wmc_layer_name[$ii] . "','". 
+ 								$this->wmc_layer_title[$ii] ."','". 
+ 								$this->wmc_layer_dataurl[$ii] . "','". 
+-								intval($cnt_layers) ."','". 
++								($this->wmc_layer_pos[$ii]!=""?$this->wmc_layer_pos[$ii]:intval($cnt_layers)) ."','". 
+ 								$this->wmc_layer_queryable[$ii] ."','".
+ 								$this->wmc_layer_minscale[$ii]  ."','". 
+ 								$this->wmc_layer_maxscale[$ii]  ."','". 
+@@ -603,12 +1198,13 @@
+ 								$this->wmc_layer_minscale[$ii]  ."','". 
+ 								$this->wmc_layer_maxscale[$ii]  ."','". 
+ 								$this->wmc_layer_metadataurl[$ii] ."','". 
+-								$this->wmc_wms_id[$ii] ."','1','1','". 
++								$this->wmc_wms_id[$i] ."','1','', '1','". 
+ 								intval(!$this->wmc_layer_hidden[$ii]) ."','". 
+ 								$this->wmc_layer_queryable[$ii] ."','". 
+-								$this->wmc_layer_querylayer[$ii] ."','".
+-								$this->wmc_layer_minscale[$ii]  ."','". 
+-								$this->wmc_layer_maxscale[$ii]  ."');\n";
++								($this->wmc_layer_querylayer[$ii]!=""?$this->wmc_layer_querylayer[$ii]:$this->wmc_layer_queryable[$ii]) ."','".
++								($this->wmc_gui_layer_minscale[$ii]!=""?$this->wmc_gui_layer_minscale[$ii]:$this->wmc_layer_minscale[$ii]) ."','".
++								($this->wmc_gui_layer_maxscale[$ii]!=""?$this->wmc_gui_layer_maxscale[$ii]:$this->wmc_layer_maxscale[$ii]) ."','".
++								$this->wmc_layer_wfs_featuretype[$ii] . "');\n";
+ 	
+ 							if ($action == "merge") {
+ 								$wmc_string .= "\t}\n";
+@@ -615,7 +1211,7 @@
+ 							} 
+ 												
+ 							// if layer is queryable, add it to querylayerlist
+-							if ($this->wmc_layer_queryable[$ii]) {
++							if (($this->wmc_layer_querylayer[$ii]!=""?$this->wmc_layer_querylayer[$ii]:$this->wmc_layer_queryable[$ii])) {
+ 								$cnt_query_layers++;
+ 								if (!in_array($this->wmc_layer_name[$ii], explode(",",$querylayerlist))) {
+ 									if ($querylayerlist == "") {$querylayerlist = $this->wmc_layer_name[$ii];} else {$querylayerlist .= "," . $this->wmc_layer_name[$ii];} 
+@@ -658,7 +1254,7 @@
+ 			$wmc_string .= "\t\tvar found = false;\n";
+ 			$wmc_string .= "\t\tfor (var j=0; j < " . $target . "wms.length && found == false; j++) {\n";
+ 			$wmc_string .= "\t\t\tif (" . $target . "wms[j].wms_getmap == old_mapObj[i].wms[0].wms_getmap) {\n";
+-			$wmc_string .= "\t\t\t\t" . $target . "mb_registerMapObj('overview', old_mapObj[i].elementName, j, old_mapObj[i].width,  old_mapObj[i].height);\n"; 
++			$wmc_string .= "\t\t\t\t" . $target . "mb_registerMapObj('overview', old_mapObj[i].elementName, j, old_mapObj[i].width,  old_mapObj[i].width);\n"; 
+ 			$wmc_string .= "\t\t\t\tfound = true;\n"; 
+ 			$wmc_string .= "\t\t\t}\n";
+ 			$wmc_string .= "\t\t}\n";
+@@ -663,7 +1259,7 @@
+ 			$wmc_string .= "\t\t\t}\n";
+ 			$wmc_string .= "\t\t}\n";
+ 			$wmc_string .= "\t\tif (!found) {\n";
+-			$wmc_string .= "\t\t\t" . $target . "mb_registerMapObj('overview', old_mapObj[i].elementName, 0, old_mapObj[i].width,  old_mapObj[i].height);\n"; 
++			$wmc_string .= "\t\t\t" . $target . "mb_registerMapObj('overview', old_mapObj[i].elementName, 0, old_mapObj[i].width,  old_mapObj[i].width);\n"; 
+ 			$wmc_string .= "\t\t}\n";
+ 			$wmc_string .= "\t}\n";
+ 			$wmc_string .= "}\n";
+@@ -668,20 +1264,47 @@
+ 			$wmc_string .= "\t}\n";
+ 			$wmc_string .= "}\n";
+ 			
+-			$sql = "SELECT minx, miny, maxx, maxy FROM layer_epsg WHERE fkey_layer_id = $1 AND epsg = $2 LIMIT 1";
+-			$v = array($this->wmc_layer_id[0], $this->wmc_bBox_SRS);
+-			$t = array('i', 's');
+-			$res = db_prep_query($sql, $v, $t);
+-			$row = db_fetch_array($res);
+-			if ($row["minx"] && $row["miny"] && $row["maxx"] && $row["maxy"]) {
+-				$ov_bbox = array($row["minx"],$row["miny"],$row["maxx"],$row["maxy"]);
+-			}
+-			else if ($this->wmc_layer_id[0] && $this->wmc_bBox_SRS){
+-				$ov_bbox = array($this->wmc_bBox_minx, $this->wmc_bBox_miny, $this->wmc_bBox_maxx, $this->wmc_bBox_maxy);
++			$ov_bbox = array();
++			// compute the union of the overview and the mapframe bbox for the new overview bbox
++			if ($this->wmc_general_extension["ov_minx"] && $this->wmc_general_extension["ov_miny"] && 
++				$this->wmc_general_extension["ov_maxx"] && $this->wmc_general_extension["ov_maxy"]) {
++
++				// box for overview
++				$ov_min = new Mapbender_point($this->wmc_general_extension["ov_minx"], $this->wmc_general_extension["ov_miny"], $this->wmc_bBox_SRS);
++				$ov_max = new Mapbender_point($this->wmc_general_extension["ov_maxx"], $this->wmc_general_extension["ov_maxy"], $this->wmc_bBox_SRS);
++				$ov_box = new Mapbender_bbox($ov_min, $ov_max, $this->wmc_bBox_SRS);
++				
++				// box for mapframe
++				$mf_min = new Mapbender_point($this->wmc_bBox_minx, $this->wmc_bBox_miny, $this->wmc_bBox_SRS);
++				$mf_max = new Mapbender_point($this->wmc_bBox_maxx, $this->wmc_bBox_maxy, $this->wmc_bBox_SRS);
++				$mf_box = new Mapbender_bbox($mf_min, $mf_max, $this->wmc_bBox_SRS);
++				
++				$unionBox = Mapbender_bbox::union(array($ov_box, $mf_box));
++				
++				array_push($ov_bbox, $unionBox->min->x); 				
++				array_push($ov_bbox, $unionBox->min->y); 				
++				array_push($ov_bbox, $unionBox->max->x); 				
++				array_push($ov_bbox, $unionBox->max->y); 				
+ 			}
+ 			else {
+-				$ov_bbox = array();
++/*
++				$sql = "SELECT minx, miny, maxx, maxy FROM layer_epsg WHERE fkey_layer_id = $1 AND epsg = $2 LIMIT 1";
++				$v = array($this->wmc_layer_id[0], $this->wmc_bBox_SRS);
++				$t = array('i', 's');
++				$res = db_prep_query($sql, $v, $t);
++				$row = db_fetch_array($res);
++				if ($row["minx"] && $row["miny"] && $row["maxx"] && $row["maxy"]) {
++					$ov_bbox = array($row["minx"],$row["miny"],$row["maxx"],$row["maxy"]);
++				}
++				else if ($this->wmc_layer_id[0] && $this->wmc_bBox_SRS){
++					$ov_bbox = array($this->wmc_bBox_minx, $this->wmc_bBox_miny, $this->wmc_bBox_maxx, $this->wmc_bBox_maxy);
++				}
++				else {
++*/
++					$ov_bbox = array(2412139.175257732, 5365000, 2767860.824742268, 5700000);		
++//				}
+ 			}
++			
+ 			$wmc_string .= "for (var i=0; i<old_mapObj.length; i++) {\n";
+ 			$wmc_string .= "\tif (old_mapObj[i].frameName != 'overview') {\n";
+ 			$wmc_string .= "\t\t".$target."mb_calculateExtent(old_mapObj[i].frameName, ";
+@@ -689,20 +1312,9 @@
+ 			$wmc_string .= $this->wmc_bBox_maxx .",".$this->wmc_bBox_maxy.");\n";
+ 			$wmc_string .= "\t}\n";
+ 			$wmc_string .= "\telse {\n";
+-			if (count($ov_bbox)>0) {
+-//				$wmc_string .= "alert('found bbox for ov: ".implode(',',$ov_bbox)."');";
+-				$wmc_string .= "\t\t".$target."mb_calculateExtent(old_mapObj[i].frameName, ";
+-				$wmc_string .= $ov_bbox[0] .",".$ov_bbox[1] .",";
+-				$wmc_string .= $ov_bbox[2] .",".$ov_bbox[3] .");\n";
+-			}
+-			else {
+-//				$wmc_string .= "alert('no bbox found for ov: old bbox ".$this->wmc_bBox_minx." etc');";
+-				$wmc_string .= "\t\t".$target."mb_calculateExtent(old_mapObj[i].frameName, ";
+-				$wmc_string .= $this->wmc_bBox_minx .",".$this->wmc_bBox_miny .",";
+-				$wmc_string .= $this->wmc_bBox_maxx .",".$this->wmc_bBox_maxy.");\n";
+-//				$wmc_string .= "\t\tvar ov_index = " . $target . "getMapObjIndexByName('overview');\n";
+-//				$wmc_string .= "\t\t" . $target . "mb_mapObj[ov_index].extent = old_mapObj[i].extent;\n"; 
+-			}
++			$wmc_string .= "\t\t".$target."mb_calculateExtent(old_mapObj[i].frameName, ";
++			$wmc_string .= $ov_bbox[0] .",".$ov_bbox[1] .",";
++			$wmc_string .= $ov_bbox[2] .",".$ov_bbox[3] .");\n";
+ 			$wmc_string .= "\t}\n";
+ 			$wmc_string .= "\t". $target . "setMapRequest(old_mapObj[i].frameName);\n";
+ 			$wmc_string .= "}\n";
+@@ -707,7 +1319,9 @@
+ 			$wmc_string .= "\t". $target . "setMapRequest(old_mapObj[i].frameName);\n";
+ 			$wmc_string .= "}\n";
+ 			$wmc_string .= $target . "mb_execloadWmsSubFunctions();\n";
++			$wmc_string .= $target . "mb_execloadWmcSubFunctions();\n";
+ 		}
++//		$e = new mb_exception("js code: " . $wmc_string);
+ 		return $wmc_string;
+ 	}
+ } 
+@@ -712,4 +1326,4 @@
+ 	}
+ } 
+ // end class
+-?>
++?>
+\ No newline at end of file
+Index: http/classes/class_wms.php
+===================================================================
+--- http/classes/class_wms.php	(revision 1939)
++++ http/classes/class_wms.php	(working copy)
+@@ -435,7 +435,7 @@
+ 				
+ 				if(strtoupper($element[tag]) == "SRS"){
+ 	  				$this->objLayer[$cnt_layer]->wms_srs1 = $element[value];
+-					$this->wms_srs = explode (" ", $this->objLayer[0]->wms_srs1);  				
++					$this->wms_srs = array_keys( array_flip(explode (" ", $this->objLayer[0]->wms_srs1)));
+ 				}						      
+ 				if(strtoupper($element[tag]) == "LATLONBOUNDINGBOX"){
+ 					$cnt_epsg++;
+Index: http/extensions/geom2wfst.php
+===================================================================
+--- http/extensions/geom2wfst.php	(revision 1939)
++++ http/extensions/geom2wfst.php	(working copy)
+@@ -115,7 +115,7 @@
+ }
+ else {
+ 	$response = "error";
+-	echo "\"error message\":\"".addslashes($data)."\",";
++	echo "\"error message\":\"".preg_replace("/\"/", "'", preg_replace("/\n/", "", preg_replace("/\r/", "", $data)))."\",";
+ }
+ echo "\"response\":\"".$response."\"}";
+ ?>
+\ No newline at end of file
+Index: http/index.php
+===================================================================
+--- http/index.php	(revision 1939)
++++ http/index.php	(working copy)
+@@ -109,7 +109,7 @@
+ 		
+ 			<div class="mapbender_welcome">Welcome to <font align="left" color="#000000">Ma</font><font color="#0000CE">p</font><font color="#C00000">b</font><font color="#000000">ender</font></div>
+ 		
+-		<font color="#ff0000">Mapbender Version 2.4.3 (2007-10-05)</font>
++		<font color="#ff0000">Mapbender Version 2.4.4 rc1 (2007-11-30)</font>
+ 		</td></tr>
+ 	</table>
+ <br>
+Index: http/javascripts/map.js
+===================================================================
+--- http/javascripts/map.js	(revision 1939)
++++ http/javascripts/map.js	(working copy)
+@@ -1,4 +1,4 @@
+-var ie=document.all?1:0;var n6=document.getElementById&&!document.all?1:0;var n4=document.layers?1:0;var mb_feature_count=100;var mb_resolution=28.35;var mb_mapObj=[];var mb_fiWin=null;var mb_panActive=false;var clickX;var clickY;var mb_start_x=0;var mb_start_y=0;var mb_end_x=0;var mb_end_y=0;var mb_offset_top=0;var mb_offset_right=0;var mb_offset_bottom=0;var mb_offset_left=0;var mb_log=null;var mb_PanSubElements=[];function mb_registerPanSubElement(elName){var ind=mb_PanSubElements.length;mb_PanSubElements[ind]=elName;}
++var ie=document.all?1:0;var n6=document.getElementById&&!document.all?1:0;var n4=document.layers?1:0;var mb_feature_count=100;var mb_resolution=28.35;var mb_mapObj=[];var mb_fiWin=null;var mb_panActive=false;var clickX;var clickY;var mb_start_x=0;var mb_start_y=0;var mb_end_x=0;var mb_end_y=0;var mb_offset_top=0;var mb_offset_right=0;var mb_offset_bottom=0;var mb_offset_left=0;var mb_log=null;var currentWmcExtensionData = {};var restoredWmcExtensionData = {};var mb_PanSubElements=[];function mb_registerPanSubElement(elName){var ind=mb_PanSubElements.length;mb_PanSubElements[ind]=elName;}
+ var mb_vendorSpecific=[];function mb_registerVendorSpecific(stringFunction){mb_vendorSpecific[mb_vendorSpecific.length]=stringFunction;}
+ var mb_security_proxy="http://wms1.ccgis.de/mapbender/tools/security_proxy.php?mb_ows_security_proxy=";var mb_trans=new Image;mb_trans.src="../img/transparent.gif";function init(){for(var i=0;i<mb_InitFunctions.length;i++){eval(mb_InitFunctions[i]);}
+ for(var i=0;i<mb_mapObj.length;i++){setMapRequest(mb_mapObj[i].frameName);}}
+Index: http/javascripts/mod_digitize_tab.php
+===================================================================
+--- http/javascripts/mod_digitize_tab.php	(revision 1939)
++++ http/javascripts/mod_digitize_tab.php	(working copy)
+@@ -853,7 +853,7 @@
+ }
+ 
+ function isInteger(str) {
+-	if (str.match(/^\d+$/)) {
++	if (str.match(/^\d*$/)) {
+ 		return true;
+ 	}
+ 	return false;
+Index: http/javascripts/mod_savewmc.php
+===================================================================
+--- http/javascripts/mod_savewmc.php	(revision 1939)
++++ http/javascripts/mod_savewmc.php	(working copy)
+@@ -26,7 +26,12 @@
+ echo "mod_savewmc_target = '".$e_target."';";
+ ?>
+ function setOnUnload() {
+-	document.getElementsByTagName('body')[0].setAttribute("onUnload", "mod_savewmc('session');");
++	if (ie) {
++		document.getElementsByTagName('body')[0].onunload = function() {var x = new Function ("", "mod_savewmc_session()"); x(); };
++	}
++	else {
++		document.getElementsByTagName('body')[0].setAttribute("onUnload", "mod_savewmc_session();");
++	}
+ }
+ 
+ try {if (saveInSession) {}}catch(e) {saveInSession = 0;}
+@@ -31,7 +36,7 @@
+ 
+ try {if (saveInSession) {}}catch(e) {saveInSession = 0;}
+ 
+-if (saveInSession == '1') {
++if (saveInSession == 1) {
+ 	mb_registerInitFunctions('setOnUnload()');
+ }
+ 
+@@ -38,22 +43,28 @@
+ var mod_savewmc_img = new Image(); mod_savewmc_img.src = "<?php  echo $e_src;  ?>";
+ //var mod_savewmc_img_over = new Image(); mod_savewmc_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
+ 
++function mod_savewmc_session(){
++	sendMapDataToServer("session", 1, function(result, status) {});
++}
+ 
+ function mod_savewmc(title){
+-	
+-	var ind = getMapObjIndexByName(mod_savewmc_target);
+-	var session = 0;
+-	var generalTitle = title;
++	var generalTitle = title ? title : prompt("Save WMC as...");
++	if (generalTitle != "" && generalTitle != null) {
++		sendMapDataToServer(generalTitle, 0, function(result, status) {alert(status + ": " + result);});
++	}
++}
+ 
+-	if (generalTitle) {
+-		if (generalTitle == 'session') {
+-			session = 1;
+-		}
++function sendMapDataToServer(generalTitle, storeInSession, callbackFunction) {
++	var user = "<?php echo $_SESSION["mb_user_id"]; ?>";
++	var ind = getMapObjIndexByName(mod_savewmc_target);
++	
++	var	extensionDataString = "";
++	if (currentWmcExtensionData != null) {
++		extensionDataString = currentWmcExtensionData.toJSONString();
+ 	}
+-	else {
+-		generalTitle = prompt("Save WMC as...");
++
++	if (storeInSession) {
++		window.frames['ajax'].$.ajaxSetup({async:false}); //TODO: find out why async doesn't work onunload
+ 	}
+-	mb_ajax_post("../php/mod_insertWmcIntoDb.php", {"saveInSession":session, "generalTitle":generalTitle, "mapObject":mb_mapObj[ind].toJSONString()}, function (result, status) {
+-		alert(result);
+-	});
++	window.frames['ajax'].$.post("../php/mod_insertWmcIntoDb.php", {"saveInSession":storeInSession, "generalTitle":generalTitle, "extensionData":extensionDataString, "mapObject":mb_mapObj[ind].toJSONString()}, callbackFunction);
+ }
+\ No newline at end of file
+Index: http/javascripts/mod_wfs_gazetteer_client.php
+===================================================================
+--- http/javascripts/mod_wfs_gazetteer_client.php	(revision 1939)
++++ http/javascripts/mod_wfs_gazetteer_client.php	(working copy)
+@@ -50,6 +50,7 @@
+ var point_px = 10;
+ var resultGeom = null;
+ var cw_fillcolor = "#cc33cc";
++var g_buffer;
+ 
+ 
+ parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initModWfsGazetteer()");
+@@ -73,8 +74,8 @@
+ 
+ function appendStyles() {
+ 	var styleObj;
+-	var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
+-	if (parent.ie) {
++        var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
++        if (parent.ie) {
+ 		var styleSheetObj=document.createStyleSheet();
+ 		styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+ 		styleObj.setAttribute("type","text/css");
+@@ -114,6 +115,7 @@
+ 		else if (wfsCount === 1) {
+ 			appendStyles();
+ 			appendWfsForm();
++			g_buffer = global_wfsConfObj[global_selectedWfsConfId].g_buffer; 
+ 		}
+ 		else {
+ 			appendWfsConfSelectBox();
+@@ -157,6 +159,8 @@
+ 	var divContainer = document.createElement("div");
+ 	divContainer.className = global_wfsConfObj[global_selectedWfsConfId].g_label_id;
+ 	
++	g_buffer = global_wfsConfObj[global_selectedWfsConfId].g_buffer; 
++
+ 	divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
+ 	
+ 	form.appendChild(divContainer);
+@@ -312,7 +316,7 @@
+ 	else if (event == "click"){
+ 		global_resultHighlight.del(resultGeom.get(index), cw_fillcolor);
+ 		var bbox = resultGeom.get(index).getBBox();
+-		var buffer = new parent.Point(1,1);
++            var buffer = new parent.Point(g_buffer,g_buffer);
+ 		bbox[0] = bbox[0].minus(buffer);
+ 		bbox[1] = bbox[1].plus(buffer);
+ 		parent.mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
+Index: http/javascripts/mod_wfs_SpatialRequest.php
+===================================================================
+--- http/javascripts/mod_wfs_SpatialRequest.php	(revision 1939)
++++ http/javascripts/mod_wfs_SpatialRequest.php	(working copy)
+@@ -103,7 +103,13 @@
+ }	
+ 
+ function wfsEnable(obj) {
+-	if (obj.id == button_point) {
++	var el = window.frames[mod_wfs_spatialRequest_target].document;
++   	el.onmouseover = null;
++   	el.onmousedown = null;
++   	el.onmouseup = null;
++	el.onmousemove = null;
++   
++   if (obj.id == button_point) {
+ 		if (activeButton == null) {
+ 			activeButton = obj;
+ 		}
+@@ -408,7 +414,7 @@
+ 			}
+ 			filter += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>';
+ 			filter += '</gml:Polygon></Within></ogc:Filter>';
+-			mb_get_geom(url, filter, i, w_[i]);
++			mb_get_geom(url, filter, i, wfs_config[w_[i]]['featuretype_name'], w_[i], w[i]);
+ 		}
+ 	}
+ 	else if(queryGeom.geomType==geomType.line){
+@@ -430,7 +436,7 @@
+ 			filter += rectangle[0].x+","+rectangle[0].y+ " " + rectangle[1].x+","+rectangle[1].y; 
+ 			filter += "</gml:coordinates></gml:Box></ogc:BBOX></ogc:Filter>";
+ 			url += param;
+-			mb_get_geom(url, filter, i, w_[i]);
++			mb_get_geom(url, filter, i, wfs_config[w_[i]]['featuretype_name'], w_[i], w[i]);
+ 		}
+ 	}
+ 	else if(queryGeom.geomType == geomType.point){
+@@ -451,7 +457,7 @@
+ 			filter += (tmp.x + buffer) + "," + (tmp.y + buffer) + " " + (tmp.x - buffer) + "," + (tmp.y + buffer) + " " + (tmp.x - buffer) + "," + (tmp.y - buffer); 
+ 			filter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></ogc:Filter>";
+ 			url += param;
+-			mb_get_geom(url, filter, i, w_[i]);
++			mb_get_geom(url, filter, i, wfs_config[w_[i]]['featuretype_name'], w_[i], w[i]);
+ 		}
+ 	}
+ //	highlight = new Highlight(mb_wfs_targets, highlight_tag_id, {"position":"absolute", "top":"0px", "left":"0px", "z-index":generalHighlightZIndex}, generalHighlightLineWidth);
+@@ -458,9 +464,9 @@
+ 	return true;
+ }
+ 
+-function mb_get_geom(url, filter, index, wfs_conf_id) {
++function mb_get_geom(url, filter, index, typename, js_wfs_conf_id, db_wfs_conf_id) {
+ 	
+-	mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,{'url':url,'filter':filter,'typename':wfs_config[wfs_conf_id]['featuretype_name'],'wfs_conf_id':wfs_conf_id},function(js_code,status){
++	mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename, {'url':url,'filter':filter,'typename':typename,'js_wfs_conf_id':js_wfs_conf_id, 'db_wfs_conf_id':db_wfs_conf_id}, function(js_code,status){
+ //		alert(js_code);
+ 		eval(js_code);
+ 		if (typeof(geom) == 'object') mb_execWfsReadSubFunctions(geom);
+Index: http/javascripts/wfs.js
+===================================================================
+--- http/javascripts/wfs.js	(revision 1939)
++++ http/javascripts/wfs.js	(working copy)
+@@ -196,7 +196,9 @@
+ 		else if (myconf['namespaces'][q]['name'] == "xsi") ns_xsi = true;
+ 		else if (myconf['namespaces'][q]['name'] == "wfs") ns_wfs = true;
+ 		else if (myconf['namespaces'][q]['name'] == "topp") ns_topp = true;
+-		str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
++		if (myconf['namespaces'][q]['name'] != 'xmlns') {
++			str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
++		}
+ 	}
+ 	
+ 	if (ns_gml == false) str += 'xmlns:gml="http://www.opengis.net/gml" ';
+@@ -205,7 +207,11 @@
+ 	if (ns_topp == false) str += 'xmlns:topp="http://www.someserver.com/topp" ';
+ 	if (ns_wfs == false) str += 'xmlns:wfs="http://www.opengis.net/wfs" ';
+ 	
+-	str += 'xsi:schemaLocation="http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">';
++	str += 'xsi:schemaLocation="http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd';
++	if (myconf['featuretype_name'] && myconf['wfs_describefeaturetype']) {
++		str += myconf['wfs_describefeaturetype'] + "typename=" + myconf['wfs_describefeaturetype'];
++	}
++	str += '">';
+ 
+ 	
+ 	//
+Index: http/php/mod_insertWmcIntoDb.php
+===================================================================
+--- http/php/mod_insertWmcIntoDb.php	(revision 1939)
++++ http/php/mod_insertWmcIntoDb.php	(working copy)
+@@ -1,5 +1,5 @@
+ <?php
+-#$Id: mod_insertWmcIntoDb.php 507 2006-11-20 10:55:57Z christoph $
++#$Id: mod_insertWmcIntoDb.php 1198 2007-10-18 14:37:52Z baudson $
+ #$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+ # Copyright (C) 2002 CCGIS 
+ #
+@@ -20,16 +20,15 @@
+ require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+ require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+ require_once(dirname(__FILE__)."/../classes/class_administration.php");
++require_once(dirname(__FILE__)."/../classes/class_wmc.php");
+ require_once(dirname(__FILE__)."/../extensions/JSON.php");
+ 
+ session_start();
+-
+ $con = db_connect($DBSERVER,$OWNER,$PW);
+ db_select_db(DB,$con);
+ 
+-
+ $json = new Services_JSON();
+-$mapObject = $json->decode($_REQUEST["mapObject"]);
++$mapObject = $json->decode(stripslashes($_POST["mapObject"]));
+ $user_id = $_SESSION["mb_user_id"];
+ $save_in_session = $_POST["saveInSession"];
+ $generalTitle = $_POST["generalTitle"];
+@@ -34,439 +33,21 @@
+ $save_in_session = $_POST["saveInSession"];
+ $generalTitle = $_POST["generalTitle"];
+ 
+-$wmc_id = $user_id . '_' . time();
+-
+-$generalWidth = $mapObject->width;
+-$generalHeight = $mapObject->height;
+-$generalBboxSrs = $mapObject->epsg;
+-
+-$arrayBBox = explode(",", $mapObject->extent);
+-$generalBboxMinx = floatval($arrayBBox[0]);
+-$generalBboxMiny = floatval($arrayBBox[1]);
+-$generalBboxMaxx = floatval($arrayBBox[2]);
+-$generalBboxMaxy = floatval($arrayBBox[3]);
+-
+-$generalName = "Mapbender WMC"; // TO do : insert proper data
+-$generalKeywords = array("Mapbender", "WMC"); // TO do : insert proper data
+-$generalAbstract = ""; // TO do : insert proper data
+-$generalLogoUrl = ""; // TO do : insert proper data
+-$generalLogoUrlWidth = ""; // TO do : insert proper data
+-$generalLogoUrlHeight = ""; // TO do : insert proper data
+-$generalLogoUrlFormat = ""; // TO do : insert proper data
+-$generalDescriptionUrl = ""; // TO do : insert proper data
+-$generalContactPerson = "";
+-$generalContactOrganization = "";
+-$generalContactPosition = "";
+-$generalContactAddressType = "";
+-$generalContactAddress = "";
+-$generalContactCity = "";
+-$generalContactStateOrProvince = "";
+-$generalContactPostCode = "";
+-$generalContactCountry = "";
+-$generalContactVoiceTelephone = "";
+-$generalContactFacsimileTelephone = "";
+-$generalContactElectronicMailAddress = "";
+-		
+-$extension_namespace = "mapbender";
+-
+-// LayerList variables
+-$layerHidden = "";
+-$layerQueryable = "";
+-$layerAbstract = "";
+-$layerName = "";
+-$layerSrs = "";
+-$layerDataUrl = "";
+-$layerMetadataUrl = "";
+-$layerFormat = "";
+-$layerFormat_current = "";
+-$layerStyle_current = "";
+-$layerStyle_name = "";
+-$layerStyle_title = "";
+-$layerStyle_legendURL = "";
+-$layerStyle_legendURL_width = "";
+-$layerStyle_legendURL_height = "";
+-$layerStyle_legendURL_format = "";		
+-
+-// generate XML
+-$doc = new DOMDocument("1.0", CHARSET);
+-$doc->preserveWhiteSpace = false;
+-
+-// ViewContext
+-$e_view_context = $doc->createElementNS("http://www.opengis.net/context", "ViewContext");
+-
+-
+-$e_view_context->setAttribute("version", "1.0.0");
+-$e_view_context->setAttribute("id", $wmc_id);
+-$e_view_context->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+-$e_view_context->setAttribute("xmlns:mapbender", "http://www.mapbender.org");
+-$e_view_context->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+-$e_view_context->setAttribute("xsi:SchemaLocation", "http://schemas.opengis.net/context/1.0.0/context.xsd");
+-
+-	// General
+-	$e_general = $doc->createElement("General");
+-
+-		$e_window = $doc->createElement("Window");
+-		if (!empty($generalWidth) && !empty($generalHeight)) {
+-			$e_window->setAttribute("width", $generalWidth);
+-			$e_window->setAttribute("height", $generalHeight);
+-		}
+-		$e_general->appendChild($e_window);
+-		
+-		$e_bbox = $doc->createElement("BoundingBox");
+-		$e_bbox->setAttribute("SRS", $generalBboxSrs);
+-		$e_bbox->setAttribute("minx", $generalBboxMinx);
+-		$e_bbox->setAttribute("miny", $generalBboxMiny);
+-		$e_bbox->setAttribute("maxx", $generalBboxMaxx);
+-		$e_bbox->setAttribute("maxy", $generalBboxMaxy);
+-		$e_general->appendChild($e_bbox);
+-		
+-		$e_name = $doc->createElement("Name", $generalName);
+-		$e_general->appendChild($e_name);
+-		
+-		$e_title = $doc->createElement("Title", $generalTitle);
+-		$e_general->appendChild($e_title);
+-		
+-		$e_keyword_list = $doc->createElement("KeywordList");
+-		for ($i=0; $i < count($generalKeywords); $i++) {
+-			$e_keyword = $doc->createElement("Keyword", $generalKeywords[$i]);
+-			$e_keyword_list->appendChild($e_keyword);
+-		}
+-		$e_general->appendChild($e_keyword_list);
+-		
+-		if ($generalAbstract){
+-			$e_abstract = $doc->createElement("Abstract", $generalAbstract);
+-			$e_general->appendChild($e_abstract);
+-		}
+-		
+-		if ($generalLogoUrlWidth && $generalLogoUrlHeight && $generalLogoUrlFormat && $generalLogoUrl){
+-			$e_logo_url = $doc->createElement("LogoURL");
+-			$e_logo_url->setAttribute("width", $generalLogoUrlWidth);
+-			$e_logo_url->setAttribute("height", $generalLogoUrlHeight);
+-			$e_logo_url->setAttribute("format", $generalLogoUrlFormat);
+-		
+-			$e_logo_url_or = $doc->createElement("OnlineResource");
+-			$e_logo_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
+-			$e_logo_url_or->setAttribute("xlink:type", "simple");
+-			$e_logo_url_or->setAttribute("xlink:href", $generalLogoUrl);
+-			$e_logo_url->appendChild($e_logo_url_or);
+-
+-			$e_general->appendChild($e_logo_url);
+-		}
+-			
+-		if ($generalDescriptionUrl){
+-			$e_description_url = $doc->createElement("DescriptionURL");
+-
+-			$e_description_url_or = $doc->createElement("OnlineResource");
+-			$e_description_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
+-			$e_description_url_or->setAttribute("xlink:type", "simple");
+-			$e_description_url_or->setAttribute("xlink:href", $generalDescriptionUrl);
+-			$e_description_url->appendChild($e_description_url_or);
+-
+-			$e_general->appendChild($e_description_url);
+-		}
+-		
+-		if ($generalContactElectronicMailAddress || $generalContactOrganization ||
+-			$generalContactPerson || $generalContactPosition || $generalContactAddressType ||
+-			$generalContactAddress || $generalContactCity || $generalContactStateOrProvince ||
+-			$generalContactPostCode || $generalContactCountry || $generalContactVoiceTelephone ||
+-			$generalContactFacsimileTelephone || $generalContactElectronicMailAddress) {
+-		
+-			$e_contact = $doc->createElement("ContactInformation");
+-		
+-			if ($generalContactPerson || $generalContactOrganization){
+-				$e_contact_person_primary = $doc->createElement("ContactPersonPrimary");
+-		
+-				if ($generalContactPerson){
+-					$e_contact_person = $doc->createElement("ContactPerson", $generalContactPerson);
+-					$e_contact_person_primary->appendChild($e_contact_person);
+-				}
+-				if ($generalContactOrganization){
+-					$e_contact_organization = $doc->createElement("ContactOrganization", $generalContactOrganization);
+-					$e_contact_person_primary->appendChild($e_contact_organization);
+-				}
+-				$e_contact->appendChild($e_contact_person_primary);
+-			}
+-		
+-			if ($generalContactPosition){
+-				$e_contact_position = $doc->createElement("ContactPosition", $generalContactPosition);
+-				$e_contact->appendChild($e_contact_position);
+-			}
+-		
+-			if ($generalContactAddressType || $arrayBBoxgeneralContactAddress || 
+-				$generalContactCity || $generalContactStateOrProvince ||
+-				$generalContactPostCode || $generalContactCountry) {
+-		
+-				$e_contact_address = $doc->createElement("ContactAddress");
+-		
+-				if ($generalContactAddressType){
+-					$e_address_type = $doc->createElement("AddressType", $generalContactAddressType);
+-					$e_contact_address->appendChild($e_address_type);
+-				}
+-				if ($generalContactAddress){
+-					$e_address = $doc->createElement("Address", $generalContactAddress);
+-					$e_contact_address->appendChild($e_address);
+-				}
+-				if ($generalContactCity){
+-					$e_city = $doc->createElement("City", $generalContactCity);
+-					$e_contact_address->appendChild($e_city);
+-				}
+-				if ($generalContactStateOrProvince){
+-					$e_state = $doc->createElement("StateOrProvince", $generalContactStateOrProvince);
+-					$e_contact_address->appendChild($e_state);
+-				}
+-				if ($generalContactPostCode){
+-					$e_postcode = $doc->createElement("PostCode", $generalContactPostCode);
+-					$e_contact_address->appendChild($e_postcode);
+-				}
+-				if ($generalContactCountry){
+-					$e_country = $doc->createElement("Country", $generalContactCountry);
+-					$e_contact_address->appendChild($e_country);
+-				}
+-				$e_contact->appendChild($e_contact_address);
+-			}
+-			
+-			if ($generalContactVoiceTelephone){
+-				$e_voice_telephone = $doc->createElement("ContactVoiceTelephone", $generalContactVoiceTelephone);
+-				$e_contact->appendChild($e_voice_telephone);
+-			}
+-			if ($generalContactFacsimileTelephone){
+-				$e_facsimile_telephone = $doc->createElement("ContactFacsimileTelephone", $generalContactFacsimileTelephone);
+-				$e_contact->appendChild($e_facsimile_telephone);
+-			}
+-			if ($generalContactElectronicMailAddress){
+-				$e_email = $doc->createElement("ContactElectronicMailAddress", $generalContactElectronicMailAddress);
+-				$e_contact->appendChild($e_email);
+-			}
+-			$e_general->appendChild($e_contact);
+-		}
+-	$e_view_context->appendChild($e_general);
+-
++$extensionData = $json->decode(stripslashes($_POST["extensionData"]));
+ 
+-	// LayerList
+-	$e_layer_list = $doc->createElement("LayerList");
+-
+-	for ($i=0; $i < count($mapObject->wms); $i++){
+-		$wmsId = $mapObject->wms[$i]->wms_id;
+-		$wms_epsg = array();
+-		$wms_epsg[0] = $mapObject->epsg;
+-	
+-		if ($mapObject->wms[$i]->gui_wms_epsg != $mapObject->epsg){
+-			$wms_epsg[1] = $mapObject->wms[$i]->gui_wms_epsg;
+-		}
+-
+-		for ($q = 0; $q < count($mapObject->wms[$i]->gui_epsg); $q++){
+-			$isInArray = false;
+-			
+-			for ($r=0 ; $r < count($wms_epsg); $r++){
+-				if ($wms_epsg[$r] == $mapObject->wms[$i]->gui_epsg[$q]){
+-					$isInArray = true;
+-				}
+-			}
+-			if ($isInArray == false){
+-				array_push($wms_epsg, $mapObject->wms[$i]->gui_epsg[$q]);
+-			}
+-		}
+-		for ($j = 0; $j < count($mapObject->wms[$i]->objLayer); $j++){
+-			if ($mapObject->wms[$i]->objLayer[$j]->layer_parent != ''){
+-				if ($mapObject->wms[$i]->objLayer[$j]->gui_layer_visible == "1"){
+-					$layerHidden = 0;
+-				}
+-				else{
+-					$layerHidden = 1;
+-				}
+-				$layerQueryable = $mapObject->wms[$i]->objLayer[$j]->layer_queryable;
+-				$layerQuerylayer = $mapObject->wms[$i]->objLayer[$j]->gui_layer_querylayer;
+-				$layerId = $mapObject->wms[$i]->objLayer[$j]->layer_uid;
+-				$layerName = $mapObject->wms[$i]->objLayer[$j]->layer_name;
+-				$layerTitle = $mapObject->wms[$i]->objLayer[$j]->layer_title;
+-				$layerAbstract = $mapObject->wms[$i]->wms_abstract; //To Do: insert actual abstract
+-				$layerDataUrl = $mapObject->wms[$i]->objLayer[$j]->layer_dataurl_href; 
+-				$layerMetadataUrl = $mapObject->wms[$i]->objLayer[$j]->layer_metadataurl;
+-				$layerMinscale = $mapObject->wms[$i]->objLayer[$j]->layer_minscale; 
+-				$layerMaxscale = $mapObject->wms[$i]->objLayer[$j]->layer_maxscale; 
+-				$wmsVersion = $mapObject->wms[$i]->wms_version;
+-				$wmsTitle = $mapObject->wms[$i]->wms_title;
+-				$wmsOnlineResource = $mapObject->wms[$i]->wms_getmap;
+-	
+-				$e_layer = $doc->createElement("Layer");
+-				$e_layer->setAttribute("queryable", $layerQueryable);
+-				$e_layer->setAttribute("hidden", $layerHidden);
+-	
+-					$e_service = $doc->createElement("Server");
+-					$e_service->setAttribute("service", "OGC:WMS");
+-					$e_service->setAttribute("version", $wmsVersion);
+-					$e_service->setAttribute("title", $wmsTitle);
+-	
+-					$e_service_or = $doc->createElement("OnlineResource");
+-					$e_service_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+-					$e_service_or->setAttribute("xlink:type", "simple");
+-					$e_service_or->setAttribute("xlink:href", $wmsOnlineResource);
+-					
+-					$e_service->appendChild($e_service_or);
+-					$e_layer->appendChild($e_service);
+-	
+-					$e_layer_name = $doc->createElement("Name", $layerName);
+-					$e_layer->appendChild($e_layer_name);
+-	
+-					$e_layer_title = $doc->createElement("Title", $layerTitle);
+-					$e_layer->appendChild($e_layer_title);
+-	
+-					if ($layerAbstract){
+-						$e_layer_abstract = $doc->createElement("Abstract", $layerAbstract);
+-						$e_layer->appendChild($e_layer_abstract);
+-					}
+-	
+-					$e_layer_srs = $doc->createElement("SRS", implode(" ", $wms_epsg));
+-					$e_layer->appendChild($e_layer_name);
+-	
+-					if ($layerDataUrl){
+-						$e_layer_data_url = $doc->createElement("DataURL");
+-		
+-						$e_layer_data_url_or = $doc->createElement("OnlineResource");
+-						$e_layer_data_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+-						$e_layer_data_url_or->setAttribute("xlink:type", "simple");
+-						$e_layer_data_url_or->setAttribute("xlink:href", $layerDataUrl);
+-						
+-						$e_layer_data_url->appendChild($e_layer_data_url_or);
+-						$e_layer->appendChild($e_layer_data_url);
+-					}
+-	
+-					if ($layerMetadataUrl){
+-						$e_layer_metadata_url = $doc->createElement("MetadataURL");
+-		
+-						$e_layer_metadata_url_or = $doc->createElement("OnlineResource");
+-						$e_layer_metadata_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+-						$e_layer_metadata_url_or->setAttribute("xlink:type", "simple");
+-						$e_layer_metadata_url_or->setAttribute("xlink:href", $layerMetadataUrl);
+-						
+-						$e_layer_metadata_url->appendChild($e_layer_metadata_url_or);
+-						$e_layer->appendChild($e_layer_metadata_url);
+-					}
+-	
+-					$e_extension = $doc->createElement("Extension");
+-	
+-					$e_scalehint = $doc->createElement($extension_namespace.":ScaleHint");
+-					$e_scalehint->setAttribute("min", $layerMinscale);
+-					$e_scalehint->setAttribute("max", $layerMaxscale);
+-					$e_extension->appendChild($e_scalehint);
+-					
+-					$e_layer_id = $doc->createElement($extension_namespace.":layer_id", $layerId);
+-					$e_extension->appendChild($e_layer_id);
+-	
+-					$e_wms_id = $doc->createElement($extension_namespace.":wms_id", $wmsId);
+-					$e_extension->appendChild($e_wms_id);
+-	
+-					$e_querylayer = $doc->createElement($extension_namespace.":querylayer", $layerQuerylayer);
+-					$e_extension->appendChild($e_querylayer);
+-					
+-					$e_layer->appendChild($e_extension);
+-	
+-					//layerFormat
+-					$e_layer_format = $doc->createElement("FormatList");
+-	
+-					$data_format_current = false;
+-	
+-					for ($k = 0; $k < count($mapObject->wms[$i]->data_format); $k++){
+-	
+-						if ($mapObject->wms[$i]->data_type[$k] == "map") {
+-							$layerFormat = $mapObject->wms[$i]->data_format[$k];
+-			
+-							$e_format = $doc->createElement("Format", $layerFormat);
+-	
+-							if ($data_format_current == false && ( 
+-									($mapObject->wms[$i]->data_format[$k] == $mapObject->wms[$i]->gui_wms_mapformat) ||
+-									($k == (count($mapObject->wms[$i]->data_format)-1))
+-							)){
+-	
+-								$e_format->setAttribute("current", "1");
+-								$data_format_current = true;
+-							}
+-							$e_layer_format->appendChild($e_format);
+-						}
+-					}
+-					$e_layer->appendChild($e_layer_format);
+-	
+-	
+-					// LayerStyle
+-					$e_layer_stylelist = $doc->createElement("StyleList");
+-		
+-					for ($k = 0; $k < count($mapObject->wms[$i]->objLayer[$j]->layer_style); $k++){
+-	
+-						if ($k == 0){
+-							$layerStyle_current = 1; // To do: insert proper data
+-						}
+-						else{
+-							$layerStyle_current = 0; // To do: insert proper data
+-						}
+-	
+-						$e_layer_style = $doc->createElement("Style");
+-	
+-						$layerStyleSLD = "";
+-	
+-						if ($layerStyleSLD){
+-							$layerStyleSLDUrl = ""; // To Do: Insert Proper Data
+-							
+-							$e_layer_style_or = $doc->createElement("OnlineResource");
+-							$e_layer_style_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+-							$e_layer_style_or->setAttribute("xlink:type", "simple");
+-							$e_layer_style_or->setAttribute("xlink:href", $layerStyleSLDUrl);
+-							$e_layer_style->appendChild($e_layer_style_or);
+-						}
+-						else{
+-							//TODO: determine correct layer style entries
+-							$layerStyle_name = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->name;
+-							$layerStyle_title = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->title;
+-							$layerStyle_legendUrl = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->legendurl;
+-							$layerStyle_legendUrl_width = ""; // To Do: add proper data
+-							$layerStyle_legendUrl_height = ""; // To Do: add proper data
+-							$layerStyle_legendUrl_format = ""; // To Do: add proper data
+-	
+-							if ($layerStyle_current == 1){
+-								$e_layer_style->setAttribute("current", "1");
+-							}
+-
+-							$e_layer_style_name = $doc->createElement("Name", $layerStyle_name);
+-							$e_layer_style->appendChild($e_layer_style_name);
+-
+-							$e_layer_style_title = $doc->createElement("Title", $layerStyle_title);
+-							$e_layer_style->appendChild($e_layer_style_title);
+-							
+-							
+-							$e_layer_style_legendurl = $doc->createElement("LegendUrl");
+-							$e_layer_style_legendurl->setAttribute("width", $layerStyle_legendUrl_width);
+-							$e_layer_style_legendurl->setAttribute("height", $layerStyle_legendUrl_height);
+-							$e_layer_style_legendurl->setAttribute("format", $layerStyle_legendUrl_format);
+-
+-							$e_layer_style_legendurl_or = $doc->createElement("OnlineResource");
+-							$e_layer_style_legendurl_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+-							$e_layer_style_legendurl_or->setAttribute("xlink:type", "simple");
+-							$e_layer_style_legendurl_or->setAttribute("xlink:href", $layerStyle_legendUrl);
+-							$e_layer_style_legendurl->appendChild($e_layer_style_legendurl_or);
+-							$e_layer_style->appendChild($e_layer_style_legendurl);
+-						}
+-						$e_layer_stylelist->appendChild($e_layer_style);
+-					}	
+-					$e_layer->appendChild($e_layer_stylelist);
+-					
+-				$e_layer_list->appendChild($e_layer);
+-			}
+-		}
+-	}
+-	$e_view_context->appendChild($e_layer_list);
+-
+-
+-$doc->appendChild($e_view_context);
+-$xml = $doc->saveXML();
++$wmc = new wmc();
++$wmc->createWMCFromObj($mapObject, $user_id, $generalTitle, $extensionData);
+ 
+ if ($save_in_session) {
+-	if (isset($_SESSION["mb_wmc"])) {
+-		$_SESSION["mb_wmc"] = $xml;
+-	}
++	$_SESSION["mb_wmc"] = $wmc->xml;
++	$_SESSION["epsg"] = $mapObject->epsg;
++	$_SESSION["previous_gui"] = $_SESSION["mb_user_gui"];
++	$e = new mb_notice("mod_insertWMCIntoDB: save WMC in session succeeded.");
+ }
+ else {
+-	if ($user_id && $wmc_id) {
++	if ($user_id && $wmc->wmc_id) {
+ 		$sql = "INSERT INTO mb_user_wmc VALUES ($1, $2, $3, $4, $5)";
+-		$v = array($wmc_id, $user_id, $xml, $generalTitle, time());
++		$v = array($wmc->wmc_id, $user_id, $wmc->xml, $generalTitle, time());
+ 		$t = array("s", "i", "s", "s", "s");
+ 		
+ 		$res = db_prep_query($sql, $v, $t);
+@@ -471,11 +52,17 @@
+ 		
+ 		$res = db_prep_query($sql, $v, $t);
+ 		if (db_error()) {
+-			 echo "Error while saving WMC document '" . $generalTitle . "': " . db_error();
++			$errMsg = "Error while saving WMC document '" . $generalTitle . "': " . db_error();
++			echo $errMsg;
++			$e = new mb_exception("mod_insertWMCIntoDB: " . $errMsg);
+ 		}
+ 		else {
+-			 echo "WMC document '" . $generalTitle . "' has been saved.";
++			echo "WMC document '" . $generalTitle . "' has been saved.";
++			$e = new mb_notice("mod_insertWMCIntoDB: WMC  '" . $generalTitle . "' saved successfully.");
+ 		}
+ 	}
++	else {
++		$e = new mb_exception("mod_insertWMCIntoDB: missing parameters (user_id: ".$user_id.", wmc_id: ".$wmc->wmc_id."))");
++	}
+ }
+ ?>
+\ No newline at end of file
+Index: http/php/mod_renameGUI.php
+===================================================================
+--- http/php/mod_renameGUI.php	(revision 1939)
++++ http/php/mod_renameGUI.php	(working copy)
+@@ -214,7 +214,7 @@
+ echo "<tr><td class='newName_str'>Name: </td><td><input class='newName' type='text' id='newGuiName' name='newGuiName'></td></tr>\n";
+ echo "<tr>";
+ echo " <td><input class='button_rename' type='button' value='rename' onclick='validate_rename()'></td>";
+-echo " <td><input class='button_copy' type='button' value='copy' onclick='validate_copy()'><div  class='button_copy_checkbox'>(<input name='withUsers' type='checkbox' /> copy users)</div></td>";
++echo " <td><input class='button_copy' type='button' value='copy' onclick='validate_copy()'><div  class='button_copy_checkbox'>(<input name='withUsers' type='checkbox' /> copy users and groups)</div></td>";
+ echo "</tr>\n";
+ echo "</table>";
+ }
+Index: http/php/mod_wfs.php
+===================================================================
+--- http/php/mod_wfs.php	(revision 1939)
++++ http/php/mod_wfs.php	(working copy)
+@@ -98,6 +98,7 @@
+ 			echo "wfs_conf[".$i."]['g_use_wzgraphics']  = '".$row["g_use_wzgraphics"]."';";
+ 			echo "wfs_conf[".$i."]['fkey_featuretype_id']  = '".$row["fkey_featuretype_id"]."';";
+ 			echo "wfs_conf[".$i."]['wfs_getfeature']  = '".$row["wfs_getfeature"]."';";
++			echo "wfs_conf[".$i."]['wfs_describefeaturetype']  = '".$row["wfs_describefeaturetype"]."';";
+ 			echo "wfs_conf[".$i."]['wfs_transaction']  = '".$row["wfs_transaction"]."';";
+ 			
+ 		}else{die("wfs_conf data not available");}
+Index: http/php/mod_wfs_result.php
+===================================================================
+--- http/php/mod_wfs_result.php	(revision 1939)
++++ http/php/mod_wfs_result.php	(working copy)
+@@ -18,7 +18,11 @@
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ 
+ $filter = stripslashes($_REQUEST["filter"]);
+-$url = stripslashes($_REQUEST['url']);
++$url = stripslashes($_REQUEST["url"]);
++$js_wfs_conf_id = $_REQUEST["js_wfs_conf_id"];
++$db_wfs_conf_id = $_REQUEST["db_wfs_conf_id"];
++$typename = $_REQUEST["typename"];
++
+ //echo $filter; die();
+ require_once("../../conf/mapbender.conf");
+ require_once("../classes/class_stripRequest.php");
+@@ -60,7 +64,6 @@
+ $el = -1;
+ $fid = -1;
+ 
+-$typename = $_REQUEST["typename"];
+ $element_str = "";
+ $geom_str = "";
+ foreach ($values as $element) {
+@@ -106,7 +109,7 @@
+ 		}
+ 		// TO DO: the following is added twice! Once suffices.
+ 		$element_str .= "geom.get(" . $member . ").e.setElement('fid', '".$fid."');\n";
+-		$element_str .= "geom.get(" . $member . ").wfs_conf = ".$_REQUEST['wfs_conf_id'].";\n";
++		$element_str .= "geom.get(" . $member . ").wfs_conf = ".$js_wfs_conf_id.";\n";
+ 	}
+ 	else if(strtoupper($element[tag]) == strtoupper("gml:coordinates") && $geom == true){
+ 		$tmp =  str_replace(",,","",str_replace(" ",",",trim($element[value])));
+Index: http/tools/mapbender_setup.php
+===================================================================
+--- http/tools/mapbender_setup.php	(revision 1939)
++++ http/tools/mapbender_setup.php	(working copy)
+@@ -21,7 +21,8 @@
+  # along with this program; if not, write to the Free Software
+  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+  
+- include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
++include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
++include_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+  
+ ?>
+  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+@@ -31,11 +32,11 @@
+ 	<meta http-equiv="pragma" content="no-cache">
+ 	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ 	<meta name="robots" content="noindex,nofollow">
+-	<title>Mapbender Setupchecker</title>
++	<title>Mapbender Setup-Checker</title>
+ </head>
+ <link rel="stylesheet" type="text/css" href="../css/mapbender.css">
+ <body>
+-<table  BGCOLOR="#ffffff" width="70%" height="70%" ALIGN="top" CELLSPACING="0" CELLPADDING="10" STYLE="-moz-border-radius:8px; border:2px #000000 solid;">
++<table  BGCOLOR="#ffffff" width="95%" height="95%" ALIGN="center" CELLSPACING="0" CELLPADDING="10" STYLE="-moz-border-radius:8px; border:2px #000000 solid;">
+ <tr><td VALIGN="center" STYLE="margin-bottom:0px; padding-bottom:0px;">
+ <H1 style="padding:0px; margin:0px; font:32px/32px bold Arial,Helvetica,sans-serif; font-stretch:extra-expanded;font-weight:bold">
+ <font align="left"" style="font-weight:bold" color="#000000">&nbsp;Ma</font><font color="#0000CE" style="font-weight:bold">p</font><font color="#C00000">b</font><font color="#000000" style="font-weight:bold">ender</font>
+@@ -53,11 +54,11 @@
+ ###########################################
+ #phpversion
+ 	$check ="<tr ><td  width=\"25%\">php Version</td>";
+-	if (phpversion()>'4.3.0'){
+-		if (phpversion()<'5.1.0') $check .="<td width=\"10\"></td><td><font color=#0000FF>Version: " . phpversion() . "! you should think about upgrade to >=php5.1!</td></tr>";
++	if (phpversion()>='5.1.0'){
++		if (phpversion()<'5.2.0') $check .="<td width=\"10\"></td><td><font color=#0000FF>Version: " . phpversion() . "! You should think about upgrade to the current php version (get it <a href='http://www.php.net/downloads.php' target='_blank'>here</a>)</td></tr>";
+ 		else $check .="<td width=\"10\">X</td><td><font color=#00D000>Version: " . phpversion() . "</td></tr>";
+ 	}
+-	else $check .="<td width=\"10\"></td><td><font color=#FF0000>Version: " . phpversion() . "! your PHP is very old, think about upgrade to >=php5.1!</td></tr>";
++	else $check .="<td width=\"10\"></td><td><font color=#FF0000>Version: " . phpversion() . "! Your PHP Version is very old, please upgrade to version >=5.1.0 to use full mapbender functionality and reduce problems!</td></tr>";
+ #php-schnittstelle 
+ 	if(php_sapi_name() == 'cgi') $check.="<tr><td >interface</td><td>X</td><td><font color=#00D000>CGI-PHP</td></tr>";
+ 	else $check.="<tr><td >interface</td><td>X</td><td><font color=#00D000>Modul-PHP</td></tr>";
+@@ -74,9 +75,14 @@
+ 	if (get_cfg_var('memory_limit')) $check .="<tr ><td>memory Limit</td><td>X</td><td><font color=#00D000>" . get_cfg_var('memory_limit') . "</font><font color='#0000FF'> (running in memory-trouble with printing? Perhaps raise your memory limit)</font></td></tr>";
+ 	else $check .="<tr ><td>memory Limit</td><td></td><td><font color=#FF0000>memory_limit must be set (30M will be enough for the moment)</font></td></tr>";
+ # error_reporting
++#Error Reporting: 6135 =>error_reporting  =  E_ALL & ~E_NOTICE (6135-8(E_NOTICE))
++#Error Reporting: 1 => error_reporting  =  E_ERROR
++#Error Reporting: 6143 => error_reporting  =  E_ALL
+ 	$check .="<tr ><td>error-reporting</td>";
+-	 if (get_cfg_var('error_reporting')!=2039) $check .="<td></td><td><font color=#FF0000>please set error_reporting to 'E_ALL & ~E_NOTICE' except for testing</td></tr>";
+-	 else $check .="<td>X</td><td><font color=#00D000>ok, error_reporting = E_ALL & ~E_NOTICE </td></tr>";
++	 if (get_cfg_var('error_reporting')==6143||get_cfg_var('error_reporting')==8) $check .="<td></td><td><font color=#FF0000>please set error_reporting to 'E_ALL & ~E_NOTICE' or 'E_ERROR' except for debugging</td></tr>";
++	elseif  (get_cfg_var('error_reporting')==6135)$check .="<td>X</td><td><font color=#00D000>ok, error_reporting = E_ALL & ~E_NOTICE</td></tr>";
++	elseif  (get_cfg_var('error_reporting')==1)$check .="<td>X</td><td><font color=#00D000>ok, error_reporting = E_ERROR</td></tr>";
++	else $check .="<td></td><td><font color=#0000FF>(Your error_reporting configuration is not implementet into this test yet. You shoul know what you are doing or set it to E_ALL & ~E_NOTICE)</td></tr>";
+ # session.save_handler
+ 	if (!get_cfg_var('session.save_handler')||get_cfg_var('session.save_handler')!='files') $check .="<tr ><td>session.save_handler</td><td></td><td><font color=#FF0000>session.save_handler must be set to 'session.save_handler = files'!</font></td></tr>";
+ 	else $check .="<tr ><td>session.save_handler</td><td>X</td><td><font color=#00D000>session.save_handler = " . get_cfg_var('session.save_handler') . "</font></td></tr>"; 
+@@ -88,6 +94,10 @@
+ 	$check .="<tr ><td>allow_url_fopen</td>"; 
+ 	if (get_cfg_var('allow_url_fopen')=='1') $check .= "<td>X</td><td><font color=#00D000>On</font></td></tr>";
+ 	else $check .= "<td></td><td><font color=#FF0000>Off =>allow_url_fopen must be on read <a href='http://www.mapbender.org/index.php/Allow_url_fopen' target=_blank>this</a></font></td></tr>";
++# short_open_tag 
++	$check .="<tr ><td>short_open_tag</td>"; 
++	if (get_cfg_var('short_open_tag')!='1') $check .= "<td>X</td><td><font color=#00D000>Off</font></td></tr>";
++	else $check .= "<td></td><td><font color=#FF0000>On => Displaying XML files will not work properly</font></td></tr>";
+ 	echo $check;
+ #################################################
+ #PHP Extensioncheck
+@@ -92,13 +102,10 @@
+ #################################################
+ #PHP Extensioncheck
+ #################################################
+-#MYSQL
+ 	?>
+-	</table>
+-	<br><br>
+-	<table style="border: 2px solid rgb(128, 128, 128); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;" bgcolor=#dddddd cellspacing=0 cellpadding=0 width="95%">
+ 	<th colspan="3" bgcolor=#F0F0F0>PHP Extensioncheck</th>
+ 	<?php
++#MYSQL	
+ 	if(!extension_loaded('mysql')) $check="<tr ><td width=\"25%\">MySQL check</td><td width=\"10\"></td><td><font color=#FF0000 >MySQL not installed! (You have to include mysql-extension if you want to use MySQL as MB-Database!)</font></td></tr>";
+ 	else $check="<tr ><td width=\"25%\">MySQL check</td><td width=\"10\">X</td><td><font color=#00D000 >MySQL installed</font></td></tr>";
+ #PGSQL
+@@ -107,7 +114,16 @@
+ #GD
+ 	if(extension_loaded('gd')) $check.="<tr ><td>GD2 check</td><td>X</td><td><font color=#00D000>GD installed</font></td></tr>";
+ 	else $check.="<tr ><td>GD2 check</td><td></td><td><font color=#FF0000>GD not installed (no printing possible)</font></td></tr>";
+-	echo $check;
++
++#mbstring
++	if(extension_loaded('mbstring')) $check.="<tr ><td>mbstring check</td><td>X</td><td><font color=#00D000>mbstring installed</font></td></tr>";
++	else $check.="<tr ><td>mbstring check</td><td></td><td><font color=#FF0000>PHP extension mbstring is not installed</font></td></tr>";
++
++#gettext
++	if(extension_loaded('gettext')) $check.="<tr ><td>gettext check</td><td>X</td><td><font color=#00D000>gettext installed</font></td></tr>";
++	else $check.="<tr ><td>gettext check</td><td></td><td><font color=#FF0000>PHP extension gettext is not installed</font></td></tr>";
++
++echo $check;	    
+ ####################################
+ # Database check
+ ####################################
+@@ -130,22 +146,22 @@
+ 			$con_postgis = pg_connect($con_string);
+ 			$sql = "Select postgis_full_version();";
+ 			$res = pg_query($con_postgis,$sql);
+-			if(!$res) $check .="<tr width=\"20%\><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</tr>";
++			if(!$res) $check .="<tr width=\"20%\><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
+ 			else{
+ 				$cnt=0;
+ 				while(pg_fetch_row($res)){
+-					$check .="<tr><td>PostGIS support</td><td>X</td><td><font color=#00D000>PostGIS function available</tr>";
++					$check .="<tr><td>PostGIS support</td><td>X</td><td><font color=#00D000>PostGIS function available</td></tr>";
+ 					$check .="<tr><td>Version</td><td>X</td><td><font color=#00D000>" . pg_fetch_result($res,$cnt,0). "</td></tr>";
+ 		  		  	$cnt++;
+ 		  		}
+-				if ($cnt==0) $check .="<tr><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</tr>";
++				if ($cnt==0) $check .="<tr><td>PostGIS support</td><td></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
+ 			}
+ 		}
+-		else $check .="<tr><td>Postgis support</td><td></td><td><font color=#FF0000>no PostGIS function available</font></tr>";
++		else $check .="<tr><td>Postgis support</td><td></td><td><font color=#FF0000>no PostGIS function available</font></td></tr>";
+ 		echo $check;
+ 	}
+ 	else{
+-		$check = "<tr><td width=\"25%\">Administration Database</td><td>X</td><td><font color=#00D000>PostgreSQL</td><tr>";
++		$check = "<tr><td width=\"25%\">Administration Database</td><td>X</td><td><font color=#00D000>PostgreSQL</td></tr>";
+ 		$check .= "<tr><td>Connect to Database</td>";
+ 		if($con) $check .="<td width=\"10\">X</td><td><font color=#00D000>connected</font></td></tr>";
+ 		else $check .="<td width=\"10\"></td><td><font color=#FF0000>not connected</font></td></tr>";
+@@ -163,9 +179,6 @@
+ # PostGIS check
+ ######################################	
+ 	?>
+-	</table>
+-	<br><br>
+-	<table style="border: 2px solid rgb(128, 128, 128); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;" bgcolor=#dddddd cellspacing=0 cellpadding=0 width="95%">
+ 	<th colspan="3" bgcolor=#F0F0F0>PostGIS check</th>
+ 	<?php
+ 		$check ="";
+@@ -173,18 +186,18 @@
+ 			$sql = "select postgis_full_version();";
+ 			if (pg_query($con,$sql))$res = pg_query($con,$sql);
+ 			else echo "<tr><td><font>pg_query($con,$sql)";
+-			if(!$res) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</tr>";
++			if(!$res) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
+ 			else{
+ 				$cnt=0;
+ 				while(pg_fetch_row($res)){
+-					$check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\">X</td><td><font color=#00D000>PostGIS function available</tr>";
++					$check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\">X</td><td><font color=#00D000>PostGIS function available</td></tr>";
+ 					$check .="<tr><td>Version</td><td width=\"10\">X</td><td><font color=#00D000>" . pg_fetch_result($res,$cnt,0). "</td></tr>";
+ 		  		  	$cnt++; 	
+ 		  		}
+-				if ($cnt==0) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</tr>";
++				if ($cnt==0) $check .="<tr><td width=\"25%\">PostGIS support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</td></tr>";
+ 			}
+ 		}
+-		else $check .="<tr><td width=\"25%\">Postgis support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</font></tr>";
++		else $check .="<tr><td width=\"25%\">Postgis support</td><td width=\"10\"></td><td><font color=#FF0000>no PostGIS function available</font></td></tr>";
+ 		echo $check;
+ 	} 
+ #################################
+@@ -194,7 +207,7 @@
+ 	</table>
+ 	<br><br>
+ 	<table style="border: 2px solid rgb(128, 128, 128); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;" bgcolor=#dddddd cellspacing=0 cellpadding=0 width="95%">
+-	<th colspan="3" bgcolor=#F0F0F0>mapbender.conf check</th>
++	<th colspan="4" bgcolor=#F0F0F0>Mapbender Configuration Check</th>
+ 	<?php 
+ # SYS_DBTYPE
+ 	if ((SYS_DBTYPE == 'mysql' || SYS_DBTYPE == 'pgsql') && defined('SYS_DBTYPE')) $check ="<tr><td>Administration Database</td><td >X</td><td><font color=#00D000>" . SYS_DBTYPE . "</font></td></tr>";
+@@ -211,15 +224,15 @@
+ # PREPAREDSTATEMENTS
+ 	if (defined('PREPAREDSTATEMENTS')){
+ 		if (PREPAREDSTATEMENTS == true){
+-			if (phpversion()<'5.1.0') $check.="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\"></td><td><font color=\"#ff0000\">PREPAREDSTATEMENTS =set to 'true' and php version " . phpversion() . " is incompatible<br>set PREPAREDSTATEMENTS to false or update php to >=5.1</td></tr>";
+-			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'true' and php " . phpversion() . " should work</td><tr/>";
++			if (phpversion()<'5.1.0') $check.="<tr><td width=\"25%\">PREPAREDSTATEMENTS</td><td width=\"10\"></td><td><font color=\"#ff0000\">PREPAREDSTATEMENTS =set to 'true' and php version " . phpversion() . " is incompatible<br>set PREPAREDSTATEMENTS to false or update php to >=5.1</td></tr>";
++			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS</td><td width=\"10\">X</td><td><font color=#00D000>set to 'true' and php " . phpversion() . " should work</td></tr>";
+ 		}
+ 		else{
+-			if (phpversion()<'5.1.0') $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work </font><font color='#0000FF'> (but think about upgrading to php 5.1)</td><tr/>";
+-			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work <font color=#0000FF>(but you can set PREPAREDSTATEMENTS to 'true')</font></td><tr/>";
++			if (phpversion()<'5.1.0') $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work </font><font color='#0000FF'> (but think about upgrading to php 5.1)</td></tr>";
++			else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\">X</td><td><font color=#00D000>set to 'false' and php " . phpversion() . " should work <font color=#0000FF>(but you can set PREPAREDSTATEMENTS to 'true')</font></td></tr>";
+ 		}
+ 	}
+-    else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\"></td><td><font color=#FF0000>PREPAREDSTATEMENTS is not defined</td><tr/>";
++    else $check .="<tr><td width=\"25%\">PREPAREDSTATEMENTS-<br>compatibility</td><td width=\"10\"></td><td><font color=#FF0000>PREPAREDSTATEMENTS is not defined</td></tr>";
+ # CHARSET
+ 	if (CHARSET != "" && defined('CHARSET')) $check .="<tr><td>CHARSET</td><td>X</td><td><font color=#00D000>" . CHARSET . "</font><font color='#0000FF'></font></td></tr>";
+ 	else $check .="<tr><td>CHARSET</td><td></td><td><font color=#FF0000>CHARSET is not defined</font></td></tr>";
+@@ -226,14 +239,49 @@
+ # TMPDIR
+ 	if (TMPDIR != "" && defined('TMPDIR')) $check .="<tr><td>TMPDIR</td><td>X</td><td><font color=#00D000>" . TMPDIR . "</font><font color='#0000FF'></font></td></tr>";
+ 	else $check .="<tr><td>TMPDIR</td><td></td><td><font color=#FF0000>TMPDIR is not defined</font></td></tr>";
++# OWSPROXY
++	if (OWSPROXY != "" && defined('OWSPROXY')) $check .="<tr><td>OWSPROXY</td><td>X</td><td><font color=#00D000>" . OWSPROXY . "</font><font color=#0000FF> (Is this the right URL to your OWSPROXY?)</font></td></tr>";
++	else $check .="<tr><td>OWSPROXY</td><td></td><td><font color=#FF0000>OWSPROXY not defined</font><font color=#0000FF>(if you want to camouflage your WMS, you should think about OWSPROXY!)</font></td></tr>";
++#AUTO_UPDATE
++	if (AUTO_UPDATE != "" && defined('AUTO_UPDATE')){
++		if (AUTO_UPDATE == '1'){ 
++			$check .="<tr><td>AUTO_UPDATE</td><td>X</td><td>set to 1: will update all out-of-date WMS automatically<td></tr>";
++			if (!TIME_LIMIT || TIME_LIMIT == "")$check .="<tr><td>TIME_LIMIT</td><td></td><td><font color=#FF0000>you should define a TIME_LIMIT for the AUTO_UPDATE funtionallity</font><td></tr>";
++		}
++		elseif (AUTO_UPDATE == '0') $check .="<tr><td>AUTO_UPDATE</td><td>X</td><td><font color=#00D000>set to 0:</font> <font color=#0000FF>(see the result of the test and update WMS manually)</font></td></tr>";
++		else $check .="<tr><td>AUTO_UPDATE</td><td></td><td><font color=#FF0000>set to " . AUTO_UPDATE . ": this configuration value is not supported(as yet!)</td></tr>";
++	} 			    	
++	else $check .="<tr><td>AUTO_UPDATE</td><td></td><td><font color=#FF0000>AUTO_UPDATE not defined </font><font color=#0000FF>(for the wms monitoring 	functionality you have to define this constant)</font></td></tr>";
++# ERROR LOGGING
++	$testLog = new mb_notice("This is a test run by the Mapbender setup script.");
++	if ($testLog->result) {
++		$check .="<tr><td>ERROR LOGGING</td><td>X</td><td><font color=#00D000>" . $testLog->message . "</font></td></tr>";		
++	}
++	else {
++		$check .="<tr><td>ERROR LOGGING</td><td></td><td><font color=#FF0000>" . $testLog->message . "</font></td></tr>";		
++	}
++#LOG_LEVEL (off,error,warning,all)
++	if (LOG_LEVEL !="" && defined('LOG_LEVEL')){
++		if (LOG_LEVEL =='off') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td>switched off: <font color=#FF0000>-no Mapbender-errors logging</font><td></tr>"; 
++		elseif (LOG_LEVEL =='error') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td><font color=#00D000>set to 'error': </font><font color=#0000FF>-Mapbender-errors will be logged</font><td></tr>";
++		elseif (LOG_LEVEL =='warning') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td><font color=#00D000>set to 'warning: </font><font color=#0000FF>- Mapbender-errors and -warnings will be logged</font><td></tr>";
++		elseif (LOG_LEVEL =='all') $check .="<tr><td>LOG_LEVEL</td><td>X</td><td><font color=#00D000>set to 'all': </font><font color=#0000FF>-really every little notice will be logged!!</font><td></tr>";
++		else $check .="<tr><td>LOG_LEVEL</td><td></td><td><font color=#FF0000>set to " . LOG_LEVEL . ": this configuration value is not supported (as yet!)</font></td></tr>";		
++	}	
++# PORTAL
++	if (defined('PORTAL')){
++		if (PORTAL == true) $check .="<tr><td width=\"25%\">PORTAL</td><td width=\"10\">X</td><td><font color=#00D000>true</font><font color='#0000FF'> (Users can create theirs own accounts)</font></td></tr>";
++		else $check .="<tr><td width=\"25%\">PORTAL</td><td width=\"10\">X</td><td><font color=#00D000>false<font color=#0000FF> (Users can't create their own accounts at the moment)</font></td></tr>";
++	}
++    else $check .="<tr><td width=\"25%\">PORTAL</td><td width=\"10\"></td><td><font color=#FF0000>PORTAL is not defined<font color=#0000FF>(Maybe an old configuration file?)</font></td></tr>";
+ # MAXLOGIN
+ 	if (MAXLOGIN != "" && defined('MAXLOGIN')) $check .="<tr><td>MAXLOGIN</td><td>X</td><td><font color=#00D000>" . MAXLOGIN . "</font><font color='#0000FF'></font></td></tr>";
+-	else $check .="<tr><td>MAXLOGIN</td><td></td><td><font color=#FF0000>MAXLOGIN is not defined</font></td></tr>";		    	
++	else $check .="<tr><td>MAXLOGIN</td><td></td><td><font color=#0000FF>MAXLOGIN is not defined</font></td></tr>";		    	
+ # LOGIN
+-	if (defined('LOGIN')) $check .= "<tr height=10/><tr><td>Login-Path</td><td colspan=2><a href='" . LOGIN . "' target='_blank'>" . LOGIN . "</a><br><font color=#0000FF> (if this link doesn't work, check out your 'URL to Login' in your mapbender.conf<br>Perhaps an alias in your httpd.conf will solve the prob')</td>";
++	if (defined('LOGIN')) $check .= "<tr height=10/><tr><td>Login-Path</td><td colspan=2><a href='" . LOGIN . "' target='_blank'>" . LOGIN . "</a><br><font color=#0000FF> (If this link doesn't work, check your url to 'Login' in your mapbender.conf<br>Perhaps an alias in your httpd.conf will solve the problem, too)</td>";
+ 	else $check .= "<tr height=10/><tr><td>Login-Path</td><td colspan=2><font color=#FF0000>LOGIN is not defined</font></td>";
+ 	echo $check;	
+-	echo "<tr height=10/><tr bgcolor=#F0F0F0><td colspan=3>Legend:<br><font color=#FF0000>red = maybe your Mapbender will run into trouble</font><br><font color=#0000FF>blue = just a tip</font><br><font color=#00D000>green = seems to be alright</font></td></tr>";
++	echo "<tr height=10/><tr bgcolor=#F0F0F0><td colspan=4>Legend:<br><font color=#FF0000>red = maybe your Mapbender will run into trouble</font><br><font color=#0000FF>blue = just a tip</font><br><font color=#00D000>green = seems to be alright</font></td></tr>";
+ 	echo "</table>";
+ 	echo "<tr><td colspan=3 align=right>for further informations visit <a href=\"http://www.mapbender.org/index.php/Installation_en\" target=\"_blank\"><font align=\"left\" style=\"font-weight:bold\" color=\"#000000\">&nbsp;Ma</font><font color=\"#0000CE\" style=\"font-weight:bold\">p</font><font color=\"#C00000\" style=\"font-weight:bold\">b</font><font color=\"#000000\" style=\"font-weight:bold\">ender</font> installation instructions</a></td></tr>";
+ 	?>



More information about the Mapbender_commits mailing list