[Mapbender-commits] r7977 - branches/2.7/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 19 09:21:23 EDT 2011


Author: astrid_emde
Date: 2011-07-19 06:21:23 -0700 (Tue, 19 Jul 2011)
New Revision: 7977

Added:
   branches/2.7/http/plugins/mb_metadata_addon.php
   branches/2.7/http/plugins/mb_metadata_showMetadataAddon.js
   branches/2.7/http/plugins/mb_metadata_xml_import.js
Modified:
   branches/2.7/http/plugins/mb_metadata_layer.js
   branches/2.7/http/plugins/mb_metadata_layer.php
   branches/2.7/http/plugins/mb_metadata_server.php
Log:
merged

Copied: branches/2.7/http/plugins/mb_metadata_addon.php (from rev 7962, trunk/mapbender/http/plugins/mb_metadata_addon.php)
===================================================================
--- branches/2.7/http/plugins/mb_metadata_addon.php	                        (rev 0)
+++ branches/2.7/http/plugins/mb_metadata_addon.php	2011-07-19 13:21:23 UTC (rev 7977)
@@ -0,0 +1,128 @@
+<?php
+	require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+?>
+<fieldset class="ui-widget" id="metadataUrlEditor" name="metadataUrlEditor" type="hidden" style="display: none">
+<input name="kindOfMetadataAddOn" id="kindOfMetadataAddOn" type="hidden" value="" />
+	<fieldset id="addonChooser" name="addonChooser" style="display: none">
+		<legend><?php echo _mb("Choose kind of coupled metadata");?></legend>
+		<p>
+			<table><tr><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage' onclick='$("#addonChooser").css("display","none");$("#link_editor").css("display","block");$("#kindOfMetadataAddOn").attr("value","link");' /></td><td><?php echo _mb("Add URL to existing Metadataset");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Here someone can add a url to an existing metadata record, which is available over www. The record can either be harvested and pushed to the own catalogue service or it is only used as a link. This links are pushed into the service metadata record and the new capabilities document.");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
+			<tr><td><img src='../img/gnome/edit-select-all.png' title='metadata'  onclick='$("#addonChooser").css("display","none");$("#simple_metadata_editor").css("display","block");$("#kindOfMetadataAddOn").attr("value","metadataset");' /></td><td><?php echo _mb("Add a simple metadata record which is mostly generated from given layer information");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("With this option someone can generate a very simple metadata record for the data which is distributed thru the wms layer. The record fulfills only the INSPIRE Metadata Regulation! Most of the needed data is pulled from the service, layer and group information of the owner of the service. The metadate will be created on the fly. It is not stored in the database!");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
+			<tr><td><img src='../img/button_blue_red/up.png' id='uploadImage' title='upload' /></td><td><?php echo _mb("Add a simple metadata record from a local file");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("With this option someone can upload an existing metadata record and couple it to the layer. The uploaded data is pushed to the catalogue and will be available for searching. The uploaded data is not fully controlled and validated. It cannot be edited but must be replaced with a new record if needed!");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
+			</table>
+		</p>
+	</fieldset>
+	<!--fieldset for save link form-->
+	<fieldset id="link_editor" name="link_editor" type="hidden" style="display: none">
+		<legend><?php echo _mb("Link Editor");?></legend>
+		<input name="link" id="link" />
+		<p>
+			<label for="export2csw"><?php echo _mb("Harvest link target and export to CSW");?></label>
+      			<input name="export2csw" id="export2csw" type="checkbox" checked="checked"/>
+		</p>
+		
+	</fieldset>
+	<!--fieldset for upload metadata form-->
+	<fieldset id="metadata_upload" name="metadata_upload" type="hidden" style="display: none">
+		<legend><?php echo _mb("Metadata upload");?></legend>
+		<input name="metadatafile" id="metadatafile" type="file"/>
+	</fieldset>
+	<!--fieldset for metadata form-->
+	<fieldset id="simple_metadata_editor" name="simple_metadata_editor" type="hidden"  style="display: none">
+		<legend><?php echo _mb("Simple metadata editor");?></legend>
+		<fieldset>
+			<legend><?php echo _mb("Resource title");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This a characteristic, and often unique, name by which the resource is known.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<input class="required" name="title" id="title"/>
+		</fieldset>
+		<fieldset>
+			<legend><?php echo _mb("Resource abstract");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This is a brief narrative summary of the content of the resource.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<input class="required" name="abstract" id="abstract"/>
+		</fieldset>
+		<fieldset>
+			<legend><?php echo _mb("Lineage");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This is a statement on process history and/or overall quality of the spatial data set. Where appropriate it may include a statement whether the data set has been validated or quality assured, whether it is the official version (if multiple versions exist), and whether it has legal validity. The value domain of this metadata element is free text.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<input class="required" name="lineage" id="lineage"/>
+		</fieldset>
+	<fieldset id="tempref" name="tempref">
+		<legend><?php echo _mb("TEMPORAL REFERENCE");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This metadata element addresses the requirement to have information on the temporal dimension of the data as referred to in Article 8(2)(d) of Directive 2007/2/EC. At least one of the metadata elements referred to in points 5.1 to 5.4 shall be provided. The value domain of the metadata elements referred to in points 5.1 to 5.4 is a set of dates. Each date shall refer to a temporal reference system and shall be expressed in a form compatible with that system. The default reference system shall be the Gregorian calendar, with dates expressed in accordance with ISO 8601.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<fieldset id="timespan" name="timespan">
+			<legend><?php echo _mb("Temporal extent");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("The temporal extent defines the time period covered by the content of the resource. This time period may be expressed as any of the following: - an individual date, - an interval of dates expressed through the starting date and end date of the interval, - a mix of individual dates and intervals of dates.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+				<label for=""><?php echo _mb("from");?>:</label>
+				<input class="required hasdatepicker" name="tmp_reference_1" id="tmp_reference_1"/>
+				<label for=""><?php echo _mb("to");?>:</label>
+				<input class="required hasdatepicker" name="tmp_reference_2" id="tmp_reference_2"/>
+		</fieldset>
+		<fieldset id="cyclicupdate" name="cyclicupdate">
+			<legend><?php echo _mb("Maintenance and update frequency");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Frequency with which changes and additions are made to the resource after the initial resource is completed. Notice: This value may change the value of the end date of temporal extent. The end date will be computed automatically from the current timestamp if a cyclic update is defined!");?>'}" src="../img/questionmark.png" alt="" /></legend>
+				<select class="required cyclic_selectbox" id='update_frequency' name='update_frequency'>
+<!-- B.5.18 MD_MaintenanceFrequencyCode <<CodeList>> of ISO19115 -->					<option value="continual"><?php echo _mb("continual");?></option>
+					<option value="daily"><?php echo _mb("daily");?></option>
+					<option value="weekly"><?php echo _mb("weekly");?></option>
+					<option value="fortnightly"><?php echo _mb("fortnightly");?></option>
+					<option value="monthly"><?php echo _mb("monthly");?></option>
+					<option value="quarterly"><?php echo _mb("quarterly");?></option>
+					<option value="biannually"><?php echo _mb("biannually");?></option>
+					<option value="annually"><?php echo _mb("annually");?></option>
+					<option value="asNeeded"><?php echo _mb("as needed");?></option>
+					<option value="irregular"><?php echo _mb("irregular");?></option>
+
+					<option value="notPlanned"><?php echo _mb("not planned");?></option>
+
+					<option value="unknown"><?php echo _mb("unknown");?></option>
+				</select>
+		</fieldset>
+	</fieldset>
+	<fieldset id="spatialres">
+		<legend><?php echo _mb("Spatial resolution");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Spatial resolution refers to the level of detail of the data set. It shall be expressed as a set of zero to many resolution distances (typically for gridded data and imagery-derived products) or equivalent scales (typically for maps or map-derived products). An equivalent scale is generally expressed as an integer value expressing the scale denominator. A resolution distance shall be expressed as a numerical value associated with a unit of length.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<label for="groundDistance">
+				<input class="required radioRes" name="spatial_res_type" id="groundDistance" type="radio"/ value="groundDistance" checked="checked">
+			<?php echo _mb("Ground distance in [m]");?>
+			</label>
+			<label for="scaleDenominator">
+				<input class="required radioRes" name="spatial_res_type" id="scaleDenominator" type="radio"/ value="scaleDenominator">
+			<?php echo _mb("Scale denominator [1:X]");?>
+			</label>
+			<!--<label for="spatial_res_type" class="error"><?php echo _mb("Please set the resolution type!");?>-->
+			</label>
+			<label><?php echo _mb("Value of resolution");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Value of spatial resolution in [m] or scale denominator");?>'}" src="../img/questionmark.png" alt="" /></label>
+			<input class="required" name="spatial_res_value" id="spatial_res_value"/>
+	</fieldset>
+	<!-- Dropdown List of CRS which are defined in mapbender.conf. For those CRS the layer extents will be computed by mapbender - this is relevant for INSPIRE.-->
+	<fieldset id="referencesystem">
+		<legend><?php echo _mb("Coordinate Reference System");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Description of the coordinate reference system(s) used in the data set.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+<?php
+	if (defined('SRS_ARRAY')) {
+		$srs_array = explode(",", SRS_ARRAY);
+		echo '<select class="required ref_system_selectbox" name="ref_system" id="ref_system">';
+		foreach ($srs_array as $epsg) {
+			echo "<option value='" . "EPSG:" .$epsg . "'>" . _mb("EPSG:".$epsg) . "</option>";
+		}
+		echo "</select>";
+		
+	} else {
+		echo '<input name="ref_system" id="ref_system"/>';
+	}
+?>
+	</fieldset>
+	<fieldset id="data_format">
+		<legend><?php echo _mb("Encoding");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Description of the computer language construct(s) specifying the representation of data objects in a record, file, message, storage device or transmission channel.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<select class="required format_selectbox" id='format' name='format'>
+			<option value="database"><?php echo _mb("Database");?></option>
+			<option value="shapefile"><?php echo _mb("Esri Shape");?></option>
+			<option value="tab"><?php echo _mb("MapInfo Tab file");?></option>
+			<option value="csv"><?php echo _mb("CSV");?></option>
+			<option value="gml"><?php echo _mb("GML");?></option>
+		</select>
+	</fieldset>
+	<fieldset id="charset">
+		<legend><?php echo _mb("Character Encoding");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("The character encoding used in the data set. This element is mandatory only if an encoding is used that is not based on UTF-8.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<select class="required charset_selectbox" id='inspire_charset' name='inspire_charset'>
+			<option value="utf8"><?php echo _mb("utf8");?></option>
+			<option value="latin1"><?php echo _mb("latin1");?></option>
+		</select>
+	</fieldset>
+	<fieldset id="consistance">
+		<legend><?php echo _mb("Topological Consistency");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Correctness of the explicitly encoded topological characteristics of the data set as described by the scope. This element is mandatory only if the data set includes types from the Generic Network Model and does not assure centreline topology (connectivity of centrelines) for the network.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<input name="inspire_top_consistence" id="inspire_top_consistence" type="checkbox" checked="checked"/>
+	</fieldset>
+	</fieldset>
+</fieldset>

Modified: branches/2.7/http/plugins/mb_metadata_layer.js
===================================================================
--- branches/2.7/http/plugins/mb_metadata_layer.js	2011-07-19 13:20:06 UTC (rev 7976)
+++ branches/2.7/http/plugins/mb_metadata_layer.js	2011-07-19 13:21:23 UTC (rev 7977)
@@ -87,13 +87,37 @@
 					return;
 				}
 				$metadataForm.easyform("fill", obj);
+				//delete metadataURL entries
+				$('.metadataEntry').remove();
+				//fill MetadataURLs into metadata_selectbox_id
+				that.fillMetadataURLs(obj);
 				that.valid();
 				that.enableResetButton();
 			}
 		});
 		req.send();		
 	};
