[Mapbender-commits] r3592 - branches/2.5/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Feb 25 11:04:16 EST 2009


Author: christoph
Date: 2009-02-25 11:04:15 -0500 (Wed, 25 Feb 2009)
New Revision: 3592

Modified:
   branches/2.5/http/php/mod_gazetteerMetadata.php
   branches/2.5/http/php/mod_gazetteerMetadata_search.php
Log:
allows Umlauts
makes found layers and wms visible on zoom (if already loaded)

Modified: branches/2.5/http/php/mod_gazetteerMetadata.php
===================================================================
--- branches/2.5/http/php/mod_gazetteerMetadata.php	2009-02-25 09:57:18 UTC (rev 3591)
+++ branches/2.5/http/php/mod_gazetteerMetadata.php	2009-02-25 16:04:15 UTC (rev 3592)
@@ -115,34 +115,75 @@
    }
 }
 
+function getLayerData (id) {
+	var ind = parent.getMapObjIndexByName("mapframe1");
+
+	var data = {
+		map : ind,
+		wms : null,
+		layer : null
+	};
+
+	for (var i = 0; i < parent.mb_mapObj[ind].wms.length; i++) {
+		var currentWms = parent.mb_mapObj[ind].wms[i];
+		for (var j = 0; j < currentWms.objLayer.length; j++) {
+			var currentLayer = currentWms.objLayer[j];
+			if (parseInt(currentLayer.layer_uid, 10) === id) {
+				data.wms = i;
+				data.layer = currentLayer.layer_name;
+				return data;
+			}
+		}
+	}
+	return null;
+}
+
 function displayTable(obj) {
 	var text = "<table>";
 	for (var attr in obj) {
 		var resultObj = obj[attr];
 		if (typeof(resultObj) != 'function') {
-			text += "<tr><td valign='top'>";
-			var imgUrl = "";
-			var onclickFunction = "";
-			if (typeof(resultObj.layer_name) !== "undefined") {
-				imgUrl = "../img/button_gray/metadata_layer.gif";
-				onclickFunction = "mod_addWMSLayerfromfilteredList(\"" + 
-					resultObj.wms_getcapabilities + "\",\"" + 
-					resultObj.wms_version + "\", \"" + 
-					resultObj.layer_name+"\");";
+			text += "<tr valign='top'><td>";
+			
+			//check if layer is not already loaded, add the load icon
+			var wmsLayerData = getLayerData(resultObj.layer_id);
+			if (wmsLayerData === null) {
+				var imgUrl = "";
+				var onclickFunction = "";
+				if (typeof(resultObj.layer_name) !== "undefined") {
+					imgUrl = "../img/button_gray/metadata_layer.gif";
+					onclickFunction = "mod_addWMSLayerfromfilteredList(\"" + 
+						resultObj.wms_getcapabilities + "\",\"" + 
+						resultObj.wms_version + "\", \"" + 
+						resultObj.layer_name+"\");";
+				}
+				else {
+					imgUrl = "../img/button_gray/metadata_wms.gif";
+					onclickFunction = "mod_addWMSfromfilteredList(\"" + 
+						resultObj.wms_getcapabilities + "\",\"" + 
+						resultObj.wms_version+"\");";
+				}
+				text += "<img name='add_wms' src='" + imgUrl + "' ";
+				text += "border='0' title='Load' ";
+				text += "onclick='" + onclickFunction + "'>";
 			}
-			else {
-				imgUrl = "../img/button_gray/metadata_wms.gif";
-				onclickFunction = "mod_addWMSfromfilteredList(\"" + 
-					resultObj.wms_getcapabilities + "\",\"" + 
-					resultObj.wms_version+"\");";
-			}
-			text += "<img name='add_wms' src='" + imgUrl + "' ";
-			text += "border='0' title='Load' ";
-			text += "onclick='" + onclickFunction + "'>";
+			text += "</td><td>";
 			if (resultObj.extent && resultObj.extent[0] !== null) {
 				text += "<img src='../img/tree_new/zoom.png' " + 
-					"onclick='" + 
-					"parent.mb_calculateExtent(\"mapframe1\", " + 
+					"onclick='";
+				
+				if (wmsLayerData !== null) {
+					//
+					// zoom to layer and make it visible
+					//
+					text += "var myMap = parent.mb_mapObj[" + wmsLayerData.map + "];" + 
+						"var myWms = myMap.wms[" + wmsLayerData.wms + "];" + 
+						"myWms.handleLayer(\"" + wmsLayerData.layer + "\", " + 
+						"\"visible\", 1);" + 
+						"myMap.restateLayers(myWms.wms_id);";
+				}	
+				
+				text +=	"parent.mb_calculateExtent(\"mapframe1\", " + 
 					resultObj.extent[0] + "," + 
 					resultObj.extent[1] + "," + 
 					resultObj.extent[2] + "," + 

Modified: branches/2.5/http/php/mod_gazetteerMetadata_search.php
===================================================================
--- branches/2.5/http/php/mod_gazetteerMetadata_search.php	2009-02-25 09:57:18 UTC (rev 3591)
+++ branches/2.5/http/php/mod_gazetteerMetadata_search.php	2009-02-25 16:04:15 UTC (rev 3592)
@@ -9,7 +9,7 @@
 $query = stripslashes($_REQUEST["search"]);
 $srs = stripslashes($_REQUEST["srs"]);
 
-if (!preg_match("/^[a-zA-Z_\- ]+$/", $query)) {
+if (!preg_match("/^[a-zA-ZäÄüÜöÖß_\- ]+$/", $query)) {
 	echo "[]"; die;
 }
 
@@ -62,7 +62,7 @@
 		array_push($obj, array(
 			'wms_getcapabilities' => $row['wms_getcapabilities'], 
 			'wms_version' => $row['wms_version'], 
-			'layer_id' => $row['layer_id'], 
+			'layer_id' => intval($row['layer_id']), 
 			'title' => $row['wms_title'],
 			'extent' => array(
 				$row['minx'],
@@ -109,7 +109,7 @@
 			'wms_getcapabilities' => $row['wms_getcapabilities'], 
 			'wms_version' => $row['wms_version'], 
 			'layer_name' => $row['layer_name'], 
-			'layer_id' => $row['layer_id'], 
+			'layer_id' => intval($row['layer_id']), 
 			'title' => $row['layer_title'],
 			'extent' => array(
 				$row['minx'],



More information about the Mapbender_commits mailing list