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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 31 11:15:19 EDT 2011


Author: verenadiewald
Date: 2011-08-31 08:15:19 -0700 (Wed, 31 Aug 2011)
New Revision: 8094

Modified:
   trunk/mapbender/http/javascripts/mod_legendDiv.php
Log:
added dyn_js.php for validation of element vars

Modified: trunk/mapbender/http/javascripts/mod_legendDiv.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_legendDiv.php	2011-08-31 15:14:16 UTC (rev 8093)
+++ trunk/mapbender/http/javascripts/mod_legendDiv.php	2011-08-31 15:15:19 UTC (rev 8094)
@@ -1,7 +1,7 @@
 <?php
 # $Id: mod_legend.php 6887 2010-09-03 14:51:46Z christoph $
 # http://www.mapbender.org/index.php/Legend
-# Copyright (C) 2005 CCGIS / terrestris 
+# Copyright (C) 2005 CCGIS / terrestris
 #
 # 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
@@ -9,14 +9,11 @@
 # any later version.
 #
 /*
-INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('Geoportal-RLP','legend',2,1,'legend','Legend','div','','',0,0,NULL ,NULL ,600,'','','div','../javascripts/mod_legendDiv.php','','mapframe1','','');
-INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('Geoportal-RLP', 'legend', 'checkbox_on_off', 'false', 'display or hide the checkbox to set the legend on/off' ,'var');
-INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('Geoportal-RLP', 'legend', 'css_file_legend', '../css/legend.css', '' ,'file/css');
-INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('Geoportal-RLP', 'legend', 'legendlink', 'false', '' ,'var');
-INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('Geoportal-RLP', 'legend', 'showgroupedlayertitle', 'true', 'show the title of the grouped layers in the legend' ,'var');
-INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('Geoportal-RLP', 'legend', 'showlayertitle', 'true', 'show the layer title in the legend' ,'var');
-INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('Geoportal-RLP', 'legend', 'showwmstitle', 'true', 'show the wms title in the legend' ,'var');
-INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('Geoportal-RLP', 'legend', 'stickylegend', 'false', 'parameter to decide wether the legend should stick on the mapframe1' ,'var');
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('<app_id>','legend',2,1,'legend','Legend','div','','',0,0,NULL ,NULL ,600,'','','div','../javascripts/mod_legendDiv.php','','mapframe1','','');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('<app_id>', 'legend', 'legendlink', 'false', '' ,'var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('<app_id>', 'legend', 'showgroupedlayertitle', 'true', 'show the title of the grouped layers in the legend' ,'var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('<app_id>', 'legend', 'showlayertitle', 'true', 'show the layer title in the legend' ,'var');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('<app_id>', 'legend', 'showwmstitle', 'true', 'show the wms title in the legend' ,'var');
 
 */
 # This program is distributed in the hope that it will be useful,
@@ -32,61 +29,55 @@
 $e_top = '10';
 $e_left = '10';
 
-
 echo "var mod_legend_target = '".$e_target."';\n";
 echo "var mod_legend_target_left = ".intval($e_left).";\n";
 echo "var mod_legend_target_top = ".intval($e_top).";\n";
-//echo "var mod_legend_target_width = ".db_result($res2,0,"e_width").";\n";
-//echo "var mod_legend_target_height = ".db_result($res2,0,"e_height").";\n";
+
+include '../include/dyn_js.php';
+//defaults for element vars
 ?>
 mod_legend_offsetLeft = 25;
 mod_legend_offsetTop = -10;
-showlayertitle = true;
-showwmstitle = true;
-legendlink = false;
 
-var checkbox_on_off = typeof checkbox_on_off === "undefined" ? 'false' : checkbox_on_off;
-var stickylegend = typeof stickylegend === "undefined" ? "false" : stickylegend;
+var legendlink = typeof legendlink === "undefined" ? 'false' : legendlink;
+var showwmstitle = typeof showwmstitle === "undefined" ? "false" : showwmstitle;
+var showlayertitle = typeof showlayertitle === "undefined" ? "false" : showlayertitle;
+var showgroupedlayertitle = typeof showgroupedlayertitle === "undefined" ? "false" : showgroupedlayertitle;
 
 function mod_legend_pos(frameName){
 	if(frameName == mod_legend_target){
 		var ind = getMapObjIndexByName(mod_legend_target);
 		var obj = document.getElementById("legend");
-	
-		if(stickylegend == 'true'){
-			obj.style.left = (parseInt(mb_mapObj[ind].width) + mod_legend_target_left + mod_legend_offsetLeft) + "px";
-		}
-	
-		
+
 		var str = "";
 		var str_tmp = "";
-						
+
 		for(var i=0; i<mb_mapObj[ind].wms.length; i++){
-			
+
 			 	var layerNames = mb_mapObj[ind].wms[i].getLayers(mb_mapObj[ind]);
 				for(var j=0; j<layerNames.length; j++){
-					var layerParent = mb_mapObj[ind].wms[i].checkLayerParentByLayerName(layerNames[j]); 
+					var layerParent = mb_mapObj[ind].wms[i].checkLayerParentByLayerName(layerNames[j]);
 					var layerTitle = mb_mapObj[ind].wms[i].getTitleByLayerName(layerNames[j]);
 					var layerStyle = mb_mapObj[ind].wms[i].getCurrentStyleByLayerName(layerNames[j]);
 					var legendUrl = false;
 					if(layerStyle == false){
-						legendUrl = mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],"");	
+						legendUrl = mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],"");
 					}
 					else{
 						legendUrl = mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],layerStyle);
 					}
-			         
+
 					if (legendUrl !== false){
-						
+
 //	 					if(layerParent == 0){
 		 					if(showlayertitle == 'true'){
-								str_tmp += "<div><span class='titles'>" + layerTitle+ "</span></div>";
+                                                        	str_tmp += "<div><span class='titles'>" + layerTitle+ "</span></div>";
 							}
 							str_tmp += "<div>";
 		                    if(legendlink == 'true'){
 		                    	str_tmp += "<a href='../php/result.php?lingo=deutsch&layer="+layerNames[j]+"' class='link_metadata' title='Zeigt Liste zum Thema: "+layerTitle+"' target='result'>";
 		                    }
-		                    str_tmp += "<img border=0 src = '";			
+		                    str_tmp += "<img border=0 src = '";
 							str_tmp += legendUrl;
 							str_tmp += "'></img>";
 							if (legendlink == 'true'){
@@ -94,7 +85,7 @@
 		                    }
 		                    str_tmp += "</div>";
 //	                	}
-					} 
+					}
 				}
 			if(str_tmp !=''){
 				if (showwmstitle == 'true'){
@@ -102,7 +93,7 @@
 				}
 				str += str_tmp;
 				str_tmp ='';
-			}		
+			}
 		}
 	    if(str != ""){
 			writeTag("", "legend", str);
@@ -112,7 +103,7 @@
 		}
 		return true;
 	}
-} 
+}
 
 // Todo: return-value may change in the next version....
 eventAfterMapRequest.register(function (obj) {
@@ -123,7 +114,7 @@
 function mod_legend_init(){
 	var obj = document.getElementById("legend");
 //	obj.style.top = mod_legend_target_top  + mod_legend_offsetTop;
-//	obj.style.left = mod_legend_target_left + mod_legend_target_width + mod_legend_offsetLeft; 
+//	obj.style.left = mod_legend_target_left + mod_legend_target_width + mod_legend_offsetLeft;
 //	var checkobj = document.getElementById("checkboxstyle");
 //	if (checkbox_on_off == 'false'){
 //		checkobj.style.display = "none";



More information about the Mapbender_commits mailing list