[Mapbender-commits] r10100 - in trunk/mapbender/http: classes html javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Apr 11 07:32:00 PDT 2019


Author: armin11
Date: 2019-04-11 07:32:00 -0700 (Thu, 11 Apr 2019)
New Revision: 10100

Modified:
   trunk/mapbender/http/classes/class_map.php
   trunk/mapbender/http/classes/class_wmc.php
   trunk/mapbender/http/classes/class_wmcToXml.php
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/html/mod_treefolderPlain.php
   trunk/mapbender/http/javascripts/initWmcObj.php
   trunk/mapbender/http/javascripts/wms.js
   trunk/mapbender/http/php/mod_GetPublishedData.php
   trunk/mapbender/http/php/mod_exportWmc2Json.php
Log:
Enhancement for optionally show table symbol in layertree if layer is coupled with metadata and this metadata describes some data which is provided in form of wfs featuretypes. 
New get parameter option to allow loading mobile client from wmc in current session.

Modified: trunk/mapbender/http/classes/class_map.php
===================================================================
--- trunk/mapbender/http/classes/class_map.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/classes/class_map.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -585,6 +585,7 @@
 				$newLayer->gui_layer_status = $currentLayer->gui_layer_status;
 				$newLayer->gui_layer_style = $currentLayer->gui_layer_style;
 				$newLayer->gui_layer_selectable = $currentLayer->gui_layer_selectable;
