[Mapbender-commits] r8338 - in trunk/mapbender/http: geoportal javascripts plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Apr 27 08:50:52 EDT 2012


Author: armin11
Date: 2012-04-27 05:50:52 -0700 (Fri, 27 Apr 2012)
New Revision: 8338

Modified:
   trunk/mapbender/http/geoportal/gaz_geom.php
   trunk/mapbender/http/geoportal/gaz_geom_mobile.php
   trunk/mapbender/http/javascripts/mod_coordsLookup.php
   trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js
   trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js
   trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
   trunk/mapbender/http/plugins/mb_wms_scheduler_server.php
Log:
Updates, bugfixes and enhancement.

Modified: trunk/mapbender/http/geoportal/gaz_geom.php
===================================================================
--- trunk/mapbender/http/geoportal/gaz_geom.php	2012-04-27 12:20:58 UTC (rev 8337)
+++ trunk/mapbender/http/geoportal/gaz_geom.php	2012-04-27 12:50:52 UTC (rev 8338)
@@ -30,23 +30,27 @@
 or die('Verbindungsaufbau fehlgeschlagen: ' . pg_last_error());
 
 function replaceChars($text){
-	$search = array( "ä",  "ö",  "ü",  "Ä",  "Ö",  "Ü",  "ß","tr." );
-	$repwith = array("ae", "oe", "ue", "AE", "OE", "UE", "ss","tr");
+//	$search = array( "ä",  "ö",  "ü",  "Ä",  "Ö",  "Ü",  "ß","tr." );
+//	$repwith = array("ae", "oe", "ue", "AE", "OE", "UE", "ss","tr");
 	
-	if(CHARSET=="UTF-8")
-		$text = utf8_decode($text);
+//	if(CHARSET=="UTF-8")
+//		$text = utf8_decode($text);
+//	$ret = str_replace($search, $repwith, $text);
 
-	$ret = str_replace($search, $repwith, $text);
+//	if(CHARSET=="UTF-8")
+//		$ret = utf8_encode($ret);
 
-	if(CHARSET=="UTF-8")
-		$ret = utf8_encode($ret);
+//	return $ret;
 
-	return $ret;
+	return $text;
+
 }
+
+
 /******* conf ***********************************/
 $factor = 1;
 if (intval($epsg) == 4326) $factor = 0.00001; 
-/******* wohnplätze *******************/
+/******* wohnplätze *******************/
 $bufferWP = 1000*$factor;
 $arrayWP = array();
 $arrayWPKey = array();
@@ -65,11 +69,11 @@
 $arrayV = array();
 $toleranceV = 1000*$factor;
 /******* strasse *********************/	
-$bufferSTR = 100*$factor;
+$bufferSTR = 175*$factor;
 $arraySTR = array();
 $toleranceSTR = 100*$factor;
 /******* Strasse / Hsnr ****************/
-$bufferSH = 100*$factor;
+$bufferSH = 75*$factor;
 $arraySH = array();
 $toleranceSH = 1000*$factor;
 
