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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Oct 29 11:53:50 EDT 2007


Author: christoph
Date: 2007-10-29 11:53:50 -0400 (Mon, 29 Oct 2007)
New Revision: 1775

Modified:
   trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
Log:
display wfs info and geom type

Modified: trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php	2007-10-29 15:40:43 UTC (rev 1774)
+++ trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php	2007-10-29 15:53:50 UTC (rev 1775)
@@ -1,333 +1,417 @@
-<?php
-# $Id: mod_wfs_gazetteer_ajax.php 1307 2007-05-09 10:06:24Z christoph $
-# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
-# http://www.mapbender.org/index.php/WFS_gazetteer
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-session_start();
-$gui_id = $_SESSION["mb_user_gui"];
-
-$target = $_REQUEST["target"];
-$e_id_css = $_REQUEST["e_id_css"];
-
-require_once("../../conf/mapbender.conf");
-
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db($DB,$con);
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset='<?php echo CHARSET;?>'">	
-<title>mod_wfs_gazetteer</title>
-
-<?php
-include '../include/dyn_css.php';
-?>
-<script type="text/javascript">
-<?php 
-	echo "var targetString = '" . $target . "';";
-	echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
-?>
-
-var targetArray = targetString.split(",");
-var global_wfsConfObj;
-var global_selectedWfsConfId;
-var point_px = 10;
-var resultGeom = null;
-var cw_fillcolor = "#cc33cc";
-
-
-parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initModWfsGazetteer()");
-
-//----------------------------------------------------------------------------------
-
-function removeChildNodes(node) {
-	while (node.childNodes.length > 0) {
-		var childNode = node.firstChild;
-		node.removeChild(childNode);
-	}
-}
-/**
- * removes whitespaces and endlines before and after a string
- *
- */ 
-function trimString (str) {
-	return str.replace(/^\s+|\s+|\n+$/g, '');
-}
-
-
-function appendStyles() {
-	var styleObj;
-	var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
-	if (parent.ie) {
-		var styleSheetObj=document.createStyleSheet();
-		styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
-		styleObj.setAttribute("type","text/css");
-		ruleArray = rule.split("}");
-		for (var i=0; i < ruleArray.length - 1; i++) {
-			var currentRule = trimString(ruleArray[i]);
-			var nameValueArray = currentRule.split("{");
-			var name = nameValueArray[0];
-			var value = nameValueArray[1];
-			styleSheetObj.addRule(name,value);
-		}
-	}
-	else {
-		styleObj=document.createElement("style");
-		styleObj.setAttribute("type","text/css");
-		document.getElementsByTagName("head")[0].appendChild(styleObj);
-		styleObj.appendChild(document.createTextNode(rule+"\n"));		
-	}
-}
-
-//----------------------------------------------------------------------------------
-
-
-function initModWfsGazetteer() {
-	parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConf",wfsConfIdString:wfsConfIdString}, function(json, status) {
-		global_wfsConfObj = json;
-		var wfsCount = 0;
-		for (var wfsConfId in global_wfsConfObj) {
-			global_selectedWfsConfId = wfsConfId; 
-			if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
-				wfsCount++;
-			}
-		}
-		if (wfsCount === 0) {
-			var e = parent.Mb_exception("no wfs conf id available.");
-		}
-		else if (wfsCount === 1) {
-			appendStyles();
-			appendWfsForm();
-		}
-		else {
-			appendWfsConfSelectBox();
-		}
-	});
-}
-
-function appendWfsConfSelectBox() {
-	var selectNode = document.createElement("select");
-	selectNode.name = "wfs_conf_sel";
-	selectNode.setAttribute("onchange", "global_selectedWfsConfId = this.value;appendStyles();appendWfsForm()");
-	
-	var isSelected = false;
-	for (var wfsConfId in global_wfsConfObj) {
-		var optionNode = document.createElement("option");
-		
-		optionNode.value = wfsConfId;
-		optionNode.innerHTML = global_wfsConfObj[wfsConfId].g_label;
-
-		if (!isSelected) {
-			optionNode.selected = true;
-			isSelected = true;
-			global_selectedWfsConfId = wfsConfId;
-		}
-		selectNode.appendChild(optionNode);
-	}
-
-	var form = document.getElementById('selectWfsConfForm');
-	form.appendChild(selectNode);
-	
-	appendStyles();
-	appendWfsForm();
-}
-
-function appendWfsForm() {
-	var form = document.getElementById("wfsForm");
-	removeChildNodes(form);
-	var resultDiv = document.getElementById("res");
-	removeChildNodes(resultDiv);
-	
-	var divContainer = document.createElement("div");
-	divContainer.className = global_wfsConfObj[global_selectedWfsConfId].g_label_id;
-	
-	divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
-	
-	form.appendChild(divContainer);
-
-	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
-
-	for (var i = 0; i < wfsConfElementArray.length; i++){
-		var spanNode = document.createElement("span");
-		spanNode.setAttribute("id", "ttttt");
-		spanNode.className = wfsConfElementArray[i].f_label_id;
-		spanNode.innerHTML = wfsConfElementArray[i].f_label;
-		var inputNode = document.createElement("input");
-		inputNode.type = "text";
-		inputNode.className = wfsConfElementArray[i].f_style_id;
-		inputNode.id = wfsConfElementArray[i].element_name;
-		
-		form.appendChild(spanNode);
-		form.appendChild(inputNode);
-		form.appendChild(document.createElement("br"));
-	}
-	var submitButton = document.createElement("input");
-	submitButton.type = "submit";
-	submitButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
-	submitButton.value = global_wfsConfObj[global_selectedWfsConfId].g_button;
-	
-	form.appendChild(submitButton);
-}
-
-function validate(){
-	global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
-
-	var filterParameterCount = getNumberOfFilterParameters();
-	
-	if(filterParameterCount == 0){
-		return false;
-	}
-	else{
-		var andConditions = "";
-		
-		var el = global_wfsConfObj[global_selectedWfsConfId].element;
-
-		for (var i = 0; i < el.length; i++) {
-			if (el[i]['f_search'] == 1 && document.getElementById(el[i]['element_name']).value != '') {
-		
-				var a = new Array();
-				a = document.getElementById(el[i]['element_name']).value.split(",");
-				var orConditions = "";
-				for (var j=0; j < a.length; j++) {
-					
-					orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-					orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
-					orConditions += "<ogc:Literal>*";
-					if(el[i]['f_toupper'] == 1){
-						orConditions += a[j].toUpperCase();
-					}
-					else{
-						orConditions += a[j];
-					}
-					orConditions += "*</ogc:Literal>";
-					orConditions += "</ogc:PropertyIsLike>";
-				}
-				if(a.length > 1){
-					andConditions += "<Or>" + orConditions + "</Or>";
-				}
-				else {
-					andConditions += orConditions;
-				}
-			}
-		}
-
-		var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
-		u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
-		u += "&filter=";
-
-		if (filterParameterCount > 1) {
-			andConditions = "<And>" + andConditions + "</And>";
-		}
-
-		var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
-
-		document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
-		var parameters = {command:"getSearchResults", "wfs_conf_id":global_selectedWfsConfId, "frame":this.name, "url":u, "filter":filter, "backlink":""};
-		parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {
-			eval(jsCode);
-			
-			for (var i=0; i < parent.wms.length; i++) {
-				for (var j=0; j < parent.wms[i].objLayer.length; j++) {
-					var currentLayer = parent.wms[i].objLayer[j];
-					var wms_id = parent.wms[i].wms_id; 
-					if (currentLayer.gui_layer_wfs_featuretype == global_selectedWfsConfId) {
-						var layer_name = currentLayer.layer_name; 
-						parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1); 
-						parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);					
-					}
-				}
-			}
-
-			var body = "";
-			if (typeof(geom) == 'object') {
-				resultGeom = geom; // set the global variable
-				for (var i=0; i < geom.count(); i++) {
-					body += "<div id='geom"+i+"'style='cursor:pointer;' ";
-					if ((i % 2) === 0) {
-						body += "class='even'";
-					}
-					else {
-						body += "class='uneven'";
-					}
-					body += " onmouseover=\"setResult('over', this.id)\" ";
-					body += " onmouseout=\"setResult('out', this.id)\" ";
-					body += " onclick=\"setResult('click', this.id)\">";
-					for (var j=0; j < geom.get(i).e.count(); j++) {
-						body += geom.get(i).e.getValue(j) + " ";
-					}
-					body += "</div>";
-				}
-			}
-			else {
-				body = "Kein Ergebnis.";
-			}
-			document.getElementById('res').innerHTML = body;
-		});
-	}
-	return false;
-}
-
-function getNumberOfFilterParameters(){
-	var cnt = 0;
-	var el = global_wfsConfObj[global_selectedWfsConfId].element;
-
-	for (var i = 0; i < el.length; i++){
-		if( el[i]['f_search'] == 1){
-			if (document.getElementById(el[i]['element_name']).value != '') {
-				cnt++;
-			}
-		}
-	}
-	return cnt;
-}
-/*
-* event -> {over || out || click}
-* geom -> commaseparated coordinates x1,y1,x2,y2 ...
-*/
-function setResult(event, id){
-	var index = parseInt(id.slice(4));
-
-	if (event == "over") {
-		global_resultHighlight.add(resultGeom.get(index), cw_fillcolor);
-	}
-	else if (event == "out"){
-		global_resultHighlight.del(resultGeom.get(index), cw_fillcolor);
-	}
-	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);
-		bbox[0] = bbox[0].minus(buffer);
-		bbox[1] = bbox[1].plus(buffer);
-		parent.mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
-		parent.zoom(targetArray[0], 'true', 1.0);
-		global_resultHighlight.add(resultGeom.get(index), cw_fillcolor);
-	}
-	return true;
-}
-
-
-</script>
-</head>
-<body leftmargin='0' topmargin='10'  bgcolor='#ffffff'>
-<form name='selectWfsConfForm' id='selectWfsConfForm'></form>
-<form name='wfsForm' id='wfsForm' onsubmit='return validate()'></form>
-<div name='res' id='res' style='width:180px'></div>
-</body>
+<?php
+# $Id: mod_wfs_gazetteer_client.php 1326 2007-10-29 10:52:03Z baudson $
+# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
+# http://www.mapbender.org/index.php/WFS_gazetteer
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+session_start();
+$gui_id = $_SESSION["mb_user_gui"];
+
+$target = $_REQUEST["e_target"];
+$e_id_css = $_REQUEST["e_id_css"];
+
+require_once("../../conf/mapbender.conf");
+
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db($DB,$con);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset='<?php echo CHARSET;?>'">	
+<title>mod_wfs_gazetteer</title>
+
+<?php
+include '../include/dyn_css.php';
+?>
+<script type="text/javascript">
+<?php 
+	echo "var targetString = '" . $target . "';";
+	echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
+?>
+
+// Element var maxHighlightedPoints
+try{
+	if (maxHighlightedPoints){
+		maxHighlightedPoints = Number(maxHighlightedPoints);
+
+		if (isNaN(maxHighlightedPoints)) {
+			var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints must be a number.");
+		}
+	}
+}
+catch(e){
+	maxHighlightedPoints = 0;
+	var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints is not set, see 'edit element vars'.");
+}
+
+var targetArray = targetString.split(",");
+var global_wfsConfObj;
+var global_selectedWfsConfId;
+var point_px = 10;
+var resultGeom = null;
+var cw_fillcolor = "#cc33cc";
+
+
+//parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initModWfsGazetteer()");
+
+function openwindow(Adresse) {
+	Fenster1 = window.open(Adresse, "Informationen", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
+	Fenster1.focus();
+}
+//----------------------------------------------------------------------------------
+
+function appendWfsConf(newWfsConfIdString) {
+	// merge with existing wfs conf ids
+	wfsConfIdString += "," + newWfsConfIdString;
+	
+	// rebuild form
+	initModWfsGazetteer();
+}
+
+function removeChildNodes(node) {
+	while (node.childNodes.length > 0) {
+		var childNode = node.firstChild;
+		node.removeChild(childNode);
+	}
+}
+
+/**
+ * removes whitespaces and endlines before and after a string
+ *
+ */ 
+function trimString (str) {
+	return str.replace(/^\s+|\s+|\n+$/g, '');
+}
+
+function appendStyles() {
+	var styleObj;
+	var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
+	if (parent.ie) {
+		var styleSheetObj=document.createStyleSheet();
+		styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+		styleObj.setAttribute("type","text/css");
+		ruleArray = rule.split("}");
+		for (var i=0; i < ruleArray.length - 1; i++) {
+			var currentRule = trimString(ruleArray[i]);
+			var nameValueArray = currentRule.split("{");
+			var name = nameValueArray[0];
+			var value = nameValueArray[1];
+			styleSheetObj.addRule(name,value);
+		}
+	}
+	else {
+		styleObj=document.createElement("style");
+		styleObj.setAttribute("type","text/css");
+		document.getElementsByTagName("head")[0].appendChild(styleObj);
+		styleObj.appendChild(document.createTextNode(rule+"\n"));		
+	}
+}
+
+//----------------------------------------------------------------------------------
+
+
+function initModWfsGazetteer() {
+	// empty nodes
+	var nodesToEmpty = ["selectWfsConfForm", "wfsForm", "res"];
+	
+	while (nodesToEmpty.length > 0) {
+		var currentId = nodesToEmpty.pop();
+		var currentNode = document.getElementById(currentId);
+		removeChildNodes(currentNode);
+	}
+	
+	parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConf",wfsConfIdString:wfsConfIdString}, function(json, status) {
+		global_wfsConfObj = json;
+		var wfsCount = 0;
+		for (var wfsConfId in global_wfsConfObj) {
+			global_selectedWfsConfId = wfsConfId; 
+			if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
+				wfsCount++;
+			}
+		}
+		if (wfsCount === 0) {
+			var e = parent.Mb_exception("no wfs conf id available.");
+		}
+		else if (wfsCount === 1) {
+			appendStyles();
+			appendWfsForm();
+			setWfsInfo();	
+		}
+		else {
+			appendWfsConfSelectBox();
+			setWfsInfo();	
+		}
+		parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
+	});
+}
+
+function setWfsInfo() {
+	var bulbNode = document.getElementById("wfsInfo"); 	
+
+	// append bulb image
+	removeChildNodes(bulbNode);
+	var imgNode = document.createElement("img");
+	imgNode.id = "wfsInfoImg";
+	imgNode.src = "../img/button_digitize/geomInfo.png";
+	imgNode.border = 0;
+	bulbNode.appendChild(imgNode);
+	bulbNode.href = "javascript:openwindow('../x_geoportal/mod_featuretypeMetadata.php?wfs_conf_id=" + global_selectedWfsConfId.toString() + "');";
+	
+	// set wfsGeomType image
+	var wfsGeomTypeNode = document.getElementById("wfsGeomType");
+	var wfsGeomType = "";
+	for (var i=0; i < global_wfsConfObj[global_selectedWfsConfId].element.length; i++) {
+		if (parseInt(global_wfsConfObj[global_selectedWfsConfId].element[i].f_geom)) {
+			wfsGeomType = global_wfsConfObj[global_selectedWfsConfId].element[i].element_type;
+		}
+	}
+	if (wfsGeomType.match(/Point/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/point_off.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else if (wfsGeomType.match(/Line/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/line_off.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else if (wfsGeomType.match(/Polygon/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/polygon_off.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else {
+		var e = new Mb_exception("WFS gazetteer: geometry type unknown.");		
+	}
+}
+
+function appendWfsConfSelectBox() {
+	var selectNode = document.createElement("select");
+	selectNode.name = "wfs_conf_sel";
+	selectNode.setAttribute("onchange", "global_selectedWfsConfId = this.value;setWfsInfo();appendStyles();appendWfsForm()");
+	
+	var isSelected = false;
+	for (var wfsConfId in global_wfsConfObj) {
+		var optionNode = document.createElement("option");
+		
+		optionNode.value = wfsConfId;
+		optionNode.innerHTML = global_wfsConfObj[wfsConfId].g_label;
+
+		if (!isSelected) {
+			optionNode.selected = true;
+			isSelected = true;
+			global_selectedWfsConfId = wfsConfId;
+		}
+		selectNode.appendChild(optionNode);
+	}
+
+	var form = document.getElementById('selectWfsConfForm');
+	form.appendChild(selectNode);
+	
+	appendStyles();
+	appendWfsForm();
+}
+
+function appendWfsForm() {
+	var form = document.getElementById("wfsForm");
+	removeChildNodes(form);
+	var resultDiv = document.getElementById("res");
+	removeChildNodes(resultDiv);
+	
+	var divContainer = document.createElement("div");
+	divContainer.className = global_wfsConfObj[global_selectedWfsConfId].g_label_id;
+	
+	divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
+	
+	form.appendChild(divContainer);
+
+	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
+
+	for (var i = 0; i < wfsConfElementArray.length; i++){
+		if (parseInt(wfsConfElementArray[i].f_search)) {
+			var spanNode = document.createElement("span");
+			spanNode.setAttribute("id", "ttttt");
+			spanNode.className = wfsConfElementArray[i].f_label_id;
+			spanNode.innerHTML = wfsConfElementArray[i].f_label;
+			var inputNode = document.createElement("input");
+			inputNode.type = "text";
+			inputNode.className = wfsConfElementArray[i].f_style_id;
+			inputNode.id = wfsConfElementArray[i].element_name;
+			
+			form.appendChild(spanNode);
+			form.appendChild(inputNode);
+			form.appendChild(document.createElement("br"));
+		}
+	}
+	var submitButton = document.createElement("input");
+	submitButton.type = "submit";
+	submitButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
+	submitButton.value = global_wfsConfObj[global_selectedWfsConfId].g_button;
+	
+	form.appendChild(submitButton);
+}
+
+function validate(){
+	global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
+
+	var filterParameterCount = getNumberOfFilterParameters();
+	
+	if(filterParameterCount == 0){
+		return false;
+	}
+	else{
+		var andConditions = "";
+		
+		var el = global_wfsConfObj[global_selectedWfsConfId].element;
+
+		for (var i = 0; i < el.length; i++) {
+			if (el[i]['f_search'] == 1 && document.getElementById(el[i]['element_name']).value != '') {
+		
+				var a = new Array();
+				a = document.getElementById(el[i]['element_name']).value.split(",");
+				var orConditions = "";
+				for (var j=0; j < a.length; j++) {
+					
+					orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+					orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+					orConditions += "<ogc:Literal>*";
+					if(el[i]['f_toupper'] == 1){
+						orConditions += a[j].toUpperCase();
+					}
+					else{
+						orConditions += a[j];
+					}
+					orConditions += "*</ogc:Literal>";
+					orConditions += "</ogc:PropertyIsLike>";
+				}
+				if(a.length > 1){
+					andConditions += "<Or>" + orConditions + "</Or>";
+				}
+				else {
+					andConditions += orConditions;
+				}
+			}
+		}
+
+		var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
+		u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
+		u += "&filter=";
+
+		if (filterParameterCount > 1) {
+			andConditions = "<And>" + andConditions + "</And>";
+		}
+
+		var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
+
+		document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
+		var parameters = {command:"getSearchResults", "wfs_conf_id":global_selectedWfsConfId, "frame":this.name, "url":u, "filter":filter, "backlink":""};
+		parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {
+			document.getElementById("res").innerHTML = "<table><tr><td>Arranging search results...</td></tr></table>";
+			eval(jsCode);
+			
+			for (var i=0; i < parent.wms.length; i++) {
+				for (var j=0; j < parent.wms[i].objLayer.length; j++) {
+					var currentLayer = parent.wms[i].objLayer[j];
+					var wms_id = parent.wms[i].wms_id; 
+					if (currentLayer.gui_layer_wfs_featuretype == global_selectedWfsConfId) {
+						var layer_name = currentLayer.layer_name; 
+						parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1); 
+						parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);					
+					}
+				}
+			}
+			var body = "";
+			if (typeof(geom) == 'object') {
+				resultGeom = geom; // set the global variable
+				for (var i=0; i < geom.count(); i++) {
+					body += "<div id='geom"+i+"'style='cursor:pointer;' ";
+					if ((i % 2) === 0) {
+						body += "class='even'";
+					}
+					else {
+						body += "class='uneven'";
+					}
+					body += " onmouseover=\"setResult('over', this.id)\" ";
+					body += " onmouseout=\"setResult('out', this.id)\" ";
+					body += " onclick=\"setResult('click', this.id)\">";
+					for (var j=0; j < geom.get(i).e.count(); j++) {
+						body += geom.get(i).e.getValue(j) + " ";
+					}
+					body += "</div>";
+				}
+			}
+			else {
+				body = "Kein Ergebnis.";
+			}
+			document.getElementById('res').innerHTML = body;
+		});
+	}
+	return false;
+}
+
+function getNumberOfFilterParameters(){
+	var cnt = 0;
+	var el = global_wfsConfObj[global_selectedWfsConfId].element;
+
+	for (var i = 0; i < el.length; i++){
+		if( el[i]['f_search'] == 1){
+			if (document.getElementById(el[i]['element_name']).value != '') {
+				cnt++;
+			}
+		}
+	}
+	return cnt;
+}
+/*
+* event -> {over || out || click}
+* geom -> commaseparated coordinates x1,y1,x2,y2 ...
+*/
+function setResult(event, id){
+	var index = parseInt(id.slice(4));
+
+	var currentGeom = resultGeom.get(index);
+	if (maxHighlightedPoints > 0 && currentGeom.getTotalPointCount() > maxHighlightedPoints) {
+		currentGeom = currentGeom.getBBox4();
+	}
+	if (event == "over") {
+		global_resultHighlight.add(currentGeom, cw_fillcolor);
+	}
+	else if (event == "out"){
+		global_resultHighlight.del(currentGeom, cw_fillcolor);
+	}
+	else if (event == "click"){
+		global_resultHighlight.del(currentGeom, cw_fillcolor);
+		var bbox = currentGeom.getBBox();
+		var buffer = new parent.Point(global_wfsConfObj[global_selectedWfsConfId].g_buffer,global_wfsConfObj[global_selectedWfsConfId].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);
+		parent.zoom(targetArray[0], 'true', 1.0);
+		global_resultHighlight.add(currentGeom, cw_fillcolor);
+	}
+	return true;
+}
+
+
+</script>
+</head>
+<body leftmargin='0' topmargin='10'  bgcolor='#ffffff'>
+<form name='selectWfsConfForm' id='selectWfsConfForm'></form>
+<img src = "" name='wfsGeomType' id='wfsGeomType'>
+<a name='wfsInfo' id='wfsInfo'/>
+<form name='wfsForm' id='wfsForm' onsubmit='return validate()'></form>
+<div name='res' id='res' style='width:180px'></div>
+</body>
 </html>
\ No newline at end of file



More information about the Mapbender_commits mailing list