[Mapbender-commits] r3585 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Feb 24 06:45:18 EST 2009


Author: christoph
Date: 2009-02-24 06:45:18 -0500 (Tue, 24 Feb 2009)
New Revision: 3585

Modified:
   trunk/mapbender/http/php/mod_gazetteerMetadata.php
   trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
Log:
http://trac.osgeo.org/mapbender/ticket/387

Modified: trunk/mapbender/http/php/mod_gazetteerMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata.php	2009-02-24 11:34:43 UTC (rev 3584)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata.php	2009-02-24 11:45:18 UTC (rev 3585)
@@ -99,9 +99,18 @@
    }
    else{   
 		document.getElementById("resultDivTag").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
-		parent.mb_ajax_json("../php/mod_gazetteerMetadata_search.php", {"search":document.form1.search.value}, function(jsonObj, status){
-			document.getElementById("resultDivTag").innerHTML = displayTable(jsonObj);
-		});
+		var ind = parent.getMapObjIndexByName('mapframe1');
+		
+		parent.mb_ajax_json(
+			"../php/mod_gazetteerMetadata_search.php", 
+			{
+				"search" : document.form1.search.value,
+				"srs" : parent.mb_mapObj[ind].epsg
+			}, 
+			function(jsonObj, status){
+				document.getElementById("resultDivTag").innerHTML = displayTable(jsonObj);
+			}
+		);
 		return false;
    }
 }
@@ -112,21 +121,41 @@
 		var resultObj = obj[attr];
 		if (typeof(resultObj) != 'function') {
 			text += "<tr><td valign='top'>";
+			var imgUrl = "";
+			var onclickFunction = "";
 			if (typeof(resultObj.layer_name) !== "undefined") {
-				text += "<a href='#' onClick='mod_addWMSLayerfromfilteredList(\""+resultObj.wms_getcapabilities+"\",\""+resultObj.wms_version+"\", \""+resultObj.layer_name+"\");'>";
-				text += "<img name='add_wms' src='../img/button_gray/metadata_layer.gif' border='0' title='Load'></a>";
-				text += "</td><td>";
-				text += "<a href='#' ";
-				text += "onClick='javascript:window.open(\"mod_layerMetadata.php?id="+resultObj.layer_id+"\", \"metadata\", \"width=450, height=600\");' title='Info'>"; 
-				text += resultObj.title+"</a>";	
+				imgUrl = "../img/button_gray/metadata_layer.gif";
+				onclickFunction = "mod_addWMSLayerfromfilteredList(\"" + 
+					resultObj.wms_getcapabilities + "\",\"" + 
+					resultObj.wms_version + "\", \"" + 
+					resultObj.layer_name+"\");";
 			}
 			else {
-				text += "<a href='#' onClick='mod_addWMSfromfilteredList(\""+resultObj.wms_getcapabilities+"\",\""+resultObj.wms_version+"\")'>";
-				text += "<img name='add_wms' src='../img/button_gray/metadata_wms.gif' border='0' title='Load'></a>";
-				text += "</td><td>";
-				text += "<a href='#' onClick='javascript:window.open(\"mod_layerMetadata.php?id="+resultObj.layer_id+"\", \"metadata\", \"width=450, height=600\");' title='Info'>";
-				text += resultObj.title+"</a>"
+				imgUrl = "../img/button_gray/metadata_wms.gif";
+				onclickFunction = "mod_addWMSfromfilteredList(\"" + 
+					resultObj.wms_getcapabilities + "\",\"" + 
+					resultObj.wms_version+"\");";
 			}
+			text += "<img name='add_wms' src='" + imgUrl + "' ";
+			text += "border='0' title='Load' ";
+			text += "onclick='" + onclickFunction + "'>";
+			if (resultObj.extent && resultObj.extent[0] !== null) {
+				text += "<img src='../img/tree_new/zoom.png' " + 
+					"onclick='" + 
+					"parent.mb_calculateExtent(\"mapframe1\", " + 
+					resultObj.extent[0] + "," + 
+					resultObj.extent[1] + "," + 
+					resultObj.extent[2] + "," + 
+					resultObj.extent[3] + ");" + 
+					"parent.zoom(\"mapframe1\", \"true\", 1.0);" + 
+					"'>";
+			}
+			text += "</td><td>";
+			text += "<a href='#' ";
+			text += "onclick='javascript:window.open(\"mod_layerMetadata.php?id=" + 
+				resultObj.layer_id + 
+				"\", \"metadata\", \"width=450, height=600\");' title='Info'>"; 
+			text += resultObj.title+"</a>";	
 			text += "</td></tr>";
 		}
 	}

Modified: trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata_search.php	2009-02-24 11:34:43 UTC (rev 3584)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata_search.php	2009-02-24 11:45:18 UTC (rev 3585)
@@ -3,9 +3,20 @@
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
 require_once(dirname(__FILE__)."/../classes/class_json.php");
 
+$json = new Mapbender_JSON();
+
 $user_id = $_SESSION["mb_user_id"];
-$query = $_REQUEST["search"];
+$query = stripslashes($_REQUEST["search"]);
+$srs = stripslashes($_REQUEST["srs"]);
 
+if (!preg_match("/^[a-zA-Z_\- ]+$/", $query)) {
+	echo "[]"; die;
+}
+
+if (!preg_match("/^[a-zA-Z_\-:0-9 ]+$/", $srs)) {
+	echo "[]"; die;
+}
+
 $n = new administration();
 $myguis = $n->getGuisByPermission($user_id, true);
 $mywms = $n->getWmsByOwnGuis($myguis);