-	
+	//function generate updated metadataUrl entries TODO: this function is defined in mb_metadata_layer.js before but it cannot be called - maybe s.th. have to be changed
+	this.fillMetadataURLs = function (obj) {
+		layerId = obj.layer_id;
+		//for size of md_metadata records:
+		for (i=0;i<obj.md_metadata.metadata_id.length;i++) {
+			if (obj.md_metadata.origin[i] == "capabilities") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "external") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "upload") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/button_blue_red/up.png' title='uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "metador") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+		}
+		$("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",true);return false;'/>").appendTo($("#metadataTable"));
+	}
+
 	this.enableResetButton = function () {
 		$("#resetIsoTopicCats").click(function () {
 			$("#layer_md_topic_category_id option").removeAttr("selected");
@@ -122,6 +146,8 @@
 
 	this.init = function (obj) {
 		delete layerId;
+		//delete metadataURL entries
+		$('.metadataEntry').remove();
 		$metadataForm.easyform("reset");
 
 		wmsId = obj;

Modified: branches/2.7/http/plugins/mb_metadata_layer.php
===================================================================
--- branches/2.7/http/plugins/mb_metadata_layer.php	2011-07-19 13:20:06 UTC (rev 7976)
+++ branches/2.7/http/plugins/mb_metadata_layer.php	2011-07-19 13:21:23 UTC (rev 7977)
@@ -57,27 +57,18 @@
 		</p>
 		<p>
 		    <div id="buttons">
+			<fieldset>
 		    	<p>
-					<label><?php echo _mb("Add Information about the underlying data");?>:</label>
-					<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Linking the WMS layer with metadata set (coupled resource), which describes the underlying informations of the representation in more detail (eg Actuality / quality). It occurs via a link to an already existing metadta set in a catalog or a simple metadata set will be generatetd using a Mapbender Layer Addon-Editor.");?>'}" src="../img/questionmark.png" alt="" />
-				</p>
-				<p>
-					<input disabled="disabled" class="" type="submit" value="<?php echo _mb("Add new Metadata Record");?>"/>
-				</p>
-				<p>
-					<input disabled="disabled" class="" type="submit" value="<?php echo _mb("Edit Metadata Linkage");?>"/>
-				</p>
-				<p>
-					<input disabled="disabled" class="" type="submit" value="<?php echo _mb("Delete Metadata Linkage");?>"/>
-				</p>
-			</div>
-			<div id="selectbox">
-				<select disabled="disabled" class="metadata_selectbox" size="2" multiple>
-					<option>not</option>
-					<option>yet</option>
-					<option>implemented</option>
-				</select>
-			</div>			
+				<label><?php echo _mb("Add Information about the underlying data");?></label>
+				<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Linking the WMS layer with a metadata set (coupled resource), which describes the underlying information of the representation in more detail (eg actuality / quality). It can be done by linking to an already existing metadata set (e.g. in a catalogue) or by generating a simple metadata file using mapbender.");?>'}" src="../img/questionmark.png" alt="" />
+			</p>
+			<p>
+				<label><?php echo _mb("Table of coupled Metadata");?>:</label>
+				<table id="metadataTable">
+				</table>
+			</p>
+		    </fieldset>
+		    </div>			
 		</p>
 	</fieldset>
 </div>
@@ -127,3 +118,4 @@
 		</p>
 	</fieldset>
 </div>
+

Modified: branches/2.7/http/plugins/mb_metadata_server.php
===================================================================
--- branches/2.7/http/plugins/mb_metadata_server.php	2011-07-19 13:20:06 UTC (rev 7976)
+++ branches/2.7/http/plugins/mb_metadata_server.php	2011-07-19 13:21:23 UTC (rev 7977)
@@ -2,6 +2,7 @@
 require_once dirname(__FILE__) . "/../../core/globalSettings.php";
 require_once dirname(__FILE__) . "/../classes/class_user.php";
 require_once dirname(__FILE__) . "/../classes/class_wms.php";
+require_once dirname(__FILE__) . "/../classes/class_Uuid.php";
 
 $ajaxResponse = new AjaxResponse($_POST);
 
@@ -10,7 +11,7 @@
 	$ajaxResponse->setSuccess(false);
 	$ajaxResponse->setMessage($message);
 	$ajaxResponse->send();
-	die;
+	die();
 };
 
 function getWms ($wmsId = null) {
@@ -165,7 +166,7 @@
 			//check if primary group is set 
 			$user = new User;
 			$userId = $user->id;
-			$e = new mb_exception("user id:".$userId);
+			//$e = new mb_exception("user id:".$userId);
 			$sql = <<<SQL
 	
 SELECT fkey_mb_group_id, mb_group_name, mb_group_title, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_logo_path, mb_group_voicetelephone FROM (SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 AND mb_user_mb_group_type = 2) AS a LEFT JOIN mb_group ON a.fkey_mb_group_id = mb_group.mb_group_id
@@ -276,7 +277,28 @@
 		while ($row = db_fetch_assoc($res)) {
 			$resultObj["layer_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_layer_id = $layerId ) 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;
@@ -532,6 +554,518 @@
 		$ajaxResponse->setSuccess(true);
 		break;
 
+	case "getLayerMetadataAddon" :
+		$layerId = $ajaxResponse->getParameter("layerId");
+		$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 layer
+			$resultObj["abstract"] = $row["abstract"]; //char - prefill from layer
+			$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 "updateLayerMetadataAddon" :
+		$layerId = $ajaxResponse->getParameter("layerId");
+		$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 "insertLayerMetadataAddon" :
+		$layerId = $ajaxResponse->getParameter("layerId");
+		$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' && $export2csw == 't' ) {
+			//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!"));
+			}
+
+			//***
+			//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');
+				//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');
+				//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
+				$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_notice("class_wms.php: code: ".$code[0]);
+				$e = new mb_notice("class_wms.php: codeSpace: ".$codeSpace[0]);
+				if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
+						
+					$datasetid = $codeSpace[0]."#".$code[0];
+					$e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
+				} else {
+						
+					$datasetid = 'undefined';# in sense of INSPIRE TODO control MD_Identifier too!
+					$e = new mb_exception("class_wms.php: datasetid: ".$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 into db - do not try to load data
+			$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 link 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_layer_id) VALUES ($1, $2)
+
+SQL;
+		$v = array($metadata_id, $layerId);
+		$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 "deleteLayerMetadataAddon" :
+		$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 "importLayerXmlAddon" :
+//this is similar to insert the metadata from external link, but came from internal file from tmp folder which has been updated before
+		$layerId = $ajaxResponse->getParameter("layerId");
+		$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!"));
+		}
+		
+		try {	
+			$iso19139Xml =  new SimpleXMLElement($metaData);
+		}
+		catch (Exception $e) {
+			abort(_mb("Parsing ISO19139 XML failed!"));
+		}
+		//get elements for database from xml by using xpath
+		//uuid
+		$uuid = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString');
+		//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');
+		//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
+		$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_notice("plugins/mb_metadata_server.php: code: ".$code[0]);
+		$e = new mb_notice("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_notice("class_wms.php: datasetid: ".$datasetid);
+		} else {		
+			$datasetid = 'undefined';# in sense of INSPIRE TODO control MD_Identifier too!
+			$e = new mb_notice("class_wms.php: datasetid: ".$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_layer_id) VALUES ($1, $2)
+
+SQL;
+	$v = array($metadata_id, $layerId);
+	$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;		
+
 	default: 
 		$ajaxResponse->setSuccess(false);
 		$ajaxResponse->setMessage(_mb("An unknown error occured."));

Copied: branches/2.7/http/plugins/mb_metadata_showMetadataAddon.js (from rev 7962, trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js)
===================================================================
--- branches/2.7/http/plugins/mb_metadata_showMetadataAddon.js	                        (rev 0)
+++ branches/2.7/http/plugins/mb_metadata_showMetadataAddon.js	2011-07-19 13:21:23 UTC (rev 7977)
@@ -0,0 +1,267 @@
+var $showMetadataAddonDiv = $(this);
+var $metadataAddonForm = $("<form></form>").appendTo($showMetadataAddonDiv);
+//var $metadataUploadForm = $("<form></form>").appendTo($showMetadataAddonDiv);
+
+var $metadataAddonPopup = $("<div></div>");
+var $metadataUploadPopup = $("<div></div>");
+
+var ShowMetadataAddonApi = function() {
+	var that = this;
+	var layerId;
+	var metadataId;
+	//Function, which pulls the metadata out off the mapbender registry and give a possibility to edit the record or link
+	this.valid = function () {
+		if (validator && validator.numberOfInvalids() > 0) {
+			$metadataAddonForm.valid();
+			return false;
+		}
+		return true;
+	};
+
+	this.getAddedMetadata = function(metadataId, layerId){
+		// get metadata from server
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "getLayerMetadataAddon",
+			parameters: {
+				"layerId": layerId,
+				"metadataId": metadataId
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					return;
+				}
+				$metadataAddonForm.easyform("reset");
+				$metadataAddonForm.easyform("fill", obj);
+				
+				//enable link element to edit link!
+				$("#link").removeAttr("disabled");
+
+				switch (obj.origin) {
+					case "external":
+						$("#metadataUrlEditor").css("display","block");
+						$("#link_editor").css("display","block");
+    						break;
+  					case "metador":
+						$("#metadataUrlEditor").css("display","block");
+						$("#simple_metadata_editor").css("display","block");
+    						break;
+  					case "capabilities":
+						$("#metadataUrlEditor").css("display","block");
+    						$("#simple_metadata_editor").css("display","block");
+    						break;			
+					default:
+    						break;
+				}
+				//select the right list entries:
+				$(".format_selectbox").val(obj.format); 				$(".charset_selectbox").val(obj.inspire_charset);
+				$(".ref_system_selectbox").val(obj.ref_system);
+				$(".cyclic_selectbox").val(obj.update_frequency);
+				$(".radioRes").filter('[value='+obj.spatial_res_type+']').attr('checked', true);
+
+			}
+		});
+		req.send();	
+	}		
+	this.insertAddedMetadata = function(layerId, data){
+		// push metadata from server
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "insertLayerMetadataAddon",
+			parameters: {
+				"layerId": layerId,
+				"data": data
+			},
+			callback: function (obj, result, message) {
+				$("<div></div>").text(message).dialog({
+					modal: true
+				});
+				//update layer form to show edited data
+				that.fillLayerForm(layerId);
+			}
+		});
+		req.send();	
+	}
+
+
+	this.updateAddedMetadata = function(metadataId, layerId, data){
+		// push metadata from server
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "updateLayerMetadataAddon",
+			parameters: {
+				"layerId": layerId,
+				"metadataId": metadataId,
+				"data": data
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					return;
+				}
+				$("<div></div>").text(message).dialog({
+					modal: true
+				});
+				//update layer form to show edited data
+				that.fillLayerForm(layerId);
+			}
+		});
+		req.send();	
+	}	
+	//function to fill layer form with changed metadata entries TODO: this function is defined in mb_metadata_layer.js before but it cannot be called - maybe s.th. have to be changed
+	this.fillLayerForm = function (layerId) {
+		// get metadata from server
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "getLayerMetadata",
+			parameters: {
+				"id": layerId
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					return;
+				}
+				//delete metadataURL entries
+				$('.metadataEntry').remove();
+				//fill MetadataURLs into metadata_selectbox_id
+				that.fillMetadataURLs(obj);
+			}
+		});
+		req.send();		
+	};
+
+	//function generate updated metadataUrl entries TODO: this function is defined in mb_metadata_layer.js before but it cannot be called - maybe s.th. have to be changed
+	this.fillMetadataURLs = function (obj) {
+		layerId = obj.layer_id;
+		//for size of md_metadata records:
+		for (i=0;i<obj.md_metadata.metadata_id.length;i++) {
+			if (obj.md_metadata.origin[i] == "capabilities") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "external") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "upload") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/button_blue_red/up.png' title='uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "metador") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+		}
+		$("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",true);return false;'/>").appendTo($("#metadataTable"));
+	}
+
+		
+	deleteAddedMetadata = function(metadataId, layerId){
+		// push metadata from server
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "deleteLayerMetadataAddon",
+			parameters: {
+				"metadataId": metadataId
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					return;
+				}
+				//delete metadataURL entries
+				$('.metadataEntry').remove();
+				//fill MetadataURLs into metadata_selectbox_id
+				//update layer form to show edited data
+				that.fillLayerForm(layerId);
+				$("<div></div>").text(message).dialog({
+					modal: true
+				});
+			}
+		});
+		req.send();	
+	}		
+
+	
+	this.showForm = function (metadataId, layerId, isNew) {
+		$metadataAddonPopup.append($metadataAddonForm);
+		$metadataAddonPopup.dialog({
+			title : "Metadata Addon Editor", 
+			autoOpen : false, 
+			draggable : true,
+			modal : true,
+			width : 600,
+			position : [600, 75],
+			buttons: {
+				"close": function() {
+					$(this).dialog('close');
+				},
+				"save": function() {
+					//get data from form
+					//supress validation for the link only way
+					//example $("#myform").validate().element( "#myselect" );
+					//$("#myform").validate({
+					// ignore: ".ignore"
+					//})
+					if ($("#addonChooser").css("display") == "block") {
+						//don't allow saving but do something else
+						return;
+						
+					}
+					if ($("#simple_metadata_editor").css("display") == "block") {
+						//validate form before send it!
+						if ($metadataAddonForm.valid() != true) {
+							alert("Form not valid - please check your input!"); //TODO use translations and make a php file from this
+							return;
+						}
+					}
+					var formData = $metadataAddonForm.easyform("serialize");
+					if (!isNew) {
+						that.updateAddedMetadata(metadataId, layerId, formData);
+					} else {
+						that.insertAddedMetadata(layerId, formData);
+					}
+					$(this).dialog('close');
+				}
+			},
+			close: function() {
+				//what to do when the dialog is closed
+				
+			}
+		});
+		$metadataAddonPopup.dialog("open");
+	};
+	
+	initUploadForm = function (layerId) {
+		$metadataAddonPopup.dialog("close");
+		initXmlImport(layerId);
+		that.fillLayerForm(layerId);
+	}
+
+
+	this.init = function (metadataId, layerId, isNew) {
+		$metadataAddonPopup.dialog("close");
+		$metadataAddonForm.load("../plugins/mb_metadata_addon.php", function () {
+			//push infos to help dialogs
+			$metadataAddonForm.find(".help-dialog").helpDialog();
+			//initialize datepicker
+			$('.hasdatepicker').datepicker({dateFormat:'yy-mm-dd', yearRange: '1900:2050', buttonImageOnly: true, changeYear: true,
+constraintInput: true});
+			//first get json
+			if (!isNew) {
+				that.getAddedMetadata(metadataId, layerId);
+			
+			} else {
+				//show chooser
+				$("#metadataUrlEditor").css("display","block"); 
+				$("#addonChooser").css("display","block");
+				$("#uploadImage").attr('onclick', 'initUploadForm('+layerId+')');
+			}
+			that.showForm(metadataId, layerId, isNew);
+		});
+		//upload form
+		
+		//$metadataUploadPopup.append($metadataUploadForm);
+	}
+	initMetadataAddon = function(metadataId, layerId, isNew) {
+		//close old window and load form
+		that.init(metadataId, layerId, isNew);	
+		//fill form
+	}
+};
+
+$showMetadataAddonDiv.mapbender(new ShowMetadataAddonApi());

