[Mapbender-commits] r2080 - branches/2.5/http/extensions

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Feb 11 09:58:49 EST 2008


Author: christoph
Date: 2008-02-11 09:58:49 -0500 (Mon, 11 Feb 2008)
New Revision: 2080

Modified:
   branches/2.5/http/extensions/geom2wfst.php
Log:
fixed faulty json encoding

Modified: branches/2.5/http/extensions/geom2wfst.php
===================================================================
--- branches/2.5/http/extensions/geom2wfst.php	2008-02-11 14:42:41 UTC (rev 2079)
+++ branches/2.5/http/extensions/geom2wfst.php	2008-02-11 14:58:49 UTC (rev 2080)
@@ -28,6 +28,7 @@
 session_start();
 require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../extensions/JSON.php");
 $con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
 
@@ -139,19 +140,24 @@
 $data = mb_eregi_replace("^[^<]*", "", $data);
 $data = mb_eregi_replace("[^>]*$", "", $data);
 header('Content-type: text/html');
-echo "{";  
+
+$resObj = array();
 if (mb_strpos(mb_strtoupper($data), "SUCCESS") !== false) {
 	$response = "success";
 	if (mb_ereg("^.*ogc:FeatureId fid=\"(.+)\"/>.*$", $data)) {
 		$fid = mb_ereg_replace("^.*ogc:FeatureId fid=\"(.+)\"/>.*$", "\\1", $data);
-		echo "\"fid\":\"".$fid."\",";
+		$resObj["fid"] = $fid;
 	}
-	echo "\"success confirmation\":\"".preg_replace("/\"/", "'", preg_replace("/\n/", "", preg_replace("/\r/", "", $data)))."\",";
+	$resObj["successConfirmation"] = $data;
 }
 else {
 	$response = "error";
-	echo "\"error message\":\"".preg_replace("/\"/", "'", preg_replace("/\n/", "", preg_replace("/\r/", "", $data)))."\",";
+	$resObj["errorMessage"] = $data;
 }
-echo "\"response\":\"".$response."\"}";
+$resObj["response"] = $response;
 $notice = new mb_notice("response:".$response);
+
+header("Content-Type:application/x-json");
+$json = new Services_JSON();
+echo $json->encode($resObj);
 ?>
\ No newline at end of file



More information about the Mapbender_commits mailing list