@@ -31,9 +42,13 @@
 	$v = array();   
 	$t = array();   
 
-	$sql_wms = "SELECT layer.layer_id, wms.wms_title, wms.wms_getcapabilities, wms.wms_version ";
-	$sql_wms .= "FROM wms LEFT JOIN layer ON wms.wms_id = layer.fkey_wms_id ";
-	$sql_wms .= "WHERE layer.layer_pos = 0 AND wms.wms_id IN ("; 
+	$sql_wms = "SELECT DISTINCT layer.layer_id, wms.wms_title, " . 
+		"wms.wms_getcapabilities, wms.wms_version, " . 
+		"e.minx, e.miny, e.maxx, e.maxy " . 
+		"FROM wms LEFT JOIN layer ON wms.wms_id = layer.fkey_wms_id " . 
+		"LEFT JOIN layer_epsg e ON layer.layer_id = e.fkey_layer_id " . 
+		"AND e.epsg = '$srs' " . 
+		"WHERE layer.layer_pos = 0 AND wms.wms_id IN ("; 
 	for($i=0; $i<count($mywms); $i++){
 		if ($i > 0) {$sql_wms .= ",";}
 		$sql_wms .= "$".($i+1);
@@ -44,32 +59,67 @@
 	$res_wms = db_prep_query($sql_wms,$v,$t);
 
 	while ($row = db_fetch_array($res_wms)) {
-		array_push($obj, array('wms_getcapabilities' => $row['wms_getcapabilities'], 'wms_version' => $row['wms_version'], 'layer_id' => $row['layer_id'], 'title' => $row['wms_title']));
+		array_push($obj, array(
+			'wms_getcapabilities' => $row['wms_getcapabilities'], 
+			'wms_version' => $row['wms_version'], 
+			'layer_id' => $row['layer_id'], 
+			'title' => $row['wms_title'],
+			'extent' => array(
+				$row['minx'],
+				$row['miny'],
+				$row['maxx'],
+				$row['maxy']
+			)
+		));
 	}
 }
 
 if (count($mylayer) > 0) {
 	$v = array();   
 	$t = array();   
-	$sql_layer = "SELECT l.layer_id, l.fkey_wms_id, l.layer_title, l.layer_name ,";
-	$sql_layer .= "w.wms_getcapabilities, w.wms_version ";
-	$sql_layer .= "FROM layer l LEFT JOIN layer_keyword lkw LEFT JOIN keyword kw ON kw.keyword_id = lkw.fkey_keyword_id ";
-	$sql_layer .= "ON l.layer_id = lkw.fkey_layer_id LEFT JOIN wms w ON  l.fkey_wms_id = w.wms_id WHERE l.layer_id IN (";
+	$sql_layer = "SELECT DISTINCT l.layer_id, l.fkey_wms_id, l.layer_title, " . 
+		"l.layer_name, w.wms_getcapabilities, w.wms_version, " . 
+		"e.minx, e.miny, e.maxx, e.maxy " . 
+		"FROM layer l LEFT JOIN layer_keyword lkw " . 
+		"LEFT JOIN keyword kw ON kw.keyword_id = lkw.fkey_keyword_id " . 
+		"ON l.layer_id = lkw.fkey_layer_id " . 
+		"LEFT JOIN wms w ON l.fkey_wms_id = w.wms_id " . 
+		"LEFT JOIN layer_epsg e ON l.layer_id = e.fkey_layer_id " . 
+		"AND e.epsg = '$srs' " . 
+		"WHERE l.layer_id IN (";
+
 	for($i = 0; $i < count($mylayer); $i++){
 		if ($i > 0) {$sql_layer .= ",";}
 		$sql_layer .= "$".($i+1);
 		array_push($v, $mylayer[$i]);
 		array_push($t, 'i');   
 	}
-	$sql_layer .= ") AND (layer_title ILIKE '%".$query."%' OR layer_name ILIKE '%".$query."%' OR layer_abstract ILIKE '%".$query."%' OR kw.keyword ILIKE '%".$query."%') ";
+
+	$sql_layer .= ") AND (" . 
+		"layer_title ILIKE '%".$query."%' OR " . 
+		"layer_name ILIKE '%".$query."%' OR " . 
+		"layer_abstract ILIKE '%".$query."%' OR " . 
+		"kw.keyword ILIKE '%".$query."%') ";
 	$sql_layer .= "ORDER BY l.layer_title;";
 	$res_layer = db_prep_query($sql_layer,$v,$t);
 
+
 	while ($row = db_fetch_array($res_layer)) {
-		array_push($obj, array('wms_getcapabilities' => $row['wms_getcapabilities'], 'wms_version' => $row['wms_version'], 'layer_name' => $row['layer_name'], 'layer_id' => $row['layer_id'], 'title' => $row['layer_title']));
+		array_push($obj, array(
+			'wms_getcapabilities' => $row['wms_getcapabilities'], 
+			'wms_version' => $row['wms_version'], 
+			'layer_name' => $row['layer_name'], 
+			'layer_id' => $row['layer_id'], 
+			'title' => $row['layer_title'],
+			'extent' => array(
+				$row['minx'],
+				$row['miny'],
+				$row['maxx'],
+				$row['maxy']
+			)
+		));
 	}
 }
-$json = new Mapbender_JSON();
 $output = $json->encode($obj);
 echo $output;
-?>
\ No newline at end of file
+?>



More information about the Mapbender_commits mailing list