[Mapbender-commits] r1768 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Oct 29 08:41:26 EDT 2007


Author: christoph
Date: 2007-10-29 08:41:26 -0400 (Mon, 29 Oct 2007)
New Revision: 1768

Modified:
   trunk/mapbender/http/javascripts/mod_savewmc.php
Log:
save WMC in session and in db use the same function sendMapDataToServer

Modified: trunk/mapbender/http/javascripts/mod_savewmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.php	2007-10-29 12:30:30 UTC (rev 1767)
+++ trunk/mapbender/http/javascripts/mod_savewmc.php	2007-10-29 12:41:26 UTC (rev 1768)
@@ -57,28 +57,29 @@
 
 var mod_savewmc_img = new Image(); mod_savewmc_img.src = "<?php  echo $e_src;  ?>";
 //var mod_savewmc_img_over = new Image(); mod_savewmc_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
+
+function mod_savewmc_session(){
+	$.ajaxSetup({async:false}); //TODO: find out why async doesn't work onunload
+	sendMapDataToServer("session");
+}
 
-function mod_savewmc_session(){
-	var user = "<?php echo $_SESSION["mb_user_id"]; ?>";
-	var ind = getMapObjIndexByName(mod_savewmc_target);
-	var generalTitle = "session";
-	$.ajaxSetup({async:false}); //TODO: find out why async doesn't work sometimes
-	$.post("../php/mod_insertWmcIntoDb.php", {"saveInSession":1, "generalTitle":generalTitle, "mapObject":$.toJSON(mb_mapObj[ind])}, function (result, status) {
-	});
+function mod_savewmc(title){
+	var generalTitle = title ? title : prompt("Save WMC as...");
+	sendMapDataToServer(generalTitle);
 }
 
-function mod_savewmc(title){
+function sendMapDataToServer(generalTitle) {
 	var user = "<?php echo $_SESSION["mb_user_id"]; ?>";
 	var ind = getMapObjIndexByName(mod_savewmc_target);
-	var generalTitle;
-	if (title) {
-		generalTitle = title;
+	
+	var	extensionDataString = "";
+	if (currentWmcExtensionData != null) {
+		extensionDataString = currentWmcExtensionData.toJSONString();
 	}
-	else {
-		generalTitle = prompt("Save WMC as...");
-	}
-	$.ajaxSetup({async:false}); //TODO: find out why async doesn't work onunload
-	$.post("../php/mod_insertWmcIntoDb.php", {"saveInSession":0, "generalTitle":generalTitle, "mapObject":$.toJSON(mb_mapObj[ind])}, function (result, status) {
-		alert(status + ": " + result);
+
+	$.post("../php/mod_insertWmcIntoDb.php", {"saveInSession":saveInSession, "generalTitle":generalTitle, "extensionData":extensionDataString, "mapObject":mb_mapObj[ind].toJSONString()}, function (result, status) {
+		if (!saveInSession) {
+			alert(status + ": " + result);
+		}
 	});
 }
\ No newline at end of file



More information about the Mapbender_commits mailing list