+//				$newLayer->layer_featuretype_coupling = $currentLayer->layer_featuretype_coupling;
 
 				if ($this->isOverview) {
 					preg_match_all("/LAYERS\=([^&]*)/", $jsMapObject->mapURL[0], $resultMatrix);
@@ -601,6 +602,7 @@
 				$newLayer->gui_layer_maxscale = $currentLayer->gui_layer_maxscale;
 				$newLayer->gui_layer_wfs_featuretype = $currentLayer->gui_layer_wfs_featuretype;
 				$newLayer->gui_layer_title = $currentLayer->gui_layer_title;
+$newLayer->layer_featuretype_coupling = $currentLayer->layer_featuretype_coupling; //TODO - test it!
 
 				// BEWARE THIS IS SUPER UGLY CODE
 				$newLayer->layer_epsg = array();

Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/classes/class_wmc.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -222,7 +222,7 @@
 	 * @param object $extensionData data exclusive to Mapbender, which will be
 	 * 								mapped into the extension part of the WMC
 	 */
-	public function createFromJs($mapObject, $generalTitle,$extensionData, $id=null) {
+	public function createFromJs($mapObject, $generalTitle, $extensionData, $id=null) {
 		if (count($mapObject) > 2) {
 			$e = new mb_exception("Save WMC only works for two concurrent map frames (overview plus main) at the moment.");
 		}
@@ -236,18 +236,18 @@
 
 		// set title
 		$this->wmc_title = $generalTitle;
-        if($mapObject[0]->kmls) {
-            $this->has_local_data = true;
-            $this->local_data_size = strlen(json_encode($mapObject[0]->kmls));
-            if(defined('MAX_WMC_LOCAL_DATA_SIZE')) {
-                if($this->local_data_size > MAX_WMC_LOCAL_DATA_SIZE) {
-                    $this->has_local_data = false;
-                    $this->local_data_size = '0';
-                    unset($mapObject[0]->kmls);
-                    unset($mapObject[0]->kmlOrder);
-                }
-            }
-        }
+        	if($mapObject[0]->kmls) {
+            		$this->has_local_data = true;
+            		$this->local_data_size = strlen(json_encode($mapObject[0]->kmls));
+            		if(defined('MAX_WMC_LOCAL_DATA_SIZE')) {
+                		if($this->local_data_size > MAX_WMC_LOCAL_DATA_SIZE) {
+                    			$this->has_local_data = false;
+                    			$this->local_data_size = '0';
+                    			unset($mapObject[0]->kmls);
+                    			unset($mapObject[0]->kmlOrder);
+                		}
+            		}
+        	}
 
 		// create the map objects
 		for ($i = 0; $i < count($mapObject); $i++) {
@@ -586,7 +586,7 @@
 		$v = array();
 		$t = array();
 		$layerIds = array();
-		$sql = "SELECT layer_id, f_get_download_options_for_layer(layer_id) AS downloadoptions, layer_name, fkey_wms_id, wms_timestamp, wms_getmap, wms_getlegendurl, wms_owsproxy FROM layer, wms WHERE layer.fkey_wms_id = wms.wms_id and layer_id in (";
+		$sql = "SELECT layer_id, layer_title, f_get_layer_featuretype_coupling(array[ layer_id ], TRUE) as featuretypecoupling, f_get_download_options_for_layer(layer_id) AS downloadoptions, layer_name, fkey_wms_id, wms_timestamp, wms_getmap, wms_getlegendurl, wms_owsproxy FROM layer, wms WHERE layer.fkey_wms_id = wms.wms_id and layer_id in (";
 		$i = 0;
 		//generate csv list of layer_ids
 		$layerList = "";
@@ -636,6 +636,7 @@
 		while($row = db_fetch_array($res)){
 			$wmsId = $row["fkey_wms_id"];
 			$layerId = $row["layer_id"];
+			$layerTitle = $row["layer_title"];
 			$e = new mb_notice("class_wmc.php - updateUrlsInDb - following layer will be processed: ".$layerId);
 			$layerName = $row["layer_name"];
 			//xpath to pull a special wmc layer object from simple xml object
@@ -662,6 +663,8 @@
   				$layer->Name = $layerName;
 				$e = new mb_notice("class_wmc: exchange old getmap url : ".$layer->Server->OnlineResource->attributes('xlink', true)->href." with new getmap url: ".$wmsGetMapUrl);
  				$layer->Server->OnlineResource->attributes('xlink', true)->href = $wmsGetMapUrl;
+				//title
+				$layer->Title = $layerTitle;
 				//check if layer has available download options
 				if (defined("SHOW_INSPIRE_DOWNLOAD_IN_TREE") && SHOW_INSPIRE_DOWNLOAD_IN_TREE == true && $row["downloadoptions"] != ""){
 					if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
@@ -673,7 +676,7 @@
 					//check if layer has a DataURL element
 					if (count($layer->DataURL) > 0) {
 						//found DataURL element
-						$e = new mb_notice("class_wmc.php - updateUrlsInDb - found existing DataURL Element!");
+						$e = new mb_notice("class_wmc.php - updateUrlsFromDb - found existing DataURL Element!");
 						//check if OnlineResource is already filled
 						if ($layer->DataURL->OnlineResource) {
 							$e = new mb_notice("class_wmc.php - updateUrlsInDb - found existing DataURL->OnlineResource Element!");
@@ -750,6 +753,15 @@
 						unset($layer->DataURL);
 					}
 				}
+				//show attribute table if layer_featuretype_coupling exists and this is defined in mapbender.conf
+				if (defined("SHOW_COUPLED_FEATURETYPES_IN_TREE") && SHOW_COUPLED_FEATURETYPES_IN_TREE == true) {
+					//put it in layer extension layer_featuretype_coupling
+					if ($row['featuretypecoupling'] !== "[]") {
+//$e = new mb_exception("class_wmc.php: updateUrlsFromDb: featuretypecoupling:".$row['featuretypecoupling']." - layer: ".(integer)$layerId);
+						//$resultOfXpath = reset($WMCDoc->xpath("/wmc:ViewContext/wmc:LayerList/wmc:Layer[wmc:Extension/mapbender:layer_id='".(integer)$layerId."']/wmc:DimensionList/wmc:Dimension[@name=\"time\" and @units=\"ISO8601\"]/@".$attributeName));
+						//$resultOfXpath->{0} = $dimension[(integer)$layerId]["time"][$attributeName];
+					}
+				}
 				//Help for problem with xlink:href attributes: http://php.net/manual/de/class.simplexmlelement.php!!!!!
 				//exchange legend urls
 				$layerDoc = simplexml_load_string($layer->saveXML());
@@ -853,7 +865,6 @@
 		}
 		return $WMCDoc->saveXML();
 	}
-	
 
 	/**
 	 * Stores this WMC in the database. The WMC has to be instantiated first, see above.
@@ -1155,7 +1166,12 @@
 		$res = db_prep_query($sql,$v,$t);
 		$row = db_fetch_array($res);
 		if ($row) {
-			return $row["wmc"];
+			$xmlDoc = new DOMDocument();
+   			$xmlDoc->loadXML($row["wmc"]);
+			$xmlDoc->encoding = 'UTF-8';
+			$xmlDoc->preserveWhiteSpace = false;
+			$xmlDoc->formatOutput = true;	
+			return $xmlDoc->saveXML();
 		}
 		return false;
 	}
@@ -1668,7 +1684,7 @@
 		//
 		$extension = false;		$general = false;		$layerlist = false;
 		$layer = false;  		$layer_dimensionlist = false;         $formatlist = false;	$layer_dataurl = false;
-		$layer_metadataurl = false; 	$stylelist = false;
+		$layer_metadataurl = false; 	$stylelist = false;		//$layer_featuretype_coupling = false;
 
 		//
 		// reset WMC data
@@ -1705,8 +1721,9 @@
 
 		//$e = new mb_exception("class_wmc.php: parsing wmc by xpath: title: ".$title[0]);
 		//$e = new mb_exception("class_wmc.php: parsing wmc by xpath: wmc_version: ".$this->wmc_version);
+//$e = new mb_exception("");
+//$e = new mb_exception("class_wmc.php: createObjFromWMC_xml: ".$data);
 
-
 		foreach ($values as $element) {
 			$tag = strtoupper(administration::sepNameSpace($element['tag']));
 			$tagLowerCase = administration::sepNameSpace($element['tag']);
@@ -1907,6 +1924,9 @@
 					// we have all necessary information to CREATE
 					// a layer object and append it to the WMS object
 					//
+/*if (isset($currentLayer["extension"]["LAYER_FEATURETYPE_COUPLING"]) && $currentLayer["extension"]["LAYER_FEATURETYPE_COUPLING"] !== "") {
+	$e = new mb_exception("class_wmc.php: found layer_featuretype_coupling: ".$currentLayer["extension"]["LAYER_FEATURETYPE_COUPLING"]);
+}*/
 						if (isset($currentLayer["extension"]["OVERVIEWHIDDEN"])) {
 							array_push($layerlistArray["overview"], $currentLayer);
 						}
@@ -2048,7 +2068,10 @@
 							$extension = false;
 						}
 						if ($extension == true) {
-						//							if ($value !== "") {
+						//
+/*if ($tag == "LAYER_FEATURETYPE_COUPLING" && $currentLayer["extension"][$tag] !== null) {							//if ($value !== "") {
+	$e = new mb_exception("classes/class_wmc.php: createObjFromWMC_xml: layer extension tag:  ".$tag." - value: ".json_encode($currentLayer["extension"][$tag]));	
+}*/
 							if (isset($currentLayer["extension"][$tag])) {
 								if (!is_array($currentLayer["extension"][$tag])) {
 									$firstValue = $currentLayer["extension"][$tag];

Modified: trunk/mapbender/http/classes/class_wmcToXml.php
===================================================================
--- trunk/mapbender/http/classes/class_wmcToXml.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/classes/class_wmcToXml.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -453,6 +453,7 @@
 		$layerExtensionData["gui_status"] = $currentLayer->gui_layer_status;
 		$layerExtensionData["layer_epsg"] = $currentLayer->layer_epsg;
 		$layerExtensionData["gui_wms_opacity"] = $currentWms->gui_wms_opacity;
+		$layerExtensionData["layer_featuretype_coupling"] = $currentLayer->layer_featuretype_coupling;
 
 		for ($i = 0; $i < count($currentWms->gui_epsg); $i++) {
 			$found = false;

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/classes/class_wms.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -172,7 +172,7 @@
 	    $layerCount = 0;
 	    $metadataCount = 0;
 	    $featuretypeCount = 0;
-	    $wfsconfCount = 0;
+	    $wfsConfCount = 0;
 	    foreach ($originalJsonArray as $layerRecord) {
 	    	if (!in_array($layerRecord['layerId'], $layerIdArray)) {
 	    	    //get all entries for metadataId
@@ -202,6 +202,7 @@
 				    }
 				}
 				$featuretypeCount = 0;
+				$wfsConfCount = 0;
 				$metadataIdArray[] = $metadataRecord['metadataId'];
 			        $metadataCount++;
 			    }
@@ -208,6 +209,8 @@
 			}
 		    }
 		    $metadataCount = 0;
+		    $featuretypeCount = 0;
+		    $wfsConfCount = 0;
 		    $layerIdArray[] = $layerRecord['layerId'];
 		    $layerCount++;
 		}
@@ -1571,6 +1574,10 @@
 		else {
 			$newLayer->gui_layer_wfs_featuretype = "";
 		}
+		if (isset($currentLayer["extension"]["LAYER_FEATURETYPE_COUPLING"])) {
+			$newLayer->layer_featuretype_coupling = $currentLayer["extension"]["LAYER_FEATURETYPE_COUPLING"];
+//$e = new mb_exception("classes/class_wms.php: newLayer: layer_featuretype_coupling: ".$currentLayer["extension"]["LAYER_FEATURETYPE_COUPLING"]);
+		}
 		$newLayer->gui_layer_queryable = $currentLayer["extension"]["GUI_QUERYABLE"];
 		$newLayer->gui_layer_querylayer = $currentLayer["extension"]["QUERYLAYER"];
 		$newLayer->gui_layer_minscale = $currentLayer["extension"]["GUI_MINSCALE"];
@@ -1700,6 +1707,8 @@
 		}
 		//do the things for each layer
 		for($i=0; $i<count($this->objLayer); $i++){
+//debug
+//$e = new mb_exception("layer: ".$this->objLayer[$i]->layer_title." - layer_featuretype_coupling: ". $this->objLayer[$i]->layer_featuretype_coupling);
 			if($parent){
 				$str .= "parent.";
 			}
@@ -1727,7 +1736,8 @@
 			$this->objLayer[$i]->gui_layer_maxscale ."','".
 			$this->objLayer[$i]->gui_layer_wfs_featuretype ."','".
 			$this->objLayer[$i]->gui_layer_title ."','".
-			$this->objLayer[$i]->layer_dataurl[0]->href ."');";
+			$this->objLayer[$i]->layer_dataurl[0]->href ."','".
+			$this->objLayer[$i]->layer_featuretype_coupling ."');";
 				
 			for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
 				$currentEpsg = $this->objLayer[$i]->layer_epsg[$j];
@@ -1863,7 +1873,9 @@
 				$this->objLayer[$i]->gui_layer_maxscale ."','".
 				$this->objLayer[$i]->gui_layer_wfs_featuretype ."','".
 				$this->objLayer[$i]->gui_layer_title ."','".
-				$this->objLayer[$i]->layer_dataurl[0]->href ."');");
+				$this->objLayer[$i]->layer_dataurl[0]->href ."','".
+				$this->objLayer[$i]->layer_featuretype_coupling ."');");
+
 			for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
 				if($i==0){
 					if($parent){
@@ -3626,7 +3638,7 @@
 		while($row = db_fetch_array($res)){
 			$layer_id = $row["fkey_layer_id"];
 			if (defined("SHOW_COUPLED_FEATURETYPES_IN_TREE") && SHOW_COUPLED_FEATURETYPES_IN_TREE == true) {
-				$sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions, f_get_layer_featuretype_coupling(array[ layer_id ], FALSE) as featuretypecoupling FROM layer WHERE layer_id = $1";
+				$sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions, f_get_layer_featuretype_coupling(array[ layer_id ], TRUE) as featuretypecoupling FROM layer WHERE layer_id = $1";
 //$e = new mb_exception("show coupling!");
 			} else {
 				$sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions FROM layer WHERE layer_id = $1";
@@ -3678,7 +3690,18 @@
 				}
 				//new in 2019 - possibility to show symbol for accessing datatable - one url for each entry in json string $row2['featuretypecoupling']
 				//link to be invoked
-				if (defined("SHOW_COUPLED_FEATURETYPES_IN_TREE") && SHOW_COUPLED_FEATURETYPES_IN_TREE == true && $row2["featuretypecoupling"] != "[]") {
+				if (defined("SHOW_COUPLED_FEATURETYPES_IN_TREE") && SHOW_COUPLED_FEATURETYPES_IN_TREE == true && $row2["featuretypecoupling"] !== "[]") {
+					//filter wfs_conf for accessiblity for current user
+					$currentUser = new User(Mapbender::session()->get("mb_user_id"));
+					$accessibleWfsConfIds = $currentUser->getWfsConfByPermission();
+					$wfsCouplingArrayOld = json_decode($row2["featuretypecoupling"]);
+					$wfsCouplingArrayNew = array();
+					foreach ($wfsCouplingArrayOld as $rowWfsConfArray) {
+						if (in_array($rowWfsConfArray->wfsConfId, $accessibleWfsConfIds)) {
+							$wfsCouplingArrayNew[] = $rowWfsConfArray;
+						}
+					}
+					$row2["featuretypecoupling"] = json_encode($wfsCouplingArrayNew);
 					//parse json and built following tree
 					/*TODO - alter json object to following struct: {"layerId": 1234,
 					    "datasetMetadata": 
@@ -3702,7 +3725,9 @@
 						$featuretypeMetadataUrl = "../php/mod_showLayerToFeaturetypeCoupling.php?outputFormat=html&struct=";
 					}*/
 					$this->objLayer[$layer_cnt]->layer_featuretype_coupling = $this->normalizeLayerFeaturetypeCoupling($row2["featuretypecoupling"]);
-//$e = new mb_exception("coupling json: ".$this->normalizeLayerFeaturetypeCoupling($row2["featuretypecoupling"]));					
+//$e = new mb_exception("coupling json - from GUI: ".$this->normalizeLayerFeaturetypeCoupling($row2["featuretypecoupling"]));					
+				} else {
+					$this->objLayer[$layer_cnt]->layer_featuretype_coupling = null;
 				}
 				//add to layer object
 				//$this->objLayer[$layer_cnt]->layer_featuretype_coupling = $jsonObject;
@@ -3895,7 +3920,7 @@
 		}
 
 		if (defined("SHOW_COUPLED_FEATURETYPES_IN_TREE") && SHOW_COUPLED_FEATURETYPES_IN_TREE == true) {
-			$sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions, f_get_layer_featuretype_coupling(array[ layer_id ], FALSE) as featuretypecoupling FROM layer WHERE fkey_wms_id = $1 ORDER BY layer_pos";
+			$sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions, f_get_layer_featuretype_coupling(array[ layer_id ], TRUE) as featuretypecoupling FROM layer WHERE fkey_wms_id = $1 ORDER BY layer_pos";
 //$e = new mb_exception("show coupling!");
 		} else {
 			$sql = "SELECT *, f_get_download_options_for_layer(layer_id) as downloadoptions FROM layer WHERE fkey_wms_id = $1 ORDER BY layer_pos";
@@ -3954,6 +3979,17 @@
 			//link to be invoked
 //$e = new mb_exception("row2 featuretypecoupling:".$row2["featuretypecoupling"]);
 			if (defined("SHOW_COUPLED_FEATURETYPES_IN_TREE") && SHOW_COUPLED_FEATURETYPES_IN_TREE == true && $row2["featuretypecoupling"] != "[]") {
+				//filter wfs_conf for accessiblity for current user
+				$currentUser = new User(Mapbender::session()->get("mb_user_id"));
+				$accessibleWfsConfIds = $currentUser->getWfsConfByPermission();
+				$wfsCouplingArrayOld = json_decode($row2["featuretypecoupling"]);
+				$wfsCouplingArrayNew = array();
+				foreach ($wfsCouplingArrayOld as $rowWfsConfArray) {
+					if (in_array($rowWfsConfArray->wfsConfId, $accessibleWfsConfIds)) {
+						$wfsCouplingArrayNew[] = $rowWfsConfArray;
+					}
+				}
+				$row2["featuretypecoupling"] = json_encode($wfsCouplingArrayNew);
 				//parse json and built following tree
 				/*TODO - alter json object to following struct: {"layerId": 1234,
 					   "datasetMetadata": 
@@ -3968,8 +4004,7 @@
 					 ]
 					     ]
                                           }
-				*/
-											
+				*/						
 				//built url for webservice
 				/*if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
 					$featuretypeMetadataUrl = MAPBENDER_PATH."/php/mod_showLayerToFeaturetypeCoupling.php?outputFormat=html&struct=";
@@ -3977,7 +4012,9 @@
 					$featuretypeMetadataUrl = "../php/mod_showLayerToFeaturetypeCoupling.php?outputFormat=html&struct=";
 				}*/
 				$this->objLayer[$layer_cnt]->layer_featuretype_coupling = $this->normalizeLayerFeaturetypeCoupling($row2["featuretypecoupling"]);
-//$e = new mb_exception("coupling json: ".$this->normalizeLayerFeaturetypeCoupling($row2["featuretypecoupling"]));					
+//$e = new mb_exception("coupling json: - no GUI ".$this->normalizeLayerFeaturetypeCoupling($row2["featuretypecoupling"]));					
+			} else {
+				$this->objLayer[$layer_cnt]->layer_featuretype_coupling = null;
 			}
 			$this->objLayer[$layer_cnt]->layer_searchable =$row2["layer_searchable"];
 			$this->objLayer[$layer_cnt]->inspire_download =$row2["inspire_download"];
@@ -4246,6 +4283,7 @@
 	var $layer_md_topic_category_id = array();
 	var $layer_inspire_category_id = array();
 	var $layer_custom_category_id = array();
+        //var $layer_featuretype_coupling;
 	
 	var $gui_layer_wms_id;
 	var $gui_layer_status = 1;

Modified: trunk/mapbender/http/html/mod_treefolderPlain.php
===================================================================
--- trunk/mapbender/http/html/mod_treefolderPlain.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/html/mod_treefolderPlain.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -39,6 +39,7 @@
 msgObj.tooltipMoveSelectionDown = '<?php echo _mb("Moves the selection down");?>';
 msgObj.tooltipMetadata = '<?php echo _mb("Show metadata");?>';
 msgObj.tooltipDownload = '<?php echo _mb("Download dataset");?>';
+msgObj.tooltipFeaturetypeCoupling = '<?php echo _mb("Coupled featuretypes");?>';
 
 if (typeof(localizetree) === 'undefined')localizetree = 'false';
 
@@ -200,6 +201,7 @@
 }
 
 if (typeof(datalink) === 'undefined')datalink = 'false';
+if (typeof(featuretypeCoupling) === 'undefined')featuretypeCoupling = 'false';
 if (typeof(metadataWidth) === 'undefined')metadataWidth = '500';
 if (typeof(metadataHeight) === 'undefined')metadataHeight = '500';
 if (typeof(activatedimension) === 'undefined')activatedimension = 'false';
@@ -1031,7 +1033,17 @@
 										controls.push('<a href="'+defaultMetadataUrl + '&id='+temp.layer_uid+'"'+' target=\'_blank\' onclick="metadata_window = window.open(this.href,\'Metadata\',\'Width=700, Height=550,scrollbars=yes,menubar=yes,toolbar=yes\');metadata_window.focus(); return false;"><img alt="'+msgObj.tooltipMetadata+'" title="'+msgObj.tooltipMetadata+'" src="'+imagedir+'/info.png" /></a>');
 									}
 									if(datalink == 'true' && mb_mapObj[i].wms[ii].objLayer[iii].layer_dataurl != ''){
-										controls.push('<a href="'+mb_mapObj[i].wms[ii].objLayer[iii].layer_dataurl+'"'+' target=\'_blank\' onclick="download_window = window.open(this.href,\'Download Data\',\'Width=450, Height=350,scrollbars=yes,menubar=yes,toolbar=yes\'); download_window.focus(); return false;"><img width="18" height="18" alt="'+msgObj.tooltipDownload+'" title="'+msgObj.tooltipDownload+'" src="'+imagedir+'/../gnome/document-save.png" /></a>');	
+										controls.push('<a href="'+mb_mapObj[i].wms[ii].objLayer[iii].layer_dataurl+'"'+' target=\'_blank\' onclick="download_window = window.open(this.href,\'Download Data\',\'Width=450, Height=350,scrollbars=yes,menubar=yes,toolbar=yes\'); download_window.focus(); return false;"><img width="18" height="18" alt="'+msgObj.tooltipDownload+'" title="'+msgObj.tooltipDownload+'" src="'+imagedir+'/../gnome/document-save.png" /></a>');
+									//
+}
+//if (typeof mb_mapObj[i].wms[ii].objLayer[iii].layer_featuretype_coupling == 'undefined') {				
+//alert(mb_mapObj[i].wms[ii].objLayer[iii].layer_title+': '+JSON.stringify(mb_mapObj[i].wms[ii].objLayer[iii].layer_featuretype_coupling));
+//}
+									if(featuretypeCoupling == 'true' && mb_mapObj[i].wms[ii].objLayer[iii].layer_featuretype_coupling != ''){
+//alert(mb_mapObj[i].wms[ii].objLayer[iii].layer_featuretype_coupling);
+										//controls.push('<a href="'+mb_mapObj[i].wms[ii].objLayer[iii].layer_featuretype_coupling+'"'+' target=\'_blank\' onclick="featuretype_window = window.open(this.href,\'Featuretype Data\',\'Width=450, Height=350,scrollbars=yes,menubar=yes,toolbar=yes\'); featuretype_window.focus(); return false;"><img width="18" height="18" alt="'+msgObj.tooltipFeaturetypeCoupling+'" title="'+msgObj.tooltipFeaturetypeCoupling+'" src="'+imagedir+'/../gnome/accessories-dictionary.png" /></a>');
+										controls.push('<img width="18" height="18" coupling="'+btoa(mb_mapObj[i].wms[ii].objLayer[iii].layer_featuretype_coupling)+'" onclick="alert(atob(this.getAttribute(\'coupling\')))" alt="'+msgObj.tooltipFeaturetypeCoupling+'" title="'+msgObj.tooltipFeaturetypeCoupling+'" src="'+imagedir+'/../osgeo_graphics/geosilk/application_view_columns.png" />');
+										//controls.push('<img width="18" height="18" onclick="alert('+mb_mapObj[i].wms[ii].objLayer[iii].layer_featuretype_coupling+');" alt="'+msgObj.tooltipFeaturetypeCoupling+'" title="'+msgObj.tooltipFeaturetypeCoupling+'" src="'+imagedir+'/../osgeo_graphics/geosilk/application_view_columns.png" />');
 									}
 									//dimension buttons
 									if (activatedimension == 'true') {
@@ -1084,6 +1096,39 @@
 	initialized=true;
 }
 
+//https://stackoverflow.com/questions/4253367/how-to-escape-a-json-string-containing-newline-characters-using-javascript
+// implement JSON stringify serialization
+JSON.stringify = JSON.stringify || function (obj) {
+    var t = typeof (obj);
+    if (t != "object" || obj === null) {
+        // simple data type
+        if (t == "string") obj = '"'+obj+'"';
+        return String(obj);
+    }
+    else {
+        // recurse array or object
+        var n, v, json = [], arr = (obj && obj.constructor == Array);
+        for (n in obj) {
+            v = obj[n]; t = typeof(v);
+            if (t == "string") v = '"'+v+'"';
+            else if (t == "object" && v !== null) v = JSON.stringify(v);
+            json.push((arr ? "" : '"' + n + '":') + String(v));
+        }
+        var rawString = (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
+       return rawString;
+    }
+};
+function escape (key, val) {
+    if (typeof(val)!="string") return val;
+
+    var replaced = encodeURIComponent(val);
+    return replaced;
+}
+
+JSON.stringifyEscaped = function(obj){
+    return JSON.stringify(obj,escape);
+}
+
 function initWmsCheckboxen(){
 	var hidden=0;
 	if( mb_mapObj.length > 0){

Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/javascripts/initWmcObj.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -1,7 +1,9 @@
 <?php
-//
-// Load WMS via WMC
-//
+/*Central module, that initialize the mapbender client (GUI) mapset. The initilization is done using the OGC WMC standard.
+The module first tries to read the actual mapset from session information, if this is defined in the GUI element 'loadWmc'
+If no session wmc is found, the module reads the mapset from database default GUI configuration.
+The module also handles the management of initial GET-Parameter: https://mb2wiki.mapbender2.org/GET-Parameter
+*/
 require_once dirname(__FILE__)."/../php/mb_validateSession.php";
 require_once dirname(__FILE__)."/../classes/class_wmc.php";
 require_once dirname(__FILE__)."/../classes/class_wmc_factory.php";
@@ -15,9 +17,9 @@
 require_once(dirname(__FILE__)."/../classes/class_owsConstraints.php");
 require_once(dirname(__FILE__)."/../classes/class_cache.php");
 
+/*check if key param can be found in SESSION, otherwise take it from $_GET
+*/
 function getConfiguration ($key) {
-//check if key param can be found in SESSION,
-// otherwise take it from GET
 	if (Mapbender::session()->exists($key)) {
 		return Mapbender::session()->get($key);
 	}
@@ -24,66 +26,22 @@
 	return $_GET[$key];
 }
 
-//for debugging purposes only
+/*for debugging purposes only
+*/
 function logit($text,$filename,$how){
 	 if($h = fopen(LOG_DIR."/".$filename,$how)){
 				$content = $text .chr(13).chr(10);
 				if(!fwrite($h,$content)){
-					#exit;
+					//exit;
 				}
 				fclose($h);
 			}
 }
 
-function getWmcFromStorage($filename) {
-	switch (TMP_WMC_SAVE_STORAGE) {
-		case "memcache":
-			$memcache_obj = new Memcache;
-			if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
-				$memcache_obj->connect(MEMCACHED_IP, MEMCACHED_PORT);
-			} else {
-				//use standard options
-				$memcache_obj->connect('localhost', 11211);
-			}
-			new mb_notice("wmc sessions load via memcache");
-			$wmc = $memcache_obj->get($filename);
-			$memcache_obj->close();
-			return $wmc;
-		break;
-		case "memcached":
-			$memcached_obj = new Memcached;
-			if (defined("MEMCACHED_IP") && MEMCACHED_IP != "" && defined("MEMCACHED_PORT") && MEMCACHED_PORT != "") {
-				$memcached_obj->addServer(MEMCACHED_IP, MEMCACHED_PORT);
-			} else {
-				//use standard options
-				$memcached_obj->addServer('localhost', 11211);
-			}
-			new mb_notice("wmc load via memcacheD");
-			$wmc = $memcached_obj->get($filename);
-			//$memcached_obj->quit();
-			return $wmc;
-		break;
-		case "cache":
-			$cache = new Cache();
-			if ($cache->isActive && $cache->cachedVariableExists($filename)) {
-				$wmc = $cache->cachedVariableFetch($filename);
-				return $wmc;
-			} else {
-				return false;
-			}
-		break;
-		case "file":
-			$wmc = file_get_contents($filename);
-			return $wmc;
-		break;
-		default:
-			$wmc = file_get_contents($filename);
-			return $wmc;
-		break;
-	}
-}
-
 $admin = new administration();
+/*
+Initial declaration of the return object, that handles some control of the distributed services
+*/
 $resultObj = array(
 	"noPermission" => array(
 		"message" => _mb("You as User")." '" .
@@ -107,51 +65,63 @@
 		"message" => ""
 	)
 );
-//
-// Load WMC from session or application
-$e = new mb_notice("javascript/initWmcObj.php: start!");
+
+/*
+Load WMC from session or application (GUI)
+*/
+$e = new mb_notice("javascript/initWmcObj.php: Initialize first WMC Object");
 $wmc = new wmc();
-$app = Mapbender::session()->get("mb_user_gui"); //if gui was set!
+/*
+activate for debugging
+*/
+$e = new mb_notice("javascript/initWmcObj.php: Current user name from session information: ".Mapbender::session()->get("mb_user_name"));
+
+$app = Mapbender::session()->get("mb_user_gui"); // if gui was set!
 //$wmcDocSession = Mapbender::session()->get("mb_wmc");
 $wmcDocSession = false;
-//check if wmc filename is in session - TODO only if should be loaded from session not else! (Module loadWMC)
+// check if wmc filename is in session - TODO only if should be loaded from session not else! (Module loadWMC)
+$e = new mb_notice("javascript/initWmcObj.php: Filename of WMC from session: ".Mapbender::session()->get("mb_wmc"));
+/*check if WMC exists in session
+*/
 if(Mapbender::session()->get("mb_wmc")) {
     $wmc_filename = Mapbender::session()->get("mb_wmc");
-    $time_start = microtime();
-    //load it from whereever it has been stored
+    //$time_start = microtime();
+    // load it from whereever it has been stored
     $wmcDocSession = $admin->getFromStorage($wmc_filename, TMP_WMC_SAVE_STORAGE);
     //$wmcDocSession = getWmcFromStorage($wmc_filename);
-    $time_end = microtime();
-    $timediff = $time_end - $time_start;
-    //$e = new mb_exception('initWmcObj.php: time to load wmc from storage: '.$timediff. '('.TMP_WMC_SAVE_STORAGE.')');
+    //$time_end = microtime();
+    //$timediff = $time_end - $time_start;
+    //$e = new mb_exception('javascript/initWmcObj.php: Time to load WMC from storage: '.$timediff. '('.TMP_WMC_SAVE_STORAGE.')');
 }
 try {
 	$loadFromSession = new ElementVar($app, "loadwmc", "loadFromSession");
 	if ($wmcDocSession && $loadFromSession->value === "1") {
-	//check if session contains a wmc,
-	//otherwise create a new wmc from application
-		//$e = new mb_notice("trying to load session WMC...");
+	// check if session contains a wmc,
+	// otherwise create a new wmc from application
+		$e = new mb_notice("javascript/initWmcObj.php: Trying to load session WMC...");
 		if (!$wmc->createFromXml($wmcDocSession)) {
-			$e = new mb_notice("loading session WMC failed.");
-			$e = new mb_notice("creating wmc from app: ".$app);
+			$e = new mb_notice("javascript/initWmcObj.php: Loading session WMC failed.");
+			$e = new mb_notice("javascript/initWmcObj.php: Creating WMC from app: ".$app);
 			$wmc->createFromApplication($app);
 		}
 	}
 	else {
-		$e = new mb_notice("loading from session WMC disabled in loadwmc or no session WMC set.");
-		$e = new mb_notice("creating wmc from app: ".$app);
-		$e = new mb_notice("initWmcObj.php: before load from app");
+		$e = new mb_notice("javascript/initWmcObj.php: Loading from session WMC disabled in loadwmc or no session WMC set.");
+		$e = new mb_notice("javascript/initWmcObj.php: Creating WMC from app: ".$app);
+		//$e = new mb_notice("javascript/initWmcObj.php: Before load from app");
 		$wmc->createFromApplication($app);
-		$e = new mb_notice("initWmcObj.php: after load from app");
+		//$e = new mb_notice("javascript/initWmcObj.php: After load from app");
 	}
 }
 catch (Exception $e) {
-	$e = new mb_exception("initWmcObj.php: ERROR while loading wmc from session - test creating wmc from app: " . $app);
+	$e = new mb_exception("javascript/initWmcObj.php: ERROR while loading WMC from session - test creating WMC from app: " . $app);
 	$wmc->createFromApplication($app);
 }
 
+/*
+
+*/
 $removeUnaccessableLayers = false;
-
 $removeUnaccessableLayers = new ElementVar($app, "loadwmc", "removeUnaccessableLayers");
 if ($removeUnaccessableLayers->success == true){
 	if ($wmcDocSession && $removeUnaccessableLayers->value === "1") {
@@ -159,16 +129,21 @@
 	}
 }
 
-//TODO: if no GET API is given then don't do the following things
-//
-// create new WMC with services from GET API
-//
-//look in wmc xml *******************************************************************
+/* TODO: if no GET API is given then don't do the following things*******************
+Create new WMC with services from GET API
+https://mb2wiki.mapbender2.org/GET-Parameter
+Look in wmc xml ********************************************************************
+*/
 //$e = new mb_exception("initWmcObj.php - debug - initial wmc xml: ".$wmc->toXml());
 //die();
-//***********************************************************************************
-//
+/*
+************************************************************************************
+*/
 $wmcGetApi = WmcFactory::createFromXml($wmc->toXml());
+
+//$e = new mb_notice("javascripts/initWmcObj.php: initial wmc doc: ".$wmc->toXml());
+//$e = new mb_exception("javascripts/initWmcObj.php: initial wmc from xml: ".json_encode($wmcGetApi));
+//die();
 $options = array();
 if (Mapbender::session()->exists("addwms_showWMS")) {
 	$options["show"] = intval(Mapbender::session()->get("addwms_showWMS"));
@@ -189,32 +164,33 @@
 	"ZOOM"=>getConfiguration("ZOOM")
 );
 $getApi = new GetApi($getParams);
-//
-// WMC
-//
-$e = new mb_notice("initWmcObj.php: check WMC API");
+/*
+WMC ID
+*/
+$e = new mb_notice("javascript/initWmcObj.php: Check WMC GET API");
 $inputWmcArray = $getApi->getWmc();
 if ($inputWmcArray) {
-	$e = new mb_notice("initWmcObj.php: some WMC id was set thru Get Api!");
+	$e = new mb_notice("javascript/initWmcObj.php: some WMC id was set thru Get Api!");
 	foreach ($inputWmcArray as $input) {
-	// just make it work for a single Wmc
+	// Just make it work for a single Wmc
 		try {
 			$wmcGetApi = WmcFactory::createFromDb($input["id"]);
-			//update urls from wmc with urls from database if id is given
+			// update urls from wmc with urls from database if id is given
+			$e = new mb_exception("javascripts/initWmcObj.php: wmc->updateUrlsFromDb");
 			$updatedWMC = $wmcGetApi->updateUrlsFromDb();
 	        	$wmcGetApi->createFromXml($updatedWMC);
-			//increment load count
+			// increment load count
 			$wmcGetApi->incrementWmcLoadCount();
 		}
 		catch (Exception $e) {
-			new mb_exception("Failed to load WMC from DB. Keeping original WMC.");
+			new mb_exception("javascripts/initWmcObj.php: Failed to load WMC from DB via ID. Keeping original WMC.");
 		}
 	}
 }
-//
-// WMS
-//
-$e = new mb_notice("initWmcObj.php: check WMS API");
+/*
+WMS
+*/
+$e = new mb_notice("javascripts/initWmcObj.php: check WMS API");
 if ($getParams['WMS']) {
 // WMS param given as array
 	if (is_array($getParams['WMS'])) {
@@ -232,16 +208,13 @@
 			foreach ($val as $attr=>$value) {
 				$multipleAssocArray[$attr] = $value;
 			}
-			//get WMS by ID with settings of given application
+			// get WMS by ID with settings of given application
 			if (array_key_exists('application', $multipleAssocArray) &&
 				array_key_exists('id', $multipleAssocArray)) {
 				$currentWms = new wms();
-				$currentWms->createObjFromDB(
-					$multipleAssocArray['application'],
-					$multipleAssocArray['id']
-				);
+				$currentWms->createObjFromDB($multipleAssocArray['application'], $multipleAssocArray['id']);
 			}
-			//get WMS by URL
+			// get WMS by URL
 			elseif (array_key_exists('url', $multipleAssocArray)) {
 				$currentWms = new wms();
 				$currentWms->createObjFromXML($multipleAssocArray['url']);
@@ -250,25 +223,21 @@
 				continue;
 			}
 			array_push($wmsArray, $currentWms);
-
 			$options['visible'] = $multipleAssocArray['visible'] === "1" ?
 				true : false;
-
 			$options['zoom'] = $multipleAssocArray['zoom'] === "1" ?
 				true : false;
-
 			$wmcGetApi->mergeWmsArray($wmsArray, $options);
 			$wmsArray = array();
 			$multipleAssocArray = array();
-		}
-		else {
+		} else {
 			$currentWms = new wms();
 			if(is_numeric($key)) {
-				//get WMS by ID
+				// get WMS by ID
 				if (is_numeric($val)) {
 					$currentWms->createObjFromDBNoGui($val);
 				}
-				//get WMS by URL
+				// get WMS by URL
 				else if (is_string($val)) {
 					$currentWms->createObjFromXML($val);
 				}
@@ -299,7 +268,7 @@
 		$wmsArray = array();
 		$singleAssocArray = array();
 	}
-	//get WMS by URL
+	// get WMS by URL
 	elseif (array_key_exists('url', $singleAssocArray)) {
 		$currentWms = new wms();
 		$currentWms->createObjFromXML($singleAssocArray['url']);
@@ -317,21 +286,18 @@
 		$singleAssocArray = array();
 	}
 }
-//
-// LAYER
-//
-$e = new mb_notice("initWmcObj.php: check LAYER API");
+/*
+LAYER
+*/
+$e = new mb_notice("javascripts/initWmcObj.php: check LAYER API");
 $inputLayerArray = $getApi->getLayers();
 if ($inputLayerArray) {
 	foreach ($inputLayerArray as $input) {
-
-	// just make it work for a single layer id
+		// just make it work for a single layer id
 		$wmsFactory = new UniversalWmsFactory();
 		try {
 			if (isset($input["application"])) {
-				$wms = $wmsFactory->createLayerFromDb(
-					$input["id"], $input["application"]
-				);
+				$wms = $wmsFactory->createLayerFromDb($input["id"], $input["application"]);
 			}
 			else {
 				$wms = $wmsFactory->createLayerFromDb($input["id"]);
@@ -343,7 +309,6 @@
 				"id" => $input["id"]
 			);
 		}
-
 		if (is_a($wms, "wms")) {
 			$options = array();
 			if ($input["visible"]) {
@@ -355,7 +320,6 @@
 				$options["querylayer"] = $input["querylayer"];
 			}
 			$wmcGetApi->mergeWmsArray(array($wms), $options);
-
 			// do not use "zoom" attribute of mergeWmsArray,
 			// as this would zoom to the entre WMS.
 			// Here we set extent to the layer extent only.
@@ -374,14 +338,13 @@
 
 				}
 			}
-
 		}
 	}
 }
-//
-// FEATURETYPE
-//
-$e = new mb_notice("initWmcObj.php: check FEATURETYPE API");
+/*
+FEATURETYPE
+*/
+$e = new mb_notice("javascripts/initWmcObj.php: Check FEATURETYPE API");
 $inputFeaturetypeArray = $getApi->getFeaturetypes();
 if ($inputFeaturetypeArray) {
 	$wfsConfIds = array();
@@ -388,7 +351,6 @@
 	foreach ($inputFeaturetypeArray as $input) {
 		array_push($wfsConfIds, $input["id"]);
 	}
-
 	$wmcGetApi->generalExtensionArray['WFSCONFIDSTRING'] = implode(",", array_unique(array_merge(
 		$wmcGetApi->generalExtensionArray['WFSCONFIDSTRING'] ?
 		explode(",", $wmcGetApi->generalExtensionArray['WFSCONFIDSTRING']) :
@@ -396,33 +358,33 @@
 		$wfsConfIds
 	)));
 }
-//
-//GEORSS
-//
+/*
+GEORSS
+*/
 $inputGeoRSSArray = $getApi->getGeoRSSFeeds();
-$e = new mb_notice("initWmcObj.php: check GEORSS API");
+$e = new mb_notice("javascripts/initWmcObj.php: check GEORSS API");
 if($inputGeoRSSArray){
 	$wmc->generalExtensionArray['GEORSS'] = $inputGeoRSSArray;
 }
-//
-//KML
-//
+/*
+KML
+*/
 $inputKmlArray = $getApi->getKml();
 if($inputKmlArray){
 	$wmc->generalExtensionArray['KML'] = $inputKmlArray;
 }
-//
-//GEOJSON
-//
+/*
+GEOJSON
+*/
 $inputGeojsonArray = $getApi->getGeojson();
-//$e = new mb_exception("get parameter for geojson: ".$inputGeojsonArray[0]);
+//$e = new mb_exception("javascripts/initWmcObj.php: GET-parameter for geojson: ".$inputGeojsonArray[0]);
 $zoomToExtent = $getApi->getGeojsonZoom();
 $offset = $getApi->getGeojsonZoomOffset();
-//$e = new mb_exception("offset from initWmcObj: ".$offset);
+//$e = new mb_exception("javascripts/initWmcObj.php: offset from initWmcObj: ".$offset);
 /*if ($offset == false) {
-	$e = new mb_exception('no offset given');
+	$e = new mb_exception("javascripts/initWmcObj.php: no offset given");
 }*/
-//$e = new mb_exception("zoomToExtent from initWmcObj: ".$zoomToExtent);
+//$e = new mb_exception("javascripts/initWmcObj.php: zoomToExtent from initWmcObj: ".$zoomToExtent);
 if ($zoomToExtent == 'true') {
 	$minx = false;
 	$miny = false;
@@ -440,19 +402,19 @@
 	//$i = 0;
 	foreach ($inputGeojsonArray as $inputGeojson) {
 		//$e = new mb_exception($inputGeojson);
-		//load json files from distributed locations
-		//check if url directly geojson is given
+		// load json files from distributed locations
+		// check if url directly geojson is given
 		if ($admin->validateUrl(urldecode($inputGeojson))) {
-			$e = new mb_notice("GEOJSON parameter will be interpreted as url - try to resolve external json!");
-			//TODO: here there may exists firewall problems which cut the request part after the first ampersand!!!!
-			//$e = new mb_exception("found url ".urldecode($inputGeojson));
-			//$e = new mb_exception("found url unencoded ".$inputGeojson);
+			$e = new mb_notice("javascripts/initWmcObj.php: GEOJSON parameter will be interpreted as url - try to resolve external json!");
+			// TODO: here there may exists firewall problems which cut the request part after the first ampersand!!!!
+			//$e = new mb_exception("javascripts/initWmcObj.php: found url ".urldecode($inputGeojson));
+			//$e = new mb_exception("javascripts/initWmcObj.php: found url unencoded ".$inputGeojson);
 			$jsonFile = new connector($inputGeojson);
-			//$e = new mb_exception("GEOJSON: ".$jsonFile->file);
+			//$e = new mb_exception("javascripts/initWmcObj.php: GEOJSON: ".$jsonFile->file);
 			//$jsonFile = new connector("http://localhost/mb_trunk/geoportal/testpolygon.json");
 			$geojson = json_decode($jsonFile->file);
 		} else {
-			$e = new mb_notice("GEOJSON parameter will be interpreted as string!");
+			$e = new mb_notice("javascripts/initWmcObj.php: GEOJSON parameter will be interpreted as string!");
 			$geojson = json_decode(urldecode($inputGeojson));
 
 		}
@@ -471,15 +433,15 @@
 				$latitudes = array();
 				$longitudes = array();
 				foreach($kmls->{$geojsonTitle}->data->features as $feature) {
-					//TODO: ugly fix to read multipolygons - delete if multiobjects are supported somewhen! 
+					//TODO: Ugly fix to read multipolygons - delete if multiobjects are supported somewhen! 
 					if ($feature->geometry->type == 'MultiPolygon') {
 						$feature->geometry->type = "Polygon";
-						//read only the first polygon!!
+						// read only the first polygon!!
 						$feature->geometry->coordinates = $feature->geometry->coordinates[0];
 					}
 					switch ($feature->geometry->type) {
 						case "Polygon":
-							//$e = new mb_exception("Polygon found!");
+							//$e = new mb_exception("javascripts/initWmcObj.php: Polygon found!");
 							foreach ($feature->geometry->coordinates as $coordinates2) {
 								foreach ($coordinates2 as $coordinates1) {
 									$longitudes[] = $coordinates1[0];
@@ -488,12 +450,12 @@
 							}
 							break;
 						case "Point":
-							//$e = new mb_exception("Point found!");
+							//$e = new mb_exception("javascripts/initWmcObj.php: Point found!");
 							$longitudes[] = $feature->geometry->coordinates[0];
 							$latitudes[] = $feature->geometry->coordinates[1];
 							break;
 						case "LineString":
-							//$e = new mb_exception("LineString found!");
+							//$e = new mb_exception("javascripts/initWmcObj.php: LineString found!");
 							foreach ($feature->geometry->coordinates as $coordinates1) {
 								$longitudes[] = $coordinates1[0];
 								$latitudes[] = $coordinates1[1];
@@ -525,9 +487,9 @@
 			$maxx = $maxx + $offsetLon;
 			$maxy = $maxy + $offsetLat;
 		}
-		//overwrite extend from getApi
+		// overwrite extend from getApi
 		$bbox = new Mapbender_bbox($minx,$miny,$maxx,$maxy,"EPSG:4326");
-		//check for current epsg and transform if needed
+		// check for current epsg and transform if needed
 		if ($wmcGetApi->mainMap->getEpsg() !== "EPSG:4326") {
 			$bbox->transform($wmcGetApi->mainMap->getEpsg());
 		}
@@ -535,32 +497,34 @@
 	}
 	if ($geojson !== null && $geojson !== false) {
 		$wmcGetApi->generalExtensionArray['kmls'] = json_encode($kmls);
+//$e = new mb_exception("javascripts/initWmcObj.php: ".$wmcGetApi->generalExtensionArray['kmls']);
+//$e = new mb_exception("javascripts/initWmcObj.php: ".$wmcGetApi->generalExtensionArray['kmlOrder']);
 		$wmcGetApi->generalExtensionArray['kmlOrder'] = json_encode($kmlOrder);
 	}
 }
-//TODO test following
-//workaround to have a fully merged WMC for loading
+// TODO test following
+// workaround to have a fully merged WMC for loading
 $xml = $wmcGetApi->toXml();
-
+//$e = new mb_notice("javascripts/initWmcObj.php: WMC document after reading information from GET-API: ".$xml);
+//$e = new mb_notice("");
+//die();
 if ($removeUnaccessableLayers == true) {
-	//$e = new mb_exception("try to remove layers without permission while loading from session!");
+	$e = new mb_notice("javascripts/initWmcObj.php: Try to remove layers without permission while loading from session!");
 	$xml = $wmcGetApi->removeUnaccessableLayers($xml);
 }
-
-//$e = new mb_exception("initWmcObj.php: XML after merging json: ".$xml);
+//$e = new mb_notice("javascripts/initWmcObj.php: WMC document after removing unaccessable layers: ".$xml);
+//$e = new mb_notice("");
 $wmcGetApi = new wmc();
-//debug
-//$e = new mb_notice("initWmcObj.php: wmc after merging: ".$xml);
-//new Object with merged layers and other features
+// For debuggin purposes
+// New Object with merged layers and other features - why?? TODO test 
 $wmcGetApi->createFromXml($xml);	
-//
-// CONSTRAINTS
-//
+/*
+CONSTRAINTS
+*/
 $currentUser = new User();
 // remove all WMS with no permission
-$e = new mb_notice("initWmcObj.php: get wms without permission");
+$e = new mb_notice("javascripts/initWmcObj.php: get wms without permission");
 $deniedIdsArray = $wmcGetApi->getWmsWithoutPermission($currentUser);
-
 $deniedIdsTitles = array();
 $deniedIdsIndices = array();
 foreach ($deniedIdsArray as $i) {
@@ -573,18 +537,15 @@
 		$deniedIdsIndices[]= $i["index"];
 	}
 }
-
 $resultObj["noPermission"]["wms"] = array_merge(
 	$resultObj["noPermission"]["wms"],
 	$deniedIdsTitles
 );
-
-
-$e = new mb_notice("initWmcObj.php: list of wms without permission created");
+$e = new mb_notice("javascripts/initWmcObj.php: list of wms without permission created");
 $wmcGetApi->removeWms($deniedIdsIndices);
-$e = new mb_notice("initWmcObj.php: wms without permission removed from wmc");
+$e = new mb_notice("javascripts/initWmcObj.php: wms without permission removed from wmc");
 // find WMS without ID
-$e = new mb_notice("initWmcObj.php: find wms without id");
+$e = new mb_notice("javascripts/initWmcObj.php: find wms without id");
 $withoutIdsArray = $wmcGetApi->getWmsWithoutId();
 $withoutIdsTitles = array();
 foreach ($withoutIdsArray as $i) {
@@ -598,9 +559,9 @@
 	$resultObj["withoutId"]["wms"],
 	$withoutIdsTitles
 );
-$e = new mb_notice("initWmcObj.php: wms without id list generated");
+$e = new mb_notice("javascripts/initWmcObj.php: wms without id list generated");
 // find orphaned WMS
-$e = new mb_notice("initWmcObj.php: find invalid wms");
+$e = new mb_notice("javascripts/initWmcObj.php: find invalid wms");
 $invalidIdsArray = $wmcGetApi->getInvalidWms();
 $invalidIdsTitles = array();
 foreach ($invalidIdsArray as $i) {
@@ -614,9 +575,9 @@
 	$resultObj["invalidId"]["wms"],
 	$invalidIdsTitles
 );
-$e = new mb_notice("initWmcObj.php: invalid wms list generated");
+$e = new mb_notice("javascripts/initWmcObj.php: invalid wms list generated");
 // find potentially unavailable WMS
-$e = new mb_notice("initWmcObj.php: find problematic wms");
+$e = new mb_notice("javascripts/initWmcObj.php: find problematic wms");
 $unavailableIdsArray = $wmcGetApi->getUnavailableWms($currentUser);
 $unavailableIdsTitles = array();
 foreach ($unavailableIdsArray as $i) {
@@ -630,9 +591,9 @@
 	$resultObj["unavailable"]["wms"],
 	$unavailableIdsTitles
 );
-$e = new mb_notice("initWmcObj.php: problematic wms list generated");
-//get terms of use from wms objects which are in the remaining wmc and are not already accepted for this session
-$e = new mb_notice("initWmcObj.php: collect known tou");
+$e = new mb_notice("javascripts/initWmcObj.php: problematic wms list generated");
+// get terms of use from wms objects which are in the remaining wmc and are not already accepted for this session
+$e = new mb_notice("javascripts/initWmcObj.php: collect known tou");
 $validWMS = $wmcGetApi->getValidWms();
 $translation['wms'] = _mb("MapService");
 $resourceSymbol = "<img src='../img/osgeo_graphics/geosilk/server_map.png' alt='".$translation['wms']." - picture' title='".$translation['wms']."'>";
@@ -643,7 +604,7 @@
 $countWMS = count($validWMS);
 for ($i = 0; $i < $countWMS; $i++) {
 	$WMS = $validWMS[$countWMS - ($i+1)];
-	//check if tou has already been read - if not show them in the message
+	// check if tou has already been read - if not show them in the message
 	$resultOfCheck = $classTou->check('wms',$WMS['id']);
 	if ($resultOfCheck['accepted'] == 0) {
 		$touHeader = $resourceSymbol." <a href='../php/mod_showMetadata.php?resource=wms&layout=tabs&id=".$WMS['id']."&languageCode=".$languageCode."' target='_blank'>".$WMS['title']."</a><br>";
@@ -654,11 +615,11 @@
 		$constraints->type = "wms";
 		$constraints->returnDirect = false;
 		$touForWMS = $constraints->getDisclaimer();
-		//add only those who have no special tou defined -
+		// add only those who have no special tou defined
 		if ($touForWMS != 'free'){
 			$tou .= $touHeader.$touForWMS;
 		}
-		//set the tou to be accepted - TODO maybe do this after the button which deletes the message window - from a ajax request.
+		// set the tou to be accepted - TODO maybe do this after the button which deletes the message window - from a ajax request.
 		$classTou->set('wms',$WMS['id']);
 	}
 }
@@ -667,11 +628,11 @@
 }
 $resultObj["wmcTou"]["message"] = $tou;
 $e = new mb_notice("initWmcObj.php: collect known tou done!");
-//
-// Output
-//
-// Check if session WMC module is loaded - TODO maybe do this before the other things are done!!!
-$e = new mb_notice("initWmcObj.php: check if disclaimer should be set");
+/*
+Output
+Check if session WMC module is loaded - TODO maybe do this before the other things are done!!!
+*/
+$e = new mb_notice("javascripts/initWmcObj.php: check if disclaimer should be set");
 $sql = "SELECT COUNT(e_id) AS i FROM gui_element WHERE fkey_gui_id = $1 AND e_id = $2";
 $v = array(Mapbender::session()->get("mb_user_gui"), "sessionWmc");
 $t = array("s", "s");
@@ -678,12 +639,12 @@
 $res = db_prep_query($sql, $v, $t);
 $row = db_fetch_assoc($res);
 $isSessionWmcModuleLoaded = intval($row["i"]);
-$e = new mb_notice("initWmcObj.php: check for disclaimer done");
-//
-//GML in session
-//
-// check if Session contains a GML, and then zoom to it
-$e = new mb_notice("initWmcObj.php: check session for GML to zoom");
+$e = new mb_notice("javascripts/initWmcObj.php: check for disclaimer done");
+/*
+GML in session
+check if Session contains a GML, and then zoom to it
+*/
+$e = new mb_notice("javascripts/initWmcObj.php: check session for GML to zoom");
 $gml_string = Mapbender::session()->get("GML");
 if($gml_string){
 	$gml = new gml2();
@@ -696,17 +657,17 @@
 	$epsg = "EPSG:".$gml->epsg);
 	$wmcGetApi->mainMap->setExtent($bbox);
 } else {
-	$e = new mb_notice("initWmcObj.php: no GML found in session!");
+	$e = new mb_notice("javascripts/initWmcObj.php: no GML found in session!");
 }
-$e = new mb_notice("initWmcObj.php: session GML zoom done");
-//overwrite extent of wmc with information from GetApi if given
-$e = new mb_notice("initWmcObj.php: check ZOOM API");
+$e = new mb_notice("javascripts/initWmcObj.php: session GML zoom done");
+// overwrite extent of wmc with information from GetApi if given
+$e = new mb_notice("javascripts/initWmcObj.php: check ZOOM API");
 $zoom = $getApi->getZoom();
 if(is_array($zoom)) {
-    $e = new mb_notice("initWmcObj.php: check ZOOM API: ".implode(',',$zoom));
+    $e = new mb_notice("javascripts/initWmcObj.php: check ZOOM API: ".implode(',', $zoom));
 }
 if (count($zoom) == 4 || count($zoom) == 5) {
-	$e = new mb_notice("initWmcObject.php: found EXTENT");
+	$e = new mb_notice("javascripts/initWmcObject.php: found EXTENT");
 	if (count($zoom) == 5){
 		$bbox = new Mapbender_bbox(
 			$zoom[0],
@@ -715,9 +676,9 @@
 			$zoom[3],
 			$epsg = $zoom[4]);
 	} else {
-		//get current epsg from wmc bounding box
-		//ViewContext->General->BoundingBox->SRS
-		//$e = new mb_notice("initWmcObject.php: SRS found in current WMC: ".$wmcGetApi->mainMap->getEpsg());
+		// get current epsg from wmc bounding box
+		// ViewContext->General->BoundingBox->SRS
+		$e = new mb_notice("javascripts/initWmcObject.php: SRS found in current WMC: ".$wmcGetApi->mainMap->getEpsg());
 		$bbox = new Mapbender_bbox(
 			$zoom[0],
 			$zoom[1],
@@ -727,7 +688,7 @@
 	}
 	$wmcGetApi->mainMap->setExtent($bbox);
 }
-//check if something have to be shown in disclaimer
+// check if something have to be shown in disclaimer
 if (
 	count($resultObj["withoutId"]["wms"]) === 0 &&
 	count($resultObj["invalidId"]["wms"]) === 0 &&
@@ -736,7 +697,6 @@
 ) {
 	//put them into the session to pull them later on
 	Mapbender::session()->set("wmcConstraints", $resultObj);
-
 //*******************************************************
 	//Alternate approach: create map object from xml:
 	//$e = new mb_notice("initWmcObj.php: build alternate js!");
@@ -751,9 +711,9 @@
 	//$e = new mb_notice("initWmcObj.php: alternate js build successfully!");
 //*******************************************************
 	$output = $wmcGetApi->wmsToJavaScript();
-	//$e = new mb_exception("javascripts/initWmcObj.php: javascript mapset: ".implode(",",$output));
+	// $e = new mb_notice("javascripts/initWmcObj.php: javascript mapset: ".implode(",",$output));
 	$wmcJs = $wmcGetApi->toJavaScript(array());//old way - why give an empty array?
-	$wmcJs = implode(";\n",$wmcJs);
+	$wmcJs = implode(";\n", $wmcJs);
 	$extentJs = $wmcGetApi->extentToJavaScript();
 	$output[] = <<<JS
 		Mapbender.events.afterInit.register(function () {
@@ -798,7 +758,7 @@
 JS;
 }
 $outputString .= $wmcFeaturetypeStr;
-//GeoRSS
+// GeoRSS
 $GeoRSSStr = " Mapbender.events.afterInit.register(function () {";
 foreach($inputGeoRSSArray as $inputGeoRSSUrl){
 	$GeoRSSStr .= 'try {$("#mapframe1").georss({url: "'.$inputGeoRSSUrl .'"})} catch(e) {new Mb_warning("GeoRSS module not loaded")}';
@@ -805,7 +765,7 @@
 }
 $GeoRSSStr .="}); ";
 $outputString .= $GeoRSSStr;
-//KML
+// KML
 $KmlStr = " Mapbender.events.afterInit.register(function () {";
 foreach($inputKmlArray as $inputKmlUrl){
 	$KmlStr .= 'try {$("#mapframe1").kml({url: "'.$inputKmlUrl .'"})} catch(e) {new Mb_warning("KML module not loaded")}';
@@ -812,13 +772,11 @@
 }
 $KmlStr .="}); ";
 $outputString .= $KmlStr;
-
 echo $outputString;
-
-//logit($outputString,"javascript_old.store","w");
+// logit($outputString,"javascript_old.store","w");
 Mapbender::session()->delete("addwms_showWMS");
 Mapbender::session()->delete("addwms_zoomToExtent");
 unset($output);
 unset($wmc);
-$e = new mb_notice("initWmcObj.php: done all!");
+$e = new mb_notice("javascripts/initWmcObj.php: All done!");
 ?>

Modified: trunk/mapbender/http/javascripts/wms.js
===================================================================
--- trunk/mapbender/http/javascripts/wms.js	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/javascripts/wms.js	2019-04-11 14:32:00 UTC (rev 10100)
@@ -280,7 +280,7 @@
 	}
 	rq += "&";
 	var currentWms = this;
-	//TODO 2016 arminadd optional dimension parameters
+	//TODO 2016 armin add optional dimension parameters
 	if (this.gui_wms_dimension_time !== false && this.gui_wms_dimension_time !== "") {
 		rq += "TIME="+encodeURIComponent(this.gui_wms_dimension_time)+"&";
 	}
@@ -799,7 +799,8 @@
 	gui_layer_maxscale,
 	gui_layer_wfs_featuretype,
 	gui_layer_title,
-	gui_layer_dataurl_href){
+	gui_layer_dataurl_href,
+        layer_featuretype_coupling ){
                       
 	wms[wms.length-1].objLayer[wms[wms.length-1].objLayer.length] = new wms_layer(
 		layer_parent,
@@ -823,7 +824,8 @@
 		parseInt(gui_layer_maxscale, 10),
 		gui_layer_wfs_featuretype,
 		gui_layer_title,
-		gui_layer_dataurl_href );
+		gui_layer_dataurl_href,
+		layer_featuretype_coupling );
 	var parentLayer = wms[wms.length-1].getLayerByLayerPos(parseInt(layer_parent, 10));
 	if(parentLayer) {
 		parentLayer.has_childs = true;
@@ -879,7 +881,8 @@
 	gui_layer_maxscale,
 	gui_layer_wfs_featuretype,
 	gui_layer_title,
-	gui_layer_dataurl_href){
+	gui_layer_dataurl_href,
+	layer_featuretype_coupling){
 	this.layer_id = wms_layer_count;
 	this.layer_uid = wms_layer_uid;
 	this.layer_parent = layer_parent;
@@ -905,6 +908,7 @@
 	this.gui_layer_style = gui_layer_style;
 	this.gui_layer_wfs_featuretype = gui_layer_wfs_featuretype;
 	this.gui_layer_dataurl_href = gui_layer_dataurl_href;
+	this.layer_featuretype_coupling = layer_featuretype_coupling;
 	this.has_childs = false;
 	this.layer_style = [];
 	this.layer_dimension = [];

Modified: trunk/mapbender/http/php/mod_GetPublishedData.php
===================================================================
--- trunk/mapbender/http/php/mod_GetPublishedData.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/php/mod_GetPublishedData.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -31,21 +31,45 @@
 }
 //validate wmc_id
 if (isset($_REQUEST["wmc_id"]) & $_REQUEST["wmc_id"] != "") {
-        $testMatch = $_REQUEST["wmc_id"];
-        $pattern = '/^[0-9]*$/';  
-        if (!preg_match($pattern,$testMatch)){
-                echo 'Parameter <b>wmc_id</b> is not valid (integer).<br/>';
-                die();
-        }
-        $wmc_serial_id = $testMatch;
-        $testMatch = NULL;
+	//validate to csv integer list
+	$testMatch = $_REQUEST["wmc_id"];
+	if ($testMatch == "current") {
+	} else { 
+		$pattern = '/^[0-9_]*$/';
+		if (!preg_match($pattern,$testMatch)){ 
+			echo 'Parameter <b>wmc_id</b> is not valid - no csv integer list!.<br/>'; 
+			die(); 		
+		}
+	}
+	$wmc_id = $testMatch;
+	$wmc_serial_id = $wmc_id;
+	$testMatch = NULL;
+} else {
+	echo "Mandatory parameter <b>wmc_id</b> is not set or empty!";
+	die();
 }
+
 //$e = new mb_exception("php/mod_GetPublishedData.php: outputFormat: ".$outputFormat);
 //create a WMC object from a WMC in the database
-$xml = wmc::getDocumentWithPublicData($wmc_serial_id);
-$myWmc = new wmc();
-$myWmc->createFromXml($xml);
 
+if ($wmc_id !== "current") {
+	$xml = wmc::getDocumentWithPublicData($wmc_serial_id);
+	$myWmc = new wmc();
+	$myWmc->createFromXml($xml);
+} else {
+	//read wmc from session if available and fill the needed fields from wmc object
+	$wmcDocSession = false;
+	//check if wmc filename is in session - TODO only if should be loaded from session not else! (Module loadWMC)
+	if(Mapbender::session()->get("mb_wmc")) {
+   	    $wmc_filename = Mapbender::session()->get("mb_wmc");
+    	    //$time_start = microtime();
+    	    //load it from whereever it has been stored
+    	    $wmcDocSession = $admin->getFromStorage($wmc_filename, TMP_WMC_SAVE_STORAGE);
+	    $myWmc->createFromXml($wmcDocSession);
+	} else {
+	    $e = new mb_exception("php/mod_GetPublishedData.php: no wmc found in session!");
+	}
+}
 //  Decode from JSON to array
 foreach ($myWmc->generalExtensionArray as $key => &$value) {
     $value = json_decode($value, true);

Modified: trunk/mapbender/http/php/mod_exportWmc2Json.php
===================================================================
--- trunk/mapbender/http/php/mod_exportWmc2Json.php	2019-04-11 13:07:10 UTC (rev 10099)
+++ trunk/mapbender/http/php/mod_exportWmc2Json.php	2019-04-11 14:32:00 UTC (rev 10100)
@@ -42,10 +42,13 @@
 if (isset($_REQUEST["wmc_id"]) & $_REQUEST["wmc_id"] != "") {
 	//validate to csv integer list
 	$testMatch = $_REQUEST["wmc_id"];
-	$pattern = '/^[0-9_]*$/';
-	if (!preg_match($pattern,$testMatch)){ 
-		echo 'Parameter <b>wmc_id</b> is not valid - no csv integer list!.<br/>'; 
-		die(); 		
+	if ($testMatch == "current") {
+	} else { 
+		$pattern = '/^[0-9_]*$/';
+		if (!preg_match($pattern,$testMatch)){ 
+			echo 'Parameter <b>wmc_id</b> is not valid - no csv integer list!.<br/>'; 
+			die(); 		
+		}
 	}
 	$wmc_id = $testMatch;
 	$testMatch = NULL;
@@ -191,18 +194,75 @@
 	{"wmc":{"id":"6","title":"Testwmc","bbox":"","timeStamp":"123123123"},"layerList":[{"internal":true,"currentFormat":"image/png","id":31452,"opacity":50},{"internal":"false","currentFormat":"image/jpeg","getMapUrl":"","layerTitle":"","layerName":"","layerAbstract":"","layerBbox":"","opacity":"50"}]}
 	*/
 	//geometryfromtext(((((((((((((((((((('POLYGON(('::text || layer_epsg.minx::text) || ' '::text) || layer_epsg.miny::text) || ','::text) || layer_epsg.minx::text) || ' '::text) || layer_epsg.maxy::text) || ','::text) || layer_epsg.maxx::text) || ' '::text) || layer_epsg.maxy::text) || ','::text) || layer_epsg.maxx::text) || ' '::text) || layer_epsg.miny::text) || ','::text) || layer_epsg.minx::text) || ' '::text) || layer_epsg.miny::text) || '))'::text, 4326) AS the_geom, (((((layer_epsg.minx::text || ','::text) || layer_epsg.miny::text) || ','::text) || layer_epsg.maxx::text) || ','::text) || layer_epsg.maxy::text AS bbox
+	if ($wmcId !== "current") {
+$e = new mb_exception("wmc_id: ".$wmcId);
+		$sql = "SELECT wmc_title, wmc_serial_id, wmc, wmc_timestamp, abstract, srs, minx, miny, maxx, maxy, srs, wmc_has_local_data, wmc_local_data_public from mb_user_wmc WHERE wmc_serial_id = $1;";
+		$v = array($wmcId);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$row = db_fetch_assoc($res);
+		$typeOfSerialId = gettype($row['wmc_serial_id']);
+		if ($typeOfSerialId == "NULL") {
+			echo "No WebMapContext document with id ".$wmcId." found in mapbender database!";
+			die();
+		}
+	} else {
+		//read wmc from session if available and fill the needed fields from wmc object
+		$wmcDocSession = false;
+		//check if wmc filename is in session - TODO only if should be loaded from session not else! (Module loadWMC)
+$e = new mb_exception("user name from session: ".Mapbender::session()->get("mb_user_name"));
+		if(Mapbender::session()->get("mb_wmc")) {
+    		    $wmc_filename = Mapbender::session()->get("mb_wmc");
+$e = new mb_exception("filename: ".$wmc_filename);
+    		    //$time_start = microtime();
+    		    //load it from whereever it has been stored
+    		    $wmcDocSession = $admin->getFromStorage($wmc_filename, TMP_WMC_SAVE_STORAGE);
+		    $myWmc->createFromXml($wmcDocSession);
+    		    //$row['minx'],$row['miny'],$row['maxx'],$row['maxy'],$row['srs'],$row['wmc_serial_id'],$row['wmc_title'],$row['wmc_timestamp'],$row['wmc_local_data_public'],$row['wmc_has_local_data'],$row['wmc'];
+//$e = new mb_exception(json_encode($myWmc->mainMap));
+	//parse wmc
+	$xmlWmc = simplexml_load_string($wmcDocSession, "SimpleXMLElement", LIBXML_NOBLANKS);
+//$e = new mb_exception($wmcDocSession);
+$test = $xmlWmc->General->BoundingBox[0]['SRS'];
+$e = new mb_exception($test);
+	//initialize layer
+	$layerCount = 0;
+	//for ($i=0; $i<count($layerArray); $i++) {
+	for ($i=count($layerArray)-1; $i>=0; $i--) {
+		$mbExtensions = $layerArray[$i]->Extension->children('http://www.mapbender.org/context');
+}
 
-	$sql = "SELECT wmc_title, wmc_serial_id, wmc, wmc_timestamp, abstract, srs, minx, miny, maxx, maxy, srs, wmc_has_local_data, wmc_local_data_public from mb_user_wmc WHERE wmc_serial_id = $1;";
-		
-	$v = array($wmcId);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$row = db_fetch_assoc($res);
-	$typeOfSerialId = gettype($row['wmc_serial_id']);
-	if ($typeOfSerialId == "NULL") {
-		echo "No WebMapContext document with id ".$wmcId." found in mapbender database!";
-		die();
+$row['minx'] = $xmlWmc->General->BoundingBox[0]['minx'];
+$row['miny'] = $xmlWmc->General->BoundingBox[0]['miny'];
+$row['maxx'] = $xmlWmc->General->BoundingBox[0]['maxx'];
+$row['maxy'] = $xmlWmc->General->BoundingBox[0]['maxy'];
+$row['srs'] = $xmlWmc->General->BoundingBox[0]['SRS'];
+$row['wmc_serial_id'] = '0';
+$row['wmc_title'] = $myWmc->wmc_title;
+$row['wmc_timestamp'] = time();
+//check local data:
+//  Decode from JSON to array
+foreach ($myWmc->generalExtensionArray as $key => &$value) {
+    $value = json_decode($value, true);
+}
+// create and numerically indexed array
+$kmls = array_values($myWmc->generalExtensionArray["KMLS"]);
+if (count($kmls) > 0) {
+	$row['wmc_has_local_data'] = 1;
+} else {
+	$row['wmc_has_local_data'] = 0;
+}
+//$row['wmc_local_data_public'] = 1;
+$row['wmc_local_data_public'] = '1'; //check! - 
+$row['wmc'] = $wmcDocSession;
+
+
+		    //
+		} else {
+		    $e = new mb_exception("php/mod_exportWmc2Json.php: no wmc found in session!");
+		}
 	}
+	
 	//transform coords if needed
 	//crs for client
 	$requestedEPSG = preg_replace("/EPSG:/","", $crs);



More information about the Mapbender_commits mailing list