svn commit: r898 - trunk/mapbender/http/javascripts/mod_savewmc.php

christoph at osgeo.org christoph at osgeo.org
Tue Nov 21 03:44:14 EST 2006


Author: christoph
Date: 2006-11-21 08:44:13+0000
New Revision: 898

Modified:
   trunk/mapbender/http/javascripts/mod_savewmc.php

Log:
* added js function htmlspecialchars
* added keywords (for a start 'Mapbender' and 'WMC')
* added scalehints (TODO: change to 'Extensions')
* changed epsg from mb_mapObj[ind].epsg to mb_mapObj[ind].wms[i].gui_wms_epsg
* added correct data format
* removed obsolete function mod_savewmc_init

Modified: trunk/mapbender/http/javascripts/mod_savewmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_savewmc.php?view=diff&rev=898&p1=trunk/mapbender/http/javascripts/mod_savewmc.php&p2=trunk/mapbender/http/javascripts/mod_savewmc.php&r1=897&r2=898
==============================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.php	(original)
+++ trunk/mapbender/http/javascripts/mod_savewmc.php	2006-11-21 08:44:13+0000
@@ -45,13 +45,7 @@
 	document.getElementsByTagName('body')[0].setAttribute("onUnload", "mod_savewmc('session');");
 }
 
-
-try {
-	if (saveInSession) {}
-}
-catch(e) {
-	saveInSession = 0;
-}
+try {if (saveInSession) {}}catch(e) {saveInSession = 0;}
 
 if (saveInSession == '1') {
 	mb_registerInitFunctions('setOnUnload()');
@@ -60,19 +54,34 @@
 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);  ?>";
 
+//0 = Keine Anführungszeichen umwandeln
+//1 = Nur einfache Anführungszeichen umwandeln
+//2 = Nur doppelte Anführungszeichen umwandeln (Standardeinstellung)
+//3 = Beide Arten (einfache und doppelte Anführungszeichen) umwandeln
+function htmlspecialchars(str,typ) {
+	if(typeof str=="undefined") str="";
+	if(typeof typ!="number") typ=2;
+	typ=Math.max(0,Math.min(3,parseInt(typ)));
+	var html=new Array();
+	html[38]="&amp;"; html[60]="&#38;#60;"; html[62]="&#38;#62;";
+	if(typ==1 || typ==3) html[39]="&#38;#39;";
+	if(typ==2 || typ==3) html[34]="&#38;#34;";
+	for(var i in html) eval("str=str.replace(/"+String.fromCharCode(i)+"/g,\""+html[i]+"\");");
+    return str;
+}
 function mod_savewmc(title){
 	var user = "<?php echo $_SESSION["mb_user_id"]; ?>";
 	var ind = getMapObjIndexByName(mod_savewmc_target);
 	var session = 0;
 	if (title) {
-		var generalTitle = title;
+		var generalTitle = htmlspecialchars(title,0);
 		title_alert = 0;
 		if (title == 'session') {
 			session = 1;
 		}
 	}
 	else {
-		var generalTitle = prompt("Save WMC as...");
+		var generalTitle = htmlspecialchars(prompt("Save WMC as..."),0);
 		title_alert = 1;
 	}
 	if (generalTitle != null){
@@ -137,7 +146,7 @@
 		// Missing: Extension
 
 		//ViewContext
-		wmc += "&lt;?xml version=\"1.0\" encoding=\"<?php echo CHARSET; ?>\" ?&gt;\n";
+		wmc += "&lt;?xml version=\"1.0\" encoding=\"<?php echo CHARSET; ?>\"?&gt;";
 		// wmc += "&lt;!ENTITY amp    \"&amp;#38;#38;\"&gt;\n";
 		wmc += "&lt;ViewContext version=\"" + version + "\" ";
 		wmc += "id = \"" + id + "\" ";
@@ -241,15 +250,15 @@
 
 			// BEGIN: new code
 
-			// in the end, this array contains all epsg´s of this wms 
+			// in the end, this array contains all epsgs of this wms 
 			var wms_epsg = new Array();
 
-			// the gui_wms_epsg is always the first epsg in this layer´s epsg list
-			wms_epsg[0] = mb_mapObj[ind].wms[i].gui_wms_epsg;
+			// the gui_wms_epsg is always the first epsg in this layers epsg list
+			wms_epsg[0] = mb_mapObj[ind].epsg;
 
 			// the epsg of the mapObj has to be in this list
 			if (mb_mapObj[ind].wms[i].gui_wms_epsg != mb_mapObj[ind].epsg){
-				wms_epsg[1] = mb_mapObj[ind].epsg;
+				wms_epsg[1] = mb_mapObj[ind].wms[i].gui_wms_epsg;
 			}
 				  
 			// add all gui_epsg if not already in the array
@@ -276,17 +285,16 @@
 						layerHidden = 1;
 					}
 					layerQueryable = mb_mapObj[ind].wms[i].objLayer[j].layer_queryable;
-					layerName = mb_mapObj[ind].wms[i].objLayer[j].layer_name;
-					layerTitle = mb_mapObj[ind].wms[i].objLayer[j].layer_title;
+					layerName = htmlspecialchars(mb_mapObj[ind].wms[i].objLayer[j].layer_name,0);
+					layerTitle = htmlspecialchars(mb_mapObj[ind].wms[i].objLayer[j].layer_title, 0);
 					layerAbstract = mb_mapObj[ind].wms[i].wms_abstract; //To Do: insert actual abstract
 					layerDataUrl = mb_mapObj[ind].wms[i].objLayer[j].layer_dataurl_href; 
-					//layerDataUrl = mb_mapObj[ind].wms[i].objLayer[j].layer_dataurl_href; 
-					layerMetadataUrl = mb_mapObj[ind].wms[i].objLayer[j].layer_metadataurl; 
-					//layerMetadataUrl = mb_mapObj[ind].wms[i].objLayer[j].layer_metadataurl; 
+					layerMetadataUrl = mb_mapObj[ind].wms[i].objLayer[j].layer_metadataurl;
+					layerMinscale = mb_mapObj[ind].wms[i].objLayer[j].layer_minscale; 
+					layerMaxscale = mb_mapObj[ind].wms[i].objLayer[j].layer_maxscale; 
 					wmsVersion = mb_mapObj[ind].wms[i].wms_version;
-					wmsTitle = mb_mapObj[ind].wms[i].wms_title;
+					wmsTitle = htmlspecialchars(mb_mapObj[ind].wms[i].wms_title,0)	;
 					wmsOnlineResource = mb_mapObj[ind].wms[i].wms_getmap;
-					//wmsOnlineResource = mb_mapObj[ind].wms[i].wms_getmap;
 
 					wmc += "\t\t&lt;Layer queryable = \"" + layerQueryable + "\" hidden = \"" + layerHidden + "\"&gt;\n";
 					wmc += "\t\t\t&lt;Server service = \"OGC:WMS\" version = \"" + wmsVersion + "\" title = \"" + wmsTitle + "\"&gt;\n";
@@ -321,26 +329,29 @@
 						wmc += "\t\t\t&lt;/MetadataURL&gt;\n";
 					}
 
