[Mapbender-commits] r4397 - in branches/2.6/http: classes javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jul 20 09:38:57 EDT 2009


Author: christoph
Date: 2009-07-20 09:38:57 -0400 (Mon, 20 Jul 2009)
New Revision: 4397

Modified:
   branches/2.6/http/classes/class_wfs.php
   branches/2.6/http/javascripts/mod_wfs_SpatialRequest.php
   branches/2.6/http/javascripts/mod_wfs_gazetteer_client.php
   branches/2.6/http/php/mod_wfs_result.php
Log:
http://trac.osgeo.org/mapbender/ticket/443

Modified: branches/2.6/http/classes/class_wfs.php
===================================================================
--- branches/2.6/http/classes/class_wfs.php	2009-07-20 13:38:38 UTC (rev 4396)
+++ branches/2.6/http/classes/class_wfs.php	2009-07-20 13:38:57 UTC (rev 4397)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_connector.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_gml.php");
 require_once(dirname(__FILE__)."/class_ows.php");
@@ -75,11 +75,6 @@
 				$this->getVersion() . "&typename=" . $featureTypeName . 
 				"&filter=" . urlencode($filter);
 
-		// this code is for compatibility with the old Mapbender client side
-//		if (strpos($featureTypeName, ":") !== -1) {
-//			preg_replace("/<ogc:PropertyName>([a-zA-Z_]+:)([a-zA-Z_]+)</ogc:PropertyName>/");
-//		}
-
 		return $this->get($url);
 	}
 	
@@ -107,10 +102,16 @@
 	}
 	
 	public function getFeature ($featureTypeName, $filter) {
-		if (strpos($this->getFeature, "?") === false) {
+
+// FOR NOW, WE ONLY DO POST REQUESTS!
+// THE FILTERS ARE CONSTRUCTED ON THE CLIENT SIDE,
+// SO CHANGING THEM HERE ACCORDING TO GET/POST
+// WOULD BE TOO MUCH FOR NOW
+//
+//		if (strpos($this->getFeature, "?") === false) {
 			return $this->getFeaturePost($featureTypeName, $filter);
-		}
-		return $this->getFeatureGet($featureTypeName, $filter);
+//		}
+//		return $this->getFeatureGet($featureTypeName, $filter);
 	}
 	
 	/**
@@ -154,13 +155,13 @@
 
 		switch (strtolower($method)) {
 			case "delete":
-				$requestData = $this->transactionDelete($feature, $featureTypeName, $authWfsConfElement);
+				$requestData = $this->transactionDelete($feature, $featureType, $authWfsConfElement);
 				break;
 			case "update":
-				$requestData = $this->transactionUpdate($feature, $featureTypeName, $authWfsConfElement, $gml, $geomColumnName);
+				$requestData = $this->transactionUpdate($feature, $featureType, $authWfsConfElement, $gml, $geomColumnName);
 				break;
 			case "insert":
-				$requestData = $this->transactionInsert($feature, $featureTypeName, $authWfsConfElement, $gml, $geomColumnName);
+				$requestData = $this->transactionInsert($feature, $featureType, $authWfsConfElement, $gml, $geomColumnName);
 				break;
 			default:
 				$e = new mb_exception("Invalid transaction method: " . $method);
@@ -171,37 +172,44 @@
 		return $this->post($this->transaction, $postData);
 	}
 	
-	protected function transactionInsert ($feature, $featureTypeName, $authWfsConfElement, $gml, $geomColumnName) {
+	protected function transactionInsert ($feature, $featureType, $authWfsConfElement, $gml, $geomColumnName) {
+		$featureTypeName = $featureType->name;
+		$ns = $this->getNamespace($featureTypeName);
+		
 		// authentication
 		$authSegment = "";
 		if (!is_null($authWfsConfElement)) {
 			$user = eval("return " . $authWfsConfElement->authVarname . ";");
-			$authSegment = "<$authWfsConfElement->name>$user</$authWfsConfElement->name>";
+			$authSegment = "<$ns:{$authWfsConfElement->name}>$user</$ns:{$authWfsConfElement->name}>";
 		}
 
 		// add properties
 		$propertiesSegment = "";
 		foreach ($feature->properties as $key => $value) {
 			if (isset($value)) {
-				$propertiesSegment .= "<$key><![CDATA[$value]]></$key>";
+				$propertiesSegment .= "<$ns:$key><![CDATA[$value]]></$ns:$key>";
 			}
 		}
 
 		// add spatial data
-		$geomSegment = "<$geomColumnName>" . $gml . "</$geomColumnName>";
+		$geomSegment = "<$ns:$geomColumnName>" . $gml . "</$ns:$geomColumnName>";
 
 		return "<wfs:Insert><$featureTypeName>" . $authSegment . 
 				$propertiesSegment . $geomSegment . 
 				"</$featureTypeName></wfs:Insert>";
 	}
 	
-	protected function transactionUpdate ($feature, $featureTypeName, $authWfsConfElement, $gml, $geomColumnName) {
+	protected function transactionUpdate ($feature, $featureType, $authWfsConfElement, $gml, $geomColumnName) {
+		$featureTypeName = $featureType->name;
+		$featureNS = $this->getNameSpace($featureType->name);
+
 		// authentication
 		$authSegment = "";
 		if (!is_null($authWfsConfElement)) {
 			$user = eval("return " . $authWfsConfElement->authVarname . ";");
 			$authSegment = "<ogc:PropertyIsEqualTo><ogc:PropertyName>" . 
-				$authWfsConfElement->name . "</ogc:PropertyName><ogc:Literal>" . 
+				$featureNS . ":" . $authWfsConfElement->name . 
+				"</ogc:PropertyName><ogc:Literal>" . 
 				$user . "</ogc:Literal></ogc:PropertyIsEqualTo>";
 
 		}
@@ -210,7 +218,7 @@
 		$propertiesSegment = "";
 		foreach ($feature->properties as $key => $value) {
 			if (isset($value)) {
-				$propertiesSegment .= "<wfs:Property><wfs:Name>$key</wfs:Name>" . 
+				$propertiesSegment .= "<wfs:Property><wfs:Name>$featureNS:$key</wfs:Name>" . 
 					"<wfs:Value><![CDATA[$value]]></wfs:Value></wfs:Property>";
 			}
 		}
@@ -227,7 +235,7 @@
 		$filterSegment = "<ogc:Filter>" . $condition . "</ogc:Filter>";
 
 		// add geometry
-		$geomSegment = "<wfs:Property><wfs:Name>$geomColumnName</wfs:Name>" . 
+		$geomSegment = "<wfs:Property><wfs:Name>$featureNS:$geomColumnName</wfs:Name>" . 
 			"<wfs:Value>" . $gml . "</wfs:Value></wfs:Property>";
 					
 
@@ -241,13 +249,17 @@
 	protected function getFeatureIdFilter ($fid) {
 	}
 	
-	protected function transactionDelete ($feature, $featureTypeName, $authWfsConfElement) {
+	protected function transactionDelete ($feature, $featureType, $authWfsConfElement) {
+		$featureTypeName = $featureType->name;
+		$featureNS = $this->getNameSpace($featureType->name);
+		
 		// authentication
 		$authSegment = "";
 		if (!is_null($authWfsConfElement)) {
 			$user = eval("return " . $authWfsConfElement->authVarname . ";");
 			$authSegment = "<ogc:PropertyIsEqualTo><ogc:PropertyName>" . 
-				$authWfsConfElement->name . "</ogc:PropertyName><ogc:Literal>" . 
+				$featureNS . ":" . $authWfsConfElement->name . 
+				"</ogc:PropertyName><ogc:Literal>" . 
 				$user . "</ogc:Literal></ogc:PropertyIsEqualTo>";
 
 		}
@@ -479,4 +491,4 @@
 		return WfsToDb::exists($this);
 	}
 }
-?>
\ No newline at end of file
+?>

Modified: branches/2.6/http/javascripts/mod_wfs_SpatialRequest.php
===================================================================
--- branches/2.6/http/javascripts/mod_wfs_SpatialRequest.php	2009-07-20 13:38:38 UTC (rev 4396)
+++ branches/2.6/http/javascripts/mod_wfs_SpatialRequest.php	2009-07-20 13:38:57 UTC (rev 4397)
@@ -418,13 +418,19 @@
 // The coordinates come from the current client (?)
 //			var srs = wfs_config[js_wfs_conf_id[i]]['featuretype_srs'];
 			var srs = mod_wfs_spatialRequest_epsg;
-			var filter = "<ogc:Filter xmlns:ogc=\"http://ogc.org\" xmlns:gml=\"http://www.opengis.net/gml\">";
+			var filter = "<ogc:Filter>";
 
+			var ftName = wfs_config[js_wfs_conf_id[i]]['featuretype_name'];
+			var pattern = /:[a-zA-Z_]+/;
+			var ftns = "";
+			if (ftName.match(pattern)) {
+				ftns = ftName.replace(pattern, ":");
+			}
 			if(buttonPolygon.filteroption=='within'){
 				filter += "<Within><ogc:PropertyName>";
 				for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
 					if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
-						filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+						filter += ftns + wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
 					}
 				}
 				filter += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
@@ -440,7 +446,7 @@
 				filter += "<Intersects><ogc:PropertyName>";
 				for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
 					if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
-						filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+						filter += ftns + wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
 					}
 				}
 				filter += "</ogc:PropertyName><gml:Polygon srsName='"+srs+"'>";
@@ -464,13 +470,20 @@
 // The coordinates come from the current client (?)
 //			var srs = wfs_config[js_wfs_conf_id[i]]['featuretype_srs'];
 			var srs = mod_wfs_spatialRequest_epsg;
-			var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>";
+			var filter = "<ogc:Filter>";
 
+			var ftName = wfs_config[js_wfs_conf_id[i]]['featuretype_name'];
+			var pattern = /:[a-zA-Z_]+/;
+			var ftns = "";
+			if (ftName.match(pattern)) {
+				ftns = ftName.replace(pattern, ":");
+			}
+
 			if(buttonRectangle.filteroption=='within'){
 				filter += "<Within><ogc:PropertyName>";
 				for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
 					if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
-						filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+						filter += ftns + wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
 					}
 				}
 				filter += "</ogc:PropertyName><gml:Polygon srsName='"+srs+"'>";
@@ -491,7 +504,7 @@
 				filter += "<Intersects><ogc:PropertyName>";
 				for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
 					if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
-						filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+						filter += ftns + wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
 					}
 				}
 				filter += "</ogc:PropertyName><gml:Polygon srsName='"+srs+"'>";
@@ -525,16 +538,25 @@
 		var realWorld2 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
 		var realWorld3 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
 		var realWorld4 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+		
+		
 		for(var i=0; i<js_wfs_conf_id.length; i++){
+
 // I guess we should use the SRS of the map client, not the WFS? 
 // The coordinates come from the current client (?)
 //			var srs = wfs_config[js_wfs_conf_id[i]]['featuretype_srs'];
+			var ftName = wfs_config[js_wfs_conf_id[i]]['featuretype_name'];
+			var pattern = /:[a-zA-Z_]+/;
+			var ftns = "";
+			if (ftName.match(pattern)) {
+				ftns = ftName.replace(pattern, ":");
+			}
 			var srs = mod_wfs_spatialRequest_epsg;
-			var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>";
+			var filter = "<ogc:Filter>";
 			filter += "<Intersects><ogc:PropertyName>";
 			for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
 				if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
-					filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+					filter += ftns + wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
 				}
 			}
 			filter += "</ogc:PropertyName><gml:Polygon srsName='"+srs+"'><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";

Modified: branches/2.6/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- branches/2.6/http/javascripts/mod_wfs_gazetteer_client.php	2009-07-20 13:38:38 UTC (rev 4396)
+++ branches/2.6/http/javascripts/mod_wfs_gazetteer_client.php	2009-07-20 13:38:57 UTC (rev 4397)
@@ -43,32 +43,9 @@
 	echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
 	echo "var e_id_css = '" . $e_id_css . "';";
 ?>
-
-// Element var maxHighlightedPoints
-try{
-	if (maxHighlightedPoints){
-		maxHighlightedPoints = Number(maxHighlightedPoints);
-
-		if (isNaN(maxHighlightedPoints)) {
-//			var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints must be a number.");
-		}
-	}
-}
-catch(e){
-	maxHighlightedPoints = 0;
-//	var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints is not set, see 'edit element vars'.");
-}
 // Element var showResultInPopup
 try {if(showResultInPopup){}}catch(e) {showResultInPopup = 1;}
 
-//element var openLinkFromSearch for opening attribute link directly onclick of searchResult entry
-try{
-	if (openLinkFromSearch){}
-}
-catch(e){
-	openLinkFromSearch =0;
-}
-
 var targetArray = targetString.split(",");
 var global_wfsConfObj;
 var global_selectedWfsConfId;
@@ -481,18 +458,18 @@
 	if (parent.ie) {
 		selectNode.onchange = function() {
 		global_selectedWfsConfId = this.value;
-     	if(typeof(resultGeometryPopup)!="undefined"){
-	 		resultGeometryPopup.destroy();
+     	if(typeof(parent.resultGeometryPopup)!="undefined"){
+	 		parent.resultGeometryPopup.destroy();
 	 	}
-	 	if(typeof(wfsPopup)!="undefined"){
-	 		wfsPopup.destroy();
+	 	if(typeof(parent.wfsPopup)!="undefined"){
+	 		parent.wfsPopup.destroy();
 	 	}
     	appendStyles();
 		appendWfsForm();
 		};
 	}
 	else{
-	   selectNode.setAttribute("onchange", "if(typeof(resultGeometryPopup)!='undefined'){resultGeometryPopup.destroy();}if(typeof(wfsPopup)!='undefined'){wfsPopup.destroy();};global_selectedWfsConfId = this.value;appendStyles();appendWfsForm();");
+	   selectNode.setAttribute("onchange", "if(typeof(parent.resultGeometryPopup)!='undefined'){parent.resultGeometryPopup.destroy();}if(typeof(parent.wfsPopup)!='undefined'){parent.wfsPopup.destroy();};global_selectedWfsConfId = this.value;appendStyles();appendWfsForm();");
 	}
 	var isSelected = false;
 	for (var wfsConfId in global_wfsConfObj) {
@@ -652,12 +629,12 @@
  	}
 
 	//remove result popup
-	if(typeof(resultGeometryPopup)!="undefined"){
- 		resultGeometryPopup.destroy();
+	if(typeof(parent.resultGeometryPopup)!="undefined"){
+ 		parent.resultGeometryPopup.destroy();
  	}
  	//remove detail popup
- 	if(typeof(wfsPopup)!="undefined"){
- 		wfsPopup.destroy();
+ 	if(typeof(parent.wfsPopup)!="undefined"){
+ 		parent.wfsPopup.destroy();
  	}
 
  	if(document.getElementById('spatialResHint')){
@@ -715,14 +692,13 @@
 	if(geomArray.count()>0){
  		geomArray.empty();
  	}
- 	if(typeof(resultGeometryPopup)!="undefined"){
- 		resultGeometryPopup.destroy();
+ 	if(typeof(parent.resultGeometryPopup)!="undefined"){
+ 		parent.resultGeometryPopup.destroy();
  	}
- 	if(typeof(wfsPopup)!="undefined"){
- 		wfsPopup.destroy();
+ 	if(typeof(parent.wfsPopup)!="undefined"){
+ 		parent.wfsPopup.destroy();
  	}
-	global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":generalHighlightZIndex}, generalHighlightLineWidth);
-
+	
 	var filterParameterCount = getNumberOfFilterParameters();
 
 	if(filterParameterCount == 0 && spatialRequestGeom == null){
@@ -736,7 +712,14 @@
 
 			var el = global_wfsConfObj[global_selectedWfsConfId].element;
 			var srs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
+			var ftName = global_wfsConfObj[global_selectedWfsConfId].featuretype_name;
 
+			var pattern = /:[a-zA-Z_]+/;
+			var ftns = "";
+			if (ftName.match(pattern)) {
+				ftns = ftName.replace(pattern, ":");
+			}
+
 			for (var i = 0; i < el.length; i++) {
 				if (el[i]['f_search'] == 1){
 					if(el[i]['f_form_element_html'].match(/\<select/)){
@@ -764,7 +747,7 @@
 					for (var j=0; j < a.length; j++) {
 						if(el[i]['f_operator']=='bothside'){
 							orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>*";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -777,7 +760,7 @@
 					}
 						else if(el[i]['f_operator']=='rightside'){
 							orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -790,7 +773,7 @@
 						}
 						else if(el[i]['f_operator']=='greater_than'){
 							orConditions += "<ogc:PropertyIsGreaterThan>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -803,7 +786,7 @@
 						}
 						else if(el[i]['f_operator']=='less_than'){
 							orConditions += "<ogc:PropertyIsLessThan>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -816,7 +799,7 @@
 						}
 						else if(el[i]['f_operator']=='less_equal_than'){
 							orConditions += "<ogc:PropertyIsLessThanOrEqualTo>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -829,7 +812,7 @@
 						}
 						else if(el[i]['f_operator']=='greater_equal_than'){
 							orConditions += "<ogc:PropertyIsGreaterThanOrEqualTo>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -842,7 +825,7 @@
 						}
 						else if(el[i]['f_operator']=='equal'){
 							orConditions += "<ogc:PropertyIsEqualTo>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -855,7 +838,7 @@
 						}
 						else{
 							orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-							orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+							orConditions += "<ogc:PropertyName>" + ftns + el[i]['element_name'] + "</ogc:PropertyName>";
 							orConditions += "<ogc:Literal>*";
 							if(el[i]['f_toupper'] == 1){
 								orConditions += a[j].toUpperCase();
@@ -882,8 +865,7 @@
 						andConditions += "<Within><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								var elementName = el[j]['element_name'];
-								andConditions += el[j]['element_name'];
+								andConditions += ftns + el[j]['element_name'];
 							}
 						}
 						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
@@ -899,8 +881,7 @@
 						andConditions += "<Intersects><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								var elementName = el[j]['element_name'];
-								andConditions += el[j]['element_name'];
+								andConditions += ftns + el[j]['element_name'];
 							}
 						}
 						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
@@ -921,8 +902,7 @@
 						andConditions += "<Within><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								var elementName = el[j]['element_name'];
-								andConditions += el[j]['element_name'];
+								andConditions += ftns + el[j]['element_name'];
 							}
 						}
 						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
@@ -943,8 +923,7 @@
 						andConditions += "<Intersects><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								var elementName = el[j]['element_name'];
-								andConditions += el[j]['element_name'];
+								andConditions += ftns + el[j]['element_name'];
 							}
 						}
 						andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
@@ -977,8 +956,7 @@
 					andConditions += "<Intersects><ogc:PropertyName>";
 					for (var j=0; j < el.length; j++) {
 						if(el[j]['f_geom']==1){
-							var elementName = el[j]['element_name'];
-							andConditions += el[j]['element_name'];
+							andConditions += ftns + el[j]['element_name'];
 						}
 					}
 					andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
@@ -986,16 +964,13 @@
 					andConditions += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
 					andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
 				}
-				//andConditions += "<ogc:Not><ogc:PropertyIsNull>";
-	            //andConditions += "<ogc:PropertyName>" + elementName + "</ogc:PropertyName>";
-	       		//andConditions += "</ogc:PropertyIsNull></ogc:Not>";
 			}
 
 			if (filterParameterCount > 1 || spatialRequestGeom != null) {
 				andConditions = "<And>" + andConditions + "</And>";
 			}
 
-			var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
+			var filter = "<ogc:Filter>"+andConditions+"</ogc:Filter>";
 
 			document.getElementById("res").innerHTML = "<table><tr><td><img src='"+progressIndicatorImg+"'></td><td>"+progressIndicatorText+"</td></tr></table>";
 			var parameters = {
@@ -1030,7 +1005,7 @@
 						}
 						else {
 							document.getElementById("res").innerHTML = '';
-							displayResult();
+							alert("No results.");
 						}
 					}
 		       		else {
@@ -1049,223 +1024,14 @@
 }
 
 function displayResult(geom){
-	geomArray = geom;
-	if(geomArray!=null && geomArray.count()>0){
-		var contentHtml = createListOfGeometries();
+	if (showResultInPopup == 1) {
+		parent.displayResultGeometryList(targetArray, geom, "popup", "gazetteerWFS", global_wfsConfObj, global_selectedWfsConfId);
 	}
-	else{
-		var contentHtml = "No results.";
+	else {
+		parent.displayResultGeometryList(targetArray, geom, "", "gazetteerWFS", global_wfsConfObj, global_selectedWfsConfId);
 	}
-
-	if(showResultInPopup==1){
-		if (typeof(resultGeometryPopup) == "undefined") {
-			resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
-		}
-		else {
-			resultGeometryPopup.destroy();
-			resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
-		}
-		resultGeometryPopup.show();
-		parent.$("#resultTable").tablesorter({
-     		sortList: [[0,0]],
-     		widgets: ['zebra']
-        });
-	}
-	else{
-		document.getElementById("res").innerHTML = contentHtml;
-	}
 }
 
-function createListOfGeometries(){
-	if(showResultInPopup==1){
-		var domPath = "window.frames['"+frameName+"'].";
-	}
-	else{
-		var domPath = "";
-	}
-	var listOfGeom = "<form name='resultListForm'><table class='tablesorter' id='resultTable'>\n";
-	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
-	var labelArray = [];
-	if (geomArray.count() > 0) {
-
-		if(showResultInPopup==1){
-			listOfGeom += "<thead><tr>";
-			var labelObj = getListTitle();
-			for (var k = 1 ; k < labelObj.length; k ++) {
-				listOfGeom += "<th>";
-				listOfGeom += labelObj[k];
-				listOfGeom += "</th>";
-			}
-			listOfGeom += "</tr></thead>";
-		}
-		listOfGeom += "<tbody>";
-		for (var i = 0 ; i < geomArray.count(); i ++) {
-			if (geomArray.get(i).get(-1).isComplete()) {
-				listOfGeom += "<tr>\n";
-				var resultElObj = getListValues(geomArray.get(i));
-				for (var l = 1 ; l < resultElObj.length; l ++) {
-					if(resultElObj[l]!=''){
-						listOfGeom += "<td style='cursor:pointer;\n";
-						if(showResultInPopup==1){
-							if ((i % 2) === 0) {
-								listOfGeom += "' class='even'";
-							}
-							else {
-								listOfGeom += "' class='odd'";
-							}
-						}
-						else{
-							if ((i % 2) === 0) {
-								listOfGeom += "' class='even'";
-							}
-							else {
-								listOfGeom += "' class='uneven'";
-							}
-						}
-						listOfGeom += " onmouseover=\""+domPath+"setResult('over',"+i+")\" ";
-						listOfGeom += " onmouseout=\""+domPath+"setResult('out',"+i+")\" ";
-						listOfGeom += " onclick=\""+domPath+"setResult('click',"+i+"); "+domPath+"showWfs("+i+");\" ";
-						listOfGeom += ">"+ resultElObj[l] +"</td>";
-					}
-				}
-				listOfGeom += "\t</tr>\n";
-			}
-		}
-	}
-	listOfGeom += "</tbody></table></form>\n";
-	return listOfGeom;
-}
-
-function getListTitle(){
-	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
-	var labelArray = [];
-	for (var j = 0 ; j < wfsConf.element.length ; j++) {
-		if(wfsConf.element[j].f_show == 1 && wfsConf.element[j].f_label!=''){
-			var labelPos = wfsConf.element[j].f_respos;
-			labelArray[labelPos] = wfsConf.element[j].f_label;
-		}
-	}
-	return labelArray;
-}
-
-function getListValues(geom){
-	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
-	var resultArray = [];
-	for (var i = 0 ; i < wfsConf.element.length ; i++) {
-		if (wfsConf.element[i].f_show == 1 && geom.e.getElementValueByName(wfsConf.element[i].element_name) !=false) {
-			var pos = wfsConf.element[i].f_respos;
-			if(pos>0){
-				resultArray[pos] = geom.e.getElementValueByName(wfsConf.element[i].element_name);
-			}
-		}
-	}
-	return resultArray;
-}
-
-function showWfs(geometryIndex) {
-	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
-	var wfsElement = geomArray.get(geometryIndex).e;
-	var showDetailsObj = [];
-	var details = 0;
-	for (var i = 0 ; i <wfsConf.element.length; i ++) {
-		if(wfsConf.element[i].f_show_detail == 1 && wfsElement.getElementValueByName(wfsConf.element[i].element_name)!=''){
-			var elPos = wfsConf.element[i].f_detailpos;
-			if(elPos>0){
-				var currentObj = {};
-//				showDetailsObj[elPos] = {};
-				currentObj.elPos = elPos;
-				currentObj.data = {};
-				//var elementVal = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
-				//showDetailsObj[elPos][wfsConf.element[i].f_label] = elementVal;
-				if(wfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
-					var newPath = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
-					var setUrl = wfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+newPath+"' target='_blank'");
-					if(setUrl.match(/><\/a>/)){
-						var newLink	=	setUrl.replace(/><\/a>/, ">"+wfsElement.getElementValueByName(wfsConf.element[i].element_name)+"</a>");
-					}
-					else{
-						var newLink = setUrl;
-					}
-					if(openLinkFromSearch=='1'){
-						window.open(elementVal, elementVal,"width=500, height=400,left=100,top=100,scrollbars=yes");
-					}
-//					showDetailsObj[elPos][wfsConf.element[i].f_label] =  newLink;
-					currentObj.data[wfsConf.element[i].f_label] = newLink;
-				}
-				else{
-//					showDetailsObj[elPos][wfsConf.element[i].f_label] = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
-					currentObj.data[wfsConf.element[i].f_label] = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
-				}
-				showDetailsObj.push(currentObj);
-			}
-		}
-	}
-	var resultHtml = "";
-	resultHtml += "<table style='background-color:#EEEEEE;'>\n";
-
-	showDetailsObj.sort(showDetailObjSort);
-	for (var i=0; i < showDetailsObj.length; i++) {
-//		var currentDetail = showDetailsObj[elPos];
-		var currentDetail = showDetailsObj[i].data;
-		for(var key in currentDetail){
-			var currentDetailName = key;
-			var currentDetailValue = currentDetail[key];
-			resultHtml +="<tr><td>\n";
-			resultHtml += currentDetailName;
-			resultHtml +="</td>\n";
-			resultHtml += "<td>\n";
-			resultHtml += currentDetailValue;
-			resultHtml += "</td></tr>\n";
-		}
-	}
-	resultHtml += "</table>\n";
-	if(showResultInPopup==1 && showDetailsObj.length > 0){
-		if (typeof(wfsPopup) == "undefined") {
-			wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
-		}
-		else {
-			wfsPopup.destroy();
-			wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
-		}
-		wfsPopup.show();
-	}
-}
-
-function showDetailObjSort (a, b) {
-	return (parseInt(a.elPos) - parseInt(b.elPos));
-}
-
-/*
-* event -> {over || out || click}
-* geom -> commaseparated coordinates x1,y1,x2,y2 ...
-*/
-function setResult(event, index){
-	var currentGeom = geomArray.get(index);
-	if (maxHighlightedPoints > 0 && currentGeom.getTotalPointCount() > maxHighlightedPoints) {
-		currentGeom = currentGeom.getBBox4();
-	}
-	if (event == "over") {
-		global_resultHighlight.add(currentGeom, generalHighlightColor);
-		global_resultHighlight.paint();
-	}
-	else if (event == "out"){
-		global_resultHighlight.del(currentGeom, generalHighlightColor);
-		global_resultHighlight.paint();
-	}
-	else if (event == "click"){
-		global_resultHighlight.del(currentGeom, generalHighlightColor);
-		var bbox = currentGeom.getBBox();
-		var bufferFloat = parseFloat(global_wfsConfObj[global_selectedWfsConfId].g_buffer);
-		var buffer = new parent.Point(bufferFloat,bufferFloat);
-		bbox[0] = bbox[0].minus(buffer);
-		bbox[1] = bbox[1].plus(buffer);
-		parent.mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
-		parent.zoom(targetArray[0], 'true', 1.0);
-		global_resultHighlight.add(currentGeom, generalHighlightColor);
-		global_resultHighlight.paint();
-	}
-	return true;
-}
 function callPick(obj){
 	dTarget = obj;
 	var dp = window.open('../tools/datepicker/datepicker.php?m=Jan_Feb_Mar_Apr_May_June_July_Aug_Sept_Oct_Nov_Dec&d=Mon_Tue_Wed_Thu_Fri_Sat_Sun&t=today','dp','left=200,top=200,width=230,height=210,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0');

Modified: branches/2.6/http/php/mod_wfs_result.php
===================================================================
--- branches/2.6/http/php/mod_wfs_result.php	2009-07-20 13:38:38 UTC (rev 4396)
+++ branches/2.6/http/php/mod_wfs_result.php	2009-07-20 13:38:57 UTC (rev 4397)
@@ -35,7 +35,7 @@
  * TODO: this function is also in mod_wfs_result!! Maybe merge someday.
  */
 function isValidVarName ($varname) {
-	if (preg_match("/[\$]{1}_[a-z]+\[\"[a-z_]+\"\]/i", $varname) != 0) {
+	if (preg_match("/[\$]{1}_[a-z]+\[\"[a-z_]+\"\]/i", $varname) !== 0) {
 		return true;
 	}
 	return false;
@@ -46,6 +46,26 @@
  */
 function checkAccessConstraint($filter, $wfs_conf_id) {
 	/* wfs_conf_element */
+	$sql = "SELECT f.featuretype_name AS name FROM " . 
+		"wfs_featuretype AS f, wfs_conf AS c " . 
+		"WHERE c.wfs_conf_id = $1 AND " . 
+		"c.fkey_featuretype_id = f.featuretype_id";
+	$v = array($wfs_conf_id);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	$row = db_fetch_array($res);
+	if ($row) {
+		$ns = substr($row["name"], 0, strpos($row["name"], ":")) . ":";
+	}
+	else {
+		$ns = "";
+	}
+	
+	unset($sql);
+	unset($v);
+	unset($t);
+	unset($res);
+			
 	$sql = "SELECT * FROM wfs_conf_element ";
 	$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
 	$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
@@ -67,7 +87,9 @@
 		if (isValidVarName($auth_varname)) {
 			$user = eval("return " . $auth_varname . ";");
 			$pattern = "(<ogc:Filter[^>]*>)(.*)(</ogc:Filter>)";
-			$replacement = "\\1<And>\\2<ogc:PropertyIsEqualTo><ogc:PropertyName>" . $element_name . "</ogc:PropertyName><ogc:Literal>" . $user . "</ogc:Literal></ogc:PropertyIsEqualTo></And>\\3"; 
+			$replacement = "\\1<And>\\2<ogc:PropertyIsEqualTo><ogc:PropertyName>" . 
+				$ns . $element_name . "</ogc:PropertyName><ogc:Literal>" . $user . 
+				"</ogc:Literal></ogc:PropertyIsEqualTo></And>\\3"; 
 			$filter = eregi_replace($pattern, $replacement, $filter);
 		}
 	}
@@ -102,4 +124,4 @@
 
 header('Content-type: text/html');
 echo $geoJson;
-?> 
\ No newline at end of file
+?> 



More information about the Mapbender_commits mailing list