[Mapbender-commits] r2503 - in trunk/mapbender/http: javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Jun 13 09:04:34 EDT 2008


Author: christoph
Date: 2008-06-13 09:04:34 -0400 (Fri, 13 Jun 2008)
New Revision: 2503

Added:
   trunk/mapbender/http/javascripts/mod_loadwmc.js
   trunk/mapbender/http/javascripts/mod_loadwmc_list.php
   trunk/mapbender/http/php/mod_loadwmc_server.php
   trunk/mapbender/http/php/mod_savewmc_server.php
Modified:
   trunk/mapbender/http/javascripts/map.php
   trunk/mapbender/http/javascripts/mod_displayWmc.php
   trunk/mapbender/http/javascripts/mod_initWmc.php
   trunk/mapbender/http/javascripts/mod_loadwmc.php
   trunk/mapbender/http/javascripts/mod_savewmc.php
   trunk/mapbender/http/php/mod_map1.php
   trunk/mapbender/http/php/mod_mapOV.php
Log:
merged with beck_dev

Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php	2008-06-13 13:03:41 UTC (rev 2502)
+++ trunk/mapbender/http/javascripts/map.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -69,30 +69,36 @@
 echo "var global_log_levels = '".LOG_LEVEL_LIST."';";
 echo "var mb_feature_count = ".MB_FEATURE_COUNT.";";
 echo "var mb_resolution = ".MB_RESOLUTION.";";
+echo "var mb_security_proxy = '" . MB_SECURITY_PROXY . "';";
 
 //
-// Load JavaScript libraries
+// Load external JavaScript libraries
 //
 require_once(dirname(__FILE__) . "/../extensions/jquery.js");
-require_once(dirname(__FILE__) . "/../javascripts/map.js");
-require_once(dirname(__FILE__) . "/../javascripts/point.js");
-require_once(dirname(__FILE__) . "/../javascripts/map_obj.js");
-require_once(dirname(__FILE__) . "/../javascripts/wfs_obj.js");
 require_once(dirname(__FILE__) . "/../extensions/jqjson.js");
-require_once(dirname(__FILE__) . "/../javascripts/style.js");
 
 //
+// Load internal JavaScript libraries
+//
+require_once(dirname(__FILE__) . "/../../lib/map_obj.js");
+require_once(dirname(__FILE__) . "/../../lib/exception.js");
+require_once(dirname(__FILE__) . "/../../lib/ajax.js");
+require_once(dirname(__FILE__) . "/../../lib/div.js");
+require_once(dirname(__FILE__) . "/../../lib/list.js");
+require_once(dirname(__FILE__) . "/../../lib/map.js");
+require_once(dirname(__FILE__) . "/../../lib/point.js");
+require_once(dirname(__FILE__) . "/../../lib/wms.js");
+require_once(dirname(__FILE__) . "/../../lib/wfs_obj.js");
+require_once(dirname(__FILE__) . "/../../lib/style.js");
+
+//
 // Load WMS
 // 
-$sql = "SELECT fkey_wms_id FROM gui_wms WHERE fkey_gui_id = $1 ORDER BY gui_wms_position";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sql, $v, $t);
+$wmsArray = wms::selectMyWmsByApplication($gui_id);
 
-while($row = db_fetch_array($res)) {
-	$mywms = new wms();
-	$mywms->createObjFromDB($gui_id, $row["fkey_wms_id"]);
-	$mywms->createJsObjFromWMS();
+for ($i = 0; $i < count($wmsArray); $i++) {
+	$currentWms = $wmsArray[$i];
+	$currentWms->createJsObjFromWMS();
 }
 
 //
@@ -141,7 +147,4 @@
 		}
 	}
 }
-
-
-
 ?>
\ No newline at end of file