@@ -150,13 +154,13 @@
 	}
 	// workflow
 	if(count($both) == 2){
-		$a = "%".strtoupper(trim($both[0]))."%";
-		$b = "%".strtoupper(trim($both[1]))."%";
+		$a = strtoupper(trim($both[0]))."%";
+		$b = strtoupper(trim($both[1]))."%";
 		$v = array($a, $a);
 		$t = array('s', 's');
-		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde AS gem FROM gis.verwaltungseinheit ";
+		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu,gemeinde_neu AS gem FROM gemeinden ";
 		$sql .= "WHERE gemeinde_upper LIKE $1";
-		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM gis.wohnplatz ";
+		$sql .= "UNION SELECT DISTINCT gem_schl_neu,gemeinde_gem_teile AS gem FROM wohnplatz ";
 		$sql .= "WHERE gemeinde_gem_teile_upper LIKE $2) AS str";
 		$res = db_prep_query($sql,$v,$t);
 		while($row = db_fetch_array($res)){
@@ -166,9 +170,9 @@
 		}
 		$v = array($b, $b);
 		$t = array('s', 's');
-		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde AS gem FROM gis.verwaltungseinheit ";
+		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu,gemeinde_neu AS gem FROM gemeinden ";
 		$sql .= "WHERE gemeinde_upper LIKE $1";
-		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM gis.wohnplatz ";
+		$sql .= "UNION SELECT DISTINCT gem_schl_neu,gemeinde_gem_teile AS gem FROM wohnplatz ";
 		$sql .= "WHERE gemeinde_gem_teile_upper LIKE $2) AS str";
 		$res = db_prep_query($sql,$v,$t);
 		while($row = db_fetch_array($res)){
@@ -182,20 +186,20 @@
 				
 				$v = array($ckeys[$i], $cmissing[$i]);
 				$t = array('i', 's');
-				$sql = "SELECT DISTINCT str_name_ewois, ";
+				$sql = "SELECT DISTINCT strassenname, ";
 				$sql .= "SRID(the_geom) AS srid, AsGML(the_geom) AS gml ,";
-				$sql .= "(xmin(the_geom) - ".$bufferSH.") as minx, ";
-				$sql .= "(ymin(the_geom) - ".$bufferSH.") as miny, ";
-				$sql .= "(xmax(the_geom) + ".$bufferSH.") as maxx, ";
-				$sql .= "(ymax(the_geom) + ".$bufferSH.") as maxy ";
-				$sql .= "FROM gis.strassenschluessel WHERE gem_schl = $1 ";
-				$sql .= " AND (str_name_ewois_upper LIKE $2)";
+				$sql .= "(xmin(the_geom) - ".$bufferSTR.") as minx, ";
+				$sql .= "(ymin(the_geom) - ".$bufferSTR.") as miny, ";
+				$sql .= "(xmax(the_geom) + ".$bufferSTR.") as maxx, ";
+				$sql .= "(ymax(the_geom) + ".$bufferSTR.") as maxy ";                       
+				$sql .= "FROM strassenschluessel WHERE gem_schl = $1 ";
+				$sql .= " AND (strassenname_upper LIKE $2)";
 				if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 					$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
 				}				
 				$res = db_prep_query($sql,$v,$t);
 				while($row = db_fetch_array($res)){
-					$show = encode($row["str_name_ewois"])."  ".$cnames[$i];
+					$show = encode($row["strassenname"])."  ".$cnames[$i];
 					stack_it($arraySTR,"str",$show,"str",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
 				}
 			}
@@ -235,14 +239,14 @@
 		$str_schl_gem = array();
 		$ckeys = array();
 		$cnames = array();
-		$a = "%".strtoupper(trim($o))."%";
+		$a = strtoupper(trim($o))."%";
 		$v = array($a, $a);
 		$t = array('s', 's');
-		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde AS gem FROM gis.verwaltungseinheit ";
+		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde_neu AS gem FROM gemeinden ";
 		$sql .= "WHERE gemeinde_upper LIKE $1";
-		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM gis.wohnplatz ";
+		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM wohnplatz ";
 		$sql .= "WHERE gemeinde_gem_teile_upper LIKE $2) AS str";
-		$res = db_prep_query($sql,$v,$t);
+		$res = db_prep_query($sql,$v,$t);   
 		while($row = db_fetch_array($res)){
 			array_push($ckeys, $row['gem_schl_neu']);
 			array_push($cnames, $row['gem']);
@@ -251,14 +255,17 @@
 		if(count($ckeys)>0){
 			for($i=0; $i<count($ckeys); $i++){	
 				
-				$v = array($ckeys[$i], "%". strtoupper(trim($s)). "%");
+				$v = array($ckeys[$i], strtoupper(trim($s)). "%");
 				$t = array('i', 's');
-				$sql = "SELECT DISTINCT str_schl_alt ";
-				$sql .= "FROM gis.strassenschluessel WHERE gem_schl = $1 ";
-				$sql .= " AND str_name_ewois_upper ILIKE $2";
+				$sql = "SELECT DISTINCT strassenschluessel ";
+				$sql .= "FROM strassenschluessel WHERE gem_schl = $1 ";
+				$sql .= " AND strassenname_upper ILIKE $2";
+
+			
+
 				$res = db_prep_query($sql,$v,$t);
 				while($row = db_fetch_array($res)){
-					array_push($str_schl, $row['str_schl_alt']);
+					array_push($str_schl, $row['strassenschluessel']);
 					array_push($str_schl_gem, $cnames[$i]);
 				}
 			}
@@ -271,8 +278,8 @@
 				$sql .= "(ymin(the_geom) - ".$bufferSH.") as miny, ";
 				$sql .= "(xmax(the_geom) + ".$bufferSH.") as maxx, ";
 				$sql .= "(ymax(the_geom) + ".$bufferSH.") as maxy ";
-				$sql .= "FROM gis.hauskoordinaten ";
-				$sql .= "WHERE hausnummer = $1 AND strschl IN (";
+				$sql .= "FROM hauskoordinaten ";
+				$sql .= "WHERE hausnummer = $1 AND strschl_gesamt IN (";
 
 				for($i=0; $i<count($str_schl); $i++){	
 					if($i > 0){$sql .= ",";}
@@ -293,7 +300,7 @@
 				if($row["zusatz"] != 'null'){
 				#	$show .= $row["zusatz"];
 				
-$show = utf8_decode($row["name"])." ".$row["hausnummer"].$row["zusatz"];
+$show = $row["name"]." ".$row["hausnummer"].$row["zusatz"];
 //$show = $row["name"]." ".$row["hausnummer"].$row["zusatz"]; TODO: exchange this, when the hauskoordinaten table is delivered in a homogenous encoding! 
 }
 	else
@@ -307,6 +314,7 @@
 		}
 	
 	}
+
 	else {
 		//is this 'else' obsolete?
 		$sql = "SELECT DISTINCT name, hausnummer, zusatz, plz, post_ortsname, ";
@@ -315,7 +323,7 @@
 		$sql .= "(ymin(the_geom) - ".$bufferSH.") as miny, ";
 		$sql .= "(xmax(the_geom) + ".$bufferSH.") as maxx, ";
 		$sql .= "(ymax(the_geom) + ".$bufferSH.") as maxy ";
-		$sql .= "FROM gis.hauskoordinaten ";
+		$sql .= "FROM hauskoordinaten ";
 		$sql .= "WHERE name ILIKE $1 AND hausnummer = $2 ";
 		$v = array("%".$s."%",$h);
 		$t = array('s','i');
@@ -341,7 +349,7 @@
 		$res = db_prep_query($sql,$v,$t);
 		while($row = db_fetch_array($res)){
 			
-			$show = utf8_encode($row["name"])." ".$row["hausnummer"];
+			$show = $row["name"]." ".$row["hausnummer"];
 			//$show = $row["name"]." ".$row["hausnummer"]; TODO: see above
 			if($row["zusatz"] != null){
 				$show .= $row["zusatz"];	
@@ -350,6 +358,9 @@
 			stack_it($arraySH,"haus",$show,"sh",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
 		}
 	}
+
+
+
 	return true;
 }
 //Wohnplatz
@@ -364,7 +375,7 @@
 	$sql .= "(ymin(the_geom) - ".$bufferWP.") as miny, ";
 	$sql .= "(xmax(the_geom) + ".$bufferWP.") as maxx, ";
 	$sql .= "(ymax(the_geom) + ".$bufferWP.") as maxy ";
-	$sql .= "FROM gis.wohnplatz WHERE ";
+	$sql .= "FROM wohnplatz WHERE ";
 	if($plz == false){
 		$sql .= "gemeinde_gem_teile_upper ILIKE $1 ";
 		array_push($v,"%".$name."%");
@@ -411,7 +422,7 @@
 	$sql .= "(ymin(the_geom) - ".$bufferG.") as miny, ";
 	$sql .= "(xmax(the_geom) + ".$bufferG.") as maxx, ";
 	$sql .= "(ymax(the_geom) + ".$bufferG.") as maxy ";
-	$sql .= "FROM gis.verwaltungseinheit WHERE gem_schl_neu IN(";
+	$sql .= "FROM gemeinden WHERE gem_schl_neu IN(";
 	for($i=0; $i<count($arrayWPKey); $i++){
 		if($i > 0){$sql .= ",";}
 		$sql .= "$".($i+1);
@@ -437,7 +448,7 @@
 	$sql .= "(ymin(the_geom) - ".$bufferG.") as miny, ";
 	$sql .= "(xmax(the_geom) + ".$bufferG.") as maxx, ";
 	$sql .= "(ymax(the_geom) + ".$bufferG.") as maxy ";
-	$sql .= "FROM gis.verwaltungseinheit WHERE gemeinde_upper ILIKE $1 ";
+	$sql .= "FROM gemeinden WHERE gemeinde_upper ILIKE $1 ";
 	#$sql .= "GROUP BY the_geom, gemeinde, gem_schl_neu";
 	if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 		$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
@@ -461,7 +472,7 @@
 	$sql .= "(ymin(the_geom)-".$bufferK.") as miny, ";
 	$sql .= "(xmax(the_geom)+".$bufferK.") as maxx, ";
 	$sql .= "(ymax(the_geom)+".$bufferK.") as maxy ";
-	$sql .= "FROM gis.kreis_pl WHERE kreis_upper ILIKE $1 ";
+	$sql .= "FROM kreis_fl WHERE kreis_upper ILIKE $1 ";
 	if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 		$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
 	}				
@@ -481,7 +492,7 @@
 	$sql .= "(ymin(the_geom)-".$bufferV.") as miny, ";
 	$sql .= "(xmax(the_geom)+".$bufferV.") as maxx, ";
 	$sql .= "(ymax(the_geom)+".$bufferV.") as maxy ";
-	$sql .= "FROM gis.vg_fl WHERE vg ILIKE $1 ";
+	$sql .= "FROM vg_fl WHERE vg ILIKE $1 ";
 	if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 		$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
 	}				
@@ -638,8 +649,8 @@
 }
 function getCKeysByName($city){
 	global $ckeys;
-	$city = "%".strtoupper(trim($city))."%";
-	$sql = "SELECT gem_schl_neu FROM gis.wohnplatz ";
+	$city = strtoupper(trim($city))."%";
+	$sql = "SELECT gem_schl_neu FROM wohnplatz ";
 	$sql .= "WHERE gemeinde_gem_teile_upper ILIKE $1 ";
 	$v = array($city);
 	$t = array('s');

Modified: trunk/mapbender/http/geoportal/gaz_geom_mobile.php
===================================================================
--- trunk/mapbender/http/geoportal/gaz_geom_mobile.php	2012-04-27 12:20:58 UTC (rev 8337)
+++ trunk/mapbender/http/geoportal/gaz_geom_mobile.php	2012-04-27 12:50:52 UTC (rev 8338)
@@ -88,19 +88,24 @@
 or die('Verbindungsaufbau fehlgeschlagen: ' . pg_last_error());
 
 function replaceChars($text){
-	$search = array( "ä",  "ö",  "ü",  "Ä",  "Ö",  "Ü", "tr.", "ß" );
-	$repwith = array("ae", "oe", "ue", "AE", "OE", "UE", "tr","ss");
+//	$search = array( "ä",  "ö",  "ü",  "Ä",  "Ö",  "Ü", "tr.", "ß" );
+//	$repwith = array("ae", "oe", "ue", "AE", "OE", "UE", "tr","ss");
 	
 	//if(CHARSET=="UTF-8")
 	//	$text = utf8_decode($text);
 
-	$ret = str_replace($search, $repwith, $text);
+//	$ret = str_replace($search, $repwith, $text);
 
 	//if(CHARSET=="UTF-8")
 	//	$ret = utf8_encode($ret);
 
-	return $ret;
+//	return $ret;
+
+	return $text;
+
 }
+
+
 /******* conf ***********************************/
 $factor = 1;
 if (intval($epsg) == 4326) $factor = 0.00001; 
@@ -123,11 +128,11 @@
 $arrayV = array();
 $toleranceV = 1000*$factor;
 /******* strasse *********************/	
-$bufferSTR = 100*$factor;
+$bufferSTR = 175*$factor;
 $arraySTR = array();
 $toleranceSTR = 100*$factor;
 /******* Strasse / Hsnr ****************/
-$bufferSH = 100*$factor;
+$bufferSH = 75*$factor;
 $arraySH = array();
 $toleranceSH = 1000*$factor;
 
@@ -136,14 +141,14 @@
 /****** Workflow *********************************/
 /**/
 $test = str_replace("ß", "ss", $sstr);
-$e = new mb_notice("replaced test string: ".$test);
+$e = new mb_exception("replaced test string: ".$test);
 $astr = split(",",replaceChars($sstr));
-$e = new mb_notice("replaced string: ".$astr[0]." ".$astr[1]." ".$astr[2]);
+$e = new mb_exception("replaced string: ".$astr[0]." ".$astr[1]." ".$astr[2]);
 //if only one string without any comma is given
 if(count($astr) == 1){
 
 	$astr[0] = trim($astr[0]);
-	$e = new mb_notice("gaz_geom_mobile: only one string detected: ".$astr[0]);
+	$e = new mb_exception("gaz_geom_mobile: only one string detected: ".$astr[0]);
 	//check if there may be a postal code
 	$plz = getPlz($astr[0]);
 	//check if there is a housenumber
@@ -168,7 +173,7 @@
 //if 2 parts are given - the first one may be a combined or a single value
 // '56743 mendig' or 'ferdinand-sauerbruch-strasse 15' or 'koblenz' or 'mendig' or, or, or ...
 else if(count($astr) == 2){
-	$e = new mb_notice("gaz_geom_mobile: two strings detected: ".$astr[0]." and ".$astr[1]);
+	$e = new mb_exception("gaz_geom_mobile: two strings detected: ".$astr[0]." and ".$astr[1]);
 	$astr[0] = trim($astr[0]);
 	$astr[1] = trim($astr[1]);
 	$ckeys = array();
@@ -185,7 +190,7 @@
 	// check first entry for postal code
 	if(getPlz($astr[0])){
 		$myplz = getPlz($astr[0]);
-		$e = new mb_notice("gaz_geom_mobile: postalcode detected: ".$myplz);
+		$e = new mb_exception("gaz_geom_mobile: postalcode detected: ".$myplz);
 		if(getNr($astr[1])){
 			$mynr = getNr($astr[1]);
 			$myzs = getAppendix($astr[1]);
@@ -200,7 +205,7 @@
 		$mynr = getNr($astr[0]);
 		$myzs = getAppendix($astr[0]);
 		$mystr = getStrn($astr[0]);
-		$e = new mb_notice('gaz_geom_mobile: search for streetname: '.$mystr);
+		$e = new mb_exception('gaz_geom_mobile: search for streetname: '.$mystr);
 		//check if in second value there is a postalcode
 		if(getPlz($astr[1])){
 			$myplz = getPlz($astr[1]);
@@ -208,7 +213,7 @@
 		//maybe it will be a city name
 		else{
 			$mycity = trim($astr[1]);
-			$e = new mb_notice('gaz_geom_mobile: search for city: '.$mycity);
+			$e = new mb_exception('gaz_geom_mobile: search for city: '.$mycity);
 		}
 	}
 	//check second for postal code
@@ -237,9 +242,9 @@
 
 		$v = array($a, $a);
 		$t = array('s', 's');
-		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde AS gem FROM gis.verwaltungseinheit ";
+		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde_neu AS gem FROM gemeinden ";
 		$sql .= "WHERE gemeinde_upper LIKE $1";
-		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM gis.wohnplatz ";
+		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM wohnplatz ";
 		$sql .= "WHERE gemeinde_gem_teile_upper LIKE $2) AS str";
 		$res = db_prep_query($sql,$v,$t);
 		while($row = db_fetch_array($res)){
@@ -249,9 +254,9 @@
 		}
 		$v = array($b, $b);
 		$t = array('s', 's');
-		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde AS gem FROM gis.verwaltungseinheit ";
+		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde_neu AS gem FROM gemeinden ";
 		$sql .= "WHERE gemeinde_upper LIKE $1";
-		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM gis.wohnplatz ";
+		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM wohnplatz ";
 		$sql .= "WHERE gemeinde_gem_teile_upper LIKE $2) AS str";
 		$res = db_prep_query($sql,$v,$t);
 		while($row = db_fetch_array($res)){
@@ -265,21 +270,21 @@
 				
 				$v = array($ckeys[$i], $cmissing[$i]);
 				$t = array('i', 's');
-				$sql = "SELECT DISTINCT str_name_ewois, ";
+				$sql = "SELECT DISTINCT strassenname, ";
 				$sql .= "SRID(the_geom) AS srid, AsGML(the_geom) AS gml ,";
-				$sql .= "(xmin(the_geom) - ".$bufferSH.") as minx, ";
-				$sql .= "(ymin(the_geom) - ".$bufferSH.") as miny, ";
-				$sql .= "(xmax(the_geom) + ".$bufferSH.") as maxx, ";
-				$sql .= "(ymax(the_geom) + ".$bufferSH.") as maxy ";
-				$sql .= "FROM gis.strassenschluessel WHERE gem_schl = $1 ";
-				$sql .= " AND (str_name_ewois_upper LIKE $2)";
+				$sql .= "(xmin(the_geom) - ".$bufferSTR.") as minx, ";
+				$sql .= "(ymin(the_geom) - ".$bufferSTR.") as miny, ";
+				$sql .= "(xmax(the_geom) + ".$bufferSTR.") as maxx, ";
+				$sql .= "(ymax(the_geom) + ".$bufferSTR.") as maxy ";
+				$sql .= "FROM strassenschluessel WHERE gem_schl = $1 ";
+				$sql .= " AND (strassenname_upper LIKE $2)";
 				if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 					$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
 				}				
 				$res = db_prep_query($sql,$v,$t);
 				while($row = db_fetch_array($res)){
-					$show = encode($row["str_name_ewois"])."  ".$cnames[$i];
-					$e = new mb_notice('gaz_geom_mobile: street found: '.$row["str_name_ewois"]);
+					$show = encode($row["strassenname"])."  ".$cnames[$i];
+					$e = new mb_exception('gaz_geom_mobile: street found: '.$row["strassenname"]);
 					stack_it($arraySTR,"str",$show,"str",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
 				}
 			}
@@ -327,9 +332,9 @@
 		$a = "%".strtoupper(trim($o))."%";
 		$v = array($a, $a);
 		$t = array('s', 's');
-		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde AS gem FROM gis.verwaltungseinheit ";
+		$sql = "SELECT DISTINCT * FROM (SELECT DISTINCT gem_schl_neu, gemeinde_neu AS gem FROM gemeinden ";
 		$sql .= "WHERE gemeinde_upper LIKE $1";
-		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM gis.wohnplatz ";
+		$sql .= "UNION SELECT DISTINCT gem_schl_neu, gemeinde_gem_teile AS gem FROM wohnplatz ";
 		$sql .= "WHERE gemeinde_gem_teile_upper LIKE $2) AS str";
 		$res = db_prep_query($sql,$v,$t);
 		while($row = db_fetch_array($res)){
@@ -343,13 +348,13 @@
 				//$v = array($ckeys[$i], "%". strtoupper(trim($s)). "%");
 				$v = array($ckeys[$i], strtoupper(trim($s)). "%");
 				$t = array('i', 's');
-				$sql = "SELECT DISTINCT str_schl_alt ";
-				$sql .= "FROM gis.strassenschluessel WHERE gem_schl = $1 ";
-				$sql .= " AND str_name_ewois_upper ILIKE $2";
+				$sql = "SELECT DISTINCT strassenschluessel ";
+				$sql .= "FROM strassenschluessel WHERE gem_schl = $1 ";
+				$sql .= " AND strassenname_upper ILIKE $2";
 				$res = db_prep_query($sql,$v,$t);
 				while($row = db_fetch_array($res)){
-					array_push($str_schl, $row['str_schl_alt']);
-					$e = new mb_notice('gaz_geom_mobile: strassenschluessel: '.$row["str_schl_alt"].' for '.$s.' found' );	
+					array_push($str_schl, $row['strassenschluessel']);
+					$e = new mb_exception('gaz_geom_mobile: strassenschluessel: '.$row["strassenname"].' for '.$s.' found' );	
 					array_push($str_schl_gem, $cnames[$i]);
 				}
 			}
@@ -363,8 +368,8 @@
 				$sql .= "(ymin(the_geom) - ".$bufferSH.") as miny, ";
 				$sql .= "(xmax(the_geom) + ".$bufferSH.") as maxx, ";
 				$sql .= "(ymax(the_geom) + ".$bufferSH.") as maxy ";
-				$sql .= "FROM gis.hauskoordinaten ";
-				$sql .= "WHERE hausnummer = $1 AND strschl IN (";
+				$sql .= "FROM hauskoordinaten ";
+				$sql .= "WHERE hausnummer = $1 AND strschl_gesamt IN (";
 
 				for($i=0; $i<count($str_schl); $i++){	
 					if($i > 0){$sql .= ",";}
@@ -385,11 +390,11 @@
 				if($row["zusatz"] != 'null'){
 				#	$show .= $row["zusatz"];
 				
-$show = utf8_decode($row["name"])." ".$row["hausnummer"].$row["zusatz"];
+$show = $row["name"]." ".$row["hausnummer"].$row["zusatz"];
 //$show = $row["name"]." ".$row["hausnummer"].$row["zusatz"]; TODO: exchange this, when the hauskoordinaten table is delivered in a homogenous encoding! 
 }
 	else
-{$show = utf8_decode( $row["name"])." ".$row["hausnummer"];}	
+{$show =  $row["name"]." ".$row["hausnummer"];}	
 		$show .= ", " . $row["plz"]. " " . $row["post_ortsname"];
 			
 
@@ -407,7 +412,7 @@
 		$sql .= "(ymin(the_geom) - ".$bufferSH.") as miny, ";
 		$sql .= "(xmax(the_geom) + ".$bufferSH.") as maxx, ";
 		$sql .= "(ymax(the_geom) + ".$bufferSH.") as maxy ";
-		$sql .= "FROM gis.hauskoordinaten ";
+		$sql .= "FROM hauskoordinaten ";
 		$sql .= "WHERE name ILIKE $1 AND hausnummer = $2 ";
 		//$v = array("%".$s."%",$h);
 		$v = array($s."%",$h);
@@ -434,13 +439,13 @@
 		$res = db_prep_query($sql,$v,$t);
 		while($row = db_fetch_array($res)){
 			
-			$show = utf8_decode($row["name"])." ".$row["hausnummer"];
-			$e = new mb_notice('gaz_geom_mobile.php: streetname2: '.utf8_decode($row["name"]));
+			$show = $row["name"]." ".$row["hausnummer"];
+			$e = new mb_exception('gaz_geom_mobile.php: streetname2: '.$row["name"]);
 			//$show = $row["name"]." ".$row["hausnummer"]; TODO: see above
 			if($row["zusatz"] != null){
 				$show .= $row["zusatz"];	
 			}
-			$show .= ", " . $row["plz"]. " " . utf8_decode($row["post_ortsname"]); 
+			$show .= ", " . $row["plz"]. " " . $row["post_ortsname"]; 
 			stack_it($arraySH,"haus",$show,"sh",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
 		}
 	}
@@ -458,7 +463,7 @@
 	$sql .= "(ymin(the_geom) - ".$bufferWP.") as miny, ";
 	$sql .= "(xmax(the_geom) + ".$bufferWP.") as maxx, ";
 	$sql .= "(ymax(the_geom) + ".$bufferWP.") as maxy ";
-	$sql .= "FROM gis.wohnplatz WHERE ";
+	$sql .= "FROM wohnplatz WHERE ";
 	if($plz == false){
 		$sql .= "gemeinde_gem_teile_upper ILIKE $1 ";
 		array_push($v,"%".$name."%");
@@ -499,39 +504,39 @@
 	}
 	$v = array();
 	$t = array();
-	$sql = "SELECT DISTINCT gemeinde, ";
+	$sql = "SELECT DISTINCT gemeinde_neu, ";
 	$sql .= "SRID(the_geom) AS srid, AsGML(Simplify(the_geom,$toleranceG)) AS gml ,";
 	$sql .= "(xmin(the_geom) - ".$bufferG.") as minx, ";
 	$sql .= "(ymin(the_geom) - ".$bufferG.") as miny, ";
 	$sql .= "(xmax(the_geom) + ".$bufferG.") as maxx, ";
 	$sql .= "(ymax(the_geom) + ".$bufferG.") as maxy ";
-	$sql .= "FROM gis.verwaltungseinheit WHERE gem_schl_neu IN(";
+	$sql .= "FROM gemeinden WHERE gem_schl_neu IN(";
 	for($i=0; $i<count($arrayWPKey); $i++){
 		if($i > 0){$sql .= ",";}
 		$sql .= "$".($i+1);
 		array_push($v,$arrayWPKey[$i]);
 		array_push($t,'i');
 	}
-	$sql .= ") GROUP BY the_geom, gemeinde";
+	$sql .= ") GROUP BY the_geom, gemeinde_neu";
 	if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 		$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
 	}				
 	$res = db_prep_query($sql,$v,$t);
 	while($row = db_fetch_array($res)){
-		stack_it($arrayG,"gemeinde",encode($row["gemeinde"]." (Wohnplatz)"),"g",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
+		stack_it($arrayG,"gemeinde_neu",encode($row["gemeinde_neu"]." (Wohnplatz)"),"g",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
 	}
 }
 function checkG($str){
 	global $bufferG, $arrayG, $toleranceG, $arrayWPKey, $epsg;
 	checkMinLength($str);
 	$tmp = array();
-	$sql = "SELECT DISTINCT gemeinde, gem_schl_neu, ";
+	$sql = "SELECT DISTINCT gemeinde_neu, gem_schl_neu, ";
 	$sql .= "SRID(the_geom) AS srid, AsGML(Simplify(the_geom,$toleranceG)) AS gml ,";
 	$sql .= "(xmin(the_geom) - ".$bufferG.") as minx, ";
 	$sql .= "(ymin(the_geom) - ".$bufferG.") as miny, ";
 	$sql .= "(xmax(the_geom) + ".$bufferG.") as maxx, ";
 	$sql .= "(ymax(the_geom) + ".$bufferG.") as maxy ";
-	$sql .= "FROM gis.verwaltungseinheit WHERE gemeinde_upper ILIKE $1 ";
+	$sql .= "FROM gemeinden WHERE gemeinde_upper ILIKE $1 ";
 	#$sql .= "GROUP BY the_geom, gemeinde, gem_schl_neu";
 	if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 		$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
@@ -540,7 +545,7 @@
 	$t = array('s');
 	$res = db_prep_query($sql,$v,$t);
 	while($row = db_fetch_array($res)){
-		stack_it($arrayG,"gemeinde",encode($row["gemeinde"]." (Gemeinde)"),"g",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
+		stack_it($arrayG,"gemeinde_neu",encode($row["gemeinde_neu"]." (Gemeinde)"),"g",$row["srid"],$row["minx"],$row["miny"],$row["maxx"],$row["maxy"],$row["gml"]);
 		$tmp[count($tmp)] = $row["gem_schl_neu"]; 
 	}
 	$arrayWPKey = array_diff($arrayWPKey,$tmp);
@@ -555,7 +560,7 @@
 	$sql .= "(ymin(the_geom)-".$bufferK.") as miny, ";
 	$sql .= "(xmax(the_geom)+".$bufferK.") as maxx, ";
 	$sql .= "(ymax(the_geom)+".$bufferK.") as maxy ";
-	$sql .= "FROM gis.kreis_pl WHERE kreis_upper ILIKE $1 ";
+	$sql .= "FROM kreis_fl WHERE kreis_upper ILIKE $1 ";
 	if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 		$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
 	}				
@@ -575,7 +580,7 @@
 	$sql .= "(ymin(the_geom)-".$bufferV.") as miny, ";
 	$sql .= "(xmax(the_geom)+".$bufferV.") as maxx, ";
 	$sql .= "(ymax(the_geom)+".$bufferV.") as maxy ";
-	$sql .= "FROM gis.vg_fl WHERE vg ILIKE $1 ";
+	$sql .= "FROM vg_fl WHERE vg ILIKE $1 ";
 	if (isset($epsg) && is_numeric($epsg) && intval($epsg) != 31466) {
 		$sql = str_replace("the_geom", "transform(the_geom,".$epsg.")", $sql);
 	}				

Modified: trunk/mapbender/http/javascripts/mod_coordsLookup.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_coordsLookup.php	2012-04-27 12:20:58 UTC (rev 8337)
+++ trunk/mapbender/http/javascripts/mod_coordsLookup.php	2012-04-27 12:50:52 UTC (rev 8338)
@@ -92,11 +92,22 @@
 		this.perimeterSelectContainer  = $(document.createElement('p')).appendTo(this.formContainer);
 		this.triggerButtonContainer    = $(document.createElement('p')).appendTo(this.formContainer);
 //		Coordinates input with label
-		this.coordsInputLabel          = $(document.createElement('label')).attr({'for':'coord-x'}).text('<?php echo _mb("coordinates");?>:').appendTo(this.coordsInputContainer);
-		this.coordXInput               = $(document.createElement('input')).attr({'id':'coord-x','size':8}).appendTo(this.coordsInputContainer);
-		this.coordYInput               = $(document.createElement('input')).attr({'id':'coord-y','size':8}).appendTo(this.coordsInputContainer);
+		
+		this.coordsInputLabel          = $(document.createElement('label')).attr({'for':'coord-x'}).text('<?php echo _mb("east / longitude");?>: ').appendTo(this.coordsInputContainer);
 		$(this.coordsInputLabel).after($(document.createElement('br')));
-		$(this.coordXInput).after('&nbsp;/&nbsp;');
+		this.coordXInput               = $(document.createElement('input')).attr({'id':'coord-x','size':18 }).appendTo(this.coordsInputContainer);
+		$(this.coordXInput).after($(document.createElement('br')));
+
+		this.coordsInputLabel          = $(document.createElement('label')).attr({'for':'coord-y'}).text('<?php echo _mb("north / latitude");?>: ').appendTo(this.coordsInputContainer);
+		$(this.coordsInputLabel).after($(document.createElement('br')));
+		this.coordYInput               = $(document.createElement('input')).attr({'id':'coord-y','size':18}).appendTo(this.coordsInputContainer);
+		$(this.coordYInput).after($(document.createElement('br')));
+
+
+
+//		$(this.coordXInput).after('&nbsp;&nbsp;');
+//		$(this.coordYInput).after('&nbsp;&nbsp;');
+		
 //		Projection select
 		this.projectionSelect          = $(document.createElement('select')).attr({'id':'projection-select'}).appendTo(this.projectionSelectContainer);
 //		Perimeter select

Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js	2012-04-27 12:20:58 UTC (rev 8337)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js	2012-04-27 12:50:52 UTC (rev 8338)
@@ -21,7 +21,7 @@
 	this.getInitialFeaturetypeMetadata = function(metadataId, featuretypeId){
 		// get metadata from server
 		var req = new Mapbender.Ajax.Request({
-			url: "../plugins/mb_metadata_server.php",
+			url: "../plugins/mb_metadata_wfs_server.php",
 			method: "getInitialFeaturetypeMetadata",
 			parameters: {
 				"featuretypeId": featuretypeId,
@@ -64,7 +64,7 @@
 	this.getAddedMetadata = function(metadataId, featuretypeId){
 		// get metadata from server
 		var req = new Mapbender.Ajax.Request({
-			url: "../plugins/mb_metadata_server.php",
+			url: "../plugins/mb_metadata_wfs_server.php",
 			method: "getFeaturetypeMetadataAddon",
 			parameters: {
 				"featuretypeId": featuretypeId,
@@ -110,7 +110,7 @@
 	this.insertAddedMetadata = function(featuretypeId, data){
 		// push metadata from server
 		var req = new Mapbender.Ajax.Request({
-			url: "../plugins/mb_metadata_server.php",
+			url: "../plugins/mb_metadata_wfs_server.php",
 			method: "insertFeaturetypeMetadataAddon",
 			parameters: {
 				"featuretypeId": featuretypeId,
@@ -131,7 +131,7 @@
 	this.updateAddedMetadata = function(metadataId, featuretypeId, data){
 		// push metadata from server
 		var req = new Mapbender.Ajax.Request({
-			url: "../plugins/mb_metadata_server.php",
+			url: "../plugins/mb_metadata_wfs_server.php",
 			method: "updateFeaturetypeMetadataAddon",
 			parameters: {
 				"featuretypeId": featuretypeId,
@@ -155,7 +155,7 @@
 	this.fillFeaturetypeForm = function (featuretypeId) {
 		// get metadata from server
 		var req = new Mapbender.Ajax.Request({
-			url: "../plugins/mb_metadata_server.php",
+			url: "../plugins/mb_metadata_wfs_server.php",
 			method: "getFeaturetypeMetadata",
 			parameters: {
 				"id": featuretypeId
@@ -179,7 +179,7 @@
 	deleteAddedMetadata = function(metadataId, featuretypeId){
 		// push metadata from server
 		var req = new Mapbender.Ajax.Request({
-			url: "../plugins/mb_metadata_server.php",
+			url: "../plugins/mb_metadata_wfs_server.php",
 			method: "deleteFeaturetypeMetadataAddon",
 			parameters: {
 				"metadataId": metadataId

Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js	2012-04-27 12:20:58 UTC (rev 8337)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js	2012-04-27 12:50:52 UTC (rev 8338)
@@ -87,7 +87,7 @@
 	this.fillMdContact = function(obj) {
 		// get mdContact from server per fkey_mb_group_id
 		var req = new Mapbender.Ajax.Request({
-			url: "../plugins/mb_metadata_server.php",
+			url: "../plugins/mb_metadata_wfs_server.php",
 			method: "getContactMetadata",
 			parameters: {
 				"id": obj

Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_server.php	2012-04-27 12:20:58 UTC (rev 8337)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_server.php	2012-04-27 12:50:52 UTC (rev 8338)
@@ -261,10 +261,38 @@
 		while ($row = db_fetch_assoc($res)) {
 			$resultObj["featuretype_keyword"][]= $row["keyword"];
 		}
+		//get MetadataURLs from md_metadata table
+		$sql = <<<SQL
+SELECT metadata_id, uuid, link, linktype, md_format, origin FROM mb_metadata 
+INNER JOIN (SELECT * from ows_relation_metadata 
+WHERE fkey_featuretype_id = $featuretypeId ) as relation ON 
+mb_metadata.metadata_id = relation.fkey_metadata_id WHERE mb_metadata.origin IN ('capabilities','external','metador','upload')
+SQL;
+		$res = db_query($sql);
+		$resultObj["md_metadata"]->metadata_id = array();
+		$resultObj["md_metadata"]->uuid = array();
+		$resultObj["md_metadata"]->origin = array();
+		$resultObj["md_metadata"]->linktype = array();
+		$resultObj["md_metadata"]->link = array();
+		$i = 0;
+		while ($row = db_fetch_assoc($res)) {
+			$resultObj["md_metadata"]->metadata_id[$i]= $row["metadata_id"];
+			$resultObj["md_metadata"]->link[$i]= $row["link"];
+			$resultObj["md_metadata"]->uuid[$i]= $row["uuid"];
+			$resultObj["md_metadata"]->origin[$i]= $row["origin"];
+			$resultObj["md_metadata"]->linktype[$i]= $row["linktype"];
+			$i++;
+		}
 
+
+
+
+
+
 		$ajaxResponse->setResult($resultObj);
 		$ajaxResponse->setSuccess(true);
 		break;
+
 	case "getFeaturetypeByWfs" :
 		$wfsId = $ajaxResponse->getParameter("id");
 //		getWms($wmsId);
@@ -293,8 +321,8 @@
 			return array(
 				"left" => $left,
 				"right" => $right,
-				#"parent" => $row["layer_parent"] !== "" ? intval($row["layer_parent"]) : null,
-				#"pos" => intval($row["layer_pos"]),
+				#"parent" => $row["featuretype_parent"] !== "" ? intval($row["featuretype_parent"]) : null,
+				#"pos" => intval($row["featuretype_pos"]),
 				"attr" => array (
 					"featuretype_id" => intval($row["featuretype_id"]),
 					"featuretype_name" => $row["featuretype_name"],
@@ -340,6 +368,595 @@
 		$ajaxResponse->setSuccess(true);
 		
 		break;
+
+	case "getFeaturetypeMetadataAddon" :
+		$featuretypeId = $ajaxResponse->getParameter("featuretypeId");
+		$metadataId = $ajaxResponse->getParameter("metadataId");
+		$sql = <<<SQL
+
+SELECT * from mb_metadata where metadata_id = $1
+
+SQL;
+		$v = array($metadataId);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$row = array();
+		if ($res) {
+			$row = db_fetch_assoc($res);
+			$resultObj["metadata_id"]= $row['metadata_id']; //serial
+			$resultObj["uuid"] = $row["uuid"]; //char
+			$resultObj["origin"] = $row["origin"]; //char
+			$resultObj["link"] = $row["link"]; //char
+			$resultObj["linktype"] = $row["linktype"]; //char
+			$resultObj["title"] = $row["title"]; //char -- prefill from featuretype
+			$resultObj["abstract"] = $row["abstract"]; //char - prefill from featuretype
+			$resultObj["format"] = $row["format"]; //char
+			$resultObj["ref_system"] = $row["ref_system"]; //char
+			$resultObj["spatial_res_type"] = $row["spatial_res_type"]; //integer
+			$resultObj["spatial_res_value"] = $row["spatial_res_value"]; //char
+			$resultObj["inspire_charset"] = $row["inspire_charset"]; //char
+			$resultObj["lineage"] = $row["lineage"]; //text
+			$resultObj["tmp_reference_1"] = $row["tmp_reference_1"]; //text
+			$resultObj["tmp_reference_2"] = $row["tmp_reference_2"]; //text
+			$export2csw = $row["export2csw"]; //boolean
+			$resultObj["update_frequency"] = $row["update_frequency"]; //text
+			switch ($export2csw) {
+				case "t" :
+					$resultObj["export2csw"] = true;
+					break;
+				case "f" :
+					$resultObj["export2csw"] = false;
+					break;
+				default:
+				break;	
+			}
+			$inspire_top_consistence = $row["inspire_top_consistence"]; //boolean
+			switch ($inspire_top_consistence) {
+				case "t" :
+					$resultObj["inspire_top_consistence"] = true;
+					break;
+				case "f" :
+					$resultObj["inspire_top_consistence"] = false;
+					break;
+				default:
+				break;	
+			}					
+			
+		}
+		$ajaxResponse->setResult($resultObj);
+		$ajaxResponse->setSuccess(true);
+		break;
+
+	case "getInitialFeaturetypeMetadata" :
+		$featuretypeId = $ajaxResponse->getParameter("featuretypeId");
+		$metadataId = $ajaxResponse->getParameter("metadataId");
+		$sql = <<<SQL
+
+SELECT featuretype_title, featuretype_abstract from wfs_featuretype where featuretype_id = $1
+
+SQL;
+		$v = array($featuretypeId);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$row = array();
+		if ($res) {
+			$row = db_fetch_assoc($res);
+			$resultObj["title"]= $row['featuretype_title']; //serial
+			$resultObj["abstract"] = $row["featuretype_abstract"]; //char	
+		}
+		$ajaxResponse->setResult($resultObj);
+		$ajaxResponse->setSuccess(true);
+		break;
+
+	case "updateFeaturetypeMetadataAddon" :
+		$featuretypeId = $ajaxResponse->getParameter("featuretypeId");
+		$metadataId = $ajaxResponse->getParameter("metadataId");
+		$data = $ajaxResponse->getParameter("data");
+		if ($data->export2csw) {
+			$data->export2csw = 't';
+		} else {
+			$data->export2csw = 'f';
+		}
+		if ($data->inspire_top_consistence) {
+			$data->inspire_top_consistence = 't';
+		} else {
+			$data->inspire_top_consistence = 'f';
+		}
+		$sql = <<<SQL
+
+UPDATE mb_metadata SET link = $2, title = $3, abstract = $4, format = $5, ref_system = $6, export2csw = $7, inspire_top_consistence = $8, tmp_reference_1 = $9, tmp_reference_2 = $10, lineage = $11, spatial_res_type = $12, spatial_res_value = $13, inspire_charset = $14, changedate = now(), update_frequency = $15 WHERE metadata_id = $1
+
+SQL;
+		$v = array($metadataId, $data->link, $data->title, $data->abstract, $data->format, $data->ref_system, $data->export2csw, $data->inspire_top_consistence, $data->tmp_reference_1, $data->tmp_reference_2, $data->lineage, $data->spatial_res_type, $data->spatial_res_value, $data->inspire_charset, $data->update_frequency);
+		$t = array('i','s','s','s','s','s','b','b','s','s','s','s','s','s','s');
+		try {
+			$res = db_prep_query($sql,$v,$t);
+		}
+		catch (Exception $e){
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage(_mb("Could not update metadata object in database!"));
+			$ajaxResponse->send();
+			die;	
+		}
+		$ajaxResponse->setMessage("Metadata updated!");
+		$ajaxResponse->setSuccess(true);
+		break;
+	case "insertFeaturetypeMetadataAddon" :
+		$featuretypeId = $ajaxResponse->getParameter("featuretypeId");
+		$data = $ajaxResponse->getParameter("data");
+		//normaly the link is only set if a link has been created
+		//if a record has been created, the link element will be empty 
+		//use this to distinguish between the to different inserts!
+		//this insert should also push one entry in the ows_relation_metadata table! - after the insert into md_metadata
+		//origin
+		if ($data->kindOfMetadataAddOn == 'link') {
+			//generate metador entry
+			$origin = 'external';
+		} else {
+			$origin = 'metador';
+		}
+		//export
+		if ($data->export2csw == "on") {
+			$data->export2csw = 't';
+		} else {
+			$data->export2csw = 'f';
+		}
+		//consistance
+		if ($data->inspire_top_consistence == "on") {
+			$data->inspire_top_consistence = 't';
+		} else {
+			$data->inspire_top_consistence = 'f';
+		}
+		//generate a uuid for the record:
+		$uuid = new Uuid();
+		//initialize database objects
+		$link = '';
+		$title = '';
+		$abstract = '';
+		$format = '';	
+		$ref_system = '';
+		$export2csw = 'f';
+		$inspire_top_consistence = 'f';
+		$tmp_reference_1 = '';
+		$tmp_reference_2 = '';
+		$lineage = '';
+		$spatial_res_type = '';
+		$spatial_res_value = '';
+		$inspire_charset = '';
+		$update_frequency = '';
+		//read out json objects 
+		if (isset($data->link)) {
+			$link = $data->link;
+		}
+		if (isset($data->export2csw)) {
+			$export2csw = $data->export2csw;
+		} else {
+			$export2csw = 'f';
+		}
+		if (isset($data->title)) {
+			$title = $data->title;
+		}
+		if (isset($data->abstract)) {
+			$abstract = $data->abstract;
+		}
+		if (isset($data->format)) {
+			$format = $data->format;
+		}
+		if (isset($data->ref_system)) {
+			$ref_system = $data->ref_system;
+		}
+		if (isset($data->inspire_top_consistence)) {
+			$inspire_top_consistence = $data->inspire_top_consistence;
+		}
+		if (isset($data->tmp_reference_1)) {
+			$tmp_reference_1 = $data->tmp_reference_1;
+		}
+		if ($tmp_reference_1 == "") {
+			$tmp_reference_1 = "2000-01-01";
+		}
+		if (isset($data->tmp_reference_2)) {
+			$tmp_reference_2 = $data->tmp_reference_2;
+		}
+		if ($tmp_reference_2 == "") {
+			$tmp_reference_2 = "2000-01-01";
+		}
+		if (isset($data->lineage)) {
+			$lineage = $data->lineage;
+		}
+		if (isset($data->spatial_res_type)) {
+			$spatial_res_type = $data->spatial_res_type;
+		}
+		if (isset($data->spatial_res_value)) {
+			$spatial_res_value = $data->spatial_res_value;
+		}
+		if (isset($data->inspire_charset)) {
+			$inspire_charset = $data->inspire_charset;
+		}
+		if (isset($data->update_frequency)) {
+			$update_frequency = $data->update_frequency;
+		}
+		$randomid = new Uuid();
+		//Check if origin is external and export2csw is activated!
+		if ($origin == 'external' ) {
+			//harvest link from location, parse the content for datasetid and push xml into data column
+			//load metadata from link TODO: function from class_wms - generate a class for metadata management and include it here and in class_wms
+			$metadataConnector = new connector();
+			$metadataConnector->set("timeOut", "5");
+			$metaData = $metadataConnector->load($link);
+			//$e = new mb_exception($metaData);
+			if (!$metaData) {
+    				abort(_mb("Could not load metadata from source url!"));
+			}
+			//delete getRecordByIdResponse from xml if there
+			$regex = "#<csw:GetRecordByIdResponse .*?>#";
+			$output = preg_replace($regex,"",$metaData);
+			$regex = "#</csw:GetRecordByIdResponse>#";
+			$output = preg_replace($regex,"",$output);
+			//$e = new mb_exception($output);
+			$metaData = $output;
+			//***
+			//write metadata to temporary file:
+			$randomFileId = new Uuid();
+				
+			$tmpMetadataFile = fopen(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml', 'w');
+			fwrite($tmpMetadataFile, $metaData);
+			fclose($tmpMetadataFile);
+			$e = new mb_exception("File which has been written: link_metadata_file_".$randomFileId.".xml");
+			//read out objects from xml structure
+			if (file_exists(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml')) {
+				$iso19139Xml=simplexml_load_file(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml');
+				//$metaData = file_get_contents(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml');
+			} else {
+				abort(_mb("Temporary file could not be parsed!"));
+			}
+			//$metaData = $metadataConnector->file;
+			//parse metadata
+			/*try {
+				$iso19139Xml =  new SimpleXMLElement($metaData);
+			}
+			catch (Exception $e) {
+				abort(_mb("Parsing ISO19139 XML failed!"));
+			}*/
+			if ($iso19139Xml != false) {
+				//get elements for database from xml by using xpath
+				//uuid
+				$uuid = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString');
+				$e = new mb_exception("plugins/mb_metadata_server.php: File Identifier found: ".$uuid);
+				//createdate
+				$createdate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
+				//changedate
+				$changedate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
+				//TODO: check if this is set, maybe DateTime must be searched instead?
+				//title
+				$title = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+				//datasetid
+				//next came from class_wms - TODO maybe put it into a special function
+				//dataset identifier - howto model into md_metadata?
+				//check where datasetid is defined - maybe as RS_Identifier or as MD_Identifier see http://inspire.jrc.ec.europa.eu/documents/Metadata/INSPIRE_MD_IR_and_ISO_v1_2_20100616.pdf page 18
+				//First check if MD_Identifier is set, then check if RS_Identifier is used!
+				//Initialize datasetid
+				$datasetid = 'undefined';
+				$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString');
+				if (isset($code[0]) && $code[0] != '') {
+					$e = new mb_exception("plugins/mb_metadata_server.php: code given thru MD_Identifier: ".$code[0]);
+					//check if code is defined by codespace and code
+					$codeSplit = explode("#",$code);
+					if (isset($codeSplit[0]) && $codeSplit[0] != '' && isset($codeSplit[1]) && $codeSplit[1] != '') {
+						$e = new mb_exception("plugins/mb_metadata_server.php: code was constructed via codespace#code !");	
+						$datasetid = $codeSplit[0]."#".$codeSplit[1];
+					} else {
+						$e = new mb_exception("plugins/mb_metadata_server.php: code was not constructed via codespace#code !");	
+						$datasetid = $code[0];
+					}
+				} else { //try to read code from RS_Identifier 		
+					$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
+					$codeSpace = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString');
+				#$e = new mb_exception("plugins/mb_metadata_server.php: code: ".$code[0]);
+				#$e = new mb_exception("plugins/mb_metadata_server.php: codeSpace: ".$codeSpace[0]);
+					if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
+						$datasetid = $codeSpace[0]."#".$code[0];
+						$e = new mb_exception("plugins/mb_metadata_server.php: datasetid: ".$datasetid);
+					} else {
+						//neither MD_Identifier nor RS_Identifier are defined in a right way
+						$e = new mb_exception("plugins/mb_metadata_server.php: the service data coupling has problems, cause the metadata doesnt have defined a datasetid");
+					}
+				}
+				//abstract
+				$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
+				//searchtext -- use keywords!
+				$keywords = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/gco:CharacterString');
+				//type 
+				$type = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
+				//tmp_reference_1
+				$tmp_reference_1 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition');
+				//tmp_reference_2
+				$tmp_reference_2 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');		//spatial_res_type
+				//spatial_res_value
+				//ref_system
+				//format
+				//inspire_charset
+				//inspire_top_consistence
+				//responsible_party
+				//fees
+				//"constraints"	
+				//fill database with elements:
+
+				$sql = <<<SQL
+
+INSERT INTO mb_metadata (link, uuid, origin, title, abstract, format, ref_system, export2csw, inspire_top_consistence, tmp_reference_1, tmp_reference_2, lineage, spatial_res_type, spatial_res_value, inspire_charset, createdate, datasetid, randomid, data, harvestresult) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, now(), $16, $17, $18, 1)
+
+SQL;
+				$v = array($link, $uuid[0], $origin, $title[0], $abstract[0], $format, $ref_system, $export2csw,$inspire_top_consistence,$tmp_reference_1[0],$tmp_reference_2[0],$lineage,$spatial_res_type,$spatial_res_value,$inspire_charset, $datasetid, $randomid, $metaData);
+				$t = array('s','s','s','s','s','s','s','b','b','s','s','s','s','s','s','s','s','s');
+		
+				try {
+					$res = db_prep_query($sql,$v,$t);
+				}
+				catch (Exception $e){
+					abort(_mb("Insert of harvested metadata into database failed!"));
+				}
+			
+			} else {
+				abort(_mb("Problem with parsing the XML structure with SimpleXML! Record was not inserted into database! Ask your administrator."));
+				//give back error message - cause parsing has problems
+			}
+		} else { //fill only links or the edited information into db 
+			$sql = <<<SQL
+
+INSERT INTO mb_metadata (link, uuid, origin, title, abstract, format, ref_system, export2csw, inspire_top_consistence, tmp_reference_1, tmp_reference_2, lineage, spatial_res_type, spatial_res_value, inspire_charset, createdate, randomid, update_frequency) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, now(), $16, $17)
+
+SQL;
+			$v = array($link, $uuid, $origin, $title, $abstract, $format, $ref_system, $export2csw,$inspire_top_consistence,$tmp_reference_1,$tmp_reference_2,$lineage,$spatial_res_type,$spatial_res_value,$inspire_charset, $randomid, $update_frequency);
+			$t = array('s','s','s','s','s','s','s','b','b','s','s','s','s','s','s','s','s');
+		
+			try {
+				$res = db_prep_query($sql,$v,$t);
+			}
+			catch (Exception $e){
+				abort(_mb("Insert of edited metadata into database failed!"));
+			}
+		}
+		//set relation into relation table
+		//get metadata_id of record which have been inserted before
+		$sql = <<<SQL
+
+SELECT metadata_id FROM mb_metadata WHERE randomid = $1
+
+SQL;
+		//maybe there are more than one results - which should be used??? case of creating new linkage with old metadata TODO TODO
+		$v = array($randomid);
+		$t = array('s');
+		try {
+			$res = db_prep_query($sql,$v,$t);
+		}
+		catch (Exception $e){
+			abort(_mb("Cannot get metadata record with following uuid from database: ".$uuid));
+		}
+		if ($res) {
+			$row = db_fetch_assoc($res);
+			$metadata_id = $row['metadata_id'];
+		}
+		$sql = <<<SQL
+
+		INSERT INTO ows_relation_metadata (fkey_metadata_id, fkey_featuretype_id) VALUES ($1, $2)
+
+SQL;
+		$v = array($metadata_id, $featuretypeId);
+		$t = array('i','i');
+		try {
+			$res = db_prep_query($sql,$v,$t);
+		}
+		catch (Exception $e){
+				abort(_mb("Cannot write relation between ows and metadata to database!"));
+		}
+		if ($dbInsertFailed != true) {	
+			$ajaxResponse->setMessage("Metadata object inserted into md_metadata!");
+			$ajaxResponse->setSuccess(true);
+		}				
+		break;
+	case "deleteFeaturetypeMetadataAddon" :
+		$metadataId = $ajaxResponse->getParameter("metadataId");
+		$sql = <<<SQL
+
+DELETE FROM mb_metadata WHERE metadata_id = $1
+
+SQL;
+		$v = array($metadataId);
+		$t = array('i');
+		try {
+			$res = db_prep_query($sql,$v,$t);
+		}
+		catch (Exception $e){
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage(_mb("Could not delete metadata from database!"));
+			$ajaxResponse->send();
+			die;	
+		}
+		$ajaxResponse->setMessage("Metadata deleted!");
+		$ajaxResponse->setSuccess(true);
+		break;
+	case "importFeaturetypeXmlAddon" :
+//this is similar to insert the metadata from external link, but came from internal file from tmp folder which has been updated before
+		$featuretypeId = $ajaxResponse->getParameter("featuretypeId");
+		$filename = $ajaxResponse->getParameter("filename");
+		//normaly the link is only set if a link has been created
+		//if a record has been created, the link element will be empty 
+		//use this to distinguish between the to different inserts!
+		//this insert should also push one entry in the ows_relation_metadata table! - after the insert into md_metadata
+		//origin
+		//generate metador entry
+		$origin = 'upload';
+		//generate a uuid for the record:
+		$uuid = new Uuid();
+		//initialize database objects
+		$link = '';
+		$title = '';
+		$abstract = '';
+		$format = '';	
+		$ref_system = '';
+		$export2csw = 't';
+		$inspire_top_consistence = 'f';
+		$tmp_reference_1 = '';
+		$tmp_reference_2 = '';
+		$lineage = '';
+		$spatial_res_type = '';
+		$spatial_res_value = '';
+		$inspire_charset = '';
+		$randomid = new Uuid();	
+		$e = new mb_exception("File to load: ".$filename);
+		//read out objects from xml structure
+		/*if (file_exists($filename)) {
+			try {	
+				
+				$iso19139Xml = simplexml_load_file($filename);
+			}
+			catch (Exception $e) {
+				abort(_mb("Loading ISO19139 XML failed!"));
+			}
+		}
+		else {
+			abort(_mb("File not found: ".$filename." !"));
+		}*/
+		$metaData = file_get_contents($filename);
+		if (!$metaData){
+			abort(_mb("Reading file ".$filename." failed!"));
+		}
+		//delete getRecordByIdResponse from xml if there
+		$regex = "#<csw:GetRecordByIdResponse .*?>#";
+		$output = preg_replace($regex,"",$metaData);
+		$regex = "#</csw:GetRecordByIdResponse>#";
+		$output = preg_replace($regex,"",$output);
+		//$e = new mb_exception($output);
+		$iso19139Xml = simplexml_load_string($output);
+		$e = new mb_exception('');
+		
+		//get elements for database from xml by using xpath
+		//uuid
+		$uuid = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString');
+		if (!isset($uuid) || $uuid == "") {
+			abort(_mb(" No fileIdentifier found, parsing ISO19139 XML maybe failed. Check if element /gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString is given and not empty!"));
+		}
+		//$e = new mb_exception("plugins/mb_metadata_server.php: File Identifier found: ".$uuid);
+		//createdate
+		$createdate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
+		//changedate
+		$changedate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
+		//TODO: check if this is set, maybe DateTime must be searched instead?
+		//title
+		$title = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+		//next came from class_wms - TODO maybe put it into a special function
+		//dataset identifier - howto model into md_metadata?
+		//check where datasetid is defined - maybe as RS_Identifier or as MD_Identifier see http://inspire.jrc.ec.europa.eu/documents/Metadata/INSPIRE_MD_IR_and_ISO_v1_2_20100616.pdf page 18
+		//First check if MD_Identifier is set, then check if RS_Identifier is used!
+		//Initialize datasetid
+		$datasetid = 'undefined';
+		$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString');
+		if (isset($code[0]) && $code[0] != '') {
+			$e = new mb_exception("plugins/mb_metadata_server.php: code given thru MD_Identifier: ".$code[0]);
+			//check if code is defined by codespace and code
+			$codeSplit = explode("#",$code);
+			if (isset($codeSplit[0]) && $codeSplit[0] != '' && isset($codeSplit[1]) && $codeSplit[1] != '') {
+				$e = new mb_exception("plugins/mb_metadata_server.php: code was constructed via codespace#code !");	
+				$datasetid = $codeSplit[0]."#".$codeSplit[1];
+			} else {
+				$e = new mb_exception("plugins/mb_metadata_server.php: code was not constructed via codespace#code !");	
+				$datasetid = $code;
+			}
+		} else { //try to read code from RS_Identifier 		
+			$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
+			$codeSpace = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString');
+		#$e = new mb_exception("plugins/mb_metadata_server.php: code: ".$code[0]);
+		#$e = new mb_exception("plugins/mb_metadata_server.php: codeSpace: ".$codeSpace[0]);
+			if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
+				$datasetid = $codeSpace[0]."#".$code[0];
+				$e = new mb_exception("plugins/mb_metadata_server.php: datasetid: ".$datasetid);
+			} else {
+				//neither MD_Identifier nor RS_Identifier are defined in a right way
+				$e = new mb_exception("plugins/mb_metadata_server.php: the service data coupling has problems, cause the metadata doesnt have defined a datasetid");
+			}
+		}
+
+
+		//abstract
+		$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
+		//searchtext -- use keywords!
+		$keywords = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/gco:CharacterString');
+		//type 
+		$type = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
+		//tmp_reference_1
+		$tmp_reference_1 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition');
+		//tmp_reference_2
+		$tmp_reference_2 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');	//spatial_res_type
+		//spatial_res_value
+		//ref_system
+		//format
+		//inspire_charset
+		//inspire_top_consistence
+		//responsible_party
+		//fees
+		//"constraints"	
+		//fill database with elements:
+		$sql = <<<SQL
+
+INSERT INTO mb_metadata (link, uuid, origin, title, abstract, format, ref_system, export2csw, inspire_top_consistence, tmp_reference_1, tmp_reference_2, lineage, spatial_res_type, spatial_res_value, inspire_charset, createdate, datasetid, randomid, data, harvestresult) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, now(), $16, $17, $18, 1)
+
+			
+SQL;
+			
+		$xml = $iso19139Xml->asXML();
+		$v = array($link, $uuid[0], $origin, $title[0], $abstract[0], $format, $ref_system, $export2csw,$inspire_top_consistence,$tmp_reference_1[0],$tmp_reference_2[0],$lineage,$spatial_res_type,$spatial_res_value,$inspire_charset, $datasetid, $randomid, $xml);
+		$t = array('s','s','s','s','s','s','s','b','b','s','s','s','s','s','s','s','s','s');
+		
+		try {
+				$res = db_prep_query($sql,$v,$t);
+		}
+		catch (Exception $e){
+			abort(_mb("Insert of harvested metadata into database failed!"));
+		}
+	//set relation into relation table
+	//get metadata_id of record which have been inserted before
+	$sql = <<<SQL
+
+SELECT metadata_id FROM mb_metadata WHERE randomid = $1
+
+SQL;
+	//maybe there are more than one results - which should be used??? case of creating new linkage with old metadata TODO TODO
+	$v = array($randomid);
+	$t = array('s');
+	try {
+		$res = db_prep_query($sql,$v,$t);
+	}
+	catch (Exception $e){
+		abort(_mb("Cannot get metadata record with following uuid from database: ".$uuid));
+	}
+	if ($res) {
+		$row = db_fetch_assoc($res);
+		$metadata_id = $row['metadata_id'];
+	}
+	$sql = <<<SQL
+
+	INSERT INTO ows_relation_metadata (fkey_metadata_id, fkey_featuretype_id) VALUES ($1, $2)
+
+SQL;
+	$v = array($metadata_id, $featuretypeId);
+	$t = array('i','i');
+	try {
+		$res = db_prep_query($sql,$v,$t);
+	}
+	catch (Exception $e){
+			abort(_mb("Cannot write relation between ows and metadata to database!"));
+	}
+	if ($dbInsertFailed != true) {	
+		$ajaxResponse->setMessage("Metadata object inserted into md_metadata!");
+		$ajaxResponse->setSuccess(true);
+	}				
+	break;		
+
+
+
+
+
+
 	case "save":
 		$data = $ajaxResponse->getParameter("data");
 		

Modified: trunk/mapbender/http/plugins/mb_wms_scheduler_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_wms_scheduler_server.php	2012-04-27 12:20:58 UTC (rev 8337)
+++ trunk/mapbender/http/plugins/mb_wms_scheduler_server.php	2012-04-27 12:50:52 UTC (rev 8338)
@@ -212,14 +212,36 @@
 			
 	case "getUserWms" :
 		$user = new User(Mapbender::session()->get("mb_user_id"));
-	    $wmsIdArray = $user->getOwnedWms();
-	    $wmsList = implode(",", $wmsIdArray);
+		$wmsSchedulerIdArray = getWmsScheduler();		
+		$wmsSchedulerList = implode(",", $wmsSchedulerIdArray);
+
+	    	$wmsIdArray = $user->getOwnedWms();
+	    	//$wmsList = implode(",", $wmsIdArray);
 		
+
 $sql = <<<SQL
+
+	SELECT fkey_wms_id FROM scheduler WHERE scheduler.scheduler_id IN ($wmsSchedulerList);
+
+SQL;
+		$res = db_query($sql);
+		$resultObj = array();
+		while ($row = db_fetch_array($res)) {
+			$resultObj[] = $row['fkey_wms_id'];
+			$e = new mb_exception($wmsList);
+    	    	}
+		//remove already scheduled elements from wms list
+		$wmsIdArray = array_diff($wmsIdArray,$resultObj);
+		$wmsList = implode(",", $wmsIdArray);
+
+		$e = new mb_exception($wmsList);
+		$e = new mb_exception($wmsSchedulerList);
+
+$sql = <<<SQL
 	
 SELECT wms.wms_id, wms.wms_title FROM wms LEFT JOIN mb_wms_availability AS m
 ON wms.wms_id = m.fkey_wms_id 
-WHERE wms_id IN ($wmsList) ORDER BY wms.wms_id;
+WHERE wms_id IN ($wmsList)  ORDER BY wms.wms_id;
 
 SQL;
 		$res = db_query($sql);
@@ -228,7 +250,7 @@
 			$resultObj[] = array(
     			"wmsId" 	=> $row['wms_id'],
     			"wmsTitle"  =>  $row['wms_title']
-    	    );
+    	    	);
 		}
         $ajaxResponse->setResult($resultObj);
 		$ajaxResponse->setSuccess(true);



More information about the Mapbender_commits mailing list