svn commit: r206 - trunk/mapbender/http/javascripts/mod_legend_tab.php

vera_schulze at osgeo.org vera_schulze at osgeo.org
Mon May 8 11:02:31 EDT 2006


Author: vera_schulze
Date: 2006-05-08 15:02:31+0000
New Revision: 206

Modified:
   trunk/mapbender/http/javascripts/mod_legend_tab.php   (contents, props changed)

Log:
Code cleaning, some comments left, 2 db_prep_query

Modified: trunk/mapbender/http/javascripts/mod_legend_tab.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_legend_tab.php?view=diff&rev=206&p1=trunk/mapbender/http/javascripts/mod_legend_tab.php&p2=trunk/mapbender/http/javascripts/mod_legend_tab.php&r1=205&r2=206
==============================================================================
--- trunk/mapbender/http/javascripts/mod_legend_tab.php	(original)
+++ trunk/mapbender/http/javascripts/mod_legend_tab.php	2006-05-08 15:02:31+0000
@@ -1,6 +1,6 @@
 <?php
-#$Id: mod_legend_tab.php,v 1.13 2006/03/09 08:54:41 uli_rothstein Exp $
-#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_legend_tab.php,v 1.13 2006/03/09 08:54:41 uli_rothstein Exp $
+# $Id$
+# http://www.mapbender.org/index.php/mod_legend_tab.php
 # Copyright (C) 2002 CCGIS 
 #
 # This program is free software; you can redistribute it and/or modify
@@ -38,8 +38,10 @@
 
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db(DB,$con);
-$sql = "SELECT e_target, e_width, e_height FROM gui_element WHERE e_id = 'legend' AND fkey_gui_id = '".$gui_id."'";
-$res = db_query($sql);
+$sql = "SELECT e_target, e_width, e_height FROM gui_element WHERE e_id = 'legend' AND fkey_gui_id = $1";
+$v = array($gui_id);
+$t = array('s');
+$res = db_prep_query($sql, $v, $t);
 $cnt = 0;
 while($row = db_fetch_array($res)){    
    $e_target = $row["e_target"];
@@ -47,8 +49,10 @@
 }
 if($cnt > 1){ echo "alert('legend: ID not unique!');";}
 #target position, with and height...
-$sql = "SELECT e_left,e_top,e_width,e_height FROM gui_element WHERE e_id = '".$e_target."' AND fkey_gui_id = '".$gui_id."'";
-$res = db_query($sql);
+$sql = "SELECT e_left,e_top,e_width,e_height FROM gui_element WHERE e_id = '".$e_target."' AND fkey_gui_id = $1";
+$v = array($gui_id);
+$t = array('s');
+$res = db_prep_query($sql, $v, $t);
 
 echo "<script type='text/javascript'>";
 echo "var mod_legend_target = '".$e_target."';";
@@ -66,56 +70,54 @@
 
 parent.mb_registerSubFunctions("window.frames['legend'].mod_legend_pos()");
 function mod_legend_init(){
-   var obj = parent.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;*/ 
+	var obj = parent.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;*/ 
 }
 function mod_legend_repaint(obj){
-//   if(obj.checked == true){
-      mod_legend_pos();     
-//   }
+	// if(obj.checked == true){
+	mod_legend_pos();     
+	// }
 }
 function mod_legend_pos(){
-  /**/
- 
-   var ind = parent.getMapObjIndexByName(mod_legend_target);
-   var obj = parent.document.getElementById("legend");
-   /*obj.style.left = parseInt(parent.mb_mapObj[ind].width) + mod_legend_target_left + mod_legend_offsetLeft;*/
-
-  /*if(document.forms[0].sw.checked ==  false){
-   parent.writeTag("legend", "leg", "");
-   return true;
-  }*/
+	var ind = parent.getMapObjIndexByName(mod_legend_target);
+	var obj = parent.document.getElementById("legend");
+	/*obj.style.left = parseInt(parent.mb_mapObj[ind].width) + mod_legend_target_left + mod_legend_offsetLeft;*/
+
+	/*if(document.forms[0].sw.checked ==  false){
+	parent.writeTag("legend", "leg", "");
+	return true;
+	}*/
 	var layers;
-  var str = "";
-   for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
-      if(parent.mb_mapObj[ind].wms[i].wms_getlegendurl != ""){
-         //header
-         layers = parent.mb_checkScale(mod_legend_target,ind,i);
-         if(layers[0] != ""){
-            str += "<span class='header'>" +parent.mb_mapObj[ind].wms[i].wms_title+ "</span>";         
+	var str = "";
+	for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
+		if(parent.mb_mapObj[ind].wms[i].wms_getlegendurl != ""){
+			//header
+			layers = parent.mb_checkScale(mod_legend_target,ind,i);
+			if(layers[0] != ""){
+				str += "<span class='header'>" +parent.mb_mapObj[ind].wms[i].wms_title+ "</span>";         
        
-            var layer = layers[0].split(",");
-            var titles = layers[2].split(",");
-        
-            for(var j=0; j<layer.length; j++){
-             str += "<div><span class='titles'>" +titles[j]+ "</span></div>";
-             str += "<div><img src = '";
-             str += parent.mb_mapObj[ind].wms[i].wms_getlegendurl + "&format=image/png&REQUEST=getlegendgraphic&VERSION=1.1.1&SERVICE=WMS&layer=";
-             str += layer[j];
-             str += "'></div>";
-             }
-          }        str += "<br>";   
-      }
-   
-   }
-   if(str != ""){
-      parent.writeTag("legend", "leg", str);
-   }
-   else{
-      parent.writeTag("legend", "leg", "");
-   }
-   return true;
+				var layer = layers[0].split(",");
+				var titles = layers[2].split(",");
+
+				for(var j=0; j<layer.length; j++){
+					str += "<div><span class='titles'>" +titles[j]+ "</span></div>";
+					str += "<div><img src = '";
+					str += parent.mb_mapObj[ind].wms[i].wms_getlegendurl + "&format=image/png&REQUEST=getlegendgraphic&VERSION=1.1.1&SERVICE=WMS&layer=";
+					str += layer[j];
+					str += "'></div>";
+				}
+			}
+			str += "<br>";   
+		}
+	}
+	if(str != ""){
+		parent.writeTag("legend", "leg", str);
+	}
+	else{
+		parent.writeTag("legend", "leg", "");
+	}
+  	return true;
 }
 
 // -->
@@ -124,7 +126,8 @@
 </head>
 <body onload='mod_legend_init()'>
 <form>
-<!--<span class='switch'>Legende ON/OFF<input type='checkbox' name='sw' checked='true' onclick='mod_legend_repaint(this)'>
+<!--
+<span class='switch'>Legende ON/OFF<input type='checkbox' name='sw' checked='true' onclick='mod_legend_repaint(this)'>
 </span>
 -->
 </form>




More information about the Mapbender_commits mailing list