[Mapbender-commits] r6153 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 10 10:58:10 EDT 2010


Author: astrid_emde
Date: 2010-05-10 10:58:10 -0400 (Mon, 10 May 2010)
New Revision: 6153

Modified:
   trunk/mapbender/http/plugins/mb_handleStartUpWmsParams.php
Log:
possibility to disable Layers added

Modified: trunk/mapbender/http/plugins/mb_handleStartUpWmsParams.php
===================================================================
--- trunk/mapbender/http/plugins/mb_handleStartUpWmsParams.php	2010-05-10 14:57:08 UTC (rev 6152)
+++ trunk/mapbender/http/plugins/mb_handleStartUpWmsParams.php	2010-05-10 14:58:10 UTC (rev 6153)
@@ -37,22 +37,41 @@
 
 $apiVisibleLayers = Mapbender::session()->get("visiblelayers");
 $apiQueryLayers = Mapbender::session()->get("querylayers");
+
+$apiDisableLayers = Mapbender::session()->get("disablelayers");
+$apiDisableQueryLayers = Mapbender::session()->get("disablequerylayers");
+
 $apiBackgroundWms = Mapbender::session()->get("backgroundwms");
 
 $apiVisibleLayersRegExpr = Mapbender::session()->get("visiblelayers_regexpr");
 $apiQueryLayersRegExpr = Mapbender::session()->get("querylayers_regexpr");
 
+$apiDisableLayersRegExpr = Mapbender::session()->get("disablelayers_regexpr");
+$apiDisableQueryLayersRegExpr = Mapbender::session()->get("disablequerylayers_regexpr");
+
 echo "var apiVisibleLayers = '" . $apiVisibleLayers . "';";
 echo "var apiVisibleLayerArray = apiVisibleLayers.split(',');";
 echo "var apiQueryLayers = '" . $apiQueryLayers . "';";
 echo "var apiQueryLayerArray = apiQueryLayers.split(',');";
+
+echo "var apiDisableLayers = '" . $apiDisableLayers . "';";
+echo "var apiDisableLayerArray = apiDisableLayers.split(',');";
+echo "var apiDisableQueryLayers = '" . $apiDisableQueryLayers . "';";
+echo "var apiDisableQueryLayerArray = apiDisableQueryLayers.split(',');";
+
 echo "var apiBackgroundWms = '" . $apiBackgroundWms . "';";
 
 echo "var checkForVisibleLayerArray = new Array();";
 echo "var checkForQueryLayerArray = new Array();";
 
+echo "var checkForDisableLayerArray = new Array();";
+echo "var checkForDisableQueryLayerArray = new Array();";
+
 echo "var apiVisibleLayersRegExpr = '" . $apiVisibleLayersRegExpr . "';";
 echo "var apiQueryLayersRegExpr = '" . $apiQueryLayersRegExpr . "';";
