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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Feb 17 05:33:06 EST 2012


Author: armin11
Date: 2012-02-17 02:33:06 -0800 (Fri, 17 Feb 2012)
New Revision: 8255

Modified:
   trunk/mapbender/http/plugins/mb_metadata_xml_import.js
Log:
Simplify upload metadata function. Call external function to refresh the html content.

Modified: trunk/mapbender/http/plugins/mb_metadata_xml_import.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_xml_import.js	2012-02-16 20:16:38 UTC (rev 8254)
+++ trunk/mapbender/http/plugins/mb_metadata_xml_import.js	2012-02-17 10:33:06 UTC (rev 8255)
@@ -13,8 +13,6 @@
 		$xmlImport.dialog("close");
 	});
 	
-
-	
 	var importUploadedFile = function(filename, layerId, callback){
 		var req = new Mapbender.Ajax.Request({
 			url: "../plugins/mb_metadata_server.php",
@@ -23,8 +21,7 @@
 				filename: filename,
 				layerId: layerId
 			},
-			callback: function (obj, result, message, errorCode) {
-				
+			callback: function (obj, result, message, errorCode) {				
 				if (!result) {
 					switch (errorCode) {
 						case -1002:
@@ -35,10 +32,11 @@
 							return;
 					}
 				}
-
 				alert(message);
 				$xmlImport.dialog("close");
-				that.fillLayerForm(layerId);
+				//invoke external script from mb_metadata_showMetadataAddon.js
+				//that.fillLayerForm(layerId);
+				Mapbender.modules.mb_md_showMetadataAddon.fillLayerForm(layerId);
 				if ($.isFunction(callback)) {
 					callback(obj.id);
 				}
@@ -47,50 +45,6 @@
 		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,
@@ -108,8 +62,7 @@
 					"type": type,
 					"id": id
 				});
-			});
-	        
+			}); 
     	}
 	}).dialog({
 		title: 'XML Import',



More information about the Mapbender_commits mailing list