[Mapbender-commits] r2395 - in branches/2.5/http: classes extensions javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Apr 18 10:46:52 EDT 2008


Author: christoph
Date: 2008-04-18 10:46:52 -0400 (Fri, 18 Apr 2008)
New Revision: 2395

Added:
   branches/2.5/http/classes/class_json.php
Modified:
   branches/2.5/http/classes/class_gml2.php
   branches/2.5/http/classes/class_kml_ows.php
   branches/2.5/http/classes/class_kml_parser_ows.php
   branches/2.5/http/classes/class_wfs_conf.php
   branches/2.5/http/classes/class_wmc.php
   branches/2.5/http/extensions/geom2wfst.php
   branches/2.5/http/javascripts/mod_tab.php
   branches/2.5/http/php/mod_addWMSfromfilteredList_server.php
   branches/2.5/http/php/mod_button_tooltips.php
   branches/2.5/http/php/mod_digitize_messages.php
   branches/2.5/http/php/mod_gazetteerMetadata_search.php
   branches/2.5/http/php/mod_gazetteerSQL_server.php
   branches/2.5/http/php/mod_insertWmcIntoDb.php
   branches/2.5/http/php/mod_tab_messages.php
   branches/2.5/http/php/mod_wfsSpatialRequest_messages.php
   branches/2.5/http/php/mod_wfs_gazetteer_server.php
   branches/2.5/http/php/mod_wfs_server.php
Log:
http://trac.osgeo.org/mapbender/ticket/201

Modified: branches/2.5/http/classes/class_gml2.php
===================================================================
--- branches/2.5/http/classes/class_gml2.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/classes/class_gml2.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 require_once("class_mb_exception.php");
 require_once("class_connector.php");
-require_once("../extensions/JSON.php");
+require_once("../classes/class_json.php");
 require_once("../../conf/mapbender.conf");
 class gml2 {
 	var $geomtype_point = 'Point';					
@@ -500,7 +500,7 @@
 				$cnt ++;
 		}
 
-		$json = new Services_JSON();
+		$json = new Mapbender_JSON();
 		$str .= $json->encode($prop); 
 		$str .= "}";
 		

Added: branches/2.5/http/classes/class_json.php
===================================================================
--- branches/2.5/http/classes/class_json.php	                        (rev 0)
+++ branches/2.5/http/classes/class_json.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -0,0 +1,81 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/JSON
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+mb_internal_encoding("UTF-8");
+
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+
+define("JSON_PEAR", "json_pear");
+define("JSON_NATIVE", "json_native");
+
+if (!function_exists("json_encode")) {
+	require_once(dirname(__FILE__)."/../classes/class_json.php");
+}
+
+/**
+ * A wrapper class for PHP JSON encoding/decoding.
+ * Uses native PHP functions if available.
+ * 
+ * @class
+ */
+class Mapbender_JSON {
+	
+	/**
+	 * Either JSON_PEAR or JSON_NATIVE
+	 */
+	private $library = JSON_PEAR;
+
+	/**
+	 * Determines which JSON lib to use.
+	 * @constructor
+	 */
+	public function __construct(){
+		if (function_exists("json_encode")) {
+			$this->library = JSON_NATIVE;
+		}
+	}
+	
+	/**
+	 * Encodes an object to JSON
+	 */
+	public function encode($anObject) {
+		if ($this->library == JSON_PEAR) {
+			$pear = new Mapbender_JSON();
+			$e = new mb_notice("using PEAR JSON");
+			return $pear->encode($anObject);
+		}
+		$e = new mb_notice("using native JSON");
+		return json_encode($anObject);
+	}
+
+	/**
+	 * Decodes a JSON string
+	 */
+	public function decode($aString) {
+		if ($this->library == JSON_PEAR) {
+			$pear = new Mapbender_JSON();
+			$e = new mb_notice("using PEAR JSON");
+			return $pear->decode($aString);
+		}
+		$e = new mb_notice("using native JSON");
+		return json_decode($aString);
+	}
+}
+?>
\ No newline at end of file


Property changes on: branches/2.5/http/classes/class_json.php
___________________________________________________________________
Name: svn:keywords
   + HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: branches/2.5/http/classes/class_kml_ows.php
===================================================================
--- branches/2.5/http/classes/class_kml_ows.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/classes/class_kml_ows.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -21,7 +21,7 @@
 mb_internal_encoding("UTF-8");
 
 require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
 require_once(dirname(__FILE__)."/../classes/class_point.php");
 
@@ -233,7 +233,7 @@
 			$kmlDoc_DOM->loadXML($kmlFromDb); 
 
 			//load the geoJSON
-			$json = new Services_JSON();
+			$json = new Mapbender_JSON();
 			$geoObj = $json->decode($geoJSON);
 
 			// construct an array that holds all metadata of the placemark
@@ -384,7 +384,7 @@
 	}
 	
 	private function updateGeometry ($currentNode, $geometry) {
-		$json = new Services_JSON();
+		$json = new Mapbender_JSON();
 		$currentNode_SimpleXML = simplexml_import_dom($currentNode);
 
 		$currentTypeXml = mb_strtoupper($currentNode->nodeName);

Modified: branches/2.5/http/classes/class_kml_parser_ows.php
===================================================================
--- branches/2.5/http/classes/class_kml_parser_ows.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/classes/class_kml_parser_ows.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -17,7 +17,7 @@
 # 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__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
 require_once(dirname(__FILE__)."/../classes/class_point.php");
 require_once(dirname(__FILE__)."/../classes/class_kml_polygon.php");
@@ -39,7 +39,7 @@
 	public function parseGeoJSON ($geoJSON, $kmlId) {
 		
 //		$e = new mb_notice("GEOJSON: " . $geoJSON);
-		$json = new Services_JSON();
+		$json = new Mapbender_JSON();
 		$geometryFromGeoJSON = $json->decode($geoJSON);
 		$id = 0;
 		

Modified: branches/2.5/http/classes/class_wfs_conf.php
===================================================================
--- branches/2.5/http/classes/class_wfs_conf.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/classes/class_wfs_conf.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -20,7 +20,7 @@
 require_once(dirname(__FILE__)."/class_mb_exception.php");
 require_once(dirname(__FILE__)."/class_user.php");
 require_once(dirname(__FILE__)."/class_administration.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 class WfsConf {
 	var $confArray = array();
@@ -33,7 +33,7 @@
 	}
 	
 	function __toString () {
-		$json = new Services_JSON();
+		$json = new Mapbender_JSON();
 		return $json->encode($this->confArray);
 	}
 	

Modified: branches/2.5/http/classes/class_wmc.php
===================================================================
--- branches/2.5/http/classes/class_wmc.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/classes/class_wmc.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -22,7 +22,7 @@
 require_once(dirname(__FILE__) . "/../classes/class_layer_monitor.php");
 require_once(dirname(__FILE__) . "/../classes/class_point.php");
 require_once(dirname(__FILE__) . "/../classes/class_bbox.php");
-require_once(dirname(__FILE__) . "/../extensions/JSON.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
 
 $con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
@@ -1090,7 +1090,7 @@
 			
 			// general extension
 			if (count($this->wmc_general_extension) > 0) {
-				$json = new Services_JSON();
+				$json = new Mapbender_JSON();
 				$wmc_string .= $target . "restoredWmcExtensionData = " . $json->encode($this->wmc_general_extension) . ";\n"; 
 			}
 			

Modified: branches/2.5/http/extensions/geom2wfst.php
===================================================================
--- branches/2.5/http/extensions/geom2wfst.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/extensions/geom2wfst.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -27,7 +27,7 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 function isValidVarName ($varname) {
 	if (preg_match("/[\$]{1}_[a-z]+\[\"[a-z_]+\"\]/i", $varname) != 0) {
@@ -155,6 +155,6 @@
 $notice = new mb_notice("response:".$response);
 
 header("Content-Type:application/x-json");
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 echo $json->encode($resObj);
 ?>
\ No newline at end of file

Modified: branches/2.5/http/javascripts/mod_tab.php
===================================================================
--- branches/2.5/http/javascripts/mod_tab.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/javascripts/mod_tab.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -20,7 +20,7 @@
 /********** Configuration*************************************************/
 
 require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 include(dirname(__FILE__)."/../include/dyn_js.php");
 
 $tab_ids = array();
@@ -37,7 +37,7 @@
 	echo "tab_titles[" . $i . "] = '" . $row["e_title"] . "';\n";	
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($tab_ids);
 
 echo "var tab_ids = " . $output . ";";	

Modified: branches/2.5/http/php/mod_addWMSfromfilteredList_server.php
===================================================================
--- branches/2.5/http/php/mod_addWMSfromfilteredList_server.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_addWMSfromfilteredList_server.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -20,7 +20,7 @@
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_wms.php"); 
 require_once(dirname(__FILE__)."/../classes/class_administration.php"); 
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 $userId = $_SESSION["mb_user_id"];
 $command = $_GET["command"];
@@ -129,7 +129,7 @@
 	}		
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($resultObj);
 echo $output;
 ?>
\ No newline at end of file

Modified: branches/2.5/http/php/mod_button_tooltips.php
===================================================================
--- branches/2.5/http/php/mod_button_tooltips.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_button_tooltips.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
 
 $buttonObj = array();
@@ -31,7 +31,7 @@
 	array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($buttonObj);
 
 header("Content-type:text/plain; charset=utf-8");

Modified: branches/2.5/http/php/mod_digitize_messages.php
===================================================================
--- branches/2.5/http/php/mod_digitize_messages.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_digitize_messages.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 $e = new mb_notice("locale: " . $_SESSION["mb_locale"] . "; lang: " . $_SESSION["mb_lang"]);
 $e = new mb_notice(setlocale(LC_ALL, $_SESSION["mb_locale"]));
@@ -67,7 +67,7 @@
 $msg_obj["measureTagLabelTotal"] = _mb("Total: ");
 $msg_obj["digitizeDefaultGeometryName"] = _mb("new");
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($msg_obj);
 
 header("Content-type:application/x-json; charset=utf-8");

Modified: branches/2.5/http/php/mod_gazetteerMetadata_search.php
===================================================================
--- branches/2.5/http/php/mod_gazetteerMetadata_search.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_gazetteerMetadata_search.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -1,7 +1,7 @@
 <?php
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 $user_id = $_SESSION["mb_user_id"];
 $query = $_REQUEST["search"];
@@ -69,7 +69,7 @@
 		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']));
 	}
 }
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($obj);
 echo $output;
 ?>
\ No newline at end of file

Modified: branches/2.5/http/php/mod_gazetteerSQL_server.php
===================================================================
--- branches/2.5/http/php/mod_gazetteerSQL_server.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_gazetteerSQL_server.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -1,6 +1,6 @@
 <?php
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../../conf/gazetteerSQL.conf");
 
 $con = 	pg_connect($connstring);		
@@ -193,7 +193,7 @@
 	$e = new mb_exception("unknown command: " . $command);
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($obj);
 echo $output;
 ?>
\ No newline at end of file

Modified: branches/2.5/http/php/mod_insertWmcIntoDb.php
===================================================================
--- branches/2.5/http/php/mod_insertWmcIntoDb.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_insertWmcIntoDb.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -20,9 +20,9 @@
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
 require_once(dirname(__FILE__)."/../classes/class_wmc.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $mapObject = $json->decode(stripslashes($_POST["mapObject"]));
 $user_id = $_SESSION["mb_user_id"];
 $save_in_session = $_POST["saveInSession"];

Modified: branches/2.5/http/php/mod_tab_messages.php
===================================================================
--- branches/2.5/http/php/mod_tab_messages.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_tab_messages.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
 
 $buttonObj = array();
@@ -38,7 +38,7 @@
 	array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
 }
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($buttonObj);
 
 header("Content-type:text/plain; charset=utf-8");

Modified: branches/2.5/http/php/mod_wfsSpatialRequest_messages.php
===================================================================
--- branches/2.5/http/php/mod_wfsSpatialRequest_messages.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_wfsSpatialRequest_messages.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 
 $e = new mb_notice("locale: " . $_SESSION["mb_locale"] . "; lang: " . $_SESSION["mb_lang"]);
 setlocale(LC_ALL, $_SESSION["mb_locale"]);
@@ -34,7 +34,7 @@
 $msg_obj["buttonLabelDialogue"] = _mb("open dialogue form");
 $msg_obj["errorMessageInvalidExtent"] = _mb("Invalid box!");
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $output = $json->encode($msg_obj);
 
 header("Content-type:application/x-json; charset=utf-8");

Modified: branches/2.5/http/php/mod_wfs_gazetteer_server.php
===================================================================
--- branches/2.5/http/php/mod_wfs_gazetteer_server.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_wfs_gazetteer_server.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -19,7 +19,7 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_gml2.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
 require_once(dirname(__FILE__)."/../classes/class_wfs_conf.php");
 

Modified: branches/2.5/http/php/mod_wfs_server.php
===================================================================
--- branches/2.5/http/php/mod_wfs_server.php	2008-04-18 08:54:22 UTC (rev 2394)
+++ branches/2.5/http/php/mod_wfs_server.php	2008-04-18 14:46:52 UTC (rev 2395)
@@ -2,9 +2,9 @@
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
 require_once(dirname(__FILE__)."/../classes/class_wfs.php");
-require_once(dirname(__FILE__) . "/../extensions/JSON.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
 
-$json = new Services_JSON();
+$json = new Mapbender_JSON();
 $obj = $json->decode(stripslashes($_REQUEST['obj']));
 
 //workflow:



More information about the Mapbender_commits mailing list