+					if (layerMinscale && layerMaxscale) {
+						wmc += "\t\t\t&lt;ScaleHint min=\""+layerMinscale+"\" max=\""+layerMaxscale+"\"/&gt;\n";
+					}
+
 					//layerFormat
 					wmc += "\t\t\t&lt;FormatList&gt;\n";
 
-					for (var k = 0; k < 1; k++){
+					var data_format_current = false;
+					for (var k = 0; k < wms[i].data_format.length; k++){
 
-						if (k == 0){
-							layerFormat_current = 1; // To do: insert proper data
-						}
-						else{
-							layerFormat_current = 0; // To do: insert proper data
-						}
-						layerFormat = mb_mapObj[ind].wms[i].gui_wms_mapformat;
-
-						wmc += "\t\t\t\t&lt;Format ";
-						if (layerFormat_current == 1){
-							wmc += "current = \"1\"";
+						if (wms[i].data_type[k] == 'map') {
+							layerFormat = mb_mapObj[ind].wms[i].data_format[k];
+							wmc += "\t\t\t\t&lt;Format";
+							if (data_format_current == false && ( 
+									(mb_mapObj[ind].wms[i].data_format[k] == mb_mapObj[ind].wms[i].gui_wms_mapformat) ||
+									(k == wms[i].data_format.length-1)
+							)){
+								wmc += " current = \"1\"";
+								data_format_current = true;
+							}
+							wmc += "&gt;" + layerFormat + "&lt;/Format&gt;\n";
 						}
-						wmc += "&gt;" + layerFormat + "&lt;/Format&gt;\n";
 					}
-
 					wmc += "\t\t\t&lt;/FormatList&gt;\n";
 
 					// LayerStyle
@@ -378,8 +389,6 @@
 							layerStyle_legendUrl_height = ""; // To Do: add proper data
 							layerStyle_legendUrl_format = ""; // To Do: add proper data
 
-							//layerStyle_legendUrl = stripAmpersand(mb_mapObj[ind].wms[i].wms_getlegendurl);
-
 							if (layerStyle_current == 1){
 								wmc += " current = \"1\"";
 							}
@@ -404,7 +413,7 @@
 		wmc += "\t&lt;/LayerList&gt;\n";
 		wmc += "&lt;/ViewContext&gt;\n";
 
-		if (session == true) {
+		if (session == 1) {
 			var wmc_win = window.open('about:blank', 'wmc_confirm', 'width=200,height=10,left='+Math.round(0.5*screen.width)+',top='+Math.round(0.5*screen.height));
 			document.sendData.target = 'wmc_confirm';
 //			document.sendData.target = '_blank';
@@ -415,12 +424,4 @@
 		document.sendData.submit();
 	}
 	return id;
-}
-function mod_savewmc_init(obj){
-	//document.getElementById("savewmc").src = mod_zoom1_img_over.src;
-	//obj.onmouseover = new Function("mod_zoomIn1_over()");
-	//obj.onmouseout = new Function("mod_zoomIn1_out()");
-}
-
-
-
+}
\ No newline at end of file




More information about the Mapbender_commits mailing list