[Mapbender-commits] r3974 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jun 2 07:01:16 EDT 2009


Author: beck
Date: 2009-06-02 07:01:16 -0400 (Tue, 02 Jun 2009)
New Revision: 3974

Removed:
   trunk/mapbender/http/javascripts/x_mod_digitize_tab.php
Log:


Deleted: trunk/mapbender/http/javascripts/x_mod_digitize_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/x_mod_digitize_tab.php	2009-06-02 10:59:34 UTC (rev 3973)
+++ trunk/mapbender/http/javascripts/x_mod_digitize_tab.php	2009-06-02 11:01:16 UTC (rev 3974)
@@ -1,1671 +0,0 @@
-<?php
-# $Id: mod_digitize_tab.php 2320 2009-02-27 14:46:23Z baudson $
-# http://www.mapbender.org/index.php/mod_digitize_tab.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.
-
-session_start();
-import_request_variables("PG");
-require_once("../php/mb_validateSession.php");
-require_once("../../conf/mapbender.conf");
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-$gui_id = $_SESSION["mb_user_gui"];
-?>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-	
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<title>Digitize</title>
-<?php
-$digitize_conf_filename = "digitize_default.conf";
-include '../include/dyn_css.php';
-
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-$sql = "SELECT e_src, e_target FROM gui_element WHERE e_id = 'digitize' AND fkey_gui_id = $1";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sql, $v, $t);
-$cnt = 0;
-while($row = db_fetch_array($res)){ 
-	$e_src = $row["e_src"];
-	$e_target = explode(",",$row["e_target"]);
-	$cnt++;
-}
-if($cnt > 1) echo "alert('digitize_button: ID not unique!');";
-
-echo "<script language='JavaScript'>";
-echo "var mod_digitize_target = '".$e_target[0]."';";
-echo "var mod_digitize_frame = '".$e_target[1]."';";
-include("../../conf/" . $digitize_conf_filename);
-?>
-
-function htmlspecialchars(p_string) {
-	p_string = p_string.replace(/&/g, '&amp;');
-	p_string = p_string.replace(/</g, '&lt;');
-	p_string = p_string.replace(/>/g, '&gt;');
-	p_string = p_string.replace(/"/g, '&quot;');
-	//	p_string = p_string.replace(/'/g, '&#039;');
-	return p_string;
-};
-
-var wfsWindow;	
-var dwin = null;
-var wfsConf = [];
-var d = new parent.GeometryArray();
-var mod_digitize_width;
-var mod_digitize_height;
-var mod_digitizeEvent = false;
-var nonTransactionalHighlight;
-
-var button_point = "Point";
-var button_line = "Line";
-var button_polygon = "Polygon";
-var button_move = "dragBasePoint";
-var button_insert = "setBasePoint";
-var button_delete = "delBasePoint";
-var button_clear = "clear";
-var button_combine = "combine";
-
-var digitizeDivTag;
-registerFunctions();
-
-var featureTypeElementFormId = "featureTypeElementForm";
-
-try {if(mod_digitize_elName){}}catch(e) {mod_digitize_elName = "digitize";}
-
-function toggleTabs(tabId) {
-	if(!initialTab) {
-		return;
-	}
-
-	var tabHeaders = wfsWindow.document.getElementsByTagName('a');
-	var tabs       = wfsWindow.document.getElementsByTagName('div');
-	
-	for(var i = 0; i < tabHeaders.length; i++) {
-		if(tabHeaders[i].id.indexOf('tabheader') != -1) {
-			tabHeaders[i].className = 'tabheader';
-		}
-	}
-	
-	for(var i = 0; i < tabs.length; i++) {
-		if(tabs[i].className === 'tabcontent') {
-			tabs[i].style.visibility = 'hidden';
-			tabs[i].style.display    = 'none';
-		}
-	}
-	
-	wfsWindow.document.getElementById('tabheader_' + tabId).className += ' active';
-	
-	wfsWindow.document.getElementById('tab_' + tabId).style.visibility = 'visible';
-	wfsWindow.document.getElementById('tab_' + tabId).style.display    = 'block';
-	
-	return false;
-}
-
-function showHelptext(helptextId) {
-	hideHelptext();
-	wfsWindow.document.getElementById('helptext' + helptextId).style.visibility = 'visible';
-	wfsWindow.document.getElementById('helptext' + helptextId).style.display    = 'block';
-
-	return false;
-}
-
-function hideHelptext(helptextId) {
-	if(helptextId) {
-		wfsWindow.document.getElementById('helptext' + helptextId).style.visibility = 'hidden';
-		wfsWindow.document.getElementById('helptext' + helptextId).style.display    = 'none';
-	}
-
-	var helptext = wfsWindow.document.getElementsByTagName('div');
-	
-	for(var i = 0; i < helptext.length; i++) {
-		if(helptext[i].className === 'helptext') {
-			helptext[i].style.visibility = 'hidden';
-			helptext[i].style.display    = 'none';
-		}
-	}
-
-	return false;
-}
-
-// ------------------------------------------------------------------------------------------------------------------------
-// --- polygon, line, point insertion (begin) ----------------------------------------------------------------------------------------------
-
-function appendGeometryArray(obj) {
-	executeDigitizePreFunctions();
-	for (i=0; i<obj.count(); i++) {
-		d.addCopy(obj.get(i));
-	}
-	executeDigitizeSubFunctions();
-}
-
-function mod_digitize_go(e){
-	parent.mb_registerGML(mod_digitize_target,d);   
-
-	// ie workaround
-	if (e == undefined) {
-		e = parent.frames[mod_digitize_target].event;
-	}
-	if (e) {
-		// track mouse position
-		parent.mb_getMousePos(e, mod_digitize_target);
-		var currentPos = new parent.Point(parent.clickX, parent.clickY);
-		s.check(currentPos);
-	}
-	else {
-//		s.clean();
-	}
-
-	var el = parent.frames[mod_digitize_target].document;
-	el.onmousedown = mod_digitize_start;
-}
-
-function mod_digitize_timeout(){
-	var el = parent.frames[mod_digitize_target].document;
-	el.onmousedown = null;
-	el.onmouseup = null;
-	el.onmousemove = null;
-}
-
-function mod_digitize_start(e){
-	// check if a proper geometry is selected	
-	if (d.getGeometry(-1,-1).isComplete() || d.count() == 0){
-		
-		if (mod_digitizeEvent != false) {
-			alert(errorMessageNoGeometrySelected[selectedLanguage]);
-		}
-		return false;
-	}
-	
-	var realWorldPos;
-	if (s.isSnapped()) {
-		realWorldPos = s.getSnappedPoint(); 
-		s.clean();
-	}
-	else {
-		parent.mb_getMousePos(e,mod_digitize_target);
-		realWorldPos = parent.mapToReal(mod_digitize_target,new parent.Point(parent.clickX,parent.clickY));
-	}
-	
-	if (d.get(-1).geomType == parent.geomType.polygon && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(0).equals(realWorldPos)) {
-				
-		// close the polygon
-		d.close();
-		parent.mb_disableThisButton(button_polygon);
-		return true;
-	}
-	else if (d.get(-1).geomType == parent.geomType.line && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(-1).equals(realWorldPos)) {
-		// close the line
-		d.close();
-		parent.mb_disableThisButton(button_line);
-		return true;
-	}
-	else {
-		// set the calculated real world position as point of the geometry
-		d.getGeometry(-1,-1).addPoint(realWorldPos);
-		
-		if(d.get(-1).geomType == parent.geomType.point){
-			d.close();
-			parent.mb_disableThisButton(button_point);
-			return true;
-		}
-		
-		// add first point of polygon to snapping list (if three points have been inserted).
-		else if (d.get(-1).geomType == parent.geomType.polygon && d.getGeometry(-1,-1).count() == 3) {
-			s.add(d.getPoint(-1, -1, 0));
-		}
-
-		// add last point of line to snapping list (if at least two points have been inserted).
-		else if (d.get(-1).geomType == parent.geomType.line && d.getGeometry(-1,-1).count() >= 2) {
-			if (mod_digitizeEvent != button_move) {
-				s.store(d);
-			}
-			s.add(d.getPoint(-1, -1, -1));
-		}
-	}
-	executeDigitizeSubFunctions();
-	return true;
-}
-// --- polygon, line, point insertion (begin) ----------------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-
-// ------------------------------------------------------------------------------------------------------------------------
-// --- basepoint handling (begin) -----------------------------------------------------------------------------------------
-
-var basepointObject = false;
-var basepointMemberIndex = null;
-var basepointGeometryIndex = null;
-var basepointPointIndex = null;
-var basepointDragActive = false;
-
-function handleBasepoint(obj,memberIndex,geometryIndex,pointIndex){
-	if(!(mod_digitizeEvent == button_move || mod_digitizeEvent == button_insert || mod_digitizeEvent == button_delete)){ return false; }
-	
-	basepointObject = obj;
-	basepointMemberIndex = memberIndex;
-	basepointGeometryIndex = geometryIndex;
-	basepointPointIndex = pointIndex;
-	
-	if(mod_digitizeEvent == button_move){
-		mod_digitize_timeout();
-		basepointObject.style.cursor = 'move';
-		basepointObject.onmousedown = parent.window.frames[mod_digitize_elName].selectBasepoint;
-	}
-
-	if(mod_digitizeEvent == button_delete){
-		mod_digitize_timeout();
-		basepointObject.style.cursor = 'crosshair';
-		basepointObject.onmousedown = parent.window.frames[mod_digitize_elName].deleteBasepoint;
-	}
-}
-
-function convertLinepointToBasepoint(obj, memberIndex, geomIndex, pointIndex){
-	if(!(mod_digitizeEvent == button_insert)){ return false; }
-	
-	if(mod_digitizeEvent == button_insert){
-		mod_digitize_timeout();
-		obj.style.cursor = 'crosshair';
-		obj.onclick = insertBasepoint;
-
-		basepointObject = obj;
-		basepointMemberIndex = memberIndex;
-		basepointGeometryIndex = geomIndex;
-		basepointPointIndex = pointIndex;
-	}
-}
-
-function insertBasepoint(e){
-	var i = basepointMemberIndex;
-	var j = basepointGeometryIndex;
-	var k = basepointPointIndex;
-	
-	parent.mb_getMousePos(e, mod_digitize_target);
-	var pos = parent.makeClickPos2RealWorldPos(mod_digitize_target,parent.clickX, parent.clickY);
-	var p = new parent.Point(pos[0], pos[1]);
-	d.getGeometry(i,j).addPointAtIndex(p, k);
-
-	executeDigitizeSubFunctions();
-}
-
-function deleteBasepoint(){
-	var i = basepointMemberIndex;
-	var j = basepointGeometryIndex;
-	var k = basepointPointIndex;
-	d.delAllPointsLike(d.getPoint(i,j,k));
-
-	executeDigitizeSubFunctions();
-}
-
-function selectBasepoint(e){
-	if(!basepointDragActive && mod_digitizeEvent == button_move){
-		basepointDragActive = true;
-		s.store(d, d.getPoint(basepointMemberIndex, basepointGeometryIndex, basepointPointIndex));
-		// replace basepoint by transparent blob
-		basepointObject.style.width = mod_digitize_width;
-		basepointObject.style.height = mod_digitize_height;
-		basepointObject.style.left = 0;
-		basepointObject.style.top = 0;
-			
-		if (parent.ie) {
-			// ie cannot handle backgroundColor = 'transparent'
-			basepointObject.style.background = "url(../img/transparent.gif)";
-		}
-		else{
-			basepointObject.style.backgroundColor = 'transparent';
-		}
-
-		basepointObject.onmouseup = releaseBasepoint;
-		basepointObject.onmousemove = dragBasepoint;
-	}
-}
-
-function dragBasepoint(e){
-	if(basepointDragActive){
-		parent.mb_getMousePos(e, mod_digitize_target);
-		var currentPos = new parent.Point(parent.clickX, parent.clickY);
-		var res = s.check(currentPos);
-
-	}
-}
-	
-function updateAllPointsOfNonTransactionalLike(oldP, newP){ 
-	for (var i = 0; i < d.count(); i++) {
-		if (isTransactional(d.get(i))) {
-			d.get(i).updateAllPointsLike(oldP, newP);
-		}
-	}
-}
-
-	
-function releaseBasepoint(e){
-	
-	var i = basepointMemberIndex;
-	var j = basepointGeometryIndex;
-	var k = basepointPointIndex;
-	basepointDragActive = false;
-	
-	parent.mb_getMousePos(e, mod_digitize_target);
-	var basepointDragEnd = new parent.Point(parent.clickX, parent.clickY);
-	basepointObject.onmousedown = null;
-	var p = parent.makeClickPos2RealWorldPos(mod_digitize_target, basepointDragEnd.x, basepointDragEnd.y);
-
-	var oldPoint = parent.cloneObject(d.getPoint(i,j,k));
-	if (s.isSnapped()) {
-		var snappedPoint = parent.cloneObject(s.getSnappedPoint());
-		if (!nonTransactionalEditable) {
-			updateAllPointsOfNonTransactionalLike(oldPoint, snappedPoint);
-		}
-		else {
-			d.updateAllPointsLike(oldPoint, snappedPoint);
-		}
-		s.clean();
-	}
-	else {
-		var newPoint = new parent.Point(p[0],p[1]);
-		if (!nonTransactionalEditable) {
-			updateAllPointsOfNonTransactionalLike(oldPoint, newPoint);
-		}
-		else {
-			d.updateAllPointsLike(oldPoint, newPoint);
-		}
-	}
-	basepointMemberIndex = null;
-	basepointGeometryIndex = null;
-	basepointPointIndex = null;	
-		
-	executeDigitizeSubFunctions();
-}
-// --- basepoint handling (end) -----------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-	
-// ------------------------------------------------------------------------------------------------------------------------
-// --- registered functions (begin) ---------------------------------------------------------------------------------------
-
-function registerDigitizePreFunctions(stringFunction){
-	mod_digitizePreFunctions[mod_digitizePreFunctions.length] = stringFunction;
-}
-
-function registerDigitizeSubFunctions(stringFunction){
-	mod_digitizeSubFunctions[mod_digitizeSubFunctions.length] = stringFunction;
-}
-
-function executeDigitizeSubFunctions(){
-	for(var i=0; i<mod_digitizeSubFunctions.length; i++){
-		eval(mod_digitizeSubFunctions[i]);
-	}
-}
-
-function executeDigitizePreFunctions(){
-	for(var i=0; i<mod_digitizePreFunctions.length; i++){
-		eval(mod_digitizePreFunctions[i]);
-	}
-}
-
-function registerFunctions(){
-	mod_digitizePreFunctions = [];
-	mod_digitizeSubFunctions = [];
-	registerDigitizePreFunctions("updateExtent()");
-	registerDigitizePreFunctions("drawDashedLine()");
-	registerDigitizeSubFunctions("updateListOfGeometries()");
-	registerDigitizeSubFunctions("drawDashedLine()");
-	registerDigitizeSubFunctions("updateMeasureTag()");
-	parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].setStyleForTargetFrame()");
-	parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].checkDigitizeTag()");
-	parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].initialiseSnapping()");
-	if (!nonTransactionalEditable) {
-		parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].initialiseHighlight()");
-	}
-	parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].initialiseMeasure()");
-	parent.mb_registerSubFunctions("window.frames['" + mod_digitize_elName + "'].updateExtent()");
-	parent.mb_registerWfsReadSubFunctions(function(geom){parent.tab_open(mod_digitize_elName);parent.window.frames[mod_digitize_elName].appendGeometryArray(geom);});
-	parent.mb_registerWfsWriteSubFunctions(function(){parent.zoom(mod_digitize_target, true, 0.999);});
-}
-
-function checkDigitizeTag(){
-	var digitizeTagName = "digitize";
-	var digitizeTagStyle = {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeTransactionalZIndex, "font-size":"10px"};
-	digitizeDivTag = new parent.DivTag(digitizeTagName, mod_digitize_target, digitizeTagStyle);
-	parent.mb_registerPanSubElement(digitizeTagName);
-	parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].drawDashedLine()");
-}
-
-
-function setStyleForTargetFrame(){
-	var cssLink = parent.window.frames[mod_digitize_target].document.createElement("link");
-	cssLink.setAttribute("href", cssUrl); 
-	cssLink.setAttribute("type", "text/css"); 
-	cssLink.setAttribute("rel", "stylesheet"); 
-	var cssTmp = parent.window.frames[mod_digitize_target].document.getElementsByTagName("head")[0];
-	cssTmp.appendChild(cssLink);
-}
-
-function initialiseSnapping(){
-	s = new parent.Snapping(mod_digitize_target, snappingTolerance, snappingColor, snappingHighlightZIndex);
-}
-function initialiseHighlight(){
-	nonTransactionalHighlight = new parent.Highlight(new Array(mod_digitize_target), "nonTransactional", {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeNonTransactionalZIndex}, nonTransactionalLineWidth);
-}
-function initialiseMeasure(){
-	measureDivTag = new parent.DivTag(measureTagName, measureTagTarget, measureTagStyle);
-	parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].updateMeasureTag()");
-}
-// --- registered functions (end) -----------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-
-
-function updateMeasureTag () {
-	if (d.count() > 0 ) {
-		if (d.get(-1).count() > 0) {
-			if (d.getGeometry(-1, -1).count() > 0) {
-				if (mod_digitizeEvent == button_line || mod_digitizeEvent == button_polygon) {
-					var measureString = "";
-					measureString += measureTagLabelCurrent[selectedLanguage] + d.getGeometry(-1, -1).getCurrentDist(measureNumberOfDigits) + "<br>";
-					measureString += measureTagLabelTotal[selectedLanguage] + d.getGeometry(-1, -1).getTotalDist(measureNumberOfDigits);
-					measureDivTag.write(measureString);
-					return true;
-				}
-			}
-		}
-	}
-	measureDivTag.clean();
-}
-
-
-
-// ------------------------------------------------------------------------------------------------------------------------
-// --- button handling (begin) --------------------------------------------------------------------------------------------
-
-function displayButtons(){
-	for (var i = 0 ; i < buttonDig_id.length ; i ++) {
-		if (parseInt(buttonDig_on[i])==1) {
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", "div_" + buttonDig_id[i]);
-// FIREFOX 
-			document.getElementById("digButtons").appendChild(divTag);
-
-//IE WORKAROUND, WORKS ALSO FOR FIREFOX
-			var tagContent = "<div style='position:absolute; top:"+buttonDig_y[i]+"px; left:"+buttonDig_x[i]+"px;'><img name=\""+buttonDig_id[i]+"\" onmouseover=\"parent.mb_regButton_frame('initDigButton', mod_digitize_elName, "+i+");\" id=\""+buttonDig_id[i]+"\" title=\""+buttonDig_title_off[i]+"\" src=\""+buttonDig_imgdir+buttonDig_src[i]+"\"></div>";
-			parent.writeTag(mod_digitize_elName,"div_" + buttonDig_id[i],tagContent);
-		}
-	}
-}
-
-function initDigButton(ind, pos){
-	parent.mb_button[ind] = document.getElementById(buttonDig_id[pos]);
-	parent.mb_button[ind].img_over = buttonDig_imgdir + buttonDig_src[pos].replace(/_off/,"_over");
-	parent.mb_button[ind].img_on = buttonDig_imgdir + buttonDig_src[pos].replace(/_off/,"_on");
-	parent.mb_button[ind].img_off = buttonDig_imgdir + buttonDig_src[pos];
-	parent.mb_button[ind].title_on = buttonDig_title_on[pos];
-	parent.mb_button[ind].title_off = buttonDig_title_off[pos];
-	parent.mb_button[ind].status = 0;
-	parent.mb_button[ind].elName = buttonDig_id[pos];
-	parent.mb_button[ind].fName = "";
-	parent.mb_button[ind].go = new Function ("digitizeEnable(parent.mb_button["+ind+"])");
-	parent.mb_button[ind].stop = new Function ("digitizeDisable(parent.mb_button["+ind+"])");
-}	
-
-function digitizeEnable(obj) {
-	if (obj.id == button_move || obj.id == button_insert || obj.id == button_delete) {
-		mod_digitizeEvent = obj.id;
-		executeDigitizePreFunctions();
-	}
-	else if (obj.id == button_point || obj.id == button_line || obj.id == button_polygon || obj.id == button_clear || obj.id == button_combine){
-		var el = parent.frames[mod_digitize_target].document;
-		el.onmousemove = mod_digitize_go;
-
-		mod_digitizeEvent = obj.id;
-
-		if (mod_digitizeEvent == button_point || mod_digitizeEvent == button_line || mod_digitizeEvent == button_polygon || mod_digitizeEvent == button_insert ) {
-			s.store(d);
-		}
-
-		executeDigitizePreFunctions();
-		obj.title = obj.title_on;
-		if (obj.id == button_point) {
-			if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
-				if (d.get(-1).geomType != parent.geomType.point) {
-					d.close();
-					executeDigitizeSubFunctions();
-				}
-				else {
-					s.add(d.getPoint(-1, -1, 0));
-				}
-			}
-			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
-				d.addMember(parent.geomType.point);
-				d.get(-1).addGeometry();
-			}
-			else {
-/*
-//
-// delete existing line or polygon
-//	
-				d.del(-1);
-				d.addMember(parent.geomType.point);
-				d.get(-1).addGeometry();
-*/
-			}
-		}
-		else if (obj.id == button_polygon) {
-			if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
-				if (d.get(-1).geomType != parent.geomType.polygon) {
-					d.close();
-					executeDigitizeSubFunctions();
-				}
-				else {
-					s.add(d.getPoint(-1, -1, 0));
-				}
-			}
-			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
-				// new geometry
-				d.addMember(parent.geomType.polygon);
-				d.get(-1).addGeometry();
-			}
-			else {
-/*
-//
-// continue a line as a polygon
-//	
-				if (d.get(-1).geomType != parent.geomType.polygon) {
-					var geometryTemplate = parent.cloneObject(d.get(-1));
-					d.del(-1);
-					d.addMember(parent.geomType.polygon);
-					for (var i = 0; i < geometryTemplate.count(); i++) {
-						d.get(-1).addGeometry();
-						for (var j = 0; j < geometryTemplate.get(i).count(); j++) {
-							d.get(-1).get(-1).addPoint(geometryTemplate.get(i).get(j));
-						}
-					}
-				}
-				s.add(d.getPoint(-1, -1, 0));
-*/
-			}
-		}
-		else if (obj.id == button_line) {
-			if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
-				if (d.get(-1).geomType != parent.geomType.line) {
-					d.close();
-					executeDigitizeSubFunctions();
-				}
-				else {
-					s.add(d.getPoint(-1, -1, 0));
-				}
-			}
-			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
-				d.addMember(parent.geomType.line);
-				d.get(-1).addGeometry();
-			}
-			else {
-/*
-//
-// continue a polygon as a line
-//	
-				if (d.get(-1).geomType != parent.geomType.line) {
-					var geometryTemplate = parent.cloneObject(d.get(-1));
-					d.del(-1);
-					d.addMember(parent.geomType.line);
-					for (var i = 0; i < geometryTemplate.count(); i++) {
-						d.get(-1).addGeometry();
-						for (var j = 0; j < geometryTemplate.get(i).count(); j++) {
-							d.get(-1).get(-1).addPoint(geometryTemplate.get(i).get(j));
-						}
-					}
-				}
-*/
-			}
-		}
-		else if (obj.id == button_clear) {
-			var clear = confirm(messageConfirmDeleteAllGeomFromList[selectedLanguage]);
-			if (clear) {
-				d = new parent.GeometryArray();
-				parent.mb_disableThisButton(button_clear);
-			}
-		}
-		else if (obj.id == button_combine) {
-//			d.combineToMultiGeometry();
-//			prompt('', d.toJSONString());
-//			parent.mb_ajax_post("../php/jsonTest.php", {json:d.toJSONString()}, function(test, status) {
-//				alert(test);
-//			});
-			parent.mb_disableThisButton(button_combine);
-		}
-	}
-}
-
-function digitizeDisable(obj) {
-	if (obj.id == button_point || obj.id == button_line || obj.id == button_polygon){
-		obj.title = obj.title_off;
-		if (d.get(-1).get(-1).count() == 0) {
-			d.delGeometry(-1,-1);
-		}
-		mod_digitize_timeout();
-		executeDigitizeSubFunctions();
-	}
-	else if (obj.id == button_clear) {
-		mod_digitize_timeout();
-		executeDigitizeSubFunctions();
-	}
-	mod_digitizeEvent = false;
-}
-// --- button handling (end) ----------------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-
-// -----------------------------------------------------------------------------------------------------------
-// --- display (begin) -----------------------------------------------------------------------------------------
-
-function updateExtent() {
-	var anInd = parent.getMapObjIndexByName(mod_digitize_target);
-	var change = false;
-	if (typeof(mod_digitize_width) == 'undefined' || mod_digitize_width != parent.mb_mapObj[anInd].width) {
-		mod_digitize_width = parent.mb_mapObj[anInd].width;
-		change = true;
-	}
-	if (typeof(mod_digitize_height) == 'undefined' || mod_digitize_height != parent.mb_mapObj[anInd].height) {
-		mod_digitize_height = parent.mb_mapObj[anInd].height;
-		change = true;
-	}
-	if (typeof(mod_digitize_epsg) == 'undefined' || mod_digitize_epsg != parent.mb_mapObj[anInd].epsg) {
-		mod_digitize_epsg = parent.mb_mapObj[anInd].epsg;
-		change = true;
-	}
-//	if (change) {
-//		drawDashedLine();
-//	}
-}
-
-function drawDashedLine(){
-	if (!nonTransactionalEditable) {
-		nonTransactionalHighlight.clean();
-	}
-	var smP = "";
-	smP += "<div class='t_img'>";
-	smP += "<img src='"+parent.mb_trans.src+"' width='"+mod_digitize_width+"' height='0'></div>";
-	smP += "<div class='t_img'>";
-	smP += "<img src='"+parent.mb_trans.src+"' width='0' height='"+mod_digitize_height+"'></div>";
-
-	for(var i=0; i<d.count(); i++){
-		if (!nonTransactionalEditable && !isTransactional(d.get(i))) {
-			nonTransactionalHighlight.add(d.get(i), nonTransactionalColor);
-		}
-		else {
-			for(var j=0; j<d.get(i).count(); j++){
-				for(var k = 0; k < d.getGeometry(i,j).count(); k++){
-					var pos = parent.makeRealWorld2mapPos(mod_digitize_target,d.getPoint(i,j,k).x,d.getPoint(i,j,k).y);
-					
-					if (!d.getGeometry(i,j).isComplete() && 
-						( (k == 0 && d.get(i).geomType == parent.geomType.polygon) || (k == d.getGeometry(i,j).count()-1 && d.get(i).geomType == parent.geomType.line))) {
-						smP += "<div class='bp' style='top:"+(pos[1]-2)+"px;left:"+(pos[0]-2)+"px;z-index:"+digitizeTransactionalZIndex+";background-color:"+linepointColor+"'";
-					}
-					else {
-						smP += "<div class='bp' style='top:"+(pos[1]-2)+"px;left:"+(pos[0]-2)+"px;z-index:"+digitizeTransactionalZIndex+";'";
-					}
-					if(j==0 && d.get(i).geomType == parent.geomType.polygon && !d.getGeometry(i,j).isComplete()){
-						smP += " title='"+closePolygon_title+"' ";
-					}
-					if(mod_digitizeEvent == button_move || mod_digitizeEvent == button_insert || mod_digitizeEvent == button_delete) {
-						smP += " onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].handleBasepoint(this,"+i+","+j+","+k+")' ;";
-					}
-					smP += "></div>";
-				}
-				var mapObjInd = parent.getMapObjIndexByName(mod_digitize_target);
-				for(var k = 1; k < d.getGeometry(i,j).count(); k++){
-					var p0 = parent.realToMap(mod_digitize_target, d.getPoint(i,j,k));
-					var p1 = parent.realToMap(mod_digitize_target, d.getPoint(i,j,k-1));
-					points = parent.calculateVisibleDash(p0, p1, parent.mb_mapObj[mapObjInd].width, parent.mb_mapObj[mapObjInd].height);
-					if (points != false) {
-						smP += evaluateDashes(points[0], points[1], i, j, k);
-					}
-				}
-			}
-		}
-	}
-	digitizeDivTag.write(smP);
-}
-
-function evaluateDashes(start, end, memberIndex, geomIndex, pointIndex){
-	var str_dashedLine = "";
-	var delta = new parent.Point(end.x - start.x, end.y - start.y);
-	 
-	var vecLength = start.dist(end);
-	var n = Math.round(vecLength/dotDistance);
-	var step = new parent.Point(delta.x/n, delta.y/n);
-	for(var i=1; i<n; i++){
-		var x = Math.round(start.x + i * step.x) - 2;
-		var y = Math.round(start.y + i * step.y) - 2;
-		if(x >= 0 && x <= mod_digitize_width && y >= 0 && y <= mod_digitize_height){
-			if (memberIndex == d.count()-1 && !d.getGeometry(-1,-1).isComplete()) {
-				str_dashedLine += "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:"+digitizeTransactionalZIndex+";background-color:"+linepointColor+"' ";
-			}
-			else {
-				str_dashedLine += "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:"+digitizeTransactionalZIndex+";' ";
-			}
-			if(mod_digitizeEvent == button_insert) {
-				str_dashedLine += "onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].convertLinepointToBasepoint(this,"+memberIndex+","+geomIndex+","+pointIndex+")'";
-			}
-			str_dashedLine += "></div>";
-		}
-	}
-	return str_dashedLine;
-}
-
-function isTransactional(geom) {
-//	alert(typeof(geom.wfs_conf) + " " + geom.wfs_conf + " " + wfsConf.length);
-	if (typeof(geom.wfs_conf) == 'number') {
-		if (geom.wfs_conf >= 0 && geom.wfs_conf < wfsConf.length) {			
-			var isTransactionalGeom = (wfsConf[geom.wfs_conf]['wfs_transaction'] != "" && wfsConf[geom.wfs_conf]['fkey_featuretype_id'] != "");
-			if (isTransactionalGeom) {
-				return true;
-			}
-			else{
-				return false;
-			}
-		}
-	}
-	else if (typeof(geom.wfs_conf) == 'undefined') {
-		return true;
-	}
-}
-
-function isValidWfsConfIndex (wfsConf, wfsConfIndex) {
-	return (typeof(wfsConfIndex) == "number" && wfsConfIndex >=0 && wfsConfIndex < wfsConf.length);
-}
-
-function getName (geom) {
-	wfsConfId = geom.wfs_conf;
-	wfsConf = parent.get_complete_wfs_conf();
-	if (isValidWfsConfIndex(wfsConf, wfsConfId)) {
-		var resultName = "";
-		for (var i = 0 ; i < wfsConf[wfsConfId]['element'].length ; i++) {
-			if (wfsConf[wfsConfId]['element'][i]['f_show'] == 1) {
-				resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
-			}
-		}
-		if (resultName == "") {
-			resultName = wfsConf[wfsConfId]['g_label'];
-		}
-		return resultName;
-	}
-	else {
-		return digitizeDefaultGeometryName[selectedLanguage];
-	}
-}
-
-function updateListOfGeometries(){
-	var listOfGeom = "<table style='position:absolute; top:"+geomList_y+"px; left:"+geomList_x+"px;'>\n";
-	if (d.count() > 0) {
-		wfsConf = parent.get_complete_wfs_conf();
-		for (var i = 0 ; i < d.count(); i ++) {
-
-			if (d.get(i).get(-1).isComplete() && (nonTransactionalEditable || isTransactional(d.get(i)))) {
-	
-				listOfGeom += "\t<tr>\n\t\t<td>\n";
-				if (wfsExistsForGeom(d.get(i), wfsConf)) {
-					listOfGeom += "\t\t\t<img src = '"+buttonDig_imgdir+buttonDig_wfs_src+"' title='"+buttonDig_wfs_title[selectedLanguage]+"' onclick='showWfs("+i+")'>\n";
-				}
-				listOfGeom += "\t\t</td>\n\t\t<td>\n";
-				listOfGeom += "\t\t\t<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+buttonDig_remove_title[selectedLanguage]+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.del("+i+");executeDigitizeSubFunctions();'>\n";
-				listOfGeom += "\t\t</td>\n\t\t<td>\n";
-	
-				if (isValidWfsConfIndex(wfsConf, d.get(i).wfs_conf)) {
-					listOfGeom += "\t\t\t<img src = '"+buttonDig_imgdir+buttonDig_removeDb_src+"' title='"+buttonDig_removeDb_title[selectedLanguage]+"' onclick=\"var deltrans = confirm('"+messageConfirmDeleteGeomFromDb[selectedLanguage]+"');if (deltrans) dbGeom('delete', "+i+")\">\n";
-				}
-				listOfGeom += "\t\t</td>\n\t\t<td style = 'color:blue;font-size:12px'>\n";
-				listOfGeom += "\t\t\t<div onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+"));' ";
-				listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+"))' ";
-				listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+"));' ";
-				var geomName = getName(d.get(i)); 
-				if (d.get(i).geomType == parent.geomType.polygon) {geomName += " ("+messageDescriptionPolygon[selectedLanguage]+")";}
-				else if (d.get(i).geomType == parent.geomType.line) {geomName += " ("+messageDescriptionLine[selectedLanguage]+")";}
-				else if (d.get(i).geomType == parent.geomType.point) {geomName += " ("+messageDescriptionPoint[selectedLanguage]+")";}
-				
-				listOfGeom += ">" + htmlspecialchars(geomName) +"</div>\t\t</td>\n\t</tr>\n";
-			}
-		}
-	}
-	listOfGeom += "</table>\n";
-	parent.writeTag(mod_digitize_elName,"listOfGeometries",listOfGeom);
-}
-// --- display (end) -----------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------
-
-
-// -----------------------------------------------------------------------------------------------------------
-// --- wfs window (begin) -----------------------------------------------------------------------------------------
-
-// -----------------------------------------------------------------------------------------------------------
-// --- wfs window form check (begin) -----------------------------------------------------------------------------------------
-
-function formCorrect(doc, formId) {
-	var isCorrect = true;
-	var errorMessage = "";
-	var result;
-	var form = doc.getElementById(formId);
-	
-	result = mandatoryFieldsNotEmpty(doc, form);
-	isCorrect = isCorrect && result.isCorrect;
-	errorMessage += result.errorMessage;
-
-	result = validBoxEntrySelected(form);
-	isCorrect = isCorrect && result.isCorrect;
-	errorMessage += result.errorMessage;
-
-	result = dataTypeIsCorrect(doc, form);
-	isCorrect = isCorrect && result.isCorrect;
-	errorMessage += result.errorMessage;
-
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-
-function validBoxEntrySelected(form){
-	var isCorrect = true;
-	var errorMessage = "";
-	var name = "";
-	for (var i = 0; i < form.childNodes.length && isCorrect; i++) {
-		if (form.childNodes[i].nodeName.toUpperCase() == "SELECT") {
-			name += form.childNodes[i].name;
-			if (parseInt(form.childNodes[i].selectedIndex) == 0 && form.childNodes[i].getAttribute("mandatory") == "true") {
-				var msg = name + ": " + messageSelectAnOption[selectedLanguage] + "\n"
-				var categ = form.childNodes[i].getAttribute("category");
-				if (typeof(categ) != "undefined") {
-					msg = categ + " => " + msg;
-				}
-				return {"isCorrect":false, "errorMessage":msg};
-			}
-		}
-		else if (form.childNodes[i].hasChildNodes()) {
-			var res = validBoxEntrySelected(form.childNodes[i]);
-			errorMessage = res.errorMessage + errorMessage;
-			isCorrect = res.isCorrect;
-			
-		}
-	}
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-
-function mandatoryFieldsNotEmpty(doc, node){
-	var isCorrect = true;
-	var errorMessage = "";
-	
-	nodeArray = doc.getElementsByName("mandatory");
-	for (var i = 0; i < nodeArray.length; i++) {
-		if (nodeArray[i].nodeName.toUpperCase() == "INPUT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,10) == "mandatory_") {
-			var nodeId = nodeArray[i].id.substr(10);
-			if (nodeArray[i].value == "true") {
-				if (doc.getElementById(nodeId).value == "") {
-					isCorrect = false;
-					errorMessage += doc.getElementById(nodeId).getAttribute("category") + " => " + doc.getElementById(nodeId).name +": "+ messageErrorFieldIsEmpty[selectedLanguage] +"\n";
-				}
-			}
-		}
-	}
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-
-function isInteger(str) {
-	if (str.match(/^\d*$/)) {
-		return true;
-	}
-	return false;
-}
-
-function isFloat(str) {
-	if (isInteger(str)) {
-		return true;
-	}
-	if (str.match(/^\d+\.\d+$/)) {
-		return true;
-	}
-	return false;
-}
-
-function replaceCommaByDecimalPoint(str) {
-	var patternString = ",";
-	var pattern = new RegExp(patternString);
-	while (str.match(pattern)) {
-		str = str.replace(pattern, ".");
-	}
-	return str;
-}
-
-function dataTypeIsCorrect(doc, node){
-	var isCorrect = true;
-	var errorMessage = "";
-	
-	nodeArray = doc.getElementsByName("datatype");
-	for (var i = 0; i < nodeArray.length ; i++) {
-		if (nodeArray[i].nodeName.toUpperCase() == "INPUT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,9) == "datatype_") {
-			var nodeId = nodeArray[i].id.substr(9);
-			var nodeValue = doc.getElementById(nodeId).value;
-			
-			if (nodeArray[i].value == "int") {
-				if (!isInteger(nodeValue)) {
-					isCorrect = false;
-					errorMessage += "'"+doc.getElementById(nodeId).name+"': "+ messageErrorNotAnInteger[selectedLanguage] + "\n";
-				}
-			}
-			else if (nodeArray[i].value == "double") {
-				nodeValue = replaceCommaByDecimalPoint(nodeValue);
-				if (!isFloat(nodeValue)) {
-					isCorrect = false;
-					errorMessage += "'"+doc.getElementById(nodeId).name+"': "+ messageErrorNotAFloat[selectedLanguage] + "\n";
-				}
-				else {
-					doc.getElementById(nodeId).value = nodeValue;
-				}
-			}
-		}
-	}
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-// --- wfs window form check (end) -----------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------
-
-function getAvailableWfsForGeom(geom, wfsConf) {
-	var wfsConfIndices = [];
-	
-	for (var attr in wfsConf) {
-		var isTrans = (wfsConf[attr]['wfs_transaction'] != "");
-		if (!isTrans) {
-			continue;
-		}
-		if (isValidWfsConfIndex(wfsConf, parseInt(geom.wfs_conf))) {
-			
-			if (parseInt(geom.wfs_conf) == parseInt(attr)) {
-				wfsConfIndices.push(attr);
-			}
-		}
-		else {
-			for (var elementIndex = 0; elementIndex < wfsConf[attr]['element'].length ; elementIndex++) {
-				var isGeomColumn = (parseInt(wfsConf[attr]['element'][elementIndex]['f_geom']) == 1); 
-				if (isGeomColumn) {
-					var isMultiPolygon = (geom.geomType == parent.geomType.polygon && wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiPolygonPropertyType');
-					var isPolygon = (geom.geomType == parent.geomType.polygon && geom.count() == 1 && wfsConf[attr]['element'][elementIndex]['element_type'] == 'PolygonPropertyType');
-					var isMultiLine = (geom.geomType == parent.geomType.line && wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiLineStringPropertyType');
-					var isLine = (geom.geomType == parent.geomType.line && geom.count() == 1 && wfsConf[attr]['element'][elementIndex]['element_type'] == 'LineStringPropertyType');
-					var isPoint = (geom.geomType == parent.geomType.point && wfsConf[attr]['element'][elementIndex]['element_type'] == 'PointPropertyType');
-//					alert(isMultiPolygon + " " + isPolygon + " " + isMultiLine + " " + isLine + " " + isPoint);
-					if (isMultiPolygon || isPolygon || isMultiLine || isLine || isPoint || wfsConf[attr]['element'][elementIndex]['element_type'] == 'GeometryAssociationType') {
-						
-						wfsConfIndices.push(attr);
-					}
-				}
-			}
-		}	
-	}
-	return wfsConfIndices;
-}
-function wfsExistsForGeom(geom, wfsConf) {
-	wfsConfIndices = getAvailableWfsForGeom(geom, wfsConf);
-//	alert(wfsConfIndices.join(","));
-	if (wfsConfIndices.length > 0) {
-		return true;
-	}
-	return false;
-}
-
-
-//
-// this method opens a new window and displays the attributes in wfs_conf
-//
-function showWfs(geometryIndex) {
-	wfsConf = parent.get_complete_wfs_conf();
-
-	wfsWindow = open("", "wfsattributes", "width="+wfsWindowWidth+", height="+wfsWindowHeight+", resizable, dependent=yes, scrollbars=yes");
-	wfsWindow.document.open("text/html");
-
-	var str = "";
-	var strStyle = "";
-	var defaultIndex = -1;
-
-	str += "<form id='wfs'>\n";
-
-	//
-	// 1. add select box 
-	//
-
-	var onChangeText = "document.getElementById('elementForm').innerHTML = ";
-	onChangeText += "window.opener.buildElementForm(this.value, " + geometryIndex + ");";
-	onChangeText += "window.opener.setWfsWindowStyle(this.value);";
-	onChangeText += "$('.hasDatepicker').datepicker();";
-	
-	str += "\t<select name='wfs' size='" + wfsConf.length + "'";
-	str += " onChange=\""+ onChangeText +"\"";
-	str += ">\n\t\t";
-
-	var wfsConfIndices = getAvailableWfsForGeom(d.get(geometryIndex), wfsConf);
-//	alert(wfsConfIndices.join(","));
-	var selected = false;
-	for (var i = 0; i < wfsConfIndices.length ; i++) {
-		str += "<option value='" + wfsConfIndices[i] + "'";
-		if (!selected) {
-			str += " selected";
-			selected = true;
-			defaultIndex = parseInt(wfsConfIndices[i]);
-		}
-		str += ">" + wfsConf[wfsConfIndices[i]]['wfs_conf_abstract'];
-		str += "</option>\n\t\t";
-	}
-
-	
-	str += "</select>\n\t\t</form>\n\t";
-	
-	var elForm = "";
-	if (defaultIndex != -1) {
-		var headStr = "<html><head><style type='text/css'>" + wfsConf[defaultIndex]['g_style'] + "</style>";
-		headStr += '<link rel="stylesheet" type="text/css" href="../extensions/theme/ui.all.css" />';
-		headStr += '<style type="text/css">'
-		headStr += 'a.tabheader { margin: 0 3px 0 0;padding: 1px 5px;text-decoration: none;color: #999;background-color: #F5F5F5;border: 1px solid #999;border-bottom: 0; }';
-		headStr += 'a.tabheader.active { color: #666;background-color: transparent;border-color: #666;border-bottom: 1px solid #FFF;cursor: default; }';
-		headStr += 'div.tabcontent { visibility: hidden;display: none;margin: -3px 0 5px 0;padding: 5px;border: 1px solid #666; }';
-		headStr += 'div.helptext { visibility: hidden;display: none;position: absolute;top: 5%;left: 5%;width: 85%;padding: 5px;color: #000;background-color: #CCC;border: 1px solid #000; }';
-		headStr += 'div.helptext p { margin: 0 ; }';
-		headStr += 'div.helptext p a.close { display: block;margin: 5px auto;text-align: center; }';
-		headStr += 'a img { vertical-align: middle;border: 0; }';
-		headStr += '</style>';
-		headStr += '</head><body onload="var $dp = $(\'.hasdatepicker\');$dp.datepicker();">';
-		wfsWindow.document.write(headStr);
-		elForm = buildElementForm(defaultIndex, geometryIndex);
-	}
-	else {
-		var headStr = "<html><head><style type='text/css'></style></head><body>";
-		wfsWindow.document.write(headStr);
-	}
-	str += "<div id='elementForm'>\n" + elForm + "</div>";
-	str += "<script type='text/javascript' src='../extensions/jquery-1.2.6.min.js'><\/script>";
-	str += "<script type='text/javascript' src='../extensions/jquery-ui-personalized-1.5.3.min.js'><\/script>";
-	str += "</body></html>";
-	wfsWindow.document.write(str);
-	wfsWindow.document.close();
-
-	toggleTabs(initialTab);
-
-}
-
-function setWfsWindowStyle(wfsConfIndex) {
-	wfsWindow.document.getElementsByTagName("style")[0].innerHTML = wfsConf[wfsConfIndex]['g_style'];
-}
-
-function prepareSelectBox (formElementHtml, categoryName, isMandatory, elementLabel, elementValue) {
-	// set category
-	if (categoryName) {
-		var patternString = "<select";
-		var pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, patternString + " category='" + categoryName + "' ");
-	}
-
-	if (isMandatory) {
-		// set border if mandatory
-		patternString = "<select";
-		pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, patternString + " mandatory='true' style='border:1px solid red' ");
-	}
-
-	// set name of select box to elementlabel
-	patternString = "name\s*=\s*\\*'\w+\\*'";
-	pattern = new RegExp(patternString);
-	if (pattern.test(formElementHtml)) {
-		formElementHtml = formElementHtml.replace(pattern, "name='" + elementLabel + "'");
-	}
-	else {
-		patternString = "<select";
-		pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, "<select name='" + elementLabel + "'");
-	}
-	
-	// preselect the correct entry of the box
-	patternString = "option value='"+elementValue+"'";
-	pattern = new RegExp(patternString);
-	formElementHtml = formElementHtml.replace(pattern, patternString+" selected");
-
-	return formElementHtml;
-}
-
-function prepareDatepicker (formElementHtml, categoryName, isMandatory, elementLabel, elementValue) {
-	// set category
-	if (categoryName) {
-		var patternString = "<input";
-		var pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, patternString + " category='" + categoryName + "' ");
-	}
-
-	if (isMandatory) {
-		// set border if mandatory
-		patternString = "<input";
-		pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, patternString + " mandatory='true' style='border:1px solid red' ");
-	}
-
-	// set name of select box to elementlabel
-	patternString = "name\s*=\s*\\*'\w+\\*'";
-	pattern = new RegExp(patternString);
-	if (pattern.test(formElementHtml)) {
-		formElementHtml = formElementHtml.replace(pattern, "name='" + elementLabel + "'");
-	}
-	else {
-		patternString = "<input";
-		pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, "<input name='" + elementLabel + "'");
-	}
-	
-	// preselect the correct entry of the box
-	patternString = "<input";
-	pattern = new RegExp(patternString);
-	formElementHtml = formElementHtml.replace(pattern, patternString + " value='"+elementValue+"'");
-
-	return formElementHtml;
-}
-
-function prepareTextArea (formElementHtml, categoryName, isMandatory, elementLabel, elementValue) {
-	// set category
-	if (categoryName) {
-		var patternString = "<textarea";
-		var pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, patternString + " category='" + categoryName + "' ");
-	}
-
-	if (isMandatory) {
-		// set border if mandatory
-		patternString = "<textarea";
-		pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, patternString + " mandatory='true' style='border:1px solid red' ");
-	}
-
-	// set name of select box to elementlabel
-	patternString = "name\s*=\s*\\*'\w+\\*'";
-	pattern = new RegExp(patternString);
-	if (pattern.test(formElementHtml)) {
-		formElementHtml = formElementHtml.replace(pattern, "name='" + elementLabel + "'");
-	}
-	else {
-		patternString = "<textarea";
-		pattern = new RegExp(patternString);
-		formElementHtml = formElementHtml.replace(pattern, "<textarea name='" + elementLabel + "'");
-	}
-	
-	// preselect the correct entry of the box
-	patternString = "<\/textarea>";
-	pattern = new RegExp(patternString);
-	formElementHtml = formElementHtml.replace(pattern, elementValue + patternString);
-
-	return formElementHtml;
-}
-
-
-
-// Returns a form with the elements of a selected WFS grouped in tabs
-// (if the original WFS is the selected WFS, the values are set too)
-var initialTab = false;
-function buildTabbedElementForm(elementCategories,wfsConfIndex,memberIndex) {
-	var featureTypeMismatch = false;
-	if (parseInt(d.get(memberIndex).wfs_conf) != parseInt(wfsConfIndex)) {featureTypeMismatch = true;}
-	var str = "";
-	var hasGeometryColumn = false;
-	var featureTypeArray = wfsConf[wfsConfIndex];
-	var memberElements;
-	var fid = false;
-
-	if (!featureTypeMismatch) {
-		memberElements = d.get(memberIndex).e;
-		fid = memberElements.getElementValueByName('fid');
-	}
-	
-	if (typeof(featureTypeArray["element"]) !== "undefined") {
-		featureTypeElementArray = featureTypeArray["element"];
-		
-		elementCategories.sort();
-
-		str += "<form id='"+featureTypeElementFormId+"'>\n\t\n";
-		
-		initialTab = elementCategories[0];
-		for(var currentCategory = 0; currentCategory < elementCategories.length; currentCategory++) {
-			str += '<a href="#" id="tabheader_' + elementCategories[currentCategory] + '" class="tabheader" onclick="return window.opener.toggleTabs(\'' + elementCategories[currentCategory] + '\')">' + elementCategories[currentCategory] + '</a>';
-		}
-		
-		for(var currentCategory = 0; currentCategory < elementCategories.length; currentCategory++) {
-		
-			//
-			// 2. add rows to form 
-			//
-			for (var i = 0 ; i < featureTypeElementArray.length ; i++) {
-				var featureTypeElement = featureTypeElementArray[i];
-
-				var elementName = featureTypeElement['element_name'];
-				var elementType = featureTypeElement['element_type'];
-				var isEditable = (parseInt(featureTypeElement['f_edit']) == 1); 
-				var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1); 
-				var isGeomColumn = (parseInt(featureTypeElement['f_geom']) == 1); 
-
-				if(featureTypeElement.f_category_name != elementCategories[currentCategory] && !isGeomColumn) {
-					continue;
-				}
-			
-				str += '<div id="tab_' + elementCategories[currentCategory] + '" class="tabcontent">';
-				str += '<table>';
-
-
-				var elementLabelExists = (featureTypeElement['f_label'] != "");
-				var elementLabel = ""; 
-				if (elementLabelExists) {
-					elementLabel = featureTypeElement['f_label'];
-				}
-				var elementLabelStyle = featureTypeElement['f_label_id'];
-
-				if (!isGeomColumn) {
-					if (isEditable) {
-						str += "\t\t<tr>\n";
-						if(elementLabelExists) {
-							str += "\t\t\t<td>\n\t\t\t\t<div class = '"+elementLabelStyle+"''>" + elementLabel + "</div>\n\t\t\t</td>\n";
-							str += "\t\t\t<td>\n";
-						}
-						else {
-							str += '<td colspan="2">';
-						}
-
-						var elementValue = "";
-						if (!featureTypeMismatch) {
-							for (var j = 0 ; j < memberElements.count() ; j ++) {
-								if (memberElements.getName(j) == featureTypeElement['element_name']) {
-									elementValue = memberElements.getValue(j);
-								}
-							}
-						}
-						var formElementHtml = featureTypeElement['f_form_element_html']; 
-						if (!formElementHtml) {
-							mandatoryHint = '';
-							var mandatoryHint = (parseInt(featureTypeElement['f_mandatory']) == 1) ? ' style="border:1px solid red;"' : '';
-						
-							str += "\t\t\t\t<input id = 'datatype_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
-							str += "\t\t\t\t<input id = 'mandatory_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
-							str += "\t\t\t\t<input category='"+elementCategories[currentCategory]+"' id = '" + elementName + "' name='" + elementLabel + "' type='text' " + mandatoryHint + " class = '"+featureTypeElement['f_style_id']+"' size=20 value = '" + elementValue + "'>\n";
-						}
-						else {
-							while (formElementHtml.match(/\\/)) {
-								formElementHtml = formElementHtml.replace(/\\/, "");
-							} 
-							
-							var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1);
-
-							var patternString = "<select";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareSelectBox(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							var patternString = "hasdatepicker";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareDatepicker(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							var patternString = "<textarea";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareTextArea(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							str += formElementHtml;
-						}
-						
-						if(featureTypeElement.f_helptext.length > 0) {
-							str += ' <a href="#" onclick="return window.opener.showHelptext(' + i + ')"><img src="../x_geoportal/img/help.png" width="16" height="16" alt="?" /></a> ';
-							str += '<div id="helptext' +i+ '" class="helptext">';
-							str += '<p>';
-							str += featureTypeElement.f_helptext.replace(/(http:\/\/\S*)/g,'<a href="$1" target="blank">$1<\/a>');
-							str += '<a href="#" class="close" onclick="return window.opener.hideHelptext(' + i + ')">close</a>';
-							str += '</p>';
-							str += '</div>';
-						}
-						
-						str += "\t\t\t</td>\n\t\t</tr>\n";
-					}
-				}
-				else {
-					hasGeometryColumn = true;
-				}
-			}
-			str += '</table>';
-			str += '</div>';
-		}
-
-		//
-		// 3. add buttons "save", "update", "delete"
-		//
-		str += "<table>";
-		var isTransactional = (featureTypeArray['wfs_transaction']); 
-		if (isTransactional) {
-			str += "\t\t<tr>\n";
-
-			var options = ["save", "update", "delete", "abort"];
-			for (var i = 0 ; i < options.length ; i++) {
-				var onClickText = "this.disabled=true;var result = window.opener.formCorrect(document, '"+featureTypeElementFormId+"');";
-				onClickText += 	"if (result.isCorrect) {";
-				onClickText += 		"window.opener.dbGeom('"+options[i]+"', "+memberIndex+"); ";
-//				onClickText +=      "window.close();";
-				onClickText += 	"}";
-				onClickText += 	"else {";
-				onClickText += 		"alert(result.errorMessage);this.disabled=false;"
-				onClickText += 	"}";
-				
-				if (options[i] == "save" && hasGeometryColumn && (!fid || showSaveButtonForExistingGeometries)) {
-					str += "\t\t\t<td><input type='button' name='saveButton' value='"+buttonLabelSaveGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\" /></td>\n";
-				}
-				
-				if (!featureTypeMismatch && fid) {
-					if (options[i] == "update" && hasGeometryColumn) {
-						str += "\t\t\t<td><input type='button' name='updateButton' value='"+buttonLabelUpdateGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\"/></td>\n";
-					}
-					if (options[i] == "delete"){ 
-						var deleteOnClickText = "var deltrans = confirm('"+messageConfirmDeleteGeomFromDb[selectedLanguage]+"');";
-						deleteOnClickText += "if (deltrans){";
-						deleteOnClickText += onClickText + "}";
-						str += "\t\t\t<td><input type='button' name='deleteButton' value='"+buttonLabelDeleteGeometry[selectedLanguage]+"' onclick=\""+deleteOnClickText+"\"/></td>\n";
-					}
-				}
-				if (options[i] == "abort") {
-					str += "\t\t\t<td><input type='button' name='abortButton' value='"+buttonLabelAbort[selectedLanguage]+"' onclick=\"window.close();\" /></td>\n";
-				}
-			}
-			str += "\t\t</tr>\n";
-		}
-		str += "\t</table>\n";
-		str += "<input type='hidden' id='fid' value='"+fid+"'>";
-//			str += "<input type='text' name='mb_wfs_conf'>";
-		str += "</form>\n";
-	}
-	return str;
-}
-
-
-// returns a form with the elements of a selected wfs
-// (if the original wfs is the selected wfs, the values are set too)
-function buildElementForm(wfsConfIndex, memberIndex){
-	var featureTypeMismatch = false;
-	if (parseInt(d.get(memberIndex).wfs_conf) != parseInt(wfsConfIndex)) {featureTypeMismatch = true;}
-	var str = "";
-	var hasGeometryColumn = false;
-	var featureTypeArray = wfsConf[wfsConfIndex];
-	var memberElements;
-	var fid = false;
-
-	if (!featureTypeMismatch) {
-		memberElements = d.get(memberIndex).e;
-		fid = memberElements.getElementValueByName('fid');
-	}
-	
-	if (typeof(featureTypeArray["element"]) !== "undefined") {
-		featureTypeElementArray = featureTypeArray["element"];
-
-
-		// Check if there are categories given and
-		// build the form in tabs if necessary
-		var elementCategories = [];
-		for(var i = 0; i < featureTypeElementArray.length; i++){
-			var categoryName         = featureTypeElementArray[i].f_category_name;
-			var categoryNameIsUnique = true;
-			
-			if(categoryName.length === 0) { continue; }
-			
-			for(var j = 0; j < elementCategories.length; j++) {
-				if(elementCategories[j] == categoryName) {
-					categoryNameIsUnique = false;
-				}
-			}
-			
-			if(categoryNameIsUnique) {
-				elementCategories.push(categoryName);
-			}
-		}
-
-		if(elementCategories.length > 0) {
-			return buildTabbedElementForm(elementCategories,wfsConfIndex,memberIndex);
-		}
-	
-
-		str += "<form id='"+featureTypeElementFormId+"'>\n\t<table>\n";
-		
-		//
-		// 2. add rows to form 
-		//
-		for (var i = 0 ; i < featureTypeElementArray.length ; i ++) {
-			var featureTypeElement = featureTypeElementArray[i];
-
-			var elementName = featureTypeElement['element_name'];
-			var elementType = featureTypeElement['element_type'];
-			var isEditable = (parseInt(featureTypeElement['f_edit']) == 1); 
-			var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1); 
-			var isGeomColumn = (parseInt(featureTypeElement['f_geom']) == 1); 
-
-			var elementLabelExists = (featureTypeElement['f_label'] != "");
-			var elementLabel = ""; 
-			if (elementLabelExists) {
-				elementLabel = featureTypeElement['f_label'];
-			}
-			var elementLabelStyle = featureTypeElement['f_label_id'];
-
-			if (!isGeomColumn) {
-				if (isEditable) {
-					str += "\t\t<tr>\n";
-					str += "\t\t\t<td>\n\t\t\t\t<div class = '"+elementLabelStyle+"''>" + elementLabel + "</div>\n\t\t\t</td>\n";
-					str += "\t\t\t<td>\n";
-
-					var elementValue = "";
-					if (!featureTypeMismatch) {
-						for (var j = 0 ; j < memberElements.count() ; j ++) {
-							if (memberElements.getName(j) == featureTypeElement['element_name']) {
-								elementValue = memberElements.getValue(j);
-							}
-						}
-					}
-					var formElementHtml = featureTypeElement['f_form_element_html']; 
-					if (!formElementHtml) {
-						var mandatoryHint = (parseInt(featureTypeElement['f_mandatory']) == 1) ? ' style="border:1px solid red;"' : '';
-
-						str += "\t\t\t\t<input id = 'datatype_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
-						str += "\t\t\t\t<input id = 'mandatory_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
-						str += "\t\t\t\t<input id = '" + elementName + "' name='" + elementLabel + "' type='text' " + mandatoryHint + " class = '"+featureTypeElement['f_style_id']+"' size=20 value = '" + elementValue + "'>\n";
-						}
-						else {
-							while (formElementHtml.match(/\\/)) {
-								formElementHtml = formElementHtml.replace(/\\/, "");
-							} 
-							
-							var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1);
-
-							var patternString = "<select";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareSelectBox(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							var patternString = "hasdatepicker";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareDatepicker(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							var patternString = "<textarea";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareTextArea(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							str += formElementHtml;
-						}
-						
-						
-						if(featureTypeElement.f_helptext.length > 0) {
-							str += ' <a href="#" onclick="return window.opener.showHelptext(' + i + ')"><img src="../x_geoportal/img/help.png" width="16" height="16" alt="?" /></a> ';
-							str += '<div id="helptext' +i+ '" class="helptext">';
-							str += '<p>';
-							str += featureTypeElement.f_helptext.replace(/(http:\/\/\S*)/g,'<a href="$1" target="blank">$1<\/a>');
-							str += '<a href="#" class="close" onclick="return window.opener.hideHelptext(' + i + ')">close</a>';
-							str += '</p>';
-							str += '</div>';
-						}
-						
-						str += "\t\t\t</td>\n\t\t</tr>\n";
-				}
-			}
-			else {
-				hasGeometryColumn = true;
-			}
-		}
-
-		//
-		// 3. add buttons "save", "update", "delete"
-		//
-		str += "</table><table>";
-		var isTransactional = (featureTypeArray['wfs_transaction']); 
-		if (isTransactional) {
-			str += "\t\t<tr>\n";
-
-			var options = ["save", "update", "delete", "abort"];
-			for (var i = 0 ; i < options.length ; i++) {
-				var onClickText = "this.disabled=true;var result = window.opener.formCorrect(document, '"+featureTypeElementFormId+"');";
-				onClickText += 	"if (result.isCorrect) {";
-				onClickText += 		"window.opener.dbGeom('"+options[i]+"', "+memberIndex+"); ";
-//				onClickText +=      "window.close();";
-				onClickText += 	"}";
-				onClickText += 	"else {";
-				onClickText += 		"alert(result.errorMessage);this.disabled=false;"
-				onClickText += 	"}";
-				
-				if (options[i] == "save" && hasGeometryColumn && (!fid || showSaveButtonForExistingGeometries)) {
-					str += "\t\t\t<td><input type='button' name='saveButton' value='"+buttonLabelSaveGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\" /></td>\n";
-				}
-				
-				if (!featureTypeMismatch && fid) {
-					if (options[i] == "update" && hasGeometryColumn) {
-						str += "\t\t\t<td><input type='button' name='updateButton' value='"+buttonLabelUpdateGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\"/></td>\n";
-					}
-					if (options[i] == "delete"){ 
-						var deleteOnClickText = "var deltrans = confirm('"+messageConfirmDeleteGeomFromDb[selectedLanguage]+"');";
-						deleteOnClickText += "if (deltrans){";
-						deleteOnClickText += onClickText + "}";
-						str += "\t\t\t<td><input type='button' name='deleteButton' value='"+buttonLabelDeleteGeometry[selectedLanguage]+"' onclick=\""+deleteOnClickText+"\"/></td>\n";
-					}
-				}
-				if (options[i] == "abort") {
-					str += "\t\t\t<td><input type='button' name='abortButton' value='"+buttonLabelAbort[selectedLanguage]+"' onclick=\"window.close();\" /></td>\n";
-				}
-			}
-			str += "\t\t</tr>\n";
-		}
-		str += "\t</table>\n";
-		str += "<input type='hidden' id='fid' value='"+fid+"'>";
-//			str += "<input type='text' name='mb_wfs_conf'>";
-		str += "</form>\n";
-	}
-	return str;
-}
-
-function dbGeom(type,m) {
-	if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
-		d.get(m).wfs_conf = parseInt(wfsWindow.document.forms[0].wfs.options[wfsWindow.document.forms[0].wfs.selectedIndex].value);
-		d.get(m).e = new parent.Wfs_element();
-	}
-	else {
-		wfsConf = parent.get_complete_wfs_conf();
-	}
-	var myconf = wfsConf[d.get(m).wfs_conf];
-	
-	var mapObjInd = parent.getMapObjIndexByName(mod_digitize_target);
-
-	if (myconf['featuretype_srs'] != parent.mb_mapObj[mapObjInd].epsg) {
-		alert(errorMessageEpsgMismatch[selectedLanguage] + parent.mb_mapObj[mapObjInd].epsg + " / "+ myconf['featuretype_srs']);
-	}
-	else {
-		var fid = false;
-		var errorMessage = "";
-		if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
-			myform = wfsWindow.document.getElementById(featureTypeElementFormId);
-		
-			for (var i=0; i<myform.length; i++){
-				if (myform.elements[i].id == "fid") {
-					fid = myform.elements[i].value;
-					d.get(m).e.setElement('fid', fid);
-				}
-				else if (myform.elements[i].type == 'text' || myform.elements[i].tagName.toUpperCase() == "TEXTAREA"){
-					if (myform.elements[i].id) {
-						d.get(m).e.setElement(myform.elements[i].id, myform.elements[i].value);
-					}
-					else {
-						errorMessage = messageErrorFormEvaluation[selectedLanguage];
-					}
-				}
-				// selectbox
-				else if (typeof(myform.elements[i].selectedIndex) == 'number') {
-					if (myform.elements[i].id && myform.elements[i].selectedIndex !== 0) {
-						d.get(m).e.setElement(myform.elements[i].id, myform.elements[i].options[myform.elements[i].selectedIndex].value);
-					}
-					else {
-						errorMessage = messageErrorFormEvaluation[selectedLanguage];
-					}
-				}
-			}
-		}
-		else {
-			fid = d.get(m).e.getElementValueByName('fid');
-		}
-		str = parent.get_wfs_str(myconf, d, m, type, fid);
-		parent.mb_ajax_post("../extensions/geom2wfst.php", {'filter':str,'url':myconf['wfs_transaction'],'featuretype_name':myconf['featuretype_name'],'wfs_conf_id':wfsConf[d.get(m).wfs_conf]['wfs_conf_id']}, function(json,status){		
-			var result = eval('('+json+')');
-			var response = result.response;
-			var fid = result.fid;
-			wfsSubWrite(m, type, status, response, fid);
-		});
-	}
-}
-
-function wfsSubWrite(m, type, status, response, fid) {
-	if (type == 'save' && fid) {
-		d.get(m).e.setElement("fid", fid);
-	}
-	if (type == 'delete') {
-		parent.mb_disableThisButton(mod_digitizeEvent);
-		d.del(m);
-	}
-	parent.mb_execWfsWriteSubFunctions();
-	executeDigitizeSubFunctions();
-	
-	if (status == "success" && response == "success") {
-		var wfsWriteMessage = messageSuccessWfsWrite[selectedLanguage];
-	}
-	else {
-		var wfsWriteMessage = messageErrorWfsWrite[selectedLanguage];
-	} 
-
-	if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
-		wfsWindow.alert(wfsWriteMessage);
-		window.setTimeout("wfsWindow.close()",0);
-	}
-	else {
-		alert(wfsWriteMessage);
-	}
-}
-// --- wfs window (begin) -----------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------
-
-	</script>
-	</head>
-	<body onload="displayButtons();">
-		<table cellpadding='0' cellspacing='0' align = center><tr><td><div id='digButtons'></div></td></tr></table>
-		<div id = 'listOfGeometries'></div>
-	</body>
-</html>
\ No newline at end of file



More information about the Mapbender_commits mailing list