+
+echo "var apiDisableLayersRegExpr = '" . $apiDisableLayersRegExpr . "';";
+echo "var apiDisableQueryLayersRegExpr = '" . $apiDisableQueryLayersRegExpr . "';";
 ?>
 // set background WMS
 Mapbender.events.init.register(function () {
@@ -71,10 +90,15 @@
 // set queryability and visibility
 Mapbender.events.init.register(function () {
 	if(apiVisibleLayers != '' || apiQueryLayers != '' || 
-		apiVisibleLayersRegExpr != '' || apiQueryLayersRegExpr != ''){
+		apiVisibleLayersRegExpr != '' || apiQueryLayersRegExpr != '' ||
+		apiDisableLayers != '' || apiDisableQueryLayers != '' || 
+		apiDisableLayersRegExpr != '' || apiDisableQueryLayersRegExpr != ''
+		 ){
 	
 		var currentVisibleLayerMatchTrue = false;
 		var currentQueryLayerMatchTrue = false;
+		var currentDisableLayerMatchTrue = false;
+		var currentDisableQueryLayerMatchTrue = false;		
 		var mapObject = Mapbender.modules[options.target[0]];
 		var wmsArray = mapObject.wms;
 		
@@ -84,6 +108,28 @@
 			for (var j in currentWms.objLayer) {
 				var currentLayer = currentWms.objLayer[j];
 				
+				// parameter apiDisableLayers
+				for (var k in apiDisableLayerArray) {
+					var disableLayer = apiDisableLayerArray[k];
+
+					if (disableLayer == currentLayer.layer_name && currentLayer.gui_layer_status == '1' && 
+						(currentLayer.gui_layer_selectable == 1 || currentLayer.gui_layer_visible == 1)
+						) {
+						currentLayer.gui_layer_visible = 0;
+						checkForDisableLayerArray.push(currentLayer.layer_name);
+					}
+				}
+				
+				// parameter apiDisableQueryLayers
+				for (var k in apiDisableQueryLayerArray) {
+					var disableQueryLayer = apiDisableQueryLayerArray[k];
+					
+					if (disableQueryLayer == currentLayer.layer_name && currentLayer.gui_layer_queryable) {
+						currentLayer.gui_layer_querylayer = 0;
+						checkForDisableQueryLayerArray.push(currentLayer.layer_name);
+					}
+				}
+								
 				// parameter apiVisibleLayers
 				for (var k in apiVisibleLayerArray) {
 					var visibleLayer = apiVisibleLayerArray[k];
@@ -106,6 +152,30 @@
 					}
 				}
 				
+				// parameter apiDisableLayersRegExpr
+				if(apiDisableLayersRegExpr !== "") { 
+					var pattern = new RegExp(apiDisableLayersRegExpr);
+					var currentDisableLayerMatch = currentLayer.layer_name.match(pattern);
+					
+					if (currentDisableLayerMatch && currentLayer.gui_layer_status == '1' && 
+						(currentLayer.gui_layer_selectable == 1 || currentLayer.gui_layer_visible == 1)
+						) {
+						currentLayer.gui_layer_visible = 0;
+						currentDisableLayerMatchTrue = true;
+					}
+				}
+				
+				// parameter apiDisableQueryLayersRegExpr
+				if (apiDisableQueryLayersRegExpr !== "") {
+					var pattern = new RegExp(apiDisableQueryLayersRegExpr);
+					var currentDisableQueryLayerMatch = currentLayer.layer_name.match(pattern);
+					
+					if (currentDisableQueryLayerMatch && currentLayer.gui_layer_queryable) {
+						currentLayer.gui_layer_querylayer = 0;
+						currentDisableQueryLayerMatchTrue = true;
+					}
+				}	
+				
 				// parameter apiVisibleLayersRegExpr
 				if(apiVisibleLayersRegExpr !== "") { 
 					var pattern = new RegExp(apiVisibleLayersRegExpr);
@@ -170,6 +240,42 @@
 			}
 		}
 		
+		if(apiDisableLayers !== "") { 
+			var disableLayerNotFound = array_diff(apiDisableLayerArray, checkForVisibleLayerArray);
+			if(disableLayerNotFound.length > 0) {
+				var disableLayerString = visibleLayerNotFound.join(",");
+				var disableLayerNotFoundMsg = "Disable Layer: Visible layer " + visibleLayerString + " not found."; 
+				new Mapbender.Notice(disableLayerNotFoundMsg);
+				//alert(disableLayerNotFoundMsg);
+			}
+		}
+		
+		if(apiDisableQueryLayers !== "") { 
+			var disableQueryLayerNotFound = array_diff(apiDisableQueryLayerArray, checkForDisableQueryLayerArray);
+			if(disableQueryLayerNotFound.length > 0) {
+				var disableQueryLayerString = queryLayerNotFound.join(",");
+				var disableQueryLayerNotFoundMsg = "Disable Query Layer: Query layer " + queryLayerString + " not found."; 
+				new Mapbender.Notice(disableQueryLayerNotFoundMsg);
+				//alert(disableQueryLayerNotFoundMsg);
+			}
+		}
+		
+		if (apiDisableLayersRegExpr !== "") {
+			if(currentDisableLayerMatchTrue === false) { 
+				var disableLayerNotFoundMsg = "Disable LAyer: No visible layer matches the given regular expression."; 
+				new Mapbender.Notice(disableLayerNotFoundMsg);
+				//alert(disableLayerNotFoundMsg);
+			}
+		}
+		
+		if (apiDisableQueryLayersRegExpr !== "") {
+			if(currentDisableQueryLayerMatchTrue === false) {
+				var disableQueryLayerNotFoundMsg = "Disable Query Layer: No queryable layer matches the given regular expression."; 
+				new Mapbender.Notice(disableQueryLayerNotFoundMsg);
+				//alert(disableQueryLayerNotFoundMsg);
+			}
+		}		
+		
 	    eventAfterMapRequest.trigger({
 	    	map: mapObject
 	    });



More information about the Mapbender_commits mailing list