[Mapbender-commits] r1033 - trunk/mapbender/http/extensions

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jan 24 08:14:06 EST 2007


Author: christoph
Date: 2007-01-24 08:14:06 -0500 (Wed, 24 Jan 2007)
New Revision: 1033

Modified:
   trunk/mapbender/http/extensions/geom2wfst.php
Log:
added ajax style wfs saving

Modified: trunk/mapbender/http/extensions/geom2wfst.php
===================================================================
--- trunk/mapbender/http/extensions/geom2wfst.php	2007-01-24 13:13:40 UTC (rev 1032)
+++ trunk/mapbender/http/extensions/geom2wfst.php	2007-01-24 13:14:06 UTC (rev 1033)
@@ -1,5 +1,3 @@
-<html>
-<head>
 <?php
 # $Id$
 # http://www.mapbender.org/index.php/geom2wfst.php
@@ -19,31 +17,47 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<title>Test WFS-T operated by CCGIS</title>
-</head>
-<body>
-<?php
+require_once("../../conf/mapbender.conf");
+require_once("../classes/class_mb_exception.php");
+
+function sepNameSpace($s){
+	$c = strpos($s,":"); 
+	if($c>0) return substr($s,$c+1);
+	return $s;
+}
+function sendToHost($host,$port,$method,$path,$data){
+	$buf = '';
+    if (empty($method)) $method = 'POST';
+    $method = strtoupper($method);
+    $fp = fsockopen($host, $port);
+    fputs($fp, "$method $path HTTP/1.1\r\n");
+    fputs($fp, "Host: $host\r\n");
+    fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
+    fputs($fp, "Content-length: " . strlen($data) . "\r\n");
+    fputs($fp, "Connection: close\r\n\r\n");
+    if ($method == 'POST') fputs($fp, $data);
+    while (!feof($fp)) $buf .= fgets($fp,4096);
+    fclose($fp);
+    return $buf;
+}
+
+$result="";
+$error = false;
 $arURL = parse_url($_REQUEST["url"]);
 $host = $arURL["host"];
 $port = $arURL["port"]; 
-if($port == ''){
-	$port = 80;	
-}
+if($port == '') $port = 80;	
+
 $path = $arURL["path"];
 $method = "POST";
+$filter = stripslashes($_REQUEST["filter"]);
 
-$data = stripslashes($_REQUEST["filter"]);
+$data = sendToHost($host,$port,$method,html_entity_decode($path),$filter);
 
-$out = sendToHost($host,$port,$method,html_entity_decode($path),$data);
-
-$data = $out;
-
 $data = eregi_replace("^[^<]*", "", $data);
 $data = eregi_replace("[^>]*$", "", $data);
 
+/*
 $parser = xml_parser_create(CHARSET);
 xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
 xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
@@ -51,85 +65,40 @@
 xml_parse_into_struct($parser,$data,$values,$tags);
 $code = xml_get_error_code ($parser);
 if ($code) {
-	echo "<br><br>Error " . $code . " (" . xml_error_string($code) .  ")<br><br>";
+	$result = "Error " . $code . " (" . xml_error_string($code) .  ")";
+	$error = true;
 }
 xml_parser_free($parser);
-	
-$section;
-$result="";
-foreach ($values as $element) {
-	$element[tag] = sepNameSpace($element[tag]);
-	if(strtoupper($element[tag]) == "SERVICEEXCEPTIONREPORT" && $element[type] == "open"){
-		$section = "serviceexceptionreport";
+if (!$error) {
+	$section;
+	foreach ($values as $element) {
+		$element[tag] = sepNameSpace($element[tag]);
+		if(strtoupper($element[tag]) == "SERVICEEXCEPTIONREPORT" && $element[type] == "open"){
+			$section = "serviceexceptionreport";
+		}
+		if ($section == "serviceexceptionreport" && strtoupper($element[tag]) == "SERVICEEXCEPTION") {
+//			$result = $element[value];
+			$result = "An error occured.";
+			$error = true;
+		}
+		if(strtoupper($element[tag]) == "STATUS" && $element[type] == "open"){
+			$section = "status";
+		}
+		if ($section == "status" && strtoupper($element[tag]) == "SUCCESS") {
+			$result = "Success.";
+			$error = false;
+		}
 	}
-	if ($section == "serviceexceptionreport" && strtoupper($element[tag]) == "SERVICEEXCEPTION") {
-		$result = $element[value];
-		$error = true;
-	}
-	if(strtoupper($element[tag]) == "STATUS" && $element[type] == "open"){
-		$section = "status";
-	}
-	if ($section == "status" && strtoupper($element[tag]) == "SUCCESS") {
-		$result = "Success.";
-		$error = false;
-	}
 }
 
+
 if ($error) {
-	#echo "wfsWindow = open('', 'wfs', 'width=400, height=300, resizable, dependent=yes, scrollbars=yes');";
-	#echo "wfsWindow.document.open('text/html');";
-	#echo "wfsWindow.document.write('<html><head></head><body>');";
-	#echo "wfsWindow.document.write('</body></html>');";
-	#echo "wfsWindow.document.getElementsByTagName('body')[0].innerHTML = '".addslashes($result)."';";
-	#echo "wfsWindow.document.close();";
-	echo $result;
 	$e = new mb_exception('WFS error at: host: '.$host.' port: '.$port.' filter: '.$_REQUEST["filter"].' - error message: '.$result);
-	echo $result;
-	echo "<script language='javascript'>";
-	echo "window.focus();";
-	echo "</script>";
 }
 else {
 	$e = new mb_exception('WFS successfull host: '.$host.' port: '.$port.' filter: '.$_REQUEST["filter"]);
-	echo "<script language='javascript'>";
-	echo "window.opener.alert('".$result."');\n";
-	echo "window.opener.focus();";
-	echo "window.close();";
-	echo "</script>";
 }
-
-function sepNameSpace($s){
-	$c = strpos($s,":"); 
-	if($c>0){
-		return substr($s,$c+1);
-	}
-	else{
-		return $s;
-	}		
-}
-function sendToHost($host,$port,$method,$path,$data)
-{
-	$buf = '';
-    if (empty($method)) {
-        $method = 'POST';
-    }
-    $method = strtoupper($method);
-    $fp = fsockopen($host, $port);
-    fputs($fp, "$method $path HTTP/1.1\r\n");
-    fputs($fp, "Host: $host\r\n");
-    fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
-    fputs($fp, "Content-length: " . strlen($data) . "\r\n");
-    fputs($fp, "Connection: close\r\n\r\n");
-    if ($method == 'POST') {
-        fputs($fp, $data);
-    }
-
-    while (!feof($fp)) {
-        $buf .= fgets($fp,4096);
-    }
-    fclose($fp);
-    return $buf;
-}
-?>
-</body>
-</html>
\ No newline at end of file
+*/
+header('Content-type: text/xml');  
+echo $data;
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list