Copied: branches/2.7/http/plugins/mb_metadata_xml_import.js (from rev 7962, trunk/mapbender/http/plugins/mb_metadata_xml_import.js)
===================================================================
--- branches/2.7/http/plugins/mb_metadata_xml_import.js	                        (rev 0)
+++ branches/2.7/http/plugins/mb_metadata_xml_import.js	2011-07-19 13:21:23 UTC (rev 7977)
@@ -0,0 +1,135 @@
+var $xmlImport = $(this);
+var importXmlLayerId;
+
+var XmlImportApi = function () {
+	var that = this;
+	var type;
+	
+	this.events = {
+		"uploadComplete" : new Mapbender.Event()
+	};
+	
+	this.events.uploadComplete.register(function () {
+		$xmlImport.dialog("close");
+	});
+	
+
+	
+	var importUploadedFile = function(filename, layerId, callback){
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "importLayerXmlAddon",
+			parameters: {
+				filename: filename,
+				layerId: layerId
+			},
+			callback: function (obj, result, message, errorCode) {
+				
+				if (!result) {
+					switch (errorCode) {
+						case -1002:
+							alert("file: "+filename+"has problems: "+message);
+							break;
+						default:
+							alert(message);
+							return;
+					}
+				}
+
+				alert(message);
+				$xmlImport.dialog("close");
+				that.fillLayerForm(layerId);
+				if ($.isFunction(callback)) {
+					callback(obj.id);
+				}
+			}
+		});
+		req.send();
+	};
+
+	//function to fill layer form with changed metadata entries TODO: this function is defined in mb_metadata_layer.js before but it cannot be called - maybe s.th. have to be changed
+	this.fillLayerForm = function (layerId) {
+		// get metadata from server
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "getLayerMetadata",
+			parameters: {
+				"id": layerId
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					return;
+				}
+				//delete metadataURL entries
+				$('.metadataEntry').remove();
+				//fill MetadataURLs into metadata_selectbox_id
+				that.fillMetadataURLs(obj);
+			}
+		});
+		req.send();		
+	};
+
+	//function generate updated metadataUrl entries TODO: this function is defined in mb_metadata_layer.js before but it cannot be called - maybe s.th. have to be changed
+	this.fillMetadataURLs = function (obj) {
+		layerId = obj.layer_id;
+		//for size of md_metadata records:
+		for (i=0;i<obj.md_metadata.metadata_id.length;i++) {
+			if (obj.md_metadata.origin[i] == "capabilities") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "external") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "upload") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/button_blue_red/up.png' title='uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin[i] == "metador") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+			}
+		}
+		$("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",true);return false;'/>").appendTo($("#metadataTable"));
+	}
+
+	
+	$xmlImport.upload({
+		size: 10,
+		timeout: 20000,
+		url: "../plugins/jq_upload.php",
+		callback: function(result,stat,msg){
+			if(!result){ 
+				alert(msg);
+				return;
+			}
+	        var uploadResultName = result.filename;
+	        var uploadResultOrigName = result.origFilename;
+	        
+	        importUploadedFile(result.filename, that.importXmlLayerId, function (id) {
+		        that.events.uploadComplete.trigger({
+					"type": type,
+					"id": id
+				});
+			});
+	        
+    	}
+	}).dialog({
+		title: 'XML Import',
+		autoOpen: false,
+		modal: true,
+		width: 580
+	});
+
+
+	this.init = function (obj) {
+		type = obj.type;
+		$xmlImport.dialog("open");
+	};
+
+	initXmlImport = function (layerId) {
+		that.importXmlLayerId = layerId;
+		$xmlImport.dialog("open");
+		return true;
+	};
+	
+};
+
+$xmlImport.mapbender(new XmlImportApi());



More information about the Mapbender_commits mailing list