[Mapbender-commits] r4595 - in trunk/mapbender: http/classes http/javascripts http/php lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Sep 3 10:10:46 EDT 2009


Author: christoph
Date: 2009-09-03 10:10:46 -0400 (Thu, 03 Sep 2009)
New Revision: 4595

Added:
   trunk/mapbender/http/php/mod_wmc2ol.php
   trunk/mapbender/http/php/wms.php
Modified:
   trunk/mapbender/http/classes/class_map.php
   trunk/mapbender/http/javascripts/mod_coordsLookup.js
   trunk/mapbender/http/javascripts/mod_loadwmc.js
   trunk/mapbender/lib/basic.js
Log:


Modified: trunk/mapbender/http/classes/class_map.php
===================================================================
--- trunk/mapbender/http/classes/class_map.php	2009-09-03 14:09:38 UTC (rev 4594)
+++ trunk/mapbender/http/classes/class_map.php	2009-09-03 14:10:46 UTC (rev 4595)
@@ -362,11 +362,10 @@
 	 * @param $jsMapObject Object
 	 */
 	public function createFromJs ($jsMapObject) {
-		$arrayBBox = explode(",", $jsMapObject->extent);
-		$minx = floatval($arrayBBox[0]);
-		$miny = floatval($arrayBBox[1]);
-		$maxx = floatval($arrayBBox[2]);
-		$maxy = floatval($arrayBBox[3]);
+		$minx = $jsMapObject->extent->min->x;
+		$miny = $jsMapObject->extent->min->y;
+		$maxx = $jsMapObject->extent->max->x;
+		$maxy = $jsMapObject->extent->max->y;
 		$srs = $jsMapObject->epsg;
 		$bbox = new Mapbender_bbox($minx, $miny, $maxx, $maxy, $srs);
 

Modified: trunk/mapbender/http/javascripts/mod_coordsLookup.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_coordsLookup.js	2009-09-03 14:09:38 UTC (rev 4594)
+++ trunk/mapbender/http/javascripts/mod_coordsLookup.js	2009-09-03 14:10:46 UTC (rev 4595)
@@ -15,8 +15,8 @@
  * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, 
  * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, 
  * > e_mb_mod, e_target, e_requires, e_url) VALUES ('<app_id>','coordsLookup',
- * > 10,1,'','','div','','',1000,0,NULL ,NULL ,NULL ,
- * > 'border:1px solid red;z-index:9999;','','div','mod_coordsLookup.js','',
+ * > 10,1,'','Coordinate lookup','div','','',1000,0,NULL ,NULL ,NULL ,
+ * > 'z-index:9999;','','div','mod_coordsLookup.js','',
  * > 'mapframe1','','');
  * >
  * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, 

Modified: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js	2009-09-03 14:09:38 UTC (rev 4594)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js	2009-09-03 14:10:46 UTC (rev 4595)
@@ -13,6 +13,7 @@
 }
 var wmcPopup = null;
 var wmcDisplayPopup = null;
+var wmcOpenlayersPopup = null;
 
 var serverSideFileName = "../php/mod_loadwmc_server.php";
 
@@ -92,7 +93,7 @@
 			// 
 			// Load WMC
 			//
