svn commit: r438 - trunk/mapbender/http/html/mod_treefolder.php

uli at osgeo.org uli at osgeo.org
Wed Jun 14 04:25:35 EDT 2006


Author: uli
Date: 2006-06-14 08:25:35+0000
New Revision: 438

Modified:
   trunk/mapbender/http/html/mod_treefolder.php

Log:
prepared statements included
switchwms included

Modified: trunk/mapbender/http/html/mod_treefolder.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/html/mod_treefolder.php?view=diff&rev=438&p1=trunk/mapbender/http/html/mod_treefolder.php&p2=trunk/mapbender/http/html/mod_treefolder.php&r1=437&r2=438
==============================================================================
--- trunk/mapbender/http/html/mod_treefolder.php	(original)
+++ trunk/mapbender/http/html/mod_treefolder.php	2006-06-14 08:25:35+0000
@@ -1,7 +1,7 @@
 <?php
 session_start();
 require_once("../../conf/mapbender.conf");
-$con = db_connect($DBSERVER,$OWNER,$PW);
+$con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
 $gui_id = $_SESSION["mb_user_gui"];
 ?>
@@ -26,11 +26,10 @@
 </script>
 <?php
 echo "<script language='JavaScript'>";
-   require_once("../../conf/mapbender.conf");
-   $con = db_connect($DBSERVER,$OWNER,$PW);
-   db_select_db(DB,$con);
-   $sql = "SELECT e_target FROM gui_element WHERE e_id = '".$_REQUEST['e_id_css']."' AND fkey_gui_id = '".$_SESSION["mb_user_gui"]."'";
-   $res = db_query($sql);
+   $sql = "SELECT e_target FROM gui_element WHERE e_id = $1 AND fkey_gui_id = $2";
+   $v = array($_REQUEST['e_id_css'],$_SESSION["mb_user_gui"]);
+   $t = array('s','s');
+   $res = db_prep_query($sql,$v,$t);
    $e_target = db_result($res,0,"e_target");   
    echo "mod_treeGDE_map = '".$e_target."';";   
 echo "</script>";
@@ -95,7 +94,6 @@
 		aNodeParent.removeChild(aNode);
 	}
 }
-  
 function handleSelectedLayer(mapObj,wms_id,layername,type,status){
 	var mywms = new Array();
 	mywms[0] = wms_id;
@@ -103,6 +101,26 @@
 	mylayername[0] = layername;
 	parent.handleSelectedLayer_array(mapObj, mywms, mylayername, type, status);
 }
+function switchWMS(w,s){
+	for(var i=0; i<parent.mb_mapObj.length; i++){
+		if(parent.mb_mapObj[i].frameName == mod_treeGDE_map){
+			for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
+				if(parent.mb_mapObj[i].wms[ii].wms_id == w){
+					for(var iii=1; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){
+						if(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_selectable == '1'){
+							parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_visible = s;
+						}
+						if(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_queryable == '1'){
+							//parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_querylayer = s;
+						}
+					}
+				}
+			}
+		}
+	}
+	parent.mb_restateLayers(mod_treeGDE_map,w);
+	parent.setSingleMapRequest(mod_treeGDE_map,w);
+}
 function mod_treeGDE(){
   /**/
 	var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
@@ -111,18 +129,28 @@
 		//layer_shortname,wms_id,{visible | querylayer}
 		var myID = document.getElementsByTagName("input")[i].id;
 		var arrayID = document.getElementsByTagName("input")[i].id.split("###");
-		var thisLayer = parent.mb_getLayerObjByName(mod_treeGDE_map,arrayID[1],arrayID[0]);
-		if(arrayID[2] == "visible"){			
-			if(thisLayer.gui_layer_visible == '1'){
-				document.getElementById(myID).checked = true;
+		var wms_ind = parent.getWMSIndexById(mod_treeGDE_map,arrayID[1]);
+		if(arrayID[2] == "visible" && typeof(wms_ind) != "undefined"){
+			var arrayLayer = parent.mb_mapObj[ind].layers[wms_ind].split(",");
+			var isOn = false;
+			for(var ii=0; ii<arrayLayer.length; ii++){
+				if(arrayID[0] == arrayLayer[ii]){
+					isOn = true;
+				}
 			}
-			else{document.getElementById(myID).checked = false;}
+			if(isOn == true){ document.getElementById(myID).checked = true;}
+			if(isOn == false){ document.getElementById(myID).checked = false;}
 		}
-		if(arrayID[2] == "querylayer"){
-			if(thisLayer.gui_layer_querylayer == '1'){
-				document.getElementById(myID).checked = true;
+		if(arrayID[2] == "querylayer" && typeof(wms_ind) != "undefined"){
+			var arrayLayer = parent.mb_mapObj[ind].querylayers[wms_ind].split(",");
+			var isOn = false;
+			for(var ii=0; ii<arrayLayer.length; ii++){
+				if(arrayID[0] == arrayLayer[ii]){
+					isOn = true;
+				}
 			}
-			else{document.getElementById(myID).checked = false;}
+			if(isOn == true){ document.getElementById(myID).checked = true;}
+			if(isOn == false){ document.getElementById(myID).checked = false;}
 		}
 	}
     /*consider scalhints*/
@@ -245,8 +273,13 @@
        
        
       }  
-      else
-        linkedName =  '<IMG SRC="'+imagedir+'/1w.gif" BORDER="0" WIDTH="3">' + treeName[i]
+      else{
+        linkedName =  '<IMG SRC="'+imagedir+'/1w.gif" BORDER="0" WIDTH="3">';
+        if(switchwms == 'true'){
+        	linkedName += '<input type="checkbox" onclick="if(this.checked){switchWMS(\''+treeWMS[i]+'\',1)}else{switchWMS(\''+treeWMS[i]+'\',0)}">';
+        }
+        linkedName += treeName[i];
+      }
       // don't link folder icon if node has no sons
       if ( i == idx-1 || treeP_id[i+1] != treeId[i] ) {
         if ( treeDeep[ i ] == 0 )
@@ -419,10 +452,8 @@
   }
 
   function initIndex() {
-    for( var i=0; i<idx; i++ ){
-      id2treeIndex[ treeId[i] ] = i;
-      // alert(i + "  " + treeId[i]);
-    }
+    for( var i=0; i<idx; i++ )
+      id2treeIndex[ treeId[i] ] = i
   }
 
   function gif_name (name, width, height) {
@@ -512,7 +543,6 @@
   }
 
   var id2treeIndex = new Array()
-  
 
   // the structure is easy to understand with a simple example
   // p_id is the id of the parent
@@ -541,7 +571,7 @@
 							var temp = parent.mb_mapObj[i].wms[ii].objLayer[iii];     
 							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){                    
 								//alert((parseInt(temp.layer_id)+1) + " , " +0 + " , " +temp.layer_title + " , " +" , "+temp.layer_metadataurl);
-								Note((parseInt(temp.layer_id)+1),0,temp.layer_title,'','','','','');
+								Note((parseInt(temp.layer_id)+1),0,temp.layer_title,'','','','','',parent.mb_mapObj[i].wms[ii].wms_id,'');
 								parentObj = temp.layer_id+1;                  
 							}
 							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == "0"){




More information about the Mapbender_commits mailing list