Modified: trunk/mapbender/http/javascripts/mod_displayWmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_displayWmc.php	2008-06-13 13:03:41 UTC (rev 2502)
+++ trunk/mapbender/http/javascripts/mod_displayWmc.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -22,9 +22,9 @@
 $wmc_id = $_GET["wmc_id"];
 
 if ($wmc_id){
-	require_once(dirname(__FILE__)."/../classes/class_administration.php");
-	$admin = new administration();
-	$wmc_gml = $admin->getWmcById($wmc_id);
+	require_once(dirname(__FILE__)."/../classes/class_wmc.php");
+	$wmc = new wmc();
+	$wmc_gml = $wmc->getDocument($wmc_id);
 
 	if ($wmc_gml){
 		//Display WMC

Modified: trunk/mapbender/http/javascripts/mod_initWmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_initWmc.php	2008-06-13 13:03:41 UTC (rev 2502)
+++ trunk/mapbender/http/javascripts/mod_initWmc.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -68,7 +68,7 @@
 			echo "var wmc_id = false;";
 			echo "wmc_id = '".$wmc_id."';";
 			$wmc = new wmc();
-			$wmc->createObjFromWMC_id($wmc_id);
+			$wmc->createFromDb($wmc_id);
 			$js_wmc .= $wmc->createJsObjFromWMC("", $e_target[0], $action);
 			
 			if (!empty($x) && !empty($y) && !empty($icon)) {

Added: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js	2008-06-13 13:04:34 UTC (rev 2503)
@@ -0,0 +1,284 @@
+// checks if element var loadFromSession exists
+try {
+	if (loadFromSession) {
+	}
+}
+catch(e) {
+	loadFromSession = 0;
+}
+
+if (loadFromSession) {
+	// function load_wmc_session() is generated by mod_loadwmc.php
+	mb_registerInitFunctions('load_wmc_session()');
+}
+var wmcPopup = null;
+var wmcDisplayPopup = null;
+
+var serverSideFileName = "../php/mod_loadwmc_server.php";
+
+function mod_importWmc(id){
+	alert(id);
+}
+
+/**
+ * is called when the load WMC button is pressed
+ */
+function mod_loadwmc(){
+
+	var initialHtml = "<div>" +
+					"<h2 style='font-family: Arial, Helvetica, sans-serif; color: #808080;'><font align='left' color='#000000'>load WMC from list</font></h2>" +
+					"<table id='loadwmc_list' width='90%' style='font-family: Arial, Helvetica, sans-serif;font-size : 12px;color: #808080;' border='1' cellpadding='3' rules='rows'>" +
+						"<tr style='background-color:#F0F0F0;' width='80px'>" +
+							"<td><b>WMC name</b></td>" +
+							"<td><b>last update</b></td>" +
+							"<td colspan=5></td>" +
+						"</tr>" +
+					"</table>" +
+				"</div>";
+
+	// creates a new pop up (if it doesn't already exist)
+	// the pop up allows you to load, append, merge, 
+	// display and delete WMC documents
+	if (wmcPopup === null) {
+		wmcPopup = new mb_popup({
+			title:"Load WMC",
+			width:500,
+			height:600,
+			top:100,
+			left:100,
+			html:initialHtml
+		});
+	}
+
+	// display the pop up
+	if (!wmcPopup.isVisible()) {
+		wmcPopup.setHtml(initialHtml);
+		wmcPopup.show();
+		
+	}
+
+	// get WMC data from server
+	var queryObj = {command:"getWmc"};
+	$.post(serverSideFileName, {queryObj:$.toJSON(queryObj)}, function(json, status) {
+		var loadWmcDataError = false;
+		if (json && status == "success") {
+			loadWmcDataError = displayWmcList(json, status);
+		}
+		if (loadWmcDataError) {
+			alert("An error has occured. WMC list could not be loaded.");
+		}
+	});
+}
+
+/**
+ * Displays available WMC documents
+ */
+function displayWmcList (json, status) {
+	var wmcObj = eval("(" + json + ")");
+
+	//
+	// for each wmc, add a row to the table
+	//
+	for (var i=0; i < wmcObj.wmc.length; i++) {
+		(function () {
+			var currentId = wmcObj.wmc[i].id;
+			var $tr = $("<tr onmouseover='this.style.backgroundColor = \"#F08080\"' onmouseout='this.style.backgroundColor = \"#ffffff\"'></tr>").appendTo($("#loadwmc_list"));
+			$tr.hide();
+			var $td;
+			
+			$tr.append($("<td>" + wmcObj.wmc[i].title + "</td>"));
+			$tr.append($("<td>" + wmcObj.wmc[i].timestamp + "</td>"));
+
+			// 
+			// Load WMC
+			//
+			$loadWmc = $("<img src='../img/button_gray/wmc_load.png' title='load this WMC'>");
+			$loadWmc.click(function() {
+				var queryObj = {command:"loadWmc", parameters:{id:currentId}};
+				$.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+					var loadWmcError = false;
+					if (json && status == "success") {
+						var resultObj = eval("(" + json + ")");
+						try {
+							if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
+								for (var j=0; j < resultObj.javascript.length; j++) {
+//									console.log("Statement: %s", resultObj.javascript[j]);
+									eval(resultObj.javascript[j]);
+								}
+							}	
+						}
+						catch (e) {
+							alert(e);
+							loadWmcError = true;
+						}
+					}
+					if (loadWmcError) {
+						alert("An error has occured while loading this WMC.");
+					}
+					else {
+						// close the Pop up
+						if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
+							wmcDisplayPopup.hide();
+						}
+						wmcPopup.hide();
+						alert("WMC has been loaded successfully.");
+					}
+				});
+			});
+			$td = $("<td></td>").append($loadWmc);
+			$tr.append($td);				
+
+			// 
+			// Merge WMC
+			//
+			$mergeWmc = $("<img src='../img/button_gray/wmc_merge.png' title='merge WMC'>");
+			$mergeWmc.click(function() {
+				var	extensionDataString = null;
+				if (currentWmcExtensionData !== null) {
+					extensionDataString = currentWmcExtensionData;
+				}
+				var queryObj = {
+					command:"mergeWmc", 
+					parameters:{
+						id:currentId, 
+						extensionData:extensionDataString, 
+						mapObject:mb_mapObj,
+						generalTitle:"currentState"
+					}
+				};
+				$.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+					var loadWmcError = false;
+					if (json && status == "success") {
+						var resultObj = eval("(" + json + ")");
+						try {
+							if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
+								for (var j=0; j < resultObj.javascript.length; j++) {
+									eval(resultObj.javascript[j]);
+								}
+							}	
+						}
+						catch (e) {
+							alert(e);
+							loadWmcError = true;
+						}
+					}
+					if (loadWmcError) {
+						alert("An error has occured while loading this WMC.");
+					}
+					else {
+						// close the Pop up
+						if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
+							wmcDisplayPopup.hide();
+						}
+						wmcPopup.hide();
+						alert("WMC has been loaded successfully.");
+					}
+				});
+			});
+			$td = $("<td></td>").append($mergeWmc);
+			$tr.append($td);				
+
+			// 
+			// Append WMC
+			//
+			$appendWmc = $("<img src='../img/button_gray/wmc_append.png' title='append WMC'>");
+			$appendWmc.click(function() {
+				var	extensionDataString = null;
+				if (currentWmcExtensionData !== null) {
+					extensionDataString = currentWmcExtensionData;
+				}
+				var queryObj = {
+					command:"appendWmc", 
+					parameters:{
+						id:currentId, 
+						extensionData:extensionDataString, 
+						mapObject:mb_mapObj,
+						generalTitle:"currentState"
+					}
+				};
+				$.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+					var loadWmcError = false;
+					if (json && status == "success") {
+						var resultObj = eval("(" + json + ")");
+						try {
+							if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
+								for (var j=0; j < resultObj.javascript.length; j++) {
+									eval(resultObj.javascript[j]);
+								}
+							}	
+						}
+						catch (e) {
+							alert(e);
+							loadWmcError = true;
+						}
+					}
+					if (loadWmcError) {
+						alert("An error has occured while loading this WMC.");
+					}
+					else {
+						// close the Pop up
+						if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
+							wmcDisplayPopup.hide();
+						}
+						wmcPopup.hide();
+						alert("WMC has been loaded successfully.");
+					}
+				});
+			});
+			$td = $("<td></td>").append($appendWmc);
+			$tr.append($td);				
+
+			// 
+			// Display WMC
+			//
+			$displayWmc = $("<img src='../img/button_gray/wmc_xml.png' title='display WMC XML'>");
+			$displayWmc.click(function() {
+				// create Popup
+				if (wmcDisplayPopup === null) {
+					wmcDisplayPopup = new mb_popup({
+						title:"WMC Document",
+						width:600,
+						height:500,
+						top:100,
+						left:300,
+						url:"../javascripts/mod_displayWmc.php?wmc_id=" + currentId
+					});
+				}
+				// set correct URL
+				if (wmcDisplayPopup.isVisible()) {
+					wmcDisplayPopup.setUrl("../javascripts/mod_displayWmc.php?wmc_id=" + currentId);
+				}
+				// display the pop up
+				wmcDisplayPopup.show();
+			});
+			$td = $("<td></td>").append($displayWmc);
+			$tr.append($td);				
+
+			$deleteWmc = $("<img src='../img/button_gray/del.png' title='delete this WMC'>");
+			$deleteWmc.click(function() {
+				var queryObj = {command:"deleteWmc", parameters:{id:currentId}};
+				$.post(serverSideFileName, {queryObj: $.toJSON(queryObj)}, function (json, status) {
+					var deleteWmcError = false;
+					if (json && status == "success") {
+						var resultObj = eval("(" + json + ")");
+						try {
+							if (resultObj.success) {
+								$tr.remove();
+							}	
+						}
+						catch (e) {
+							deleteWmcError = true;
+						}
+					}
+					if (deleteWmcError) {
+						alert("An error has occured while deleting this WMC.");
+					}
+				});
+			});
+			$td = $("<td></td>").append($deleteWmc);
+			$tr.append($td);
+
+			$tr.fadeIn("slow");
+		}());
+	}
+}
\ No newline at end of file

Modified: trunk/mapbender/http/javascripts/mod_loadwmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.php	2008-06-13 13:03:41 UTC (rev 2502)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -22,8 +22,6 @@
 
 include(dirname(__FILE__) . "/../include/dyn_js.php");
 
-echo "mod_loadwmc_target = '".$e_target[0]."';";
-
 /*
 // this may be added at a later stage
 if ($new_wmc == 1) {
@@ -46,53 +44,50 @@
 	}
 }
 */
-?>
-function load_wmc_session() {
-	<?php
-		if (isset($_SESSION['mb_wmc'])) {
-			$wmc = new wmc();
-			if ($wmc->createObjFromWMC_xml($_SESSION['mb_wmc'])) {
-				$js = "";
-				if ($_SESSION['layer_preview']) {
-//					echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: layer preview');";
-					$js = $wmc->createJsObjFromWMC("", $e_target, "load");
-				}
-				else if ($startup == true) {
-//					echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: load new wmc');";
-					$js = $wmc->createJsObjFromWMC("", $e_target, "merge");
-					$startup = false;
-				}		
-				else {
-//					echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: load old wmc');";
-					$js = $wmc->createJsObjFromWMC("", $e_target, "load");
-				}
-				echo $js;
-			}
-			else {
-				echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: error parsing wmc');";
-			}
-		}
-		else {
-			echo "var e = new Mb_warning('mod_loadwmc: load_wmc_session: no wmc set!');";
-		}
-	?>
+
+//
+// Creates the function load_wmc_session.
+// This function loads a WMC from the session, if the element var
+// "loadFromSession" is set to true.
+//
+echo "function load_wmc_session() {";
+if (isset($_SESSION['mb_wmc'])) {
+	$wmc = new wmc();
+	if ($wmc->createFromXml($_SESSION['mb_wmc'])) {
+		$jsArray = array();
+//		if ($_SESSION['layer_preview']) {
+//			$js = $wmc->createJsObjFromWMC("", $e_target, "load");
+//		}
+//		else if ($startup == true) {
+//			$js = $wmc->createJsObjFromWMC("", $e_target, "merge");
+//			$startup = false;
+//		}		
+//		else {
+			$jsArray = $wmc->toJavaScript();
+//		}
+		echo implode("", $jsArray);
+		
+		// test wmc from app
+		$newWmc = new wmc();
+		$newWmc->createFromApplication($_SESSION["mb_user_gui"]);
+		
+		
+	}
+	else {
+		echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: error parsing wmc');";
+	}
 }
+else {
+	echo "var e = new Mb_warning('mod_loadwmc: load_wmc_session: no wmc set!');";
+}
+echo "}";
 
-try {if (loadFromSession) {}}catch(e) {loadFromSession = 0;}
 
-if (loadFromSession) {
-	mb_registerInitFunctions('load_wmc_session()');
-}
+echo "var mod_loadwmc_img = new Image(); mod_loadwmc_img.src = '" . $e_src . "';";
 
-var mod_loadwmc_img = new Image(); mod_loadwmc_img.src = "<?php echo $e_src; ?>";
-//var mod_loadwmc_img_over = new Image(); mod_loadwmc_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
 
-function mod_importWmc(id){
-	alert(id);
-}
-function mod_loadwmc(obj){
-	windowWmc = window.open("../php/mb_listWMCs.php?<?php echo SID;?>","displayWmc","width=500, height=600, scrollbars=yes, dependent=yes");
-}
-function mod_loadwmc_init(obj){
-	//document.getElementById("loadwmc").src = mod_zoom1_img_over.src;
-}
\ No newline at end of file
+//
+// Creates a pop up with a dialogue to load, view or delete WMC documents
+//
+include("mod_loadwmc.js");
+?>
\ No newline at end of file

Added: trunk/mapbender/http/javascripts/mod_loadwmc_list.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc_list.php	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_loadwmc_list.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -0,0 +1,3 @@
+<?php
+	echo "fisch";
+?>
\ No newline at end of file

Modified: trunk/mapbender/http/javascripts/mod_savewmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.php	2008-06-13 13:03:41 UTC (rev 2502)
+++ trunk/mapbender/http/javascripts/mod_savewmc.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -64,5 +64,5 @@
 	if (storeInSession) {
 		$.ajaxSetup({async:false}); //TODO: find out why async doesn't work onunload
 	}
-	$.post("../php/mod_insertWmcIntoDb.php", {"saveInSession":storeInSession, "generalTitle":generalTitle, "extensionData":extensionDataString, "mapObject":$.toJSON(mb_mapObj[ind])}, callbackFunction);
+	$.post("../php/mod_savewmc_server.php", {"saveInSession":storeInSession, "generalTitle":generalTitle, "extensionData":extensionDataString, "mapObject":$.toJSON(mb_mapObj)}, callbackFunction);
 }
\ No newline at end of file

Added: trunk/mapbender/http/php/mod_loadwmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_loadwmc_server.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_loadwmc_server.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -0,0 +1,174 @@
+<?php
+require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
+require_once(dirname(__FILE__) . "/../classes/class_user.php");
+require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
+
+/**
+ * encodes and delivers the data
+ * 
+ * @param object the un-encoded object 
+ */
+function sendOutput($out){
+	global $json;
+	$output = $json->encode($out);
+	header("Content-Type: text/x-json");
+	echo $output;
+}
+
+/**
+ * Get all available WMC documents from the database
+ * 
+ * @return mixed[] an array of wmcs 
+ * 					(wmc = assoc. array of "id", "title", "timestamp")
+ */
+function getWmc(){
+	global $con;
+	global $userId;
+	
+	$wmcArray = array();
+	
+	// get WMC ids 
+	$currentUser = new User($userId);
+	$wmcIdArray = $currentUser->getWmcByOwner();
+	
+	// get WMC data
+	$v = array();
+	$t = array();
+	$wmcIdList = "";
+
+	for ($i = 0; $i < count($wmcIdArray); $i++) {
+		if ($i > 0) { 
+			$wmcIdList .= ",";
+		}
+		$wmcIdList .= "$".($i+1);
+		array_push($v, $wmcIdArray[$i]);
+		array_push($t, 's');
+	}
+
+	$sql = "SELECT DISTINCT wmc_id, wmc_title, wmc_timestamp " . 
+		"FROM mb_user_wmc WHERE wmc_id IN (" . $wmcIdList . ") " .
+		"ORDER BY wmc_timestamp DESC";
+	
+	$res = db_prep_query($sql, $v, $t);
+	while($row = db_fetch_array($res)){
+		$currentResult = array();
+		$currentResult["id"] = $row["wmc_id"];
+		$currentResult["title"] = $row["wmc_title"];
+		$currentResult["timestamp"] = date("M d Y H:i:s", $row["wmc_timestamp"]); 
+		array_push($wmcArray, $currentResult);
+	}
+	return $wmcArray;
+}
+
+$json = new Mapbender_JSON();
+$queryObj = $json->decode(stripslashes($_REQUEST['queryObj']));
+$resultObj = array();
+
+$e = new mb_exception("command: " . $queryObj->command);
+
+$wmc = new wmc();
+$userId = $_SESSION[mb_user_id];
+
+switch($queryObj->command){
+
+	// gets available WMCs
+	case 'getWmc':
+		$resultObj["wmc"] = getWmc();
+	break;
+
+	// gets XML document of a WMC
+	case 'getWmcDocument':
+		$wmcId = $queryObj->parameters->id;
+		$doc = $wmc->getDocument($wmcId);
+		if (!$doc) {
+			$resultObj["error"] = "The WMC document could not be found.";
+		}
+		else {
+			$resultObj["wmc"] = array("document" => $doc);
+		}
+	break;
+
+	// deletes a WMC
+	case 'deleteWmc':
+		$wmcId = $queryObj->parameters->id;
+		if ($wmc->delete($wmcId)) {
+			$resultObj["success"] = "WMC has been deleted from the database.";
+		}
+		else {
+			$resultObj["error"] = "WMC could not be deleted.";
+		}
+	break;
+	
+	// loads a WMC (returns array of JS code)
+	case 'loadWmc':
+		$wmcId = $queryObj->parameters->id;
+		$wmc->createFromDb($wmcId);
+		$jsArray = $wmc->toJavaScript();
+		if ($jsArray) {
+			$resultObj["javascript"] = $jsArray;
+		}
+		else {
+			$resultObj["error"] = "WMC could not be loaded.";
+		}
+	break;
+
+	// merges data with WMC and loads it (returns array of JS code)
+	case 'mergeWmc':
+		$params = $queryObj->parameters;
+		
+		// generate a WMC for the current client state
+		$currentWmc = new wmc();
+		$currentWmc->createFromJs($params->mapObject, $params->generalTitle, $params->extensionData);
+
+		// get the desired WMC from the database
+		$wmcId = $queryObj->parameters->id;
+		$wmcXml = wmc::getDocument($wmcId);
+
+		// merge the two WMCs
+		$currentWmc->merge($wmcXml);
+		
+		// load the merged WMC
+		$jsArray = $currentWmc->toJavaScript();
+
+		if (is_array($jsArray) && count($jsArray) > 0) {
+			$resultObj["javascript"] = $jsArray;
+		}
+		else {
+			$resultObj["error"] = "WMC could not be loaded.";
+		}
+	break;
+	
+	// appends a WMC (returns JS code)
+	case 'appendWmc':
+		$params = $queryObj->parameters;
+		// generate a WMC for the current client state
+		$currentWmc = new wmc();
+		$currentWmc->createFromJs($params->mapObject, $params->generalTitle, $params->extensionData);
+
+		// get the desired WMC from the database
+		$wmcId = $queryObj->parameters->id;
+		$wmcXml = wmc::getDocument($wmcId);
+
+		// merge the two WMCs
+		$currentWmc->append($wmcXml);
+		
+		// load the merged WMC
+		$jsArray = $currentWmc->toJavaScript();
+
+		if (is_array($jsArray) && count($jsArray) > 0) {
+			$resultObj["javascript"] = $jsArray;
+		}
+		else {
+			$resultObj["error"] = "WMC could not be appended.";
+		}
+	break;
+	
+
+	// Invalid command
+	default:
+		$resultObj["error"] = "no action specified...";
+}
+
+sendOutput($resultObj);
+?>
\ No newline at end of file

Modified: trunk/mapbender/http/php/mod_map1.php
===================================================================
--- trunk/mapbender/http/php/mod_map1.php	2008-06-13 13:03:41 UTC (rev 2502)
+++ trunk/mapbender/http/php/mod_map1.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -54,8 +54,6 @@
 function init () {
 	parent.eventInitMap.register(function init_mod_map1(){
 		parent.mb_registerMapObj('mapframe1', 'maps', null,mod_map1_width, mod_map1_height);
-		document.getElementById("maps").style.width = mod_map1_width;
-		document.getElementById("maps").style.height = mod_map1_height;
 	});
 }
 

Modified: trunk/mapbender/http/php/mod_mapOV.php
===================================================================
--- trunk/mapbender/http/php/mod_mapOV.php	2008-06-13 13:03:41 UTC (rev 2502)
+++ trunk/mapbender/http/php/mod_mapOV.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -68,12 +68,12 @@
 		document.onmousedown = parent.mod_box_start;
 		document.onmouseup = mod_ov_getExtent;
 		document.onmousemove = parent.mod_box_run;
-		document.getElementById("maps").style.width = mod_overview_width;
-		document.getElementById("maps").style.height = mod_overview_height;   
 		
 		var ind = parent.getMapObjIndexByName('overview');
 		var ov_extent = parent.mb_mapObj[ind].getExtentInfos();
-		parent.mb_setWmcExtensionData({"ov_minx":ov_extent.minx,"ov_miny":ov_extent.miny,"ov_maxx":ov_extent.maxx,"ov_maxy":ov_extent.maxy});
+//		parent.mb_setWmcExtensionData({"ov_minx":ov_extent.minx,"ov_miny":ov_extent.miny,"ov_maxx":ov_extent.maxx,"ov_maxy":ov_extent.maxy});
+	
+		parent.mb_mapObj[ind].isOverview = true;
 	});
 }
 function mod_ov_setHandler(e){

Added: trunk/mapbender/http/php/mod_savewmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_savewmc_server.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_savewmc_server.php	2008-06-13 13:04:34 UTC (rev 2503)
@@ -0,0 +1,50 @@
+<?php
+#$Id: mod_insertWmcIntoDb.php 1198 2007-10-18 14:37:52Z baudson $
+#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../classes/class_wmc.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
+
+$json = new Mapbender_JSON();
+
+// get data from POST and SESSION
+$mapObject = $json->decode(stripslashes($_POST["mapObject"]));
+$userId = $_SESSION["mb_user_id"];
+$saveInSession = $_POST["saveInSession"];
+$generalTitle = $_POST["generalTitle"];
+$extensionData = $json->decode(stripslashes($_POST["extensionData"]));
+
+// create WMC object
+$wmc = new wmc();
+$wmc->createFromJs($mapObject, $generalTitle, $extensionData);
+
+if ($saveInSession) {
+	// store XML in session
+	$_SESSION["mb_wmc"] = $wmc->xml;
+	$_SESSION["epsg"] = $mapObject->epsg;
+	$_SESSION["previous_gui"] = $_SESSION["mb_user_gui"];
+	$e = new mb_notice("mod_insertWMCIntoDB: save WMC in session succeeded.");
+}
+else {
+	// insert WMC into database
+	$result = $wmc->insert();
+	echo $result["message"];
+}
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list