-			$loadWmc = $("<img src='../img/button_gray/wmc_load.png' title='load this WMC'>");
+			var $loadWmc = $("<img src='../img/button_gray/wmc_load.png' title='load this WMC'>");
 			$loadWmc.click(function() {
 				var queryObj = {command:"loadWmc", parameters:{id:currentId}};
 				$.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
@@ -131,7 +132,7 @@
 			// 
 			// Merge WMC
 			//
-			$mergeWmc = $("<img src='../img/button_gray/wmc_merge.png' title='merge WMC'>");
+			var $mergeWmc = $("<img src='../img/button_gray/wmc_merge.png' title='merge WMC'>");
 			$mergeWmc.click(function() {
 				var	extensionDataString = null;
 				if (currentWmcExtensionData !== null) {
@@ -181,7 +182,7 @@
 			// 
 			// Append WMC
 			//
-			$appendWmc = $("<img src='../img/button_gray/wmc_append.png' title='append WMC'>");
+			var $appendWmc = $("<img src='../img/button_gray/wmc_append.png' title='append WMC'>");
 			$appendWmc.click(function() {
 				var	extensionDataString = null;
 				if (currentWmcExtensionData !== null) {
@@ -231,7 +232,7 @@
 			// 
 			// Display WMC
 			//
-			$displayWmc = $("<img src='../img/button_gray/wmc_xml.png' title='display WMC XML'>");
+			var $displayWmc = $("<img src='../img/button_gray/wmc_xml.png' title='display WMC XML'>");
 			$displayWmc.click(function() {
 				// create Popup
 				if (wmcDisplayPopup === null) {
@@ -246,7 +247,7 @@
 				}
 				// set correct URL
 				if (wmcDisplayPopup.isVisible()) {
-					wmcDisplayPopup.setUrl("../javascripts/mod_displayWmc.php?wmc_id=" + currentId);
+					wmcDisplayPopup.setUrl("../javascripts/mod_displayWmc.php?wmc_id=" + currentId + "&" + mb_session_name + "=" + mb_nr);
 				}
 				// display the pop up
 				wmcDisplayPopup.show();
@@ -254,7 +255,36 @@
 			$td = $("<td></td>").append($displayWmc);
 			$tr.append($td);				
 
-			$deleteWmc = $("<img src='../img/button_gray/del.png' title='delete this WMC'>");
+			//
+			// OpenLayers Export
+			//
+			var imgHtml = "<img src='../img/OpenLayers.trac.png' " + 
+				"title='export to OpenLayers' border=0>";
+			var $openlayersWmc = $(imgHtml);
+			$openlayersWmc.click(function () {
+				// create Popup
+				if (wmcOpenlayersPopup === null) {
+					wmcOpenlayersPopup = new mb_popup({
+						title:"WMC Document",
+						width:600,
+						height:500,
+						top:100,
+						left:300,
+						url:"../php/mod_wmc2ol.php?wmc_id=" + currentId + 
+							"&" + mb_session_name + "=" + mb_nr
+					});
+				}
+				// set correct URL
+				if (wmcOpenlayersPopup.isVisible()) {
+					wmcOpenlayersPopup.setUrl("../php/mod_wmc2ol.php?wmc_id=" + currentId + "&" + mb_session_name + "=" + mb_nr);
+				}
+				// display the pop up
+				wmcOpenlayersPopup.show();
+			});
+			$td = $("<td></td>").append($openlayersWmc);
+			$tr.append($td);
+
+			var $deleteWmc = $("<img src='../img/button_gray/del.png' title='delete this WMC'>");
 			$deleteWmc.click(function() {
 				var queryObj = {command:"deleteWmc", parameters:{id:currentId}};
 				$.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
@@ -277,6 +307,7 @@
 			});
 			$td = $("<td></td>").append($deleteWmc);
 			$tr.append($td);
+			
 
 			$tr.fadeIn("slow");
 		}());

Added: trunk/mapbender/http/php/mod_wmc2ol.php
===================================================================
--- trunk/mapbender/http/php/mod_wmc2ol.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_wmc2ol.php	2009-09-03 14:10:46 UTC (rev 4595)
@@ -0,0 +1,438 @@
+<?php
+# 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.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+
+$userId = Mapbender::session()->get("mb_user_id");
+
+
+//check for parameter wmc_id
+if (!isset($_GET["wmc_id"])) {
+	echo 'Error: wmc_id not requested<br>';
+	die;
+	//must leave script
+}
+
+function _e ($str) {
+	return htmlentities($str, ENT_QUOTES, CHARSET);
+}
+
+//the next functions should come from class administration, but they are not included as they are needed
+//TODO
+function getLayerPermission($wms_id, $layer_id, $user_id){
+	//$layer_id = $this->getLayerIdByLayerName($wms_id,$layer_name);
+	$array_guis = getGuisByPermission($user_id,true);
+	$v = array();
+	$t = array();
+	$sql = "SELECT * FROM gui_layer WHERE fkey_gui_id IN (";
+	$c = 1;
+	//generate guilist assigned to specific user
+	for($i=0; $i<count($array_guis); $i++){
+		if($i>0){ $sql .= ",";}
+		$sql .= "$".$c;
+		$c++;
+		array_push($v, $array_guis[$i]);
+		array_push($t, 's');
+	}
+	$sql .= ") AND fkey_layer_id = $".$c." AND gui_layer_status = 1"; //status 1 must be
+	array_push($v,$layer_id);
+	array_push($t,'i');
+	$res = db_prep_query($sql,$v,$t);
+	if($row = db_fetch_array($res)){
+		return true;
+	}
+	else{
+		return false;
+	}
+}
+
+function getGuisByPermission($mb_user_id,$ignoreublic){
+	$arrayGuis = array();
+	$mb_user_groups = array();
+	$sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
+	$v = array($mb_user_id);
+	$t = array("i");
+	$res_groups = db_prep_query($sql_groups,$v,$t);
+	$cnt_groups = 0;
+	while($row = db_fetch_array($res_groups)){
+		$mb_user_groups[$cnt_groups] = $row["fkey_mb_group_id"];
+		$cnt_groups++;
+	}
+	if($cnt_groups > 0){
+		$v = array();
+		$t = array();
+		$sql_g = "SELECT gui.gui_id FROM gui JOIN gui_mb_group ";
+		$sql_g .= " ON gui.gui_id = gui_mb_group.fkey_gui_id WHERE gui_mb_group.fkey_mb_group_id IN (";
+		for($i=0; $i<count($mb_user_groups);$i++){
+			if($i > 0){$sql_g .= ",";}
+			$sql_g .= "$".strval($i+1);
+			array_push($v,$mb_user_groups[$i]);
+			array_push($t,"i");
+		}
+		$sql_g .= ") GROUP BY gui.gui_id";
+		$res_g = db_prep_query($sql_g,$v,$t);
+		while($row = db_fetch_array($res_g)){
+			array_push($arrayGuis,$row["gui_id"]);
+		}
+	}
+	$sql_guis = "SELECT gui.gui_id FROM gui JOIN gui_mb_user ON gui.gui_id = gui_mb_user.fkey_gui_id";
+	$sql_guis .= " WHERE (gui_mb_user.fkey_mb_user_id = $1) ";
+	if (!isset($ignore_public) OR $ignore_public== false){
+		$sql_guis .= " AND gui.gui_public = 1 ";
+	}
+	$sql_guis .= " GROUP BY gui.gui_id";
+	$v = array($mb_user_id);
+	$t = array("i");
+	$res_guis = db_prep_query($sql_guis,$v,$t);
+	$guis = array();
+	while($row = db_fetch_array($res_guis)){
+		if(!in_array($row['gui_id'],$arrayGuis)){
+			array_push($arrayGuis,$row["gui_id"]);
+		}
+	}
+	return $arrayGuis;
+}
+//end of functions which m,ay be included from class_administration in next versions
+#**************************************************************************
+
+//Function to create an OpenLayers Javascript from a mapbender wmc document
+function createOlFromWMC_id($wmc_id){
+	//Get WMC out of mb Database
+	$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = '" . $wmc_id . "'";
+	$res = db_query($sql);
+	$wmc = db_fetch_row($res);
+	//Read out WMC into XML object
+	$xml=simplexml_load_string($wmc[0]);
+	//generate general html data
+	$html='';
+	$html.="<html xmlns='http://www.w3.org/1999/xhtml'>\n";
+	$html.="<head>\n";
+	//define global variables for extent out of WMC File
+	$windowWidth=$xml->General->Window->attributes()->width;
+	$windowHeight=$xml->General->Window->attributes()->height;
+	$htmlWidth=$windowWidth+40;
+	$htmlHeight=$windowHeight+70;
+	//define CSS 
+   	$html.="<style type='text/css'>\n";
+        $html.=" #map {\n";
+        	$html.="width: ".$windowWidth."px;\n";
+        	$html.="height: ".$windowHeight."px;\n";
+        	$html.="border: 1px solid black;\n";
+		$html.="overflow:visible;\n";
+        $html.="}\n";
+	$html.=" #srs {\n";
+	        $html.="font-size: 80%;\n";
+	        $html.="color: #444;\n";
+	        $html.="}\n";
+	$html.=" #showpos {\n";
+	        $html.="font-size: 80%;\n";
+	        $html.="color: #444;\n";
+	        $html.="}\n";
+	$html.="</style>\n";
+	//Generate Title
+	$html.="<title>".$xml->General->Title."</title>\n";
+	//include OL libs from local source - must be minimized
+	$html.="<script src='../extensions/OpenLayers-2.8/OpenLayers.js'></script>\n";
+	$html.="<script type='text/javascript'>\n";
+	//check for queryable layers
+	$layer_array_queryable=array();
+	$layer_array=$xml->LayerList->Layer;
+	$html.="var map;\n";
+	$someLayerQueryable=false;
+	for ($i=0; $i<count($layer_array); $i++) {
+		$html.="var layer".$i.";\n";
+		$mb_extensions=$xml->LayerList->Layer[$i]->Extension->children('http://www.mapbender.org');
+		$layer_array_queryable[$i]=$mb_extensions->querylayer;
+		if (($layer_array_queryable[$i]=='1') and ($xml->LayerList->Layer[$i]->attributes()->hidden=='0')){
+			$someLayerQueryable=true;
+		}	
+	}
+	//define special BBOX
+	$out_box=0.3;
+	//get min/max extents for olbox
+	$minx = $xml->General->BoundingBox->attributes()->minx;
+	$miny = $xml->General->BoundingBox['miny'];
+	$maxx = $xml->General->BoundingBox['maxx'];
+	$maxy = $xml->General->BoundingBox['maxy'];
+	$centralx=floor(($maxx+$minx)/2);
+	$centraly=floor(($maxy+$miny)/2);
+	$dx=$maxx-$minx;//in meters
+	$dy=$maxy-$miny;//in meters
+	//define zoom levels
+	$numberZoomLevels=20;
+	//define central position in projected system
+	$html.="var lat = $centralx;\n"; 
+       	$html.="var lon = $centraly;\n";
+	$centralPointx=($maxx+$minx)/2;
+	$centralPointy=($maxy+$miny)/2;
+	//startzoom faktor - check if usefull
+     	$html.="var zoom = 10;\n";
+	//start function for initialize client
+	$html.="function init(){\n";
+	//define ol map object	
+	$html.="map = new OpenLayers.Map( 'map' );\n";
+	$html.=" var markers;\n";
+	//define options for ol map object	
+	$html.="var options = {\n";
+        	$html.=" projection: \"".$xml->General->BoundingBox['SRS']."\",\n";
+		if ($xml->General->BoundingBox['SRS']=='EPSG:4326'){
+			echo 'Please choose an other coordinatereferencesystem. Converting Scales to Geographic Coordinates is not yet implemented!';
+			return; 
+		}
+		$html.=" units: \"m\",\n";
+		$html.="numZoomLevels: ".$numberZoomLevels.",\n";
+		$html.="minResolution: 0.01\n";
+	$html.="};\n";
+	//New for given GET Params mb_myBBOX and mb_myBBOXEpsg******************************************
+	//Before defining the bounds check if mb_myBBOX and mb_myBBOXEpsg are defined.
+	//Check for given mb_myBBOX
+	if(isset($_REQUEST["mb_myBBOX"])){
+		//Check for numerical values for BBOX
+		$array_bbox=explode(',',$_REQUEST["mb_myBBOX"]);
+		if ((is_numeric($array_bbox[0])) and (is_numeric($array_bbox[1])) and (is_numeric($array_bbox[2])) and (is_numeric($array_bbox[3])) ) {
+			if(isset($_REQUEST["mb_myBBOXEpsg"])){
+				//Check epsg
+				$targetEpsg=intval($_REQUEST["mb_myBBOXEpsg"]);
+				if (($targetEpsg >= 1) and ($targetEpsg <= 50001)) {
+					#echo "is in the codespace of the epsg registry\n";
+					} else {
+					#echo "is outside\n";
+ 					echo "alert('The REQUEST parameter mb_myBBOXEpsg is not in the epsg realm - please define another EPSG Code.');";
+ 					return;
+				}
+				//Check if epsg is equal to BBOXEpsg
+				//Get epsg code out of WMC
+				$xml_epsg=str_replace('EPSG:','',$xml->General->BoundingBox['SRS']);
+				if ($_REQUEST["mb_myBBOXEpsg"]!=$xml_epsg){
+					//Transform the given BBOX to epsg of WMC
+					$sql= "select asewkt(transform(GeometryFromText ( 'LINESTRING ( ".$array_bbox[0]." ".$array_bbox[1].",".$array_bbox[2]." ".$array_bbox[3]." )', $targetEpsg ),".intval($xml_epsg)."))";
+					$e = new mb_notice("mod_wms2ol.php: sql (transform)=".$sql);
+					$res = db_query($sql);
+					//read out result
+					$text_bbox = db_fetch_row($res);
+					$e = new mb_notice("mod_wms2ol.php: text_bbox=".$text_bbox[0]);
+					$pattern = '~LINESTRING\((.*)\)~i';
+					preg_match($pattern, $text_bbox[0], $subpattern);
+					$e = new mb_notice("mod_wms2ol.php: subpattern=".$subpattern[1]);
+					//exchange blancspaces
+					$new_bbox = str_replace(" ", ",", $subpattern[1]);
+					//set new BBOX
+					$array_bbox_new=explode(',',$new_bbox);
+					$minx_new=$array_bbox_new[0];
+					$miny_new=$array_bbox_new[1];
+					$maxx_new=$array_bbox_new[2];
+					$maxy_new=$array_bbox_new[3];
+					$centralx=($maxx_new+$minx_new)/2;
+					$centraly=($maxy_new+$miny_new)/2;
+				}
+				else
+				{
+				//Set the new BBOX unaltered
+				$minx=$array_bbox[0];
+				$miny=$array_bbox[1];
+				$maxx=$array_bbox[2];
+				$maxy=$array_bbox[3];
+				}
+			}
+		}
+		else
+		{
+			echo "alert('The REQUEST parameters for mb_myBBOX are not numeric - please give numeric values!');";
+			return;
+		}
+	} 
+	//**********************************************************************************************
+	//define variable bounds	
+	$html.="var bounds = new OpenLayers.Bounds(".$minx.",".$miny.",".$maxx.",".$maxy.");\n";
+	//if some layer defined, create base layer -> first layer in wmc	
+	if (count($layer_array) != 0){
+		$i=0;
+		$html.="layer0 = new OpenLayers.Layer.WMS( \"".$xml->LayerList->Layer[$i]->Title."\",\n";
+		$extensions=$xml->LayerList->Layer[$i]->Extension->children('http://www.mapbender.org');
+		$layer_id=$extensions->layer_id;
+		$wms_id=$extensions->wms_id;
+//	?!	$has_permission=getLayerPermission($wms_id,$layer_id,2);//problem: guest user must have fix id
+		$has_permission=getLayerPermission($wms_id,$layer_id,$userId);//problem: guest user must have fix id
+		//echo $layer_id."<br>";
+		if ($has_permission || $layer_id==''){
+			$html.="\"".$xml->LayerList->Layer[$i]->Server->OnlineResource->attributes('http://www.w3.org/1999/xlink')->href."\",\n";
+			$html.="{\n";
+			$html.="layers: \"".$xml->LayerList->Layer[$i]->Name."\",\n";
+			//get FormatList and the current active format -> TODO: make a function for getting actual format for request
+			$format='png';
+			foreach ($xml->LayerList->Layer[$i]->FormatList->Format as $current_format) {
+				if ($current_format->attributes()->current=='1'){    
+					$format=$current_format;
+				}
+			}
+			$format=str_replace('image/','',$format);
+			$html.="format: \"".$format."\",\n";
+			$html.="transparent: \"On\"\n";
+			$html.="},\n";
+			$html.="{\n";
+	             	$html.="maxExtent: new OpenLayers.Bounds(".$minx.",".$miny.",".$maxx.",".$maxy."),\n";                    
+                        // then check map.baseLayer.resolutions[0] for
+                        // a reasonable value.
+			$html.="projection: \"".$xml->General->BoundingBox['SRS']."\",\n";  
+              		$html.="units: \"m\",\n"; 
+			$html.="numZoomLevels: ".$numberZoomLevels.",\n";
+			$minScale = $extensions->guiScaleHint->attributes()->min;
+			$maxScale = $extensions->guiScaleHint->attributes()->max;
+			if (!$maxScale){
+				$maxScale='10000000';
+			}
+			if (!$minScale){
+				$minScale='0.1';
+			}
+			$html.="minScale: ".$minScale.",\n"; 
+			$html.="maxScale: ".$maxScale.",\n"; 
+			$html.="singleTile: true\n";
+                 	//Only neccesary for working with scales.
+                	$html.="  } );\n";
+          		$html.=" map.addLayer(layer0);\n";
+		} else {
+			echo "Guest don't have permission on Base-Layer or ".$layer_id." therefor OpenLayers client will not be generated!<br>";
+		}
+	}
+	//create the overlay layers for which the user guest has permissions
+	for ($i=1; $i<count($layer_array); $i++) {
+		$extensions=$xml->LayerList->Layer[$i]->Extension->children('http://www.mapbender.org');
+		$layer_id=$extensions->layer_id;
+		$wms_id=$extensions->wms_id;
+		$has_permission=getLayerPermission($wms_id,$layer_id,ANONYMOUS_USER);//problem: guest user must have fix id TODO
+		if (($xml->LayerList->Layer[$i]->attributes()->hidden=='0' && $has_permission) ||
+			($layer_id=='' && $xml->LayerList->Layer[$i]->attributes()->hidden=='0')){
+				
+			$html.="layer".$i." = new OpenLayers.Layer.WMS( \"".$xml->LayerList->Layer[$i]->Title."\",\n";
+			$html.="\"".$xml->LayerList->Layer[$i]->Server->OnlineResource->attributes('http://www.w3.org/1999/xlink')->href."\",\n";
+			$html.="{\n";
+			$html.="layers: \"".$xml->LayerList->Layer[$i]->Name."\",\n";
+			//Get FormatList and the current active format
+			$format='png';
+			foreach ($xml->LayerList->Layer[$i]->FormatList->Format as $current_format) {
+				if ($current_format->attributes()->current=='1'){    
+					$format=$current_format;
+				}
+			}
+			$format=str_replace('image/','',$format);
+			$html.="format: \"".$format."\",\n";
+			$html.="transparent: \"TRUE\"\n";
+			$html.="},\n";
+			$html.="{\n";
+             		$html.="maxExtent: new OpenLayers.Bounds(".$minx.",".$miny.",".$maxx.",".$maxy."),\n";       
+			$html.="projection: \"".$xml->General->BoundingBox['SRS']."\",\n";  
+              		$html.="units: \"m\",\n"; 
+			$html.="singleTile: true,\n";
+			$html.="numZoomLevels: ".$numberZoomLevels.",\n";
+			//$extensions=$xml->LayerList->Layer[$i]->Extension->children('http://www.mapbender.org');
+			$minScale=$extensions->guiScaleHint->attributes()->min;
+			$maxScale=$extensions->guiScaleHint->attributes()->max;
+			if (!$maxScale){
+				$maxScale='10000000';
+			}
+			if (!$minScale){
+				$minScale='0.1';
+			}
+			$html.="minScale: ".$minScale.",\n"; 
+			$html.="maxScale: ".$maxScale.",\n"; 
+			$html.="'isBaseLayer': false\n";
+                	$html.="  } );\n";
+          		$html.=" map.addLayer(layer".$i.");\n";
+		}
+	}
+	//do some global things
+	//vector layer for logo or link
+	//$html.="var vector = new OpenLayers.Layer.Vector('Simple Geometry',\n";
+	//$html.="{attribution:'test'});\n";
+  	//$html.="map.addLayer(vector);\n";
+   	//$html.="map.addControl(new OpenLayers.Control.Attribution({'div':OpenLayers.Util.getElement('attribution')}));\n";
+	//Check if central marker should be set and draw one
+	if(isset($_REQUEST["mb_drawCentre"])&isset($centralx)&isset($centraly)){
+		if ($_REQUEST["mb_drawCentre"]='1'){
+			$html.="var markers = new OpenLayers.Layer.Markers(\"Markers\", {'calculateInRange': function() { return true; }});\n";
+			$html.="var size = new OpenLayers.Size(15,20);\n";
+			$html.="calculateOffset = function(size) {return new OpenLayers.Pixel(-(size.w/2), -size.h); };\n";
+			$html.="var icon = new OpenLayers.Icon('../../openlayers/img/marker.png',size, null, calculateOffset);\n";
+			$html.="markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(".$centralx.",".$centraly."),icon));\n";
+			$html.="map.addLayer(markers);\n";
+		}
+		else {
+			echo "alert('The REQUEST parameter mb_drawCentre is outside of his realm!');";
+ 			return;
+		}
+	}
+	//Zoom to extent of given mb_myBBOX 
+	if(isset($_REQUEST["mb_myBBOX"])){
+		$html.="var newBounds = new OpenLayers.Bounds(".$minx_new.",".$miny_new.",".$maxx_new.",".$maxy_new.");\n";
+		$html.="map.setCenter(new OpenLayers.LonLat(".$centralx.",".$centraly."),zoom);\n";
+		$html.="map.zoomToExtent(newBounds);\n";
+
+	} else {
+		$html.="map.zoomToExtent(bounds);\n";
+	}
+	if(isset($_REQUEST["showCoords"])){
+		if($_REQUEST["showCoords"]=='1'){
+			$html.="var mp = new OpenLayers.Control.MousePosition({'div':OpenLayers.Util.getElement('showpos'),'numDigits':2});\n";
+			$html.="mp.numDigits = 2;\n";
+			$html.="map.addControl(mp);";
+		}	
+	}
+	//Generate the possibility to do GetFeatureInfo if this was activated in wmc
+	if ($someLayerQueryable){
+		$html.="map.events.register('click', map, function (e) {\n";
+		//loop for all layers
+		for ($i=0; $i<count($layer_array); $i++){
+			if ($layer_array_queryable[$i]=='1'){
+				$html.="var url".$i." =  layer".$i.".getFullRequestString({\n";
+                      		$html.=" REQUEST: \"GetFeatureInfo\",\n";
+				$html.="EXCEPTIONS: \"application/vnd.ogc.se_xml\",\n";
+				$html.="BBOX: layer".$i.".map.getExtent().toBBOX(),\n";
+				$html.="X: e.xy.x,\n";
+				$html.="Y: e.xy.y,\n";
+				$html.="INFO_FORMAT: 'text/html',\n";
+				$html.="QUERY_LAYERS: layer".$i.".params.LAYERS,\n";
+				$html.=" WIDTH: layer".$i.".map.size.w,\n";
+				$html.="HEIGHT: layer".$i.".map.size.h});\n";
+				$html.="window.open(url".$i.",target=\"_blank\",\"width=300,height=400,left=100,top=200\");\n";	
+			}	
+		}
+		$html.="OpenLayers.Event.stop(e);\n";
+		$html.=" });\n";
+	}
+	//end GetfeatureInfo
+	$html.="}\n";//End of function
+ 	$html.="</script>\n";
+ 	$html.=" </head>\n";
+  	$html.="<body onload='init()'>\n";
+   	$html.="<div id='tags'></div>\n";
+   	$html.="<div id='map' class='smallmap'></div>\n";//class dont exists
+   	$html.="<div id='docs'>\n";
+  	$html.="\n";
+   	$html.="</div>\n";
+	//Show coords if wished
+	if($_REQUEST["mb_showCoords"]=='1'){
+		$html.="<div id='srs' class='csrs'>Koordinaten in <a href = '../../../mediawiki/index.php/".$xml->General->BoundingBox['SRS']."' target='_blank'>".$xml->General->BoundingBox['SRS']."</a>:</div>\n";
+	}
+	$html.="<div id='showpos'></div>\n";
+	$html.="<div id='attribution'></div>\n";
+  	$html.="</body>\n";
+	$html.="</html>\n";
+	//Print out HTML code
+	echo $html;
+}
+
+//end of function createOlfromWMC_id()
+createOlfromWMC_id($_GET["wmc_id"]);
+?>

Added: trunk/mapbender/http/php/wms.php
===================================================================
--- trunk/mapbender/http/php/wms.php	                        (rev 0)
+++ trunk/mapbender/http/php/wms.php	2009-09-03 14:10:46 UTC (rev 4595)
@@ -0,0 +1,1093 @@
+<?php
+# $Id: mb_listGUIs.php 11 2006-07-31 16:22:36Z rothstein $
+# http://www.mapbender.org/index.php/mb_listGUIs.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_layer_monitor.php");
+
+//
+// make all parameters available as upper case
+//
+foreach($_GET as $key => $val) {
+	$_GET[strtoupper($key)] = $val;
+}
+
+$requestType = $_GET["REQUEST"];
+$version = $_GET["VERSION"];
+$service = strtoupper($_GET["SERVICE"]);
+$layerId = $_GET["LAYER_ID"];
+$updateSequence = intval($_GET["UPDATESEQUENCE"]);
+$mapbenderMetadataUrl = preg_replace("/(.*)frames\/login.php/", "$1php/mod_layerMetadata.php?id=", LOGIN);
+
+/**
+ * Creates an XML Exception according to WMS 1.1.1
+ * 
+ * @return an XML String
+ * @param $errorCode String
+ * @param $errorMessage String
+ */
+function createExceptionXml ($errorCode, $errorMessage) {
+	// see http://de2.php.net/manual/de/domimplementation.createdocumenttype.php
+	$imp = new DOMImplementation;
+	$dtd = $imp->createDocumentType("ServiceExceptionReport", "", "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd");
+	
+	$doc = $imp->createDocument("", "", $dtd);
+	$doc->encoding = 'UTF-8';
+	$doc->standalone = false;
+	
+	$el = $doc->createElement("ServiceExceptionReport");
+	$exc = $doc->createElement("ServiceException", $errorMessage);
+	if ($errorCode) {
+		$exc->setAttribute("code", $errorCode);
+	}
+	$el->appendChild($exc);
+	$doc->appendChild($el);
+	
+	return $doc->saveXML();
+}
+
+//
+// check if service param is set
+//
+if (!isset($service) || $service === "" || $service != "WMS") {
+	header("Content-type: application/xhtml+xml; charset=UTF-8");
+	echo createExceptionXml("", "Parameter SERVICE invalid");
+	die;
+}
+
+//
+// check if request param is set
+//
+if (!isset($requestType) || $requestType === "" || 
+	($service == "WMS" && $requestType != "GetCapabilities")) {
+		
+	header("Content-type: application/xhtml+xml; charset=UTF-8");
+	echo createExceptionXml("", "Parameter REQUEST invalid");
+	die;
+}
+
+//
+// check if version param is set
+//
+if (!isset($version) || $version === "" || 
+	($service == "WMS" && $version != "1.1.1")) {
+		
+	// optional parameter, set to 1.1.1 if not set
+	$version = "1.1.1";
+}
+
+//
+// check if layer id is set
+//
+if (!isset($layerId) || !is_numeric($layerId)) {
+	// TO DO: create exception XML
+	header("Content-type: application/xhtml+xml; charset=UTF-8");
+	echo createExceptionXml(
+		"Layer not defined", 
+		"Unknown layer id " . $layerId
+	);
+	die;
+}
+
+//
+// check if layer is stored in database
+//
+$wms_sql = "SELECT * FROM wms AS w, layer AS l " . 
+	"where l.layer_id = $1 AND l.fkey_wms_id = w.wms_id LIMIT 1";
+$v = array($layerId);
+$t = array("i");
+$res_wms_sql = db_prep_query($wms_sql, $v, $t);
+$wms_row = db_fetch_array($res_wms_sql);
+
+if (!$wms_row["wms_id"]) {
+	// TO DO: create exception XML
+	header("Content-type: application/xhtml+xml; charset=UTF-8");
+	echo createExceptionXml(
+		"Layer not defined", 
+		"Unknown layer id " . $layerId
+	);
+	die;
+}
+
+//
+// check if update sequence is valid
+//
+$updateSequenceDb = intval($wms_row["wms_timestamp"]);
+
+if ($updateSequence) {
+	if ($updateSequence > $updateSequenceDb) {
+		// Exception: code=InvalidUpdateSequence
+		header("Content-type: application/xhtml+xml; charset=UTF-8");
+		echo createExceptionXml("InvalidUpdateSequence", "Invalid update sequence");
+		die;
+	}
+	else if ($updateSequence == $updateSequenceDb) {
+		// Exception: code=CurrentUpdateSequence
+		header("Content-type: application/xhtml+xml; charset=UTF-8");
+		echo createExceptionXml("CurrentUpdateSequence", "Current update sequence");
+		die;
+	}
+}
+
+//
+// increment layer count
+//
+$monitor = new Layer_load_count();
+$monitor->increment($layerId);
+
+// ---------------------------------------------------------------------------
+//
+// START TO CREATE CAPABILITIES DOC
+// (return most recent Capabilities XML)
+//
+// ---------------------------------------------------------------------------
+
+$doc = new DOMDocument('1.0');
+$doc->encoding = 'UTF-8';
+$doc->standalone = false;
+
+#Check for existing content in database
+#to be adopted TODO armin 
+function validate ($contactInformation_column) {
+    if ($contactInformation_column <> "" AND $contactInformation_column <> NULL) {
+             $contactinformationcheck = true;
+    }
+    else {
+		$contactinformationcheck = false;
+	}
+	return $contactinformationcheck;
+}
+ 
+	
+#Creating the "WMT_MS_Capabilities" node
+$wmt_ms_capabilities = $doc->createElement("WMT_MS_Capabilities");
+$wmt_ms_capabilities->setAttribute("updateSequence", $wms_row["wms_timestamp"]);
+$wmt_ms_capabilities = $doc->appendChild($wmt_ms_capabilities);
+$wmt_ms_capabilities->setAttribute('version', '1.1.1');
+
+#Creatig the "Service" node 
+$service = $doc->createElement("Service");
+$service = $wmt_ms_capabilities->appendChild($service);
+
+#Creating the "Name" Node
+$name = $doc->createElement("Name");
+$name = $service->appendChild($name);
+$nameText = $doc->createTextNode("OGC:WMS");
+$nameText = $name->appendChild($nameText);
+
+#Creating the "Title" node
+if($wms_row['wms_title'] <> "" AND $wms_row['wms_title'] <> NULL) {
+    $title = $doc->createElement("Title");
+	$title = $service->appendChild($title);
+	$titleText = $doc->createTextNode($wms_row['wms_title']);
+	$titleText = $title->appendChild($titleText);
+}
+
+#Creating the "Abstract" node
+if($wms_row['wms_abstract'] <> "" AND $wms_row['wms_abstract'] <> NULL) {
+	$abstract = $doc->createElement("Abstract");
+	$abstract = $service->appendChild($abstract);
+	$abstractText = $doc->createTextNode($wms_row['wms_abstract']);
+	$abstractText = $abstract->appendChild($abstractText);
+}
+	
+# switch URLs for OWSPROXY
+if($wms_row['wms_owsproxy'] <> "" AND $wms_row['wms_owsproxy'] <> NULL) {
+	$tmpOR = "http://".$_SERVER["HTTP_HOST"]."/owsproxy/".session_id()."/".$wms_row["wms_owsproxy"]."?";
+	$tmpOR = str_replace(SERVERIP, SERVERNAME, $tmpOR);
+	$wms_row['wms_getcapabilities'] = $tmpOR;
+	$wms_row['wms_getmap'] = $tmpOR;
+	$wms_row['wms_getfeatureinfo'] = $tmpOR;
+
+}
+#Creating the "OnlineResource" node
+//if($wms_row['wms_getcapabilities'] <> "" AND $wms_row['wms_getcapabilities'] <> NULL) {
+    $onlineResource = $doc->createElement("OnlineResource");
+	$onlineResource = $service->appendChild($onlineResource);
+	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+//	$onlineResource->setAttribute("xlink:href", $wms_row['wms_getcapabilities']);
+	$onlRes = $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "?layer_id=" . $layerId."&".session_name()."=".session_id();
+	if (isset($_SERVER["HTTPS"])) {
+		$onlRes = "https://" . $onlRes;
+	}
+	else {
+		$onlRes = "http://" . $onlRes;
+	}
+	$onlineResource->setAttribute("xlink:href", $onlRes);
+	$onlineResource->setAttribute("xlink:type", "simple");
+//}
+
+#Insert contact information
+
+#Creating "Contact Information" node
+if (validate($wms_row['contactperson']) &&
+	validate($wms_row['contactorganization']) &&
+	validate($wms_row['contactposition']) && 
+	validate($wms_row['address']) && 
+	validate($wms_row['city']) && 
+	validate($wms_row['stateorprovince']) && 
+	validate($wms_row['postcode']) /*AND validate($wms_row['country'])*/ &&
+	validate($wms_row['contactvoicetelephone']) && 
+	validate($wms_row['contactfacsimiletelephone']) &&
+	validate($wms_row['contactelectronicmailaddress']))
+{
+$contactInformation = $doc->createElement("ContactInformation");
+$contactInformation = $service->appendChild($contactInformation);
+
+#Creating "Contact Person Primary" node
+if(validate($wms_row['contactperson']) AND validate($wms_row['contactorganization']))
+{
+$contactPersonPrimary = $doc->createElement("ContactPersonPrimary");
+$contactPersonPrimary = $contactInformation->appendChild($contactPersonPrimary); 
+}
+
+#Creating the "ContactPerson" node
+if(validate($wms_row['contactperson']))
+{
+    $contactPerson = $doc->createElement("ContactPerson");
+    $contactPerson = $contactPersonPrimary->appendChild($contactPerson);
+    $contactPersonText = $doc->createTextNode($wms_row['contactperson']);
+    $contactPersonText = $contactPerson->appendChild($contactPersonText);
+}
+
+#Creating the "ContactOrganization" node
+if(validate($wms_row['contactorganization']))
+{
+    $contactOrganization = $doc->createElement("ContactOrganization");
+    $contactOrganization = $contactPersonPrimary->appendChild($contactOrganization);
+    $contactOrganizationText = $doc->createTextNode($wms_row['contactorganization']);
+    $contactOrganizationText = $contactOrganization->appendChild($contactOrganizationText);
+}
+
+
+#Creating the "ContactPosition" node
+if(validate($wms_row['contactposition']))
+{
+    $contactPosition = $doc->createElement("ContactPosition");
+    $contactPosition = $contactInformation->appendChild($contactPosition);
+    $contactPositionText = $doc->createTextNode($wms_row['contactposition']);
+    $contactPositionText = $contactPosition->appendChild($contactPositionText);    
+}
+
+#Creating "ContactAddress" node
+if(validate($wms_row['address']) AND validate($wms_row['city']) AND validate($wms_row['stateorprovince']) AND               validate($wms_row['postcode']) /*AND validate($wms_row['country'])*/)
+{
+$contactAddress = $doc->createElement("ContactAddress");
+$contactAddress = $contactInformation->appendChild($contactAddress); 
+}
+
+#Creating the "AddressType" and "Address" textnode
+if(validate($wms_row['address']))
+{
+	
+    $addressType = $doc->createElement("AddressType");
+    $addressType = $contactAddress->appendChild($addressType);
+    $addresstypeText = $doc->createTextNode("postal");
+    $addresstypeText = $addressType->appendChild($addresstypeText);
+    
+    $address = $doc->createElement("Address");
+    $address = $contactAddress->appendChild($address);
+    $addressText = $doc->createTextNode($wms_row['address']);
+    $addressText = $address->appendChild($addressText);
+}
+
+#Creatig the "City" node  
+if(validate($wms_row['city']))
+{
+    $city = $doc->createElement("City");
+    $city = $contactAddress->appendChild($city);
+    $cityText = $doc->createTextNode($wms_row['city']);
+    $cityText = $city->appendChild($cityText);
+}
+
+#Creatig the "StateOrProvince" node    
+if(validate($wms_row['stateorprovince']))
+{
+    $stateOrProvince = $doc->createElement("StateOrProvince");
+    $stateOrProvince = $contactAddress->appendChild($stateOrProvince);
+    $stateOrProvinceText = $doc->createTextNode($wms_row['stateorprovince']);
+    $stateOrProvinceText = $stateOrProvince->appendChild($stateOrProvinceText);
+}
+
+#Creatig the "PostCode" node    
+if(validate($wms_row['postcode']))
+{
+    $postCode = $doc->createElement("PostCode");
+    $postCode = $contactAddress->appendChild($postCode);
+    $postCodeText = $doc->createTextNode($wms_row['postcode']);
+    $postCodeText = $postCode->appendChild($postCodeText);
+}
+
+ 
+#Creatig the "Country" node   
+if(isset($wms_row['country']) AND validate($wms_row['country']))
+{
+    $country = $doc->createElement("Country");
+    $country = $contactAddress->appendChild($country);
+    $countryText = $doc->createTextNode($wms_row['country']);
+    $countryText = $country->appendChild($countryText);
+}
+
+#Creatig the "ContactVoiceTelephone" node
+if(validate($wms_row['contactvoicetelephone']))
+{
+    $contactVoiceTelephone = $doc->createElement("ContactVoiceTelephone");
+    $contactVoiceTelephone = $contactInformation->appendChild($contactVoiceTelephone);
+    $contactVoiceTelephoneText = $doc->createTextNode($wms_row['contactvoicetelephone']);
+    $contactVoiceTelephoneText = $contactVoiceTelephone->appendChild($contactVoiceTelephoneText);
+}
+
+#Creatig the "ContactFacsimileTelephone" node
+if(validate($wms_row['contactfacsimiletelephone']))
+{
+    $contactFacsimileTelephone = $doc->createElement("ContactFacsimileTelephone");
+    $contactFacsimileTelephone = $contactInformation->appendChild($contactFacsimileTelephone);
+    $contactFacsimileTelephoneText = $doc->createTextNode($wms_row['contactfacsimiletelephone']);
+    $contactFacsimileTelephoneText = $contactFacsimileTelephone->appendChild($contactFacsimileTelephoneText);
+}
+
+#Creatig the "ContactElectronicMailAddress" node
+if(validate($wms_row['contactelectronicmailaddress']))
+{
+    $contactElectronicMailAddress = $doc->createElement("ContactElectronicMailAddress");
+    $contactElectronicMailAddress = $contactInformation->appendChild($contactElectronicMailAddress);
+    $contactElectronicMailAddressText = $doc->createTextNode($wms_row['contactelectronicmailaddress']);
+    $contactElectronicMailAddressText = $contactElectronicMailAddress->appendChild($contactElectronicMailAddressText);
+}
+}
+
+#Creatig the "Fees" node
+if(validate($wms_row['fees']))
+{
+    $fees = $doc->createElement("Fees");
+    $fees = $service->appendChild($fees);
+    $feesText = $doc->createTextNode($wms_row['fees']);
+    $feesText = $fees->appendChild($feesText);
+}
+   
+#Creating the "AccessConstraints" node
+if(validate($wms_row['accessconstraints']))
+{
+	$accessConstraints = $doc->createElement("AccessConstraints");
+    $accessConstraints = $service->appendChild($accessConstraints);
+    $accessConstraintsText = $doc->createTextNode($wms_row['accessconstraints']);
+    $accessConstraintsText = $accessConstraints->appendChild($accessConstraintsText);
+}
+
+ 
+#Creatig the "Capability" node 
+$capability = $doc->createElement("Capability");
+$capability = $wmt_ms_capabilities->appendChild($capability);
+
+#Creatig the "Request" node 
+$request = $doc->createElement("Request");
+$request = $capability->appendChild($request);
+
+############################################################
+#GetCapabilities
+#Creatig the "GetCapabilities" node 
+$getCapabilities = $doc->createElement("GetCapabilities");
+$getCapabilities = $request->appendChild($getCapabilities);
+
+#Creatig the "Format" node 
+$wms_format_sql ="SELECT data_format FROM wms_format WHERE fkey_wms_id = $1 AND data_type = 'capability'";
+$v = array($wms_row['wms_id']);
+$t = array("i");
+$res_wms_format_sql = db_prep_query($wms_format_sql, $v, $t);
+while ($wms_format_row = db_fetch_array($res_wms_format_sql)) {
+    $format = $doc->createElement("Format");
+    $format = $getCapabilities->appendChild($format);
+    $formatText = $doc->createTextNode($wms_format_row['data_format']);
+    $formatText = $format->appendChild($formatText);    
+}
+#cause the format for capabilities is not read :
+    $format = $doc->createElement("Format");
+    $format = $getCapabilities->appendChild($format);
+    $formatText = $doc->createTextNode('application/vnd.ogc.wms_xml');
+    $formatText = $format->appendChild($formatText); 
+
+
+
+#Creating the "DCPType" node
+$DCPType = $doc->createElement("DCPType");
+$DCPType = $getCapabilities->appendChild($DCPType);
+
+#Creating the "HTTP" node
+$HTTP = $doc->createElement("HTTP");
+$HTTP = $DCPType->appendChild($HTTP);
+
+#Creating the "Get" node
+$get = $doc->createElement("Get");
+$get = $HTTP->appendChild($get);
+
+#Creating the "OnlineResource" node
+
+//if ($wms_row['wms_getcapabilities'] <> "" AND $wms_row['wms_getcapabilities'] <> NULL) {
+	$onlineResource = $doc->createElement("OnlineResource");
+	$onlineResource = $get->appendChild($onlineResource);
+	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+//	$onlineResource->setAttribute("xlink:href", $wms_row['wms_getcapabilities']);
+	$onlRes = $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "?layer_id=" . $layerId;
+	if (isset($_SERVER["HTTPS"])) {
+		$onlRes = "https://" . $onlRes;
+	}
+	else {
+		$onlRes = "http://" . $onlRes;
+	}
+	$onlineResource->setAttribute("xlink:href", $onlRes);
+	$onlineResource->setAttribute("xlink:type", "simple");		
+//}
+
+#Creating the "Post" node
+$post = $doc->createElement("Post");
+$post = $HTTP->appendChild($post);
+
+#Creating the "OnlineResource" node
+//if ($wms_row['wms_getcapabilities'] <> "" AND $wms_row['wms_getcapabilities'] <> NULL) {
+	$onlineResource = $doc->createElement("OnlineResource");
+	$onlineResource = $post->appendChild($onlineResource);
+	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+//	$onlineResource->setAttribute("xlink:href", $wms_row['wms_getcapabilities']);
+	$onlRes = $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "?layer_id=" . $layerId;
+	if (isset($_SERVER["HTTPS"])) {
+		$onlRes = "https://" . $onlRes;
+	}
+	else {
+		$onlRes = "http://" . $onlRes;
+	}
+	$onlineResource->setAttribute("xlink:href", $onlRes);
+	$onlineResource->setAttribute("xlink:type", "simple");
+//}
+
+##########################################################
+#GetMap	
+#Creatig the "GetMap" node 
+$getMap = $doc->createElement("GetMap");
+$getMap = $request->appendChild($getMap);
+
+#Creatig the "Format" node 
+$wms_format_sql ="SELECT data_format FROM wms_format WHERE fkey_wms_id = $1 AND data_type = 'map'";
+$v = array($wms_row['wms_id']);
+$t = array("i");
+$res_wms_format_sql = db_prep_query($wms_format_sql, $v, $t);
+
+while ($wms_format_row = db_fetch_array($res_wms_format_sql)) {
+    $format = $doc->createElement("Format");
+    $format = $getMap->appendChild($format);
+    $formatText = $doc->createTextNode($wms_format_row['data_format']);
+    $formatText = $format->appendChild($formatText);	
+}
+
+#Creating the "DCPType" node
+$DCPType = $doc->createElement("DCPType");
+$DCPType = $getMap->appendChild($DCPType);
+
+#Creating the "HTTP" node
+$HTTP = $doc->createElement("HTTP");
+$HTTP = $DCPType->appendChild($HTTP);
+
+#Creating the "Get" node
+$get = $doc->createElement("Get");
+$get = $HTTP->appendChild($get);
+
+#Creating the "OnlineResource" node
+if ($wms_row['wms_getmap'] <> "" AND $wms_row['wms_getmap'] <> NULL) {
+	$onlineResource = $doc->createElement("OnlineResource");
+	$onlineResource = $get->appendChild($onlineResource);
+	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+	$onlineResource->setAttribute("xlink:href", $wms_row['wms_getmap']);
+	$onlineResource->setAttribute("xlink:type", "simple");
+}
+
+#Creating the "Post" node
+$post = $doc->createElement("Post");
+$post = $HTTP->appendChild($post);
+
+#Creating the "OnlineResource" node
+if($wms_row['wms_getmap'] <> "" AND $wms_row['wms_getmap'] <> NULL) {
+	$onlineResource = $doc->createElement("OnlineResource");
+	$onlineResource = $post->appendChild($onlineResource);
+	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+	$onlineResource->setAttribute("xlink:href", $wms_row['wms_getmap']);
+	$onlineResource->setAttribute("xlink:type", "simple");
+}
+
+##########################################################
+#GetFeatureInfo	
+#Creatig the "GetFeatureInfo" node 
+$getFeatureInfo = $doc->createElement("GetFeatureInfo");
+$getFeatureInfo = $request->appendChild($getFeatureInfo);
+
+#Creatig the "Format" node 
+$wms_format_sql ="SELECT data_format FROM wms_format WHERE fkey_wms_id = $1 AND data_type = 'featureinfo'";
+$v = array($wms_row['wms_id']);
+$t = array("i");
+$res_wms_format_sql = db_prep_query($wms_format_sql, $v, $t);
+while ($wms_format_row = db_fetch_array($res_wms_format_sql))
+{
+    $format = $doc->createElement("Format");
+    $format = $getFeatureInfo->appendChild($format);
+    $formatText = $doc->createTextNode($wms_format_row['data_format']);
+    $formatText = $format->appendChild($formatText);    
+}
+	
+#Creating the "DCPType" node
+$DCPType = $doc->createElement("DCPType");
+$DCPType = $getFeatureInfo->appendChild($DCPType);
+
+#Creating the "HTTP" node
+$HTTP = $doc->createElement("HTTP");
+$HTTP = $DCPType->appendChild($HTTP);
+
+#Creating the "Get" node
+$get = $doc->createElement("Get");
+$get = $HTTP->appendChild($get);
+
+#Creating the "OnlineResource" node
+if($wms_row['wms_getfeatureinfo'] <> "" AND $wms_row['wms_getfeatureinfo'] <> NULL)
+{
+	$onlineResource = $doc->createElement("OnlineResource");
+	$onlineResource = $get->appendChild($onlineResource);
+	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+	$onlineResource->setAttribute("xlink:href", $wms_row['wms_getfeatureinfo']);
+	$onlineResource->setAttribute("xlink:type", "simple");
+}
+#Creating the "Post" node
+$post = $doc->createElement("Post");
+$post = $HTTP->appendChild($post);
+
+#Creating the "OnlineResource" node
+
+if($wms_row['wms_getfeatureinfo'] <> "" AND $wms_row['wms_getfeatureinfo'] <> NULL) {
+	$onlineResource = $doc->createElement("OnlineResource");
+	$onlineResource = $post->appendChild($onlineResource);
+	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+	$onlineResource->setAttribute("xlink:href", $wms_row['wms_getfeatureinfo']);
+	$onlineResource->setAttribute("xlink:type", "simple");
+}
+	
+#Creating the "Exeption" node
+$exception = $doc->createElement("Exception");
+$exception = $capability->appendChild($exception);	
+
+#Creatig the "Format" node 
+$wms_format_sql ="SELECT data_format FROM wms_format WHERE fkey_wms_id = $1 AND data_type = 'exception'";
+$v = array($wms_row['wms_id']);
+$t = array("i");
+$res_wms_format_sql = db_prep_query($wms_format_sql, $v, $t);
+while ($wms_format_row = db_fetch_array($res_wms_format_sql)) {
+    $format = $doc->createElement("Format");
+    $format = $exception->appendChild($format);
+    $formatText = $doc->createTextNode($wms_format_row['data_format']);
+    $formatText = $format->appendChild($formatText); 
+} 
+
+################################################################
+#Querying layer table
+$layer_sql = "SELECT * FROM layer WHERE layer.fkey_wms_id = $1 AND layer.layer_parent = ''";
+$v = array($wms_row['wms_id']);
+$t = array("i");
+
+$res_layer_sql = db_prep_query($layer_sql, $v, $t);
+$layer_row = db_fetch_array($res_layer_sql);
+			
+#Creating layer node
+$layer = $doc->createElement("Layer");
+$layer = $capability->appendChild($layer);
+
+#Write layer to parent layer array
+$parentLayerArray[$layer_row['layer_pos']] = $layer;
+		
+#Creating Name node
+if ($layer_row['layer_name'] <> "" AND $layer_row['layer_name'] <> NULL) {
+	$name = $doc->createElement("Name");
+	$name = $layer->appendChild($name);
+	$nameText = $doc->createTextNode($layer_row['layer_name']);
+	$nameText = $name->appendChild($nameText);
+}
+
+#Creating Title node
+if ($layer_row['layer_title'] <> "" AND $layer_row['layer_title'] <> NULL) {
+	$title = $doc->createElement("Title");
+	$title = $layer->appendChild($title);
+	$titleText = $doc->createTextNode($layer_row['layer_title']);
+	$titleText = $title->appendChild($titleText);
+}
+
+#Creating the "Abstract" node
+if($layer_row['layer_abstract'] <> "" AND $layer_row['layer_abstract'] <> NULL) {
+    $abstract = $doc->createElement("Abstract");
+    $abstract = $layer->appendChild($abstract);
+    $abstractText = $doc->createTextNode($layer_row['layer_abstract']);
+    $abstractText = $abstract->appendChild($abstractText);	
+}
+
+#Request the specific wms- and layerkeywords
+
+$keyword_sql = "SELECT DISTINCT keyword FROM keyword, layer_keyword, layer " . 
+	"WHERE keyword.keyword_id = layer_keyword.fkey_keyword_id " . 
+	"AND layer_keyword.fkey_layer_id = layer.layer_id " . 
+	"AND layer.fkey_wms_id = $1";
+$v = array($wms_row['wms_id']);
+$t = array("i");
+$res_keyword_sql = db_prep_query($keyword_sql, $v, $t);
+
+#Creating list of keyword nodes
+#Iterating over a List of Keywords
+$keywordlistExist = 0;
+
+while ($keyword_sql = db_fetch_array($res_keyword_sql))
+{
+    #Creating the "KeywordList" node
+    if ($keywordlistExist == 0) {
+        $keywordList = $doc->createElement("KeywordList");
+        $keywordList = $layer->appendChild($keywordList);
+		$keywordlistExist = 1;	
+    }
+    
+    #Creating the "Keyword" node
+    $keyword_dom = $doc->createElement("Keyword");
+    $keyword_dom = $keywordList->appendChild($keyword_dom); 
+    $keyword_domText = $doc->createTextNode($keyword_sql['keyword']);
+    $keyword_domText = $keyword_dom->appendChild($keyword_domText);
+}
+
+
+
+#SQL statement to get additional layer information from layer epsg	
+$epsg_sql = "SELECT layer_epsg.epsg, layer_epsg.minx, layer_epsg.miny, " . 
+	"layer_epsg.maxy, layer_epsg.maxx " . 
+	"FROM layer_epsg WHERE layer_epsg.fkey_layer_id = $1";
+	
+$v = array($layer_row['layer_id']);
+$t = array("i");
+$res_espg_sql = db_prep_query($epsg_sql, $v, $t);
+
+$latLonBoundingBoxCreated = false;
+$BoundingBoxCreated = false;
+
+while ($epsg_row = db_fetch_array($res_espg_sql)) {
+
+	#Creating SRS node
+	$srs = $doc->createElement("SRS");
+	$srs = $layer->appendChild($srs);
+	$srsText = $doc->createTextNode($epsg_row['epsg']);
+	$srsText = $srs->appendChild($srsText);
+	
+
+}
+
+#SQL statement to get additional layer information from layer epsg	
+$epsg_sql = "SELECT layer_epsg.epsg, layer_epsg.minx, layer_epsg.miny, " . 
+	"layer_epsg.maxy, layer_epsg.maxx " . 
+	"FROM layer_epsg WHERE layer_epsg.fkey_layer_id = $1";
+	
+$v = array($layer_row['layer_id']);
+$t = array("i");
+$res_espg_sql = db_prep_query($epsg_sql, $v, $t);
+
+while ($epsg_row = db_fetch_array($res_espg_sql)) {
+	#set only epsg 4326 for latlonbbox
+	if ($epsg_row['epsg'] == "EPSG:4326") {
+		
+		$latlon['minx'] = $epsg_row['minx'];
+		$latlon['miny'] = $epsg_row['miny'];
+		$latlon['maxx'] = $epsg_row['maxx'];
+		$latlon['maxy'] = $epsg_row['maxy'];
+
+		#Creating LatLongBoundingBox node
+		$latLonBoundingBox = $doc->createElement("LatLonBoundingBox");
+		$latLonBoundingBox = $layer->appendChild($latLonBoundingBox);
+		$latLonBoundingBox->setAttribute('minx', $latlon['minx']);
+		$latLonBoundingBox->setAttribute('miny', $latlon['miny']);
+		$latLonBoundingBox->setAttribute('maxx', $latlon['maxx']);
+		$latLonBoundingBox->setAttribute('maxy', $latlon['maxy']);
+	    break;
+    }	
+}
+
+#SQL statement to get additional layer information from layer epsg	
+$epsg_sql = "SELECT layer_epsg.epsg, layer_epsg.minx, layer_epsg.miny, " . 
+	"layer_epsg.maxy, layer_epsg.maxx " . 
+	"FROM layer_epsg WHERE layer_epsg.fkey_layer_id = $1";
+	
+$v = array($layer_row['layer_id']);
+$t = array("i");
+$res_espg_sql = db_prep_query($epsg_sql, $v, $t);
+
+while ($epsg_row = db_fetch_array($res_espg_sql)) {
+	#set only first epsg for bbox
+	$bbox['epsg'] = $epsg_row['epsg'];
+	$bbox['minx'] = $epsg_row['minx'];
+	$bbox['miny'] = $epsg_row['miny'];
+	$bbox['maxx'] = $epsg_row['maxx'];
+	$bbox['maxy'] = $epsg_row['maxy'];
+
+	#Creating BoundingBox node
+	$boundingBox = $doc->createElement("BoundingBox");
+	$boundingBox = $layer->appendChild($boundingBox);
+	$boundingBox->setAttribute('SRS', $bbox['epsg']);
+	$boundingBox->setAttribute('minx', $bbox['minx']);
+	$boundingBox->setAttribute('miny', $bbox['miny']);
+	$boundingBox->setAttribute('maxx', $bbox['maxx']);
+	$boundingBox->setAttribute('maxy', $bbox['maxy']);
+}
+
+
+#Append epsg string to srs node
+$srsText = $doc->createTextNode($epsgText);
+$srsText = $srs->appendChild($srsText);
+
+
+####### duplicate root layer 
+#if layer is root layer itself!
+#<armin>
+##if ($layer_row['layer_pos']=='0'){
+#</armin>
+##$clonedLayer = $layer->cloneNode(true);
+##$clonedLayer->setAttribute("queryable", "0");
+##$clonedLayer->setAttribute("cascaded", "0");
+##$layer->appendChild($clonedLayer);
+#<armin>
+##}
+#</armin>
+
+
+
+############## sublayer 
+	
+#SQL statement to get all layers
+$sub_layer_sql = "SELECT * FROM layer WHERE fkey_wms_id = $1 AND layer_parent <> ''";
+$v = array($wms_row['wms_id']);
+$t = array("i");
+
+if (isset($layerId) && $layerId > 0) {	
+	$sub_layer_sql .= " AND layer_id = $2";
+	array_push($v, $layerId);
+	array_push($t, "i");
+}
+$sub_layer_sql .= " ORDER BY layer_pos";
+$res_sub_layer_sql = db_prep_query($sub_layer_sql, $v, $t);
+
+
+#<armin>
+$res_sub_layer_sql_2 = db_prep_query($sub_layer_sql, $v, $t);   
+$sub_layer_row_2 = db_fetch_array($res_sub_layer_sql_2);
+
+
+if (!isset($sub_layer_row_2['layer_pos'])) {
+	$clonedLayer = $layer->cloneNode(true);
+	$clonedLayer->setAttribute("queryable", "0");
+	$clonedLayer->setAttribute("cascaded", "0");
+	$layer->appendChild($clonedLayer);
+}
+#</armin>
+
+
+
+
+while ($sub_layer_row = db_fetch_array($res_sub_layer_sql)) {
+	
+	#Creating layer node
+
+	$sub_layer = $doc->createElement("Layer");
+	
+	$parent = $parentLayerArray[$sub_layer_row['layer_parent']];
+	$sub_layer = $parent->appendChild($sub_layer);
+    
+    if($sub_layer_row['layer_queryable'] <> "" AND $sub_layer_row['layer_queryable'] <> NULL) {
+		$sub_layer->setAttribute('queryable', $sub_layer_row['layer_queryable']);
+    }
+	#Getting information about the hierarchie of layers
+	$cascadeSQL = "SELECT COUNT(*) FROM layer WHERE fkey_wms_id = ".$wms_row[0] . 
+		" AND layer_parent = ".$sub_layer_row['layer_pos']."";
+	$res_cascadeSQL = db_query($cascadeSQL);
+	$cascade = 0;
+	$cascade_row = db_fetch_row($res_cascadeSQL);
+	if($cascade_row[0] > 0)
+	{
+		$cascade = 1;
+	}
+	$sub_layer->setAttribute('cascaded', $cascade);
+	
+	#Write layer to parent layer array
+	$parentLayerArray[$sub_layer_row['layer_pos']] = $sub_layer;
+	
+	#Creating name node
+    if($sub_layer_row['layer_name'] <> "" AND $sub_layer_row['layer_name'] <> NULL)
+    {
+		$name = $doc->createElement("Name");
+		$name = $sub_layer->appendChild($name);
+		$nameText = $doc->createTextNode($sub_layer_row['layer_name']);
+		$nameText = $name->appendChild($nameText);
+    }
+	
+	#Creating Title node
+    if($sub_layer_row['layer_title'] <> "" AND $sub_layer_row['layer_title'] <> NULL)
+    {
+		$title = $doc->createElement("Title");
+		$title = $sub_layer->appendChild($title);
+		$titleText = $doc->createTextNode($sub_layer_row['layer_title']);
+		$titleText = $title->appendChild($titleText);
+    }
+	
+		#Creating the "Abstract" node
+    if($sub_layer_row['layer_abstract'] <> "" AND $sub_layer_row['layer_abstract'] <> NULL)
+    {
+    	$abstract = $doc->createElement("Abstract");
+    	$abstract = $sub_layer->appendChild($abstract);
+    	$abstractText = $doc->createTextNode($sub_layer_row['layer_abstract']);
+    	$abstractText = $abstract->appendChild($abstractText);
+    }
+	
+    #Request the specific wms- and layerkeywords
+    $keyword_sql = "SELECT DISTINCT keyword FROM layer LEFT JOIN layer_keyword ON layer_keyword.fkey_layer_id = layer.layer_id LEFT JOIN keyword ON  keyword.keyword_id = layer_keyword.fkey_keyword_id WHERE layer.fkey_wms_id = ".$wms_row['wms_id']." AND layer.layer_id = ".$sub_layer_row['layer_id']."";
+    $res_keyword_sql = db_query($keyword_sql);
+    
+    #Creating list of keyword nodes
+    #Iterating over a List of Keywords
+    $keywordlistExist = 0;
+    while ($keyword_sql = db_fetch_array($res_keyword_sql))
+    {
+        #Creating the "KeywordList" node
+        if ($keywordlistExist == 0)
+        {
+            $keywordList = $doc->createElement("KeywordList");
+            $keywordList = $sub_layer->appendChild($keywordList);
+		    $keywordlistExist = 1;			
+        }
+        
+        #Creating the "Keyword" node
+        $keyword_dom = $doc->createElement("Keyword");
+        $keyword_dom = $keywordList->appendChild($keyword_dom); 
+        $keyword_domText = $doc->createTextNode($keyword_sql['keyword']);
+        $keyword_domText = $keyword_dom->appendChild($keyword_domText);
+    }
+
+	// inherit srs from parent layer
+	$layer_srs_sql = "SELECT DISTINCT epsg FROM layer_epsg " . 
+			"WHERE fkey_layer_id = ".$sub_layer_row['layer_id'] . 
+			" OR fkey_layer_id = " . $layer_row['layer_id'];
+	$res_layer_srs_sql = db_query($layer_srs_sql);
+
+	while ($layer_srs_row = db_fetch_array($res_layer_srs_sql)) {
+		#Creating SRS node
+		$srs = $doc->createElement("SRS");
+		$srs = $sub_layer->appendChild($srs);
+		$srsText = $doc->createTextNode($layer_srs_row['epsg']);
+		$srsText = $srs->appendChild($srsText);
+
+	}
+	#SQL statement to get additional layer information from layer epsg	
+	$epsg_sql = "SELECT layer_epsg.epsg, layer_epsg.minx, layer_epsg.miny, " . 
+			"layer_epsg.maxy, layer_epsg.maxx FROM layer_epsg " . 
+			"WHERE layer_epsg.fkey_layer_id = ".$sub_layer_row['layer_id'];
+	$res_espg_sql = db_query($epsg_sql);
+	
+	while ($epsg_row = db_fetch_array($res_espg_sql)) {
+		#set epsg 4326 for latlonbbox
+		if ($epsg_row['epsg'] == "EPSG:4326" AND $latLonBoundingBoxCreated == false) {
+			
+			$latlon['minx'] = $epsg_row['minx'];
+			$latlon['miny'] = $epsg_row['miny'];
+			$latlon['maxx'] = $epsg_row['maxx'];
+			$latlon['maxy'] = $epsg_row['maxy'];
+
+			#Creating LatLongBoundingBox node
+		    $latLonBoundingBox = $doc->createElement("LatLonBoundingBox");
+		    $latLonBoundingBox = $sub_layer->appendChild($latLonBoundingBox);
+		    $latLonBoundingBox->setAttribute('minx', $latlon['minx']);
+		    $latLonBoundingBox->setAttribute('miny', $latlon['miny']);
+		    $latLonBoundingBox->setAttribute('maxx', $latlon['maxx']);
+		    $latLonBoundingBox->setAttribute('maxy', $latlon['maxy']);
+	    }	
+	}
+	
+	#SQL statement to get additional layer information from layer epsg	
+	$epsg_sql = "SELECT layer_epsg.epsg, layer_epsg.minx, layer_epsg.miny, " . 
+			"layer_epsg.maxy, layer_epsg.maxx FROM layer_epsg " . 
+			"WHERE layer_epsg.fkey_layer_id = ".$sub_layer_row['layer_id'];
+	$res_espg_sql = db_query($epsg_sql);
+	
+	while ($epsg_row = db_fetch_array($res_espg_sql)) {
+	
+		
+		#set only first epsg for bbox
+		$bbox['epsg'] = $epsg_row['epsg'];
+		$bbox['minx'] = $epsg_row['minx'];
+		$bbox['miny'] = $epsg_row['miny'];
+		$bbox['maxx'] = $epsg_row['maxx'];
+		$bbox['maxy'] = $epsg_row['maxy'];
+
+		#Creating BoundingBox node
+		$boundingBox = $doc->createElement("BoundingBox");
+		$boundingBox = $sub_layer->appendChild($boundingBox);
+		$boundingBox->setAttribute('SRS', $bbox['epsg']);
+		$boundingBox->setAttribute('minx', $bbox['minx']);
+		$boundingBox->setAttribute('miny', $bbox['miny']);
+		$boundingBox->setAttribute('maxx', $bbox['maxx']);
+		$boundingBox->setAttribute('maxy', $bbox['maxy']);
+	}
+	
+	# Creating Metadata Node
+	
+	$metadataUrl = $doc->createElement("MetadataURL");
+	$metadataUrl = $sub_layer->appendChild($metadataUrl);
+	$metadataUrl->setAttribute('type', "TC211");
+	
+	$format = $doc->createElement("Format");
+    $format = $metadataUrl->appendChild($format);
+    $formatText = $doc->createTextNode('text/html');
+    $formatText = $format->appendChild($formatText); 
+
+	if ($wms_row['wms_owsproxy'] <> "" AND $wms_row['wms_owsproxy'] <> NULL) {
+		$onlineResource = $doc->createElement("OnlineResource");
+	   	$onlineResource = $metadataUrl->appendChild($onlineResource);
+	   	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+		$onlineResource->setAttribute("xlink:href", OWSPROXY."/".session_id()."/".$wms_row["wms_owsproxy"]."?");
+		$onlineResource->setAttribute("xlink:type", "simple");
+	}
+	else {
+		if ($sub_layer_row['layer_metadataurl'] <> "" AND $sub_layer_row['layer_metadataurl'] <> NULL) {
+	    	$onlineResource = $doc->createElement("OnlineResource");
+	    	$onlineResource = $metadataUrl->appendChild($onlineResource);
+			$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+			$onlineResource->setAttribute("xlink:href", $sub_layer_row['layer_metadataurl']);
+			$onlineResource->setAttribute("xlink:type", "simple");
+	    }
+else
+{
+ $onlineResource = $doc->createElement("OnlineResource");
+                $onlineResource = $metadataUrl->appendChild($onlineResource);
+                        $onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+                        $onlineResource->setAttribute("xlink:type", "simple");
+
+}
+
+
+	}
+	# Creating DataURL Node
+	$dataUrl = $doc->createElement("DataURL");
+	$dataUrl = $sub_layer->appendChild($dataUrl);
+	
+	
+	
+	$format = $doc->createElement("Format");
+    $format = $dataUrl->appendChild($format);
+    $formatText = $doc->createTextNode('text/html');
+    $formatText = $format->appendChild($formatText); 
+
+
+	if($wms_row['wms_owsproxy'] <> "" AND $wms_row['wms_owsproxy'] <> NULL)
+	{
+		$onlineResource = $doc->createElement("OnlineResource");
+	   	$onlineResource = $dataUrl->appendChild($onlineResource);
+	   	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+		$onlineResource->setAttribute("xlink:href", OWSPROXY."/".session_id()."/".$wms_row["wms_owsproxy"]."?");
+		$onlineResource->setAttribute("xlink:type", "simple");
+	}
+	else
+	{
+		if($sub_layer_row['layer_dataurl'] <> "" AND $sub_layer_row['layer_dataurl'] <> NULL)
+	    {
+	    	$onlineResource = $doc->createElement("OnlineResource");
+	    	$onlineResource = $dataUrl->appendChild($onlineResource);
+			$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+			$onlineResource->setAttribute("xlink:href", $sub_layer_row['layer_dataurl']);
+			$onlineResource->setAttribute("xlink:type", "simple");
+	    }
+else
+{
+ $onlineResource = $doc->createElement("OnlineResource");
+                $onlineResource = $dataUrl->appendChild($onlineResource);
+                        $onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+                        $onlineResource->setAttribute("xlink:href", $mapbenderMetadataUrl.$sub_layer_row['layer_id']);
+                        $onlineResource->setAttribute("xlink:type", "simple");
+
+}
+
+
+
+
+
+
+
+	}
+	
+	
+	#Creating Style Node
+	$style = $doc->createElement("Style");
+	$style = $sub_layer->appendChild($style);
+	
+	$name = $doc->createElement("Name");
+    $name = $style->appendChild($name);
+    $nameText = $doc->createTextNode('default');
+    $nameText = $name->appendChild($nameText);
+
+	$title = $doc->createElement("Title");
+    $title = $style->appendChild($title);
+    $titleText = $doc->createTextNode('default');
+    $titleText = $title->appendChild($titleText);
+	
+
+
+    if($wms_row['wms_getlegendurl'] <> "" AND $wms_row['wms_getlegendurl'] <> NULL){	
+	$legendUrl = $doc->createElement("LegendURL");
+	$legendUrl = $style->appendChild($legendUrl);
+	$legendUrl->setAttribute("width", "10" );
+	$legendUrl->setAttribute("height", "8" );
+
+	$format = $doc->createElement("Format");
+    $format = $legendUrl->appendChild($format);
+    $formatText = $doc->createTextNode('image/png');
+    $formatText = $format->appendChild($formatText); 
+
+	if($wms_row['wms_owsproxy'] <> "" AND $wms_row['wms_owsproxy'] <> NULL)
+	{
+		$onlineResource = $doc->createElement("OnlineResource");
+	   	$onlineResource = $legendUrl->appendChild($onlineResource);
+	   	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+		$onlineResource->setAttribute("xlink:href", OWSPROXY."/".session_id()."/".$wms_row["wms_owsproxy"]."?version=1.1.1&service=WMS&request=GetLegendGraphic&layer=".$sub_layer_row['layer_name']."&format=image/png");
+		$onlineResource->setAttribute("xlink:type", "simple");
+	}
+	else
+	{
+		if($wms_row['wms_getlegendurl'] <> "" AND $wms_row['wms_getlegendurl'] <> NULL)
+	    {
+	    	$onlineResource = $doc->createElement("OnlineResource");
+	    	$onlineResource = $legendUrl->appendChild($onlineResource);
+			$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+			$onlineResource->setAttribute("xlink:href", $wms_row['wms_getlegendurl']."version=1.1.1&service=WMS&request=GetLegendGraphic&layer=".$sub_layer_row['layer_name']."&format=image/png");
+			$onlineResource->setAttribute("xlink:type", "simple");
+	    }
+	}
+
+
+}
+	#Creating "ScaleHint" node
+    if ($sub_layer_row['layer_minscale'] <> "" AND $sub_layer_row['layer_minscale'] <> NULL) {
+		$scaleHint = $doc->createElement("ScaleHint");
+		$scaleHint = $sub_layer->appendChild($scaleHint);
+		$scaleHint->setAttribute('min', (floatval($sub_layer_row['layer_minscale'])/2004.3976484406788493955738891127));
+		$scaleHint->setAttribute('max', (floatval($sub_layer_row['layer_maxscale'])/2004.3976484406788493955738891127));
+    }
+}	
+
+header("Content-type: application/xhtml+xml; charset=UTF-8");
+echo $doc->saveXml();
+?>

Modified: trunk/mapbender/lib/basic.js
===================================================================
--- trunk/mapbender/lib/basic.js	2009-09-03 14:09:38 UTC (rev 4594)
+++ trunk/mapbender/lib/basic.js	2009-09-03 14:10:46 UTC (rev 4595)
@@ -1,8 +1,6 @@
 var clickX;
 var clickY;
 
-
-
 // transparent GIF
 var mb_trans = new Image(); 
 mb_trans.src = "../img/transparent.gif";



More information about the Mapbender_commits mailing list