[Mapbender-commits] r7179 - trunk/mapbender/http/html

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Dec 2 07:53:44 EST 2010


Author: christoph
Date: 2010-12-02 04:53:44 -0800 (Thu, 02 Dec 2010)
New Revision: 7179

Modified:
   trunk/mapbender/http/html/mod_treefolderPlain.php
Log:
#729


Modified: trunk/mapbender/http/html/mod_treefolderPlain.php
===================================================================
--- trunk/mapbender/http/html/mod_treefolderPlain.php	2010-12-02 12:53:15 UTC (rev 7178)
+++ trunk/mapbender/http/html/mod_treefolderPlain.php	2010-12-02 12:53:44 UTC (rev 7179)
@@ -2,7 +2,7 @@
 # $Id: mod_treefolder2.php 2975 2008-09-18 12:58:42Z nimix $
 # http://www.mapbender.org/index.php/Mod_treefolder2.php
 # Copyright (C) 2007 Melchior Moos
-# 
+#
 # 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)
@@ -25,7 +25,7 @@
 	Fenster1.focus();
 }
 <?php
-	echo "mod_treeGDE_map = '".$e_target[0]."';";   
+	echo "mod_treeGDE_map = '".$e_target[0]."';";
 ?>
 var msgObj = {};
 msgObj.tooltipHandleWms = '<?php echo _mb("(De)activate this service");?>';
@@ -49,14 +49,14 @@
 	}
 	for(var i = 0; i < map.wms.length; i++) {
 		var currentWms = map.wms[i];
-		
+
 		treefolderTitleArray.push({
 			title : currentWms.objLayer.length > 0 ?
-				currentWms.objLayer[0].gui_layer_title : 
+				currentWms.objLayer[0].gui_layer_title :
 				currentWms.wms_title,
 			layer : []
 		});
-		
+
 		for (var j = 0; j < currentWms.objLayer.length; j++) {
 			var currentLayer = currentWms.objLayer[j];
 			treefolderTitleArray[treefolderTitleArray.length-1].layer.push({
@@ -76,7 +76,7 @@
 			for (var i = 0; i < translatedTitleArray.length; i++) {
 				var currentWms = map.wms[i];
 				currentWms.wms_currentTitle = translatedTitleArray[i].title;
-				
+
 				for(var j = 0; j < currentWms.objLayer.length; j++) {
 					var currentLayer = currentWms.objLayer[j];
 					if (translatedTitleArray[i].layer.length > j) {
@@ -136,7 +136,7 @@
 	array_push($str, $left);
 	array_push($nr, $row['rgt']);
 	array_push($str, $right);
-	
+
 	//finish all nodes that have no further childs
 	while(count($rights) > 0 && $rights[count($rights)-1]<$row['lft']){
 		array_pop($rights);
@@ -156,7 +156,7 @@
 if(count($str)>0){
 	//order js array elements
 	array_multisort($nr, $str);
-	
+
 	//output javascript vars
 	$arrNodesStr = "[['root_id', ['Layer','javascript:_foo()'],[".implode("",$str)."]]];";
 	$arrNodesStr = str_replace(array("[]", ",]"),array("","]"),$arrNodesStr);
@@ -184,7 +184,7 @@
 if (typeof(alerterror) === 'undefined')alerterror = 'false';
 if (typeof(openfolder) === 'undefined')openfolder = 'false';
 if (typeof(handlesublayer) === 'undefined')handlesublayer = 'false';
-if (typeof(enlargetreewidth) === 'undefined') enlargetreewidth = 'false'; 
+if (typeof(enlargetreewidth) === 'undefined') enlargetreewidth = 'false';
 if (typeof(menu) === 'undefined')menu = '';
 if (typeof(redirectToMetadataUrl) !== 'undefined' && redirectToMetadataUrl == "false") {
 	redirectToMetadataUrl = false;
@@ -260,11 +260,11 @@
 	if(selectedMap==-1 && selectedWMS==-1 && selectedLayer==-1){
 		selectedMap=i;
 		selectedWMS=ii;
-		selectedLayer=iii;		
+		selectedLayer=iii;
 		return;
 	}
 	//scalehints
-	var scale = parseInt(mb_getScale(mod_treeGDE_map));	
+	var scale = parseInt(mb_getScale(mod_treeGDE_map));
 	if(scale < parseInt(mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) && parseInt(mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) != 0){
 		if(selectedLayer==0)
 		   	setNodeColor(arrNodes[0][0]+"|wms_"+ mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
@@ -296,7 +296,7 @@
 		var scale = parseInt( myMapObj.getScale());
 		for(var ii=0; ii< myMapObj.wms.length; ii++){
 			for(var iii=1; iii< myMapObj.wms[ii].objLayer.length; iii++){
-				if(scale < parseInt( myMapObj.wms[ii].objLayer[iii].gui_layer_minscale) && parseInt( myMapObj.wms[ii].objLayer[iii].gui_layer_minscale) != 0){                    
+				if(scale < parseInt( myMapObj.wms[ii].objLayer[iii].gui_layer_minscale) && parseInt( myMapObj.wms[ii].objLayer[iii].gui_layer_minscale) != 0){
 						if(iii==0)
 					   	setNodeColor(arrNodes[0][0]+"|wms_"+ myMapObj.wms[ii].wms_id, '#999999');
 						else
@@ -317,7 +317,7 @@
 				}
 			}
 		}
-	}	
+	}
 
 function updateCheckState(){
 	if(!initialized||lock_check)return;
@@ -332,7 +332,7 @@
 						path = arrNodes[0][0]+"|wms_"+ mb_mapObj[i].wms[ii].wms_id+"|"+ mb_mapObj[i].wms[ii].objLayer[iii].layer_id;
 						checkNode(path, 0,  mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_visible==='1'||mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_visible===1, false);
 						if(ficheckbox == 'true')
-							checkNode(path, 1,  mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_querylayer=='1', false);	
+							checkNode(path, 1,  mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_querylayer=='1', false);
 					}
 				}
 			}
@@ -344,7 +344,7 @@
 function operaLoad(){
 	initArray();
 	renderTree();
-	setTimeout('initWmsCheckboxen();updateScale();',100);	
+	setTimeout('initWmsCheckboxen();updateScale();',100);
 }
 
 function loadTree(){
@@ -358,7 +358,7 @@
 	document.getElementById("treeGDE").appendChild(div);
 
 	if(window.opera){
-		setTimeout('operaLoad()',200);	
+		setTimeout('operaLoad()',200);
 		return;
 	}
 	initArray();
@@ -379,7 +379,7 @@
 		init_mapcheck();
 	renderTree();
 	if(window.opera)
-		setTimeout('initWmsCheckboxen();updateScale();',100);	
+		setTimeout('initWmsCheckboxen();updateScale();',100);
 	else{
 		initWmsCheckboxen();
 		updateScale();
@@ -392,7 +392,7 @@
 	t.onerror=null;
 	t.onabort=null;
 	if(state[wms]!=-1 && alerterror=='true'){
-		state[wms]=-1;	
+		state[wms]=-1;
 		if(confirm('Failed to Load WMS "'+ mb_mapObj[map].wms[wms].objLayer[0].layer_currentTitle+'" from Server "'+ mb_mapObj[map].wms[wms].wms_getmap.substr(0, mb_mapObj[map].wms[wms].wms_getmap.length-1)+'"\nDo you want to try to load it in a new window?')){
 			window.open(t.src,"");
 		}
@@ -405,10 +405,10 @@
 
 function checkComplete(wms, map, img, first){
 	var ind= getMapObjIndexByName(mod_treeGDE_map);
-	if (mb_mapObj[ind].wms[wms].mapURL == false || 
+	if (mb_mapObj[ind].wms[wms].mapURL == false ||
 		!mb_mapObj[ind].getDomElement().ownerDocument.getElementById(map) ||
 		mb_mapObj[ind].getDomElement().ownerDocument.getElementById(map).complete) {
-		
+
 		if(state[wms]!=-1){
 			for(var i=1;i< mb_mapObj[ind].wms[wms].objLayer.length;i++){
 				if(mb_mapObj[ind].wms[wms].objLayer[i].gui_layer_visible===1||mb_mapObj[ind].wms[wms].objLayer[i].gui_layer_visible==="1"){
@@ -425,13 +425,13 @@
 			state[wms]=0;
 //			 frames[mod_treeGDE_map].document.getElementById(map).onerror=imgerror;
 //			 frames[mod_treeGDE_map].document.getElementById(map).onabort=imgerror;
-	
+
 			if(showstatus=='true')
 				setNodeImage(img, "loading_folder.gif");
 		}
 
 		if(state[wms]!=-1)
-			setTimeout('checkComplete('+wms+', "'+map+'", "'+img+'");',100);		
+			setTimeout('checkComplete('+wms+', "'+map+'", "'+img+'");',100);
 	}
 }
 
@@ -508,7 +508,7 @@
 		dialogHtml += ">" + my.layer_style[i].title + "</option>";
 	}
 	dialogHtml += "</select>";
-	
+
 	if(my.layer_style.length > 1) {
 		$("<div id='changeStyleDialog' title='<?php echo _mb('Change layer style');?>'><?php echo _mb('Please select a style');?>: </div>").dialog(
 			{
@@ -531,7 +531,7 @@
 	else {
 		alert("<?php echo _mb('There is no different style available for this layer.');?>");
 	}
-	
+
 }
 
 //---begin------------- opacity --------------------
@@ -562,7 +562,7 @@
 		l=selectedLayer;
 	}
 	if(j==-1||k==-1||l==-1){
-		alert("<?php echo _mb('You have to select the WMS you want to move up!');?> ")	
+		alert("<?php echo _mb('You have to select the WMS you want to move up!');?> ")
 		return;
 	}
 	var lid= mb_mapObj[j].wms[k].objLayer[l].layer_id;
@@ -594,7 +594,7 @@
 		l=selectedLayer;
 	}
 	if(j==-1||k==-1||l==-1){
-		alert("<?php echo _mb('You have to select the WMS you want to move down!');?>")	
+		alert("<?php echo _mb('You have to select the WMS you want to move down!');?>")
 		return;
 	}
 	var lid= mb_mapObj[j].wms[k].objLayer[l].layer_id;
@@ -604,7 +604,7 @@
 	}
 	treeState = getState();
 	 mb_mapObj[j].zoom(true, 1.0);
-	 mb_execloadWmsSubFunctions();	
+	 mb_execloadWmsSubFunctions();
 	//find layer and select
 	for(k=0;k< mb_mapObj[j].wms.length;k++){
 		for(l=0;l< mb_mapObj[j].wms[k].objLayer.length;l++){
@@ -626,7 +626,7 @@
 		l=selectedLayer;
 	}
 	if(j==-1||k==-1||l==-1){
-		alert("<?php echo _mb('You have to select the WMS you want to delete!');?>")	
+		alert("<?php echo _mb('You have to select the WMS you want to delete!');?>")
 		return;
 	}
 	if(l!=0){
@@ -642,15 +642,15 @@
 		return;
 	}
 	if(confirm('<?php echo _mb("Are you sure you want to remove");?>' + ' "'+ mb_mapObj[j].wms[k].objLayer[l].layer_currentTitle+'"?')){
-  		 mb_mapObjremoveWMS(j,k); 
+  		 mb_mapObjremoveWMS(j,k);
 		 mb_mapObj[j].zoom(true, 1.0);
-		 mb_execloadWmsSubFunctions();	
+		 mb_execloadWmsSubFunctions();
 	}
 }
 
 function updateParent(path){
 	if(lock_check)return;
-	var reset_lock=!lock_update; 
+	var reset_lock=!lock_update;
 	lock_update=true;
 	var state=getChildrenCheckState(path, 0);
 	//enableCheckbox(path, (state!=-1)); //3rd state
@@ -661,20 +661,36 @@
 	else{
 		setTimeout('setNodeImage("'+path+'", "closed_folder.png");', 100);
 	}
-	
-	if(reset_lock)
+
+	if(reset_lock){
 		lock_update=false;
+	}
+	handleSelectedWMS(path, true);
+
 }
 
 function handleSelectedWMS(path){
 	if(lock_update)return;
 	var t = path.split("|");
 	var wms_id = t[t.length-1].substr(4);
-	var reset_lock=!lock_check; 
+	var reset_lock=!lock_check;
 	var ind =  getMapObjIndexByName(mod_treeGDE_map);
 	var wms =  getWMSIndexById(mod_treeGDE_map,wms_id);
 	var layername =  mb_mapObj[ind].wms[wms].objLayer[0].layer_name;
-	var bChk = IsChecked(path, 0);	
+	var bChk = IsChecked(path, 0);
+
+	// in this case, only the root layer visibility/querylayer
+	// needs to be adjusted, without cascading the changes to
+	// its children
+	if (arguments.length === 2 && arguments[1]) {
+		var l = mb_mapObj[ind].wms[wms].getLayerByLayerName(layername);
+		l.gui_layer_visible = bChk ? 1 : 0;
+		l.gui_layer_querylayer = bChk ? 1 : 0;
+
+		mb_restateLayers(mod_treeGDE_map,wms_id);
+		setSingleMapRequest(mod_treeGDE_map,wms_id);
+		return;
+	}
 	 mb_mapObj[ind].wms[wms].handleLayer(layername,"visible",bChk?"1":"0");
 	 mb_mapObj[ind].wms[wms].handleLayer(layername,"querylayer",bChk?"1":"0");
 	lock_check=true;
@@ -696,9 +712,9 @@
 
 function handleSelection(path, box){
 	if(lock_update)return;
-	var reset_lock=!lock_check; 
+	var reset_lock=!lock_check;
 	lock_check=true;
-	var bChk = IsChecked(path, box);	
+	var bChk = IsChecked(path, box);
 //	enableCheckbox(path, 0, true);
 	checkChildren(path, box, bChk);
 	if(reset_lock){
@@ -719,14 +735,14 @@
 	var controls="";
 	if( mb_mapObj.length > 0){
 		for(var i=0; i< mb_mapObj.length; i++){
-			if( mb_mapObj[i].elementName == mod_treeGDE_map){ 
+			if( mb_mapObj[i].elementName == mod_treeGDE_map){
 				for(var ii=0; ii< mb_mapObj[i].wms.length; ii++){
 					if( mb_mapObj[i].wms[ii].gui_wms_visible === '1' ||  mb_mapObj[i].wms[ii].gui_wms_visible === 1){
-						for(var iii=0; iii< mb_mapObj[i].wms[ii].objLayer.length; iii++){          
-							var temp =  mb_mapObj[i].wms[ii].objLayer[iii];     
-							if( mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){ 
+						for(var iii=0; iii< mb_mapObj[i].wms[ii].objLayer.length; iii++){
+							var temp =  mb_mapObj[i].wms[ii].objLayer[iii];
+							if( mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){
 								if(!temp.gui_layer_selectable == '1' && !temp.gui_layer_queryable == '1')
-									continue;				
+									continue;
 
 								parentNode = arrNodes[0][0];
 								if(eval("categories.wms_"+ mb_mapObj[i].wms[ii].wms_id) !== undefined)
@@ -753,7 +769,7 @@
 								if(switchwms=='true')controls='<INPUT type="checkbox" title="' + msgObj.tooltipHandleWms + '"  onclick="handleSelectedWMS(\''+parentNode+'|wms_'+ mb_mapObj[i].wms[ii].wms_id+'\');" />';
 								if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\''+ defaultMetadataUrl + '&id='+temp.layer_uid+'\');'+'"><img alt="'+msgObj.tooltipMetadata+'" title="'+msgObj.tooltipMetadata+'" src="'+imagedir+'/info.png" /></a>';
 								addNode(parentNode,["wms_"+ mb_mapObj[i].wms[ii].wms_id,[temp.layer_currentTitle,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"'+ defaultMetadataUrl + '&id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,,temp.layer_currentTitle,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
-								parentObj = parentNode+"|wms_"+ mb_mapObj[i].wms[ii].wms_id;              
+								parentObj = parentNode+"|wms_"+ mb_mapObj[i].wms[ii].wms_id;
 							}
 							if( mb_mapObj[i].wms[ii].objLayer[iii].layer_parent && (handlesublayer=="true"|| mb_mapObj[i].wms[ii].objLayer[iii].layer_parent=="0")){
 								var parentLayer = "";
@@ -764,8 +780,8 @@
 										if( mb_mapObj[i].wms[ii].objLayer[jj].layer_pos==parseInt( mb_mapObj[i].wms[ii].objLayer[j].layer_parent)){
 											j=jj;
 											break;
-										}										
-									}									
+										}
+									}
 									parentLayer = "|" +  mb_mapObj[i].wms[ii].objLayer[j].layer_id + parentLayer;
 								}
 								if(temp.gui_layer_selectable == '1' || temp.gui_layer_queryable == '1'){
@@ -786,7 +802,7 @@
 									if(menu.indexOf("change_style")!=-1)c_menu+="menu_style,";
 									if(menu.indexOf("legend")!=-1)c_menu+="menu_legend";
 									c_menu+="]";
-									
+
 									controls = [];
 									controls.push('<input type="checkbox"  title="' + msgObj.tooltipLayerVisible + '" ');
 									if(temp.layer_name=="")
@@ -822,20 +838,20 @@
 			}
 		}
 	}
-	initialized=true;   
+	initialized=true;
 }
 
 function initWmsCheckboxen(){
 	var hidden=0;
 	if( mb_mapObj.length > 0){
 		for(var i=0; i< mb_mapObj.length; i++){
-			if( mb_mapObj[i].elementName == mod_treeGDE_map){ 
+			if( mb_mapObj[i].elementName == mod_treeGDE_map){
 				for(var ii=0; ii< mb_mapObj[i].wms.length; ii++){
 					if( mb_mapObj[i].wms[ii].gui_wms_visible === '1' ||  mb_mapObj[i].wms[ii].gui_wms_visible === 1){
-						for(var iii=0; iii< mb_mapObj[i].wms[ii].objLayer.length; iii++){          
-							var temp =  mb_mapObj[i].wms[ii].objLayer[iii];     
-							if( mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){                    
-								updateParent(arrNodes[0][0]+"|wms_"+ mb_mapObj[i].wms[ii].wms_id);                  
+						for(var iii=0; iii< mb_mapObj[i].wms[ii].objLayer.length; iii++){
+							var temp =  mb_mapObj[i].wms[ii].objLayer[iii];
+							if( mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){
+								updateParent(arrNodes[0][0]+"|wms_"+ mb_mapObj[i].wms[ii].wms_id);
 							}
 						}
 					}
@@ -848,7 +864,7 @@
 					setState(treeState);
 				}
 				else if(openfolder!='false' && openFolderIndex < mb_mapObj[i].wms.length && openFolderIndex > 0) {
-								
+
 					setState(arrNodes[0][0]+"|wms_"+ mb_mapObj[i].wms[ openFolderIndex].wms_id);
 				}
 			}



More information about the Mapbender